mirror of
https://github.com/wassname/side-by-side.git
synced 2026-08-21 11:21:53 +08:00
21 lines
494 B
CoffeeScript
21 lines
494 B
CoffeeScript
angular.module("sideBySide").factory("jsonReader", ->
|
|
# Read json poem
|
|
#
|
|
# For sample input, see:
|
|
# source/documents/tests/services/reader/json.js.coffee
|
|
#
|
|
# @param source [String] Json poem
|
|
# @return [Object] Poem object
|
|
(source) ->
|
|
parsed = eval('(' + source + ')')
|
|
|
|
for i,verse of parsed.content
|
|
if typeof verse == "string"
|
|
parsed.content[i] = { section: "", text: verse }
|
|
else
|
|
verse.section = "" if "section" not of verse
|
|
parsed.content[i] = verse
|
|
|
|
parsed
|
|
)
|