Commit 4268f040 by Valera Rozuvan Committed by Alexander Kryklia

Updated JS part to use new XML format.

parent 36b1d4f1
......@@ -8,34 +8,46 @@ define(['logme'], function (logme) {
return updateInput;
function updateInput(state) {
var inputEl, stateStr, targets;
var inputEl, stateStr, targets, draggables, c1, c2, tempObj;
draggables = [];
if (state.individualTargets === false) {
for (c1 = 0; c1 < state.draggables.length; c1++) {
if (state.draggables[c1].x !== -1) {
tempObj = {};
tempObj[state.draggables[c1].id] = {
'x': state.draggables[c1].x,
'y': state.draggables[c1].y
};
draggables.push(tempObj);
}
}
stateStr = JSON.stringify({
'individualTargets': false,
'draggables': state.draggables
'targets': false,
'draggables': draggables
});
} else {
targets = [];
(function (c1) {
while (c1 < state.targets.length) {
targets.push({
'id': state.targets[c1].id,
'draggables': state.targets[c1].draggable
});
c1 += 1;
for (c1 = 0; c1 < state.targets.length; c1++) {
for (c2 = 0; c2 < state.targets[c1].draggable.length; c2++) {
tempObj = {};
tempObj[state.targets[c1].draggable[c2]] = state.draggables[c1].id;
draggables.push(tempObj);
}
}(0));
}
stateStr = JSON.stringify({
'individualTargets': true,
'targets': targets
'targets': true,
'draggables': draggables
});
}
inputEl = $('#input_' + state.problemId);
inputEl.val(stateStr);
logme(inputEl.val());
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment