var DRTcompare = new Object();
DRTcompare.Config = {
Redmin: 1,
Redmax: 35,
Redlen: 12,
Bluemin: 1,
Bluemax: 12,
Bluelen: 6,
msieEnter: unescape("%0D%0A"),
geckoEnter: unescape("%0A"),
List: "5+2,5+1,5+0,4+2,4+1,4+0,3+2,3+1,3+0,2+2,2+1,2+0,1+2,1+1,1+0,0+2,0+1,0+0".split(","),
exArea: 0,
batchMax: 30
};
DRTcompare.Window_onLoad = function ()
{
DRTcompare.Result_onLoad();
};
DRTcompare.r_onclick = function (object)
{
var in1 = document.getElementById("in1");
var in2 = document.getElementById("in2");
var data = $(object).val();
if (data == "0")
{
$("#leftul").attr("class","list array bot-line");
$("#rightul").attr("class","list array selected");
} else if (data == "1")
{
$("#leftul").attr("class","list array bot-line selected");
$("#rightul").attr("class","list array");
}
};
DRTcompare.cRedBlue_onLoad = function (type)
{
var mins = DRTcompare.Config[type + "min"];
var maxs = DRTcompare.Config[type + "max"];
var lens = DRTcompare.Config[type + "len"];
var o = "";
for (var i = mins; i <= maxs; i++)
{
//o += ""+"" + i.addzero(2) + "";
o += "" + i.addzero(2) + "";
if (i % lens == 0) o += "
";
};
document.getElementById("c" + type + "s").innerHTML = o;
//var obj = document.forms["frm"].elements["c" + type];
var obj = $("span[name=c" + type+"]");
for (var i = 0; i < obj.length; i++)
{
obj[i].onclick = function () { DRTcompare.cRedBlue_onClick(this); };
};
};
DRTcompare.cRedBlue_onClick = function (object)
{
//debugger;
//var type = (object.name == "cRed") ? "Red" : "Blue";
var type = ($(object).attr("name") == "cRed") ? "Red" : "Blue";
if ($(object).attr("class") == "bigball ball-red-28")
{ $(object).attr("class","bigball bgrey-28"); }
else { $(object).attr("class","bigball ball-red-28"); }
//object.nextSibling.className = (object.checked == true) ? "t" + type : "";
DRTcompare.hRedBlue_onLoad("c",type,object);
};
DRTcompare.cRedBlue_Reform = function (type)
{
var tRedBlue = document.forms["frm"].elements["tRedBlue"].value.split("+");
tRedBlue = (type == "Red") ? tRedBlue[0] : tRedBlue[1];
//var object = document.forms["frm"].elements["c" + type];
var object = $("span[name=[c" + type + "]");
for (var i = 0; i < object.length; i++)
{
//object[i].checked = (tRedBlue.indexOf(Math.round(object[i].value).addzero(2)) != -1) ? true : false;
//object[i].nextSibling.className = (object[i].checked == true) ? "t" + type : "";
//$(object[i]).attr("class", "");
};
};
DRTcompare.tRedBlue_onLoad = function (type,value)
{
var o = " ";
document.getElementById("t" + type + "s").innerHTML += o;
var object = document.forms["frm"].elements["t" + type];
object = object[object.length - 1];
object.onpaste = function () { return false; };
object.onclick = function () { this.select(); };
object.onkeyup = function () { DRTcompare.tRedBlue_onKeyup(this); };
object.onblur = function () { DRTcompare.tRedBlue_onBlur(this); };
};
DRTcompare.tRedBlue_onKeyup = function (object)
{
object.value = object.value.replace(/\D/gi,"");
if (object.value.length == 2) DRTcompare.tRedBlue_Check(object);
};
DRTcompare.tRedBlue_onBlur = function (object)
{
if (object.value.length == 1)
{
object.value = Math.round(object.value).addzero(2);
DRTcompare.tRedBlue_Check(object);
};
};
DRTcompare.tRedBlue_Check = function (object)
{
var type = (object.name == "tRed") ? "Red" : "Blue";
var mins = DRTcompare.Config[type + "min"];
var maxs = DRTcompare.Config[type + "max"];
if (Math.round(object.value) > maxs || Math.round(object.value) < mins) object.value = "";
if (object.value != "") DRTcompare.hRedBlue_onLoad("t",type,object);
};
DRTcompare.tRedBlue_Reform = function (type)
{
document.getElementById("t" + type + "s").innerHTML = "";
var tRedBlue = document.forms["frm"].elements["tRedBlue"].value.split("+");
tRedBlue = (type == "Red") ? tRedBlue[0] : tRedBlue[1];
tRedBlue = (tRedBlue + " ").split(" ");
var object = document.forms["frm"].elements["t" + type];
for (var i = 0; i < (tRedBlue.length - 1); i++)
{ DRTcompare.tRedBlue_onLoad(type,tRedBlue[i]); };
};
DRTcompare.tRedBlue_focus = function (type)
{
var object = document.forms["frm"].elements["t" + type];
if (DRTcompare.BrowInfo == "msie") object[object.length - 1].focus();
};
DRTcompare.hRedBlue_onLoad = function (source,type)
{
//debugger;
var tRedBlue = document.forms["frm"].elements["tRedBlue"].value.split("+");
switch (type)
{
case "Red": tRedBlue[0] = DRTcompare.hRedBlue_Gather(source,type); break;
case "Blue": tRedBlue[1] = DRTcompare.hRedBlue_Gather(source,type); break;
};
document.forms["frm"].elements["tRedBlue"].value = tRedBlue.join("+");
DRTcompare.hRedBlue_Reform(source,type);
if (tRedBlue[0] != "")
document.forms["frm"].elements["red_n"].value = (tRedBlue[0] + " ").split(" ").length - 1;
if (tRedBlue[1] != "")
document.forms["frm"].elements["blue_n"].value = (tRedBlue[1] + " ").split(" ").length - 1;
};
DRTcompare.hRedBlue_Gather = function (source,type) {
//debugger;
//var object = document.forms["frm"].elements[source + type];
var object = $("span[name=" + source + type + "]");//.find("class=bigball ball-red-28");
var mins = DRTcompare.Config[type + "min"];
var maxs = DRTcompare.Config[type + "max"];
var tmpStr = "";
for (var i = 0; i < object.length; i++)
{
var objValue = $(object[i]).text();
if ((tmpStr.indexOf(Math.round(objValue).addzero(2)) == -1) && (objValue != ""))
{
if (Math.round(objValue) >= mins && Math.round(objValue) <= maxs)
{
switch (source)
{
case "c":
if ($(object[i]).attr("class") == "bigball ball-red-28")
tmpStr += " " + Math.round(objValue).addzero(2);
break;
case "t":
tmpStr += " " + Math.round(objValue).addzero(2);
break;
};
};
};
};
return tmpStr.trim();
};
DRTcompare.hRedBlue_Reform = function (source,type)
{
DRTcompare.tRedBlue_Reform(type);
DRTcompare.cRedBlue_Reform(type);
DRTcompare.tRedBlue_onLoad(type,"");
switch (type)
{
case "Red": setTimeout("DRTcompare.tRedBlue_focus('Red')",0); break;
case "Blue": setTimeout("DRTcompare.tRedBlue_focus('Blue')",0); break;
};
};
DRTcompare.Calculate_onClick = function ()
{
var r1 = ($("ul[name='r1']").attr("class") != "hide") ? 1 : 2;
DRTcompare.hRedBlue_Value = "";
if (r1 == 1) {
var reditems = $("input[name='db']");
for (var i = 0; i < reditems.length; i++) {
if ($(reditems[i]).prop("checked"))
DRTcompare.hRedBlue_Value = DRTcompare.hRedBlue_Value + $(reditems[i]).val().replace("\n", "").trim() + " ";
}
DRTcompare.hRedBlue_Value += "+";
var blueitems = $("input[name='hdb']");
for (var i = 0; i < blueitems.length; i++) {
if ($(blueitems[i]).prop("checked"))
DRTcompare.hRedBlue_Value = DRTcompare.hRedBlue_Value + $(blueitems[i]).val().replace("\n", "").trim() + " ";
}
} else {
DRTcompare.hRedBlue_Value = $("textarea[class='textarea']").val();
}
if ((DRTcompare.hRedBlue_Value == "") || (DRTcompare.hRedBlue_Value == "+")) { alert(DRTcompare.AlertMsg["0001"]); return false; };
if (DRTcompare.hRedBlue_Value.search(/[^0-9\+\r\n\ ]/g,"") >= 0) { alert(DRTcompare.AlertMsg["0002"]); return false; }
DRTcompare.hRedBlue_Value += DRTcompare.Config[DRTcompare.BrowInfo + "Enter"];
DRTcompare.hRedBlue_Value = DRTcompare.hRedBlue_Value.split(DRTcompare.Config[DRTcompare.BrowInfo + "Enter"]);
for (var i = DRTcompare.hRedBlue_Value.length - 1; i >= 0; i--)
{
DRTcompare.hRedBlue_Value[i] = DRTcompare.hRedBlue_Value[i].trim();
if (DRTcompare.hRedBlue_Value[i] != "")
{
DRTcompare.hRedBlue_Value[i] = DRTcompare.hRedBlue_Value[i].replace(/\ {2,}/gi," ");
if (DRTcompare.hRedBlue_Value[i].indexOf("+") == -1) DRTcompare.hRedBlue_Value[i] += "+";
DRTcompare.hRedBlue_Value[i] = DRTcompare.hRedBlue_Value[i].split("+");
DRTcompare.hRedBlue_Value[i][0] += " ";
DRTcompare.hRedBlue_Value[i][1] += " ";
DRTcompare.hRedBlue_Value[i][0] = DRTcompare.hRedBlue_Value[i][0].split(" ");
DRTcompare.hRedBlue_Value[i][1] = DRTcompare.hRedBlue_Value[i][1].split(" ");
if (DRTcompare.hRedBlue_Value[i][0].length <= 5) { alert(DRTcompare.AlertMsg["0003"]); return false; }
} else { DRTcompare.hRedBlue_Value = DRTcompare.hRedBlue_Value.slice(0,DRTcompare.hRedBlue_Value.length - 1); };
};
if (DRTcompare.hRedBlue_Value.length > DRTcompare.Config["batchMax"]) { alert(DRTcompare.AlertMsg["0021"]); return false; };
for (var i = 0; i < DRTcompare.ResultList.length; i++) { DRTcompare.ResultList[i] = ""; };
DRTcompare.Calculate_Start();
};
DRTcompare.Calculate_Start = function () {
var CountA, CountB;
var historyA, historyB;
var Zero, tmpArray;
for (var i = 0; i < h2b.length; i++) {
for (var j = 0; j < DRTcompare.hRedBlue_Value.length; j++) {
historyA = "," + h2b[i][0] + ",";
historyB = "," + h2b[i][1] + ",";
tmpArray = "";
CountA = DRTcompare.Calculate_Count(historyA, DRTcompare.hRedBlue_Value[j][0]);
CountB = DRTcompare.Calculate_Count(historyB, DRTcompare.hRedBlue_Value[j][1]);
if (CountA > 0) historyA = DRTcompare.Calculate_AddHTML(historyA, DRTcompare.hRedBlue_Value[j][0], "red");
if (CountB > 0) historyB = DRTcompare.Calculate_AddHTML(historyB, DRTcompare.hRedBlue_Value[j][1], "blue");
numZero = DRTcompare.Calculate_Zero(CountA, CountB);
historyA = historyA.substring(1, historyA.length - 1).split(",");
historyB = historyB.substring(1, historyB.length - 1).split(",");
tmpArray = historyA + "+" + historyB + "+" + h2b[i][2] + "+" + i + "+" + j;
DRTcompare.ResultList[numZero] += tmpArray + "||";
};
};
var obj;
for (var i = 0; i < DRTcompare.ResultList.length; i++) {
DRTcompare.ResultList[i] = DRTcompare.ResultList[i].split("||");
document.getElementById("resultx_" + i).innerHTML = DRTcompare.ResultList[i].length - 1;
var info = DRTcompare.Result_Start(i);
document.getElementById("show_" + i).innerHTML=info;
};
$('.hidden').hide();
$(".list").click(function () {
$(this).next().siblings(".list").find("a").attr('class', '');
$(this).next().slideDown();
$(this).find("a").attr('class', 'blue');
$(this).next().siblings(".hidden").slideUp();
});
document.getElementById("result1").style.display = "";
};
DRTcompare.Calculate_Count = function (history,Array)
{
var tmpCount = 0;
for (var i = 0; i < Array.length - 1; i++)
{
if (history.indexOf("," + Array[i] + ",") != -1) tmpCount++;
};
return tmpCount;
};
DRTcompare.Calculate_AddHTML = function (history,Array,type) {
var tmpHistory = history;
for (var i = 0; i < Array.length - 1; i++)
{
tmpHistory = tmpHistory.replace("," + Array[i] + ",","," + Array[i] + ",");
};
return tmpHistory;
};
DRTcompare.Calculate_Zero = function (CountA,CountB)
{
var tmpZ;
for (var i = 0; i < DRTcompare.Config["List"].length; i++)
{
if ((DRTcompare.Config["List"][i][0] == CountA) && (DRTcompare.Config["List"][i][2] == CountB))
{
tmpZ = i;
break;
};
};
return tmpZ;
};
DRTcompare.Result_onLoad = function ()
{
DRTcompare.ResultList = new Array();
var o = "";
o += DRTcompare.Result_onLoad2(0, 17, "result11");
document.getElementById("result1").innerHTML = o;
};
DRTcompare.Result_onLoad2 = function (start,end,idname)
{
var o = "";
o += "