"parsing" a text document to specific javascript format? -
edit - think parsing wrong word use, i'm looking format text file format provided.
i'm working on project , i've ran slight problem. need mass editing text file format. don't know how this. example, here text file: http://frankerfacez.com/users.txt
that has list of users , emotes (users without periods, emotes with). need changed format of
//user "emote":["cdn.frankerfacez.com/channel/ user / emote.png"], for reference, need format be: https://dl.dropboxusercontent.com/u/23313911/customemotes.js
i don't know how easy or if possible, appreciated!
lines = txtfile.responsetext.split("\n"); var user = null; var emote = null; var o = {}; (i in lines) { var line = lines[i]; if (line.charat(0) != ".") user = line; else { try{ emote = line.substring(1, line.legth); var = new array(); eval("var cnd = new string('cdn.frankerfacez.com/channel/'+user+'/'+emote+'.png');"); a.push(cnd.tostring()); eval("o."+emote+" = a;"); }catch(e){ console.error(emote + " - " + user); console.error(e); } } } console.log(o);
Comments
Post a Comment