Updated JS part to use new XML format.
This commit is contained in:
committed by
Alexander Kryklia
parent
36b1d4f1d0
commit
4268f04069
@@ -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
|
||||
});
|
||||
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;
|
||||
|
||||
c1 += 1;
|
||||
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());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user