mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-23 13:50:24 +08:00
Add pickings and simplify poems service
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
angular.module("sideBySide").service "poems", ['$q', 'fetch', ($q, fetch) ->
|
||||
all = []
|
||||
@active = [{
|
||||
meta: {}
|
||||
@all = [{
|
||||
meta: {
|
||||
Active: true
|
||||
}
|
||||
content: [{
|
||||
section: 'Loading...'
|
||||
text: 'Please be patient!'
|
||||
@@ -9,29 +10,18 @@ angular.module("sideBySide").service "poems", ['$q', 'fetch', ($q, fetch) ->
|
||||
}]
|
||||
@heading = undefined
|
||||
|
||||
updateActive = () =>
|
||||
@active = (poem for poem in all when poem.meta.Active is true)
|
||||
|
||||
@load = (base = '') =>
|
||||
config = base.replace(/\./g, '/') + "/config.json"
|
||||
|
||||
fetch(config).then (result) =>
|
||||
$q.all(result.promises).then (results) =>
|
||||
@all = []
|
||||
for poem in results
|
||||
if not poem.meta.Active?
|
||||
poem.meta.Active = true
|
||||
all.push poem
|
||||
@all.push poem
|
||||
|
||||
@heading = result.heading
|
||||
updateActive()
|
||||
|
||||
@show = (id) ->
|
||||
all[id].meta.Active = true
|
||||
updateActive()
|
||||
|
||||
@hide = (id) ->
|
||||
all[id].meta.Active = false
|
||||
updateActive()
|
||||
|
||||
@
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user