Last active
July 28, 2016 17:12
-
-
Save SergProduction/64d54f0bd76b877135b6ae087f84d15a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let id = 0; | |
let init = []; | |
socket.ws.send('{"cmd":"GetScript"}'); | |
socket.onMessage( data => { | |
if (data.cmd == 'SetScript') { | |
Parse(data.script); | |
} | |
}) | |
function Parse(mod, parent = 0 ){ | |
let my = {}; | |
mod.forEach((el, i, arr) => { | |
id+=1; | |
my = { | |
id: id, | |
parent: parent, | |
key: el.keyname, | |
question: el.qwest, | |
answer: el.ans, | |
file: null, | |
url: null | |
}; | |
init.push(my); | |
if (el.node.length) { | |
Parse(el.node, id) | |
} | |
}) | |
return init | |
} | |
export default init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment