|
|
@ -18,6 +18,7 @@ function init(){ |
|
|
|
var w = 160; |
|
|
|
var w = 160; |
|
|
|
var wh = h+6; |
|
|
|
var wh = h+6; |
|
|
|
var ww = w+6; |
|
|
|
var ww = w+6; |
|
|
|
|
|
|
|
var clickFlag = false; |
|
|
|
|
|
|
|
|
|
|
|
var ubwidget = $("#ubwidget").ubwidget({ |
|
|
|
var ubwidget = $("#ubwidget").ubwidget({ |
|
|
|
width:w, |
|
|
|
width:w, |
|
|
@ -72,9 +73,15 @@ function init(){ |
|
|
|
.appendTo($("body")); |
|
|
|
.appendTo($("body")); |
|
|
|
|
|
|
|
|
|
|
|
var space = $("<div></div>"); |
|
|
|
var space = $("<div></div>"); |
|
|
|
space.css({width:5, height:1, float:"left"}); |
|
|
|
space.css({ |
|
|
|
|
|
|
|
width:5,
|
|
|
|
|
|
|
|
height:1,
|
|
|
|
|
|
|
|
float:"left" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var keysPanel = $("<div id='keysPanel'></div>").css({float:"left"}); |
|
|
|
var keysPanel = $("<div id='keysPanel'></div>").css({ |
|
|
|
|
|
|
|
float:"left" |
|
|
|
|
|
|
|
}); |
|
|
|
var mode = "standard"; |
|
|
|
var mode = "standard"; |
|
|
|
var calc = ""; |
|
|
|
var calc = ""; |
|
|
|
var displayTrunk = ""; |
|
|
|
var displayTrunk = ""; |
|
|
@ -83,7 +90,10 @@ function init(){ |
|
|
|
var subtrunk = 0; |
|
|
|
var subtrunk = 0; |
|
|
|
var itrunk = 0; |
|
|
|
var itrunk = 0; |
|
|
|
var trunkpos = 0; |
|
|
|
var trunkpos = 0; |
|
|
|
var lastchar = {type:"NaN", value:"null"}; |
|
|
|
var lastchar = { |
|
|
|
|
|
|
|
type:"NaN",
|
|
|
|
|
|
|
|
value:"null" |
|
|
|
|
|
|
|
}; |
|
|
|
var inparenthesis = false; |
|
|
|
var inparenthesis = false; |
|
|
|
var erase = false; |
|
|
|
var erase = false; |
|
|
|
var abtn; |
|
|
|
var abtn; |
|
|
@ -114,48 +124,148 @@ function init(){ |
|
|
|
textAlign:"right", |
|
|
|
textAlign:"right", |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var standardPanel = $("<div></div>").css({float:"left"}); |
|
|
|
var standardPanel = $("<div></div>").css({ |
|
|
|
|
|
|
|
float:"left" |
|
|
|
var cKeySize = {w:33, h:36}; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var btn7 = $("<div><img src='images/touche7.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
var cKeySize = { |
|
|
|
.mousedown(function(){appendToDisplay("7", 1)}); |
|
|
|
w:33,
|
|
|
|
var btn8 = $("<div><img src='images/touche8.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
h:36 |
|
|
|
.mousedown(function(){appendToDisplay("8", 1)}); |
|
|
|
}; |
|
|
|
var btn9 = $("<div><img src='images/touche9.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
|
|
|
|
.mousedown(function(){appendToDisplay("9", 1)}); |
|
|
|
var btn7 = $("<div><img src='images/touche7.png'/></div>").ubwbutton({ |
|
|
|
var btnDiv = $("<div><img src='images/touchediv.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
w:cKeySize.w,
|
|
|
|
.mousedown(function(){appendToDisplay("/", 0)}); |
|
|
|
h:cKeySize.h |
|
|
|
var btn4 = $("<div><img src='images/touche4.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
}) |
|
|
|
.mousedown(function(){appendToDisplay("4", 1)}); |
|
|
|
.mousedown(function(){ |
|
|
|
var btn5 = $("<div><img src='images/touche5.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
appendToDisplay("7", 1) |
|
|
|
.mousedown(function(){appendToDisplay("5", 1)}); |
|
|
|
}); |
|
|
|
var btn6 = $("<div><img src='images/touche6.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
var btn8 = $("<div><img src='images/touche8.png'/></div>").ubwbutton({ |
|
|
|
.mousedown(function(){appendToDisplay("6", 1)}); |
|
|
|
w:cKeySize.w,
|
|
|
|
var btnMul = $("<div><img src='images/touchef.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
h:cKeySize.h |
|
|
|
.mousedown(function(){appendToDisplay("*", 0)}); |
|
|
|
}) |
|
|
|
var btn1 = $("<div><img src='images/touche1.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
.mousedown(function(){ |
|
|
|
.mousedown(function(){appendToDisplay("1", 1)}); |
|
|
|
appendToDisplay("8", 1) |
|
|
|
var btn2 = $("<div><img src='images/touche2.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
}); |
|
|
|
.mousedown(function(){appendToDisplay("2", 1)}); |
|
|
|
var btn9 = $("<div><img src='images/touche9.png'/></div>").ubwbutton({ |
|
|
|
var btn3 = $("<div><img src='images/touche3.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
w:cKeySize.w,
|
|
|
|
.mousedown(function(){appendToDisplay("3", 1)}); |
|
|
|
h:cKeySize.h |
|
|
|
var btnSou = $("<div><img src='images/touchem.png'/></div>").ubwbutton({w:68, h:34}) |
|
|
|
}) |
|
|
|
.mousedown(function(){appendToDisplay("-", 0)}); |
|
|
|
.mousedown(function(){ |
|
|
|
var btn0 = $("<div><img src='images/touche0.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
appendToDisplay("9", 1) |
|
|
|
.mousedown(function(){appendToDisplay("0", 1)}); |
|
|
|
}); |
|
|
|
var btnDot = $("<div><img src='images/touchedot.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
var btnDiv = $("<div><img src='images/touchediv.png'/></div>").ubwbutton({ |
|
|
|
.mousedown(function(){appendToDisplay(".", 1)}); |
|
|
|
w:cKeySize.w,
|
|
|
|
var btnC = $("<div><img src='images/touchec.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
h:cKeySize.h |
|
|
|
.mousedown(function(){reset()}); |
|
|
|
}) |
|
|
|
var btnAdd = $("<div><img src='images/touchep.png'/></div>").ubwbutton({w:68, h:34}) |
|
|
|
.mousedown(function(){ |
|
|
|
.mousedown(function(){appendToDisplay("+", 0)}); |
|
|
|
appendToDisplay("/", 0) |
|
|
|
var btnPaL = $("<div><img src='images/touchepg.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
}); |
|
|
|
.mousedown(function(){appendToDisplay("(", 1)}); |
|
|
|
var btn4 = $("<div><img src='images/touche4.png'/></div>").ubwbutton({ |
|
|
|
var btnPaR = $("<div><img src='images/touchepd.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
w:cKeySize.w,
|
|
|
|
.mousedown(function(){appendToDisplay(")", 1)}); |
|
|
|
h:cKeySize.h |
|
|
|
var btnEqu = $("<div><img src='images/toucheeq.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
}) |
|
|
|
.mousedown(function(){compute()});
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("4", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btn5 = $("<div><img src='images/touche5.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("5", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btn6 = $("<div><img src='images/touche6.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("6", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btnMul = $("<div><img src='images/touchef.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("*", 0) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btn1 = $("<div><img src='images/touche1.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("1", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btn2 = $("<div><img src='images/touche2.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("2", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btn3 = $("<div><img src='images/touche3.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("3", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btnSou = $("<div><img src='images/touchem.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:68,
|
|
|
|
|
|
|
|
h:34 |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("-", 0) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btn0 = $("<div><img src='images/touche0.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("0", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btnDot = $("<div><img src='images/touchedot.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay(".", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btnC = $("<div><img src='images/touchec.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
reset() |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btnAdd = $("<div><img src='images/touchep.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:68,
|
|
|
|
|
|
|
|
h:34 |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("+", 0) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btnPaL = $("<div><img src='images/touchepg.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay("(", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btnPaR = $("<div><img src='images/touchepd.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
appendToDisplay(")", 1) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var btnEqu = $("<div><img src='images/toucheeq.png'/></div>").ubwbutton({ |
|
|
|
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.mousedown(function(){ |
|
|
|
|
|
|
|
compute() |
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var historyPanel = $("<div id='historyPanel'></div>") |
|
|
|
var historyPanel = $("<div id='historyPanel'></div>") |
|
|
|
.css({ |
|
|
|
.css({ |
|
|
@ -190,20 +300,30 @@ function init(){ |
|
|
|
var sleft = $("<div></div>"); |
|
|
|
var sleft = $("<div></div>"); |
|
|
|
var sright = $("<div></div>"); |
|
|
|
var sright = $("<div></div>"); |
|
|
|
|
|
|
|
|
|
|
|
stop.css({width:140}) |
|
|
|
stop.css({ |
|
|
|
|
|
|
|
width:140 |
|
|
|
|
|
|
|
}) |
|
|
|
.append(btnAdd).append(btnSou) |
|
|
|
.append(btnAdd).append(btnSou) |
|
|
|
.append(btn7).append(btn8).append(btn9).append(btnMul) |
|
|
|
.append(btn7).append(btn8).append(btn9).append(btnMul) |
|
|
|
.append(btn4).append(btn5).append(btn6).append(btnDiv); |
|
|
|
.append(btn4).append(btn5).append(btn6).append(btnDiv); |
|
|
|
|
|
|
|
|
|
|
|
sleft.css({width:105, float:"left"}) |
|
|
|
sleft.css({ |
|
|
|
|
|
|
|
width:105,
|
|
|
|
|
|
|
|
float:"left" |
|
|
|
|
|
|
|
}) |
|
|
|
.append(btn1).append(btn2).append(btn3) |
|
|
|
.append(btn1).append(btn2).append(btn3) |
|
|
|
.append(btn0).append(btnDot).append(btnC); |
|
|
|
.append(btn0).append(btnDot).append(btnC); |
|
|
|
|
|
|
|
|
|
|
|
sright.css({width:45, float:"left"}) |
|
|
|
sright.css({ |
|
|
|
|
|
|
|
width:45,
|
|
|
|
|
|
|
|
float:"left" |
|
|
|
|
|
|
|
}) |
|
|
|
.append(btnEqu); |
|
|
|
.append(btnEqu); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
standardPanel.css({width:150}) |
|
|
|
standardPanel.css({ |
|
|
|
|
|
|
|
width:150 |
|
|
|
|
|
|
|
}) |
|
|
|
.append(stop) |
|
|
|
.append(stop) |
|
|
|
.append(sleft).append(sright); |
|
|
|
.append(sleft).append(sright); |
|
|
|
|
|
|
|
|
|
|
@ -224,21 +344,11 @@ function init(){ |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function resizeWidget(w, h){ |
|
|
|
function resizeWidget(w, h){ |
|
|
|
window.sankore.resize(w+2, h+2); |
|
|
|
window.sankore.resize(w+2, h+2); |
|
|
|
$("#indicator").remove(); |
|
|
|
} |
|
|
|
var indicator = $("<div id='indicator'></div>") |
|
|
|
|
|
|
|
.css({ |
|
|
|
|
|
|
|
width:w, |
|
|
|
|
|
|
|
height:h, |
|
|
|
|
|
|
|
position:"absolute", |
|
|
|
|
|
|
|
left:0, |
|
|
|
|
|
|
|
top:0, |
|
|
|
|
|
|
|
border:"1px solid #ff0000" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function compute(){ |
|
|
|
function compute(){ |
|
|
|
var result = eval(calc)
|
|
|
|
var result = eval(calc)
|
|
|
|
|
|
|
|
|
|
|
|
$("#display").text(updateDisplay(result)); |
|
|
|
$("#display").text(updateDisplay(result)); |
|
|
@ -258,18 +368,18 @@ function compute(){ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
lastHistory = $("#historyBox").val(); |
|
|
|
lastHistory = $("#historyBox").val(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function reset(){ |
|
|
|
function reset(){ |
|
|
|
$("#display").text("0"); |
|
|
|
$("#display").text("0"); |
|
|
|
calc=""; |
|
|
|
calc=""; |
|
|
|
displayTrunk=""; |
|
|
|
displayTrunk=""; |
|
|
|
historyTrunk=""; |
|
|
|
historyTrunk=""; |
|
|
|
$("#historyBox").val(lastHistory); |
|
|
|
$("#historyBox").val(lastHistory); |
|
|
|
$("#historyBox").scrollTop(99999); |
|
|
|
$("#historyBox").scrollTop(99999); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function formatNumberWithDelimiters(number) { |
|
|
|
function formatNumberWithDelimiters(number) { |
|
|
|
var delimiter = gThousandsSeparator; |
|
|
|
var delimiter = gThousandsSeparator; |
|
|
|
var numString = number.toString(); |
|
|
|
var numString = number.toString(); |
|
|
|
|
|
|
|
|
|
|
@ -306,10 +416,10 @@ function formatNumberWithDelimiters(number) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return (dot ? (newNumber + numString.substr(dot, stop)) : newNumber); |
|
|
|
return (dot ? (newNumber + numString.substr(dot, stop)) : newNumber); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function formatNumberWithScientificNotation(number) { |
|
|
|
function formatNumberWithScientificNotation(number) { |
|
|
|
if (number == 0) |
|
|
|
if (number == 0) |
|
|
|
return number; |
|
|
|
return number; |
|
|
|
|
|
|
|
|
|
|
@ -325,9 +435,9 @@ function formatNumberWithScientificNotation(number) { |
|
|
|
return "0"; |
|
|
|
return "0"; |
|
|
|
|
|
|
|
|
|
|
|
return sci; |
|
|
|
return sci; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function updateDisplay(number){ |
|
|
|
function updateDisplay(number){ |
|
|
|
if(String(number).length > 8){ |
|
|
|
if(String(number).length > 8){ |
|
|
|
number = formatNumberWithScientificNotation(number); |
|
|
|
number = formatNumberWithScientificNotation(number); |
|
|
|
} |
|
|
|
} |
|
|
@ -336,9 +446,9 @@ function updateDisplay(number){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return number; |
|
|
|
return number; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function appendToDisplay(_char, v){ |
|
|
|
function appendToDisplay(_char, v){ |
|
|
|
var char = _char; |
|
|
|
var char = _char; |
|
|
|
|
|
|
|
|
|
|
|
// Display
|
|
|
|
// Display
|
|
|
@ -400,6 +510,17 @@ function appendToDisplay(_char, v){ |
|
|
|
|
|
|
|
|
|
|
|
lastchar.value = char; |
|
|
|
lastchar.value = char; |
|
|
|
$("#display").text(updateDisplay(displayTrunk)); |
|
|
|
$("#display").text(updateDisplay(displayTrunk)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#historyBox").click(function(){ |
|
|
|
|
|
|
|
if(!clickFlag){ |
|
|
|
|
|
|
|
$(this).select(); |
|
|
|
|
|
|
|
clickFlag = true;
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
clickFlag = false; |
|
|
|
|
|
|
|
$(this).blur(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
$(document).disableTextSelect(); |
|
|
|
}; |
|
|
|
}; |
|
|
|