Commit f9169613 by Valera Rozuvan Committed by Alexander Kryklia

Making JS work with the new XML format.

parent 4268f040
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
(function (requirejs, require, define) { (function (requirejs, require, define) {
define(['logme'], function (logme) { define(['logme'], function (logme) {
return TargetContainer; return BaseImage;
function TargetContainer(state) { function BaseImage(state) {
var targetImgSrc, targetElContainer, mouseMoveDiv; var targetImgSrc, targetElContainer, mouseMoveDiv;
targetImgSrc = state.config.imageDir + '/' + state.config.target_container; targetImgSrc = state.config.imageDir + '/' + state.config.base_image;
targetElContainer = $( targetElContainer = $(
'<div ' + '<div ' +
......
...@@ -14,33 +14,33 @@ define(['logme'], function (logme) { ...@@ -14,33 +14,33 @@ define(['logme'], function (logme) {
state.config = { state.config = {
'imageDir': '/static/' + imageDir + '/images', 'imageDir': '/static/' + imageDir + '/images',
'draggable': [], 'draggables': [],
'targets': [], 'targets': [],
'target_container': '' 'base_image': ''
}; };
if ($.isArray(config.draggable) === true) { if ($.isArray(config.draggables) === true) {
(function (i) { (function (i) {
while (i < config.draggable.length) { while (i < config.draggables.length) {
if (processDraggable(config.draggable[i]) !== true) { if (processDraggable(config.draggables[i]) !== true) {
returnStatus = false; returnStatus = false;
} }
i += 1; i += 1;
} }
}(0)); }(0));
} else if ($.isPlainObject(config.draggable) === true) { } else if ($.isPlainObject(config.draggables) === true) {
if (processDraggable(config.draggable) !== true) { if (processDraggable(config.draggables) !== true) {
returnStatus = false; returnStatus = false;
} }
} else { } else {
logme('ERROR: The type of config.draggable is no supported.'); logme('ERROR: The type of config.draggables is no supported.');
returnStatus = false; returnStatus = false;
} }
if (typeof config.target_container === 'string') { if (typeof config.base_image === 'string') {
state.config.target_container = config.target_container; state.config.base_image = config.base_image;
} else { } else {
logme('ERROR: Property config.target_container is not of type "string".'); logme('ERROR: Property config.base_image is not of type "string".');
returnStatus = false; returnStatus = false;
} }
...@@ -104,7 +104,7 @@ define(['logme'], function (logme) { ...@@ -104,7 +104,7 @@ define(['logme'], function (logme) {
if (!attrIsString(obj, 'icon')) { return false; } if (!attrIsString(obj, 'icon')) { return false; }
if (!attrIsString(obj, 'label')) { return false; } if (!attrIsString(obj, 'label')) { return false; }
state.config.draggable.push(obj); state.config.draggables.push(obj);
true; true;
} }
......
...@@ -14,8 +14,8 @@ define(['logme', 'update_input'], function (logme, updateInput) { ...@@ -14,8 +14,8 @@ define(['logme', 'update_input'], function (logme, updateInput) {
state.draggables = []; state.draggables = [];
(function (i) { (function (i) {
while (i < state.config.draggable.length) { while (i < state.config.draggables.length) {
processDraggable(state.config.draggable[i], i + 1); processDraggable(state.config.draggables[i], i + 1);
i += 1; i += 1;
} }
}(0)); }(0));
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
(function (requirejs, require, define) { (function (requirejs, require, define) {
define( define(
['logme', 'state', 'config_parser', 'container', 'target_container', 'scroller', 'draggables', 'targets'], ['logme', 'state', 'config_parser', 'container', 'base_image', 'scroller', 'draggables', 'targets'],
function (logme, State, configParser, Container, TargetContainer, Scroller, Draggables, Targets) { function (logme, State, configParser, Container, BaseImage, Scroller, Draggables, Targets) {
return Main; return Main;
function Main() { function Main() {
...@@ -57,7 +57,7 @@ define( ...@@ -57,7 +57,7 @@ define(
} }
Container(state); Container(state);
TargetContainer(state); BaseImage(state);
Scroller(state); Scroller(state);
Draggables(state); Draggables(state);
Targets(state); Targets(state);
......
...@@ -47,7 +47,6 @@ define(['logme'], function (logme) { ...@@ -47,7 +47,6 @@ define(['logme'], function (logme) {
inputEl = $('#input_' + state.problemId); inputEl = $('#input_' + state.problemId);
inputEl.val(stateStr); 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