Commit f9169613 by Valera Rozuvan Committed by Alexander Kryklia

Making JS work with the new XML format.

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