Skip to content

Instantly share code, notes, and snippets.

@kgadek
Last active September 26, 2015 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgadek/1124869 to your computer and use it in GitHub Desktop.
Save kgadek/1124869 to your computer and use it in GitHub Desktop.
JavaScript: ascii-art parser (Windmobile reports presenter)
// Ta tabela jest rozumiana przez JS -- wszystkie zmiany wprowadzać tutaj.
// | from | to | employees | seta | premia | kanał | prezencja | prefix | agregacja |
// |---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------|
var flds = [ dateFromField , dateToField, includeWorkersCb, setaType , forPremiaCb , accChannel , presence , prefix , agreg ];
var r2fl ={//|---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------|
'R0' : " | | x | | | | | | ",
'R1a' : " x | x | x | | | x | x | | ",
'R2' : " x | x | x | | | x | x | | ",
'R2a' : " x | x | x | | | x | x | | ",
'R3' : " x | x | x | | | x | x | | ",
'R3a' : " x | x | x | | | x | x | | ",
'R4' : " x | x | x | | | x | x | | ",
'R5' : " x | x | x | | | | | | ",
'R6' : " | x | x | | | | x | | ",
'R6a' : " x | x | x | | | | x | | ",
'R7' : " x | | x | | | | | x | ",
'R8' : " | | x | | | | | | ",
'R9' : " | | x | | | | | | ",
'R12' : " x | x | x | | | x | x | | ",
'R13' : " x | x | x | | | x | x | | ",
'R13a' : " x | x | x | | | x | x | | ",
'R14' : " x | x | | | | | | | ",
'R15' : " x | x | | | | | | | ",
'R16' : " | | | | | | | | ",
'R17' : " x | x | | | | | | | ",
'R18' : " x | x | x | | | | | | ",
'R20' : " x | x | x | | | | | | x ",
'R21' : " x | x | | x | x | | | | "
};
var thisReport = r2fl[reportId].split(" | ");
for(var key in thisReport)
if(typeof(thisReport[key])=='string' && thisReport[key].replace(/^\s\s*/, '').replace(/\s\s*$/, '') == 'x') // isString AND trim-->equal('x')?
paramsFields.push(flds[key]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment