").appendTo(container);
var imgs_answers = $("").appendTo(container);
var imgs_container = $("
").appendTo(container);
var number = $("
1
").appendTo(sub_container);
var text = $("
" + sankoreLang.short_desc + "
").appendTo(sub_container);
$("").appendTo(imgs_container);
var img1 = $("");
$("").appendTo(img1);
$("").appendTo(img1);
var img2 = $("");
$("").appendTo(img2);
$("").appendTo(img2);
var img3 = $("");
$("").appendTo(img3);
$("").appendTo(img3);
var img4 = $("");
$("").appendTo(img4);
$("").appendTo(img4);
var img5 = $("");
$("").appendTo(img5);
$("").appendTo(img5);
tmp_array.push(img1, img2, img3, img4, img5);
tmp_array = shuffle(tmp_array);
for(var i = 0; i");
var answers = "";
$(this).parent().find(".imgs_answers .img_block").each(function(){
answers += $(this).find("input").val();
});
if(tmp_cont.children()[0].tagName == "IMG")
tmp_cont.removeClass("imgs_answers_green")
.removeClass("imgs_answers_red")
.addClass("imgs_answers_gray");
else
if(tmp_cont.children().length == 1){
if(tmp_cont.children().find("input").val() == "1")
tmp_cont.removeClass("imgs_answers_gray")
.removeClass("imgs_answers_red")
.addClass("imgs_answers_green");
else
tmp_cont.removeClass("imgs_answers_gray")
.removeClass("imgs_answers_green")
.addClass("imgs_answers_red");
}
}
}
}
});
//container.appendTo("body")
}
//check result
function checkResult(event)
{
var str = "";
var right_str = $(event.target).find("input").val();
$(event.target).find(".img_block").each(function(){
str += $(this).find("input").val() + "*";
});
if(str == right_str)
$(event.target).css("background-color","#9f9");
}
//add new container
function addContainer(){
var container = $("
");
var sub_container = $("
").appendTo(container);
var imgs_container = $("
").appendTo(container);
var close = $("
").appendTo(container);
var number = $("
"+ ($(".cont").size() + 1) +"
").appendTo(sub_container);
var text = $("
Enter your condition here ...
").appendTo(sub_container);
$("").appendTo(imgs_container);
var add_img = $("
").appendTo(imgs_container);
container.insertBefore($(".add_block"));
}
//add new img block
function addImgBlock(dest){
var img_block = $("").insertBefore(dest);
$("
").appendTo(img_block);
$("
").appendTo(img_block);
$("
").appendTo(img_block);
$("").appendTo(img_block);
$("").appendTo(img_block);
}
function refreshBlockNumbers(){
var i = 0;
$(".cont").each(function(){
$(this).find(".number_cont").text(++i);
})
}
//shuffles an array
function shuffle( arr )
{
var pos, tmp;
for( var i = 0; i < arr.length; i++ )
{
pos = Math.round( Math.random() * ( arr.length - 1 ) );
tmp = arr[pos];
arr[pos] = arr[i];
arr[i] = tmp;
}
return arr;
}
function stringToXML(text){
if (window.ActiveXObject){
var doc=new ActiveXObject('Microsoft.XMLDOM');
doc.async='false';
doc.loadXML(text);
} else {
var parser=new DOMParser();
doc=parser.parseFromString(text,'text/xml');
}
return doc;
}
function onDropTarget(obj, event) {
$(obj).find("img").remove();
if (event.dataTransfer) {
var format = "text/plain";
var textData = event.dataTransfer.getData(format);
if (!textData) {
alert(":(");
}
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
tmp = tmp.substr(1, tmp.length);
var tmp_img = $("").attr("src", tmp);
$(obj).append(tmp_img);
setTimeout(function(){
if(tmp_img.height() >= tmp_img.width())
tmp_img.attr("height", "120");
else{
tmp_img.attr("width","120");
tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0");
}
}, 6)
}
else {
alert ("Your browser does not support the dataTransfer object.");
}
if (event.stopPropagation) {
event.stopPropagation ();
}
else {
event.cancelBubble = true;
}
return false;
}