Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
TaskhelTemplate
//JavaScript-C24.2.0 (SpiderMonkey) print("Hello, world!") var headingsInput = "_id,_subject,_topic"; var valuesInput = "TASHKEL00001,sub,top,LTRS0021,LTRS0022,LTRS0020*LTRS0021*LTRS0022*LTRS0020*LTRS0021*LTRS002,0*0*0*0*0*1,LTRS0021,LTRS0022,LTRS0020*LTRS0021*LTRS0022*LTRS0020*LTRS0021*LTRS002,0*0*0*0*0*1"; var columnCountOfEachPage = 4; function TaskhelTemplate(headingsInput, valuesInput) { // Utilities.sleep(1000); var json = {}; if(valuesInput !== undefined && headingsInput !== undefined) { var headingsArray = headingsInput.toString().split(","); var valuesArray = valuesInput.toString().split(","); json[headingsArray[0]] = valuesArray[0]; json[headingsArray[1]] = valuesArray[1]; json[headingsArray[2]] = valuesArray[2]; var _taskhelPages = []; var pagesCount = (valuesArray.length - 3) / columnCountOfEachPage; print("pagesCount : "+pagesCount) for(var i = 0; i < pagesCount; i++) { if(valuesArray[3 + (i * columnCountOfEachPage)] == "") continue; var _taskhelPage = {}; _taskhelPage["_optionalImagekey"] = valuesArray[3 + (i * columnCountOfEachPage)]; _taskhelPage["_questionStatement"] = valuesArray[4 + (i * columnCountOfEachPage)]; var _options = []; var _optionsArray = valuesArray[5 + (i * columnCountOfEachPage)].toString().split("*"); if(_optionsArray !== undefined) { for(var j = 0; j < _optionsArray.length; j++) _options.push(_optionsArray[j]); } _taskhelPage["_options"] = _options; var _placeHolderForTaskhel = []; var _placeHolderForTaskhelArray = valuesArray[6 + (i * columnCountOfEachPage)].toString().split("*"); if(_placeHolderForTaskhelArray !== undefined) { for(var k = 0; k < _placeHolderForTaskhelArray.length; k++) _placeHolderForTaskhel.push(_placeHolderForTaskhelArray[k]); } _taskhelPage["_placeHolderForTaskhel"] = _placeHolderForTaskhel; _taskhelPages.push(_taskhelPage); } json["_taskhelPages"] = _taskhelPages; var finalObj = {}; finalObj[valuesArray[0]] = json; } return JSON.stringify(finalObj); } print(TaskhelTemplate(headingsInput, valuesInput));
run
|
edit
|
history
|
help
0
class Stack
новинка
Error
JavaScript - Looping thru strings
Time it has been since Tuesday, January 1st, 2019
First Non Repeating Character
Probability
JS exam part 2 - BPM
My first app
game green