|
|
|
@ -18,6 +18,7 @@ function init(){ |
|
|
|
|
var w = 160; |
|
|
|
|
var wh = h+6; |
|
|
|
|
var ww = w+6; |
|
|
|
|
var clickFlag = false; |
|
|
|
|
|
|
|
|
|
var ubwidget = $("#ubwidget").ubwidget({ |
|
|
|
|
width:w, |
|
|
|
@ -72,9 +73,15 @@ function init(){ |
|
|
|
|
.appendTo($("body")); |
|
|
|
|
|
|
|
|
|
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 calc = ""; |
|
|
|
|
var displayTrunk = ""; |
|
|
|
@ -83,7 +90,10 @@ function init(){ |
|
|
|
|
var subtrunk = 0; |
|
|
|
|
var itrunk = 0; |
|
|
|
|
var trunkpos = 0; |
|
|
|
|
var lastchar = {type:"NaN", value:"null"}; |
|
|
|
|
var lastchar = { |
|
|
|
|
type:"NaN",
|
|
|
|
|
value:"null" |
|
|
|
|
}; |
|
|
|
|
var inparenthesis = false; |
|
|
|
|
var erase = false; |
|
|
|
|
var abtn; |
|
|
|
@ -114,48 +124,148 @@ function init(){ |
|
|
|
|
textAlign:"right", |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
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}) |
|
|
|
|
.mousedown(function(){appendToDisplay("7", 1)}); |
|
|
|
|
var btn8 = $("<div><img src='images/touche8.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
|
.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 btnDiv = $("<div><img src='images/touchediv.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
|
.mousedown(function(){appendToDisplay("/", 0)}); |
|
|
|
|
var btn4 = $("<div><img src='images/touche4.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) |
|
|
|
|
.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 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 |
|
|
|
|
}) |
|
|
|
|
.mousedown(function(){ |
|
|
|
|
appendToDisplay("7", 1) |
|
|
|
|
}); |
|
|
|
|
var btn8 = $("<div><img src='images/touche8.png'/></div>").ubwbutton({ |
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
}) |
|
|
|
|
.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 btnDiv = $("<div><img src='images/touchediv.png'/></div>").ubwbutton({ |
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
}) |
|
|
|
|
.mousedown(function(){ |
|
|
|
|
appendToDisplay("/", 0) |
|
|
|
|
}); |
|
|
|
|
var btn4 = $("<div><img src='images/touche4.png'/></div>").ubwbutton({ |
|
|
|
|
w:cKeySize.w,
|
|
|
|
|
h:cKeySize.h |
|
|
|
|
}) |
|
|
|
|
.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>") |
|
|
|
|
.css({ |
|
|
|
@ -190,20 +300,30 @@ function init(){ |
|
|
|
|
var sleft = $("<div></div>"); |
|
|
|
|
var sright = $("<div></div>"); |
|
|
|
|
|
|
|
|
|
stop.css({width:140}) |
|
|
|
|
stop.css({ |
|
|
|
|
width:140 |
|
|
|
|
}) |
|
|
|
|
.append(btnAdd).append(btnSou) |
|
|
|
|
.append(btn7).append(btn8).append(btn9).append(btnMul) |
|
|
|
|
.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(btn0).append(btnDot).append(btnC); |
|
|
|
|
|
|
|
|
|
sright.css({width:45, float:"left"}) |
|
|
|
|
sright.css({ |
|
|
|
|
width:45,
|
|
|
|
|
float:"left" |
|
|
|
|
}) |
|
|
|
|
.append(btnEqu); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
standardPanel.css({width:150}) |
|
|
|
|
standardPanel.css({ |
|
|
|
|
width:150 |
|
|
|
|
}) |
|
|
|
|
.append(stop) |
|
|
|
|
.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); |
|
|
|
|
$("#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)
|
|
|
|
|
|
|
|
|
|
$("#display").text(updateDisplay(result)); |
|
|
|
@ -258,18 +368,18 @@ function compute(){ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
lastHistory = $("#historyBox").val(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function reset(){ |
|
|
|
|
function reset(){ |
|
|
|
|
$("#display").text("0"); |
|
|
|
|
calc=""; |
|
|
|
|
displayTrunk=""; |
|
|
|
|
historyTrunk=""; |
|
|
|
|
$("#historyBox").val(lastHistory); |
|
|
|
|
$("#historyBox").scrollTop(99999); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function formatNumberWithDelimiters(number) { |
|
|
|
|
function formatNumberWithDelimiters(number) { |
|
|
|
|
var delimiter = gThousandsSeparator; |
|
|
|
|
var numString = number.toString(); |
|
|
|
|
|
|
|
|
@ -306,10 +416,10 @@ function formatNumberWithDelimiters(number) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return (dot ? (newNumber + numString.substr(dot, stop)) : newNumber); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function formatNumberWithScientificNotation(number) { |
|
|
|
|
function formatNumberWithScientificNotation(number) { |
|
|
|
|
if (number == 0) |
|
|
|
|
return number; |
|
|
|
|
|
|
|
|
@ -325,9 +435,9 @@ function formatNumberWithScientificNotation(number) { |
|
|
|
|
return "0"; |
|
|
|
|
|
|
|
|
|
return sci; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function updateDisplay(number){ |
|
|
|
|
function updateDisplay(number){ |
|
|
|
|
if(String(number).length > 8){ |
|
|
|
|
number = formatNumberWithScientificNotation(number); |
|
|
|
|
} |
|
|
|
@ -336,9 +446,9 @@ function updateDisplay(number){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return number; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function appendToDisplay(_char, v){ |
|
|
|
|
function appendToDisplay(_char, v){ |
|
|
|
|
var char = _char; |
|
|
|
|
|
|
|
|
|
// Display
|
|
|
|
@ -400,6 +510,17 @@ function appendToDisplay(_char, v){ |
|
|
|
|
|
|
|
|
|
lastchar.value = char; |
|
|
|
|
$("#display").text(updateDisplay(displayTrunk)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$("#historyBox").click(function(){ |
|
|
|
|
if(!clickFlag){ |
|
|
|
|
$(this).select(); |
|
|
|
|
clickFlag = true;
|
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
clickFlag = false; |
|
|
|
|
$(this).blur(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
$(document).disableTextSelect(); |
|
|
|
|
}; |
|
|
|
|