Skip to content

Instantly share code, notes, and snippets.

@SergProduction
Last active July 28, 2016 17:12
Show Gist options
  • Save SergProduction/64d54f0bd76b877135b6ae087f84d15a to your computer and use it in GitHub Desktop.
Save SergProduction/64d54f0bd76b877135b6ae087f84d15a to your computer and use it in GitHub Desktop.
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