updating web-browser, notes and calculator

preferencesAboutTextFull
unknown 13 years ago
parent 42a7fef652
commit 2d60b8f329
  1. 56
      resources/library/interactive/Calculator.wgt/index.html
  2. 787
      resources/library/interactive/Calculator.wgt/js/ubw-main.js
  3. 347
      resources/library/interactive/Notes.wgt/js/ubw-main.js
  4. 397
      resources/library/interactive/WebBrowser.wgt/index.html
  5. 146
      resources/library/interactive/WebBrowser.wgt/scripts/jquery.oembed.js

@ -1,33 +1,33 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>ubwidget</title> <title>ubwidget</title>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script> <script src="js/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<script src="js/jquery.disable.text.select.js" type="text/javascript"></script> <script src="js/jquery.disable.text.select.js" type="text/javascript"></script>
<script src="js/jquery.center.js" type="text/javascript"></script> <script src="js/jquery.center.js" type="text/javascript"></script>
<script src="js/jquery.ubwidget.js" type="text/javascript"></script> <script src="js/jquery.ubwidget.js" type="text/javascript"></script>
<script src="js/DD_roundies_0.0.2a.js" type="text/javascript"></script> <script src="js/DD_roundies_0.0.2a.js" type="text/javascript"></script>
<script src="js/ubw-main.js" type="text/javascript"></script> <script src="js/ubw-main.js" type="text/javascript"></script>
<script src="js/calculate.js" type="text/javascript"></script> <script src="js/calculate.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/ubwidget.css" /> <link rel="stylesheet" type="text/css" href="css/ubwidget.css" />
</head> </head>
<body> <body>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
init(); init();
}); });
</script> </script>
<div id="ubwidget"></div> <div id="ubwidget"></div>
</body> </body>
</html> </html>

@ -14,392 +14,513 @@
*/ */
function init(){ function init(){
var h = 292; var h = 292;
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({
width:w, var ubwidget = $("#ubwidget").ubwidget({
height:h width:w,
}); height:h
});
var historyTab = $("<div></div>") var historyTab = $("<div></div>")
.css({ .css({
height:h, height:h,
marginRight:0, marginRight:0,
width:20, width:20,
float:"left", float:"left",
backgroundImage:"url(images/historytab.png)", backgroundImage:"url(images/historytab.png)",
backgroundRepeat:"no-repeat" backgroundRepeat:"no-repeat"
}) })
.toggle( .toggle(
function(){ function(){
resizeWidget(370, 294); resizeWidget(370, 294);
historyPanel.show(); historyPanel.show();
$(".ubw-container").css({ $(".ubw-container").css({
backgroundImage:"url(images/back.png)", backgroundImage:"url(images/back.png)",
width:328 width:328
}); });
if(window.sankore){ if(window.sankore){
window.sankore.setPreference('historyTab', "visible"); window.sankore.setPreference('historyTab', "visible");
}; };
}, },
function(){ function(){
resizeWidget(200, 294); resizeWidget(200, 294);
historyPanel.hide(); historyPanel.hide();
$(".ubw-container").css({ $(".ubw-container").css({
backgroundImage:"url(images/back_small.png)", backgroundImage:"url(images/back_small.png)",
width:160 width:160
}); });
if(window.sankore){ if(window.sankore){
window.sankore.setPreference('historyTab', "hidden"); window.sankore.setPreference('historyTab', "hidden");
}; };
} }
) )
.hover( .hover(
function(){ function(){
$(this).css({ $(this).css({
backgroundImage:"url(images/historytabOver.png)" backgroundImage:"url(images/historytabOver.png)"
}); });
}, },
function(){ function(){
$(this).css({ $(this).css({
backgroundImage:"url(images/historytab.png)" backgroundImage:"url(images/historytab.png)"
}); });
} }
) )
.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({
var mode = "standard"; float:"left"
var calc = ""; });
var displayTrunk = ""; var mode = "standard";
var historyTrunk = ""; var calc = "";
var lastHistory = ""; var displayTrunk = "";
var subtrunk = 0; var historyTrunk = "";
var itrunk = 0; var lastHistory = "";
var trunkpos = 0; var subtrunk = 0;
var lastchar = {type:"NaN", value:"null"}; var itrunk = 0;
var inparenthesis = false; var trunkpos = 0;
var erase = false; var lastchar = {
var abtn; type:"NaN",
var readyToCompute = false; value:"null"
var lastResult = "0"; };
var gDecimalSeparator = ""; var inparenthesis = false;
var gThousandsSeparator = ""; var erase = false;
var gDecimalCode = 0; var abtn;
var gDecimalString = ""; var readyToCompute = false;
var gError = false; var lastResult = "0";
var gDecimalSeparator = "";
var gThousandsSeparator = "";
var gDecimalCode = 0;
var gDecimalString = "";
var gError = false;
var historyTxt = "0"; var historyTxt = "0";
var display = $("<div id='display'>0</div>") var display = $("<div id='display'>0</div>")
.addClass("ubw-inputbox") .addClass("ubw-inputbox")
.css({ .css({
padding:"12px", padding:"12px",
marginLeft:"2px", marginLeft:"2px",
marginBottom:"9px", marginBottom:"9px",
marginTop:7, marginTop:7,
backgroundImage:"url(images/display.png)", backgroundImage:"url(images/display.png)",
fontSize:"22px", fontSize:"22px",
fontFamily:"Arial, Helvetica, Sans-serif", fontFamily:"Arial, Helvetica, Sans-serif",
color:"#777788", color:"#777788",
width:118, width:118,
height:28, height:28,
overflow:"hidden", overflow:"hidden",
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 cKeySize = {
w:33,
h:36
};
var btn7 = $("<div><img src='images/touche7.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) var btn7 = $("<div><img src='images/touche7.png'/></div>").ubwbutton({
.mousedown(function(){appendToDisplay("7", 1)}); w:cKeySize.w,
var btn8 = $("<div><img src='images/touche8.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) 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(){
.mousedown(function(){appendToDisplay("9", 1)}); appendToDisplay("7", 1)
var btnDiv = $("<div><img src='images/touchediv.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) });
.mousedown(function(){appendToDisplay("/", 0)}); var btn8 = $("<div><img src='images/touche8.png'/></div>").ubwbutton({
var btn4 = $("<div><img src='images/touche4.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) w:cKeySize.w,
.mousedown(function(){appendToDisplay("4", 1)}); h:cKeySize.h
var btn5 = $("<div><img src='images/touche5.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) })
.mousedown(function(){appendToDisplay("5", 1)}); .mousedown(function(){
var btn6 = $("<div><img src='images/touche6.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) appendToDisplay("8", 1)
.mousedown(function(){appendToDisplay("6", 1)}); });
var btnMul = $("<div><img src='images/touchef.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) var btn9 = $("<div><img src='images/touche9.png'/></div>").ubwbutton({
.mousedown(function(){appendToDisplay("*", 0)}); w:cKeySize.w,
var btn1 = $("<div><img src='images/touche1.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) 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(){
.mousedown(function(){appendToDisplay("2", 1)}); appendToDisplay("9", 1)
var btn3 = $("<div><img src='images/touche3.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) });
.mousedown(function(){appendToDisplay("3", 1)}); var btnDiv = $("<div><img src='images/touchediv.png'/></div>").ubwbutton({
var btnSou = $("<div><img src='images/touchem.png'/></div>").ubwbutton({w:68, h:34}) w:cKeySize.w,
.mousedown(function(){appendToDisplay("-", 0)}); h:cKeySize.h
var btn0 = $("<div><img src='images/touche0.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) })
.mousedown(function(){appendToDisplay("0", 1)}); .mousedown(function(){
var btnDot = $("<div><img src='images/touchedot.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) appendToDisplay("/", 0)
.mousedown(function(){appendToDisplay(".", 1)}); });
var btnC = $("<div><img src='images/touchec.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) var btn4 = $("<div><img src='images/touche4.png'/></div>").ubwbutton({
.mousedown(function(){reset()}); w:cKeySize.w,
var btnAdd = $("<div><img src='images/touchep.png'/></div>").ubwbutton({w:68, h:34}) h:cKeySize.h
.mousedown(function(){appendToDisplay("+", 0)}); })
var btnPaL = $("<div><img src='images/touchepg.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) .mousedown(function(){
.mousedown(function(){appendToDisplay("(", 1)}); appendToDisplay("4", 1)
var btnPaR = $("<div><img src='images/touchepd.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) });
.mousedown(function(){appendToDisplay(")", 1)}); var btn5 = $("<div><img src='images/touche5.png'/></div>").ubwbutton({
var btnEqu = $("<div><img src='images/toucheeq.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) w:cKeySize.w,
.mousedown(function(){compute()}); 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({
backgroundImage:"url(images/historyback.png)", backgroundImage:"url(images/historyback.png)",
width:"auto", width:"auto",
height:"auto", height:"auto",
float:"left", float:"left",
marginLeft:3, marginLeft:3,
marginRight:2, marginRight:2,
marginTop:6 marginTop:6
}) })
.hide(); .hide();
var historyBox = $("<textarea id='historyBox'></textarea>") var historyBox = $("<textarea id='historyBox'></textarea>")
.css({ .css({
padding:10, padding:10,
fontSize:"20px", fontSize:"20px",
fontFamily:"Arial, Helvetica, Sans-serif", fontFamily:"Arial, Helvetica, Sans-serif",
width:143, width:143,
height:236, height:236,
backgroundColor:"transparent", backgroundColor:"transparent",
resize:"none", resize:"none",
border:"none", border:"none",
overlay:"none", overlay:"none",
color:"#eeeeee" color:"#eeeeee"
}) })
.val("0"); .val("0");
historyPanel.append(historyBox); historyPanel.append(historyBox);
var stop = $("<div></div>"); var stop = $("<div></div>");
var sleft = $("<div></div>"); var sleft = $("<div></div>");
var sright = $("<div></div>"); var sright = $("<div></div>");
stop.css({width:140}) stop.css({
.append(btnAdd).append(btnSou) width:140
.append(btn7).append(btn8).append(btn9).append(btnMul) })
.append(btn4).append(btn5).append(btn6).append(btnDiv); .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({
.append(btn1).append(btn2).append(btn3) width:105,
.append(btn0).append(btnDot).append(btnC); float:"left"
})
.append(btn1).append(btn2).append(btn3)
.append(btn0).append(btnDot).append(btnC);
sright.css({width:45, float:"left"}) sright.css({
.append(btnEqu); width:45,
float:"left"
})
.append(btnEqu);
standardPanel.css({width:150}) standardPanel.css({
.append(stop) width:150
.append(sleft).append(sright); })
.append(stop)
.append(sleft).append(sright);
keysPanel keysPanel
.append(display) .append(display)
.append(standardPanel); .append(standardPanel);
ubwidget ubwidget
.append(historyPanel) .append(historyPanel)
.append(keysPanel); .append(keysPanel);
if(window.sankore){ if(window.sankore){
historyTxt = window.sankore.preference('historyTxt', historyTxt); historyTxt = window.sankore.preference('historyTxt', historyTxt);
var ht = window.sankore.preference('historyTab', "hidden"); var ht = window.sankore.preference('historyTab', "hidden");
$("#historyBox").val(historyTxt); $("#historyBox").val(historyTxt);
if(ht === "visible"){ if(ht === "visible"){
historyTab.trigger("click"); historyTab.trigger("click");
}; };
} }
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));
lastResult = result; lastResult = result;
lastchar.type = "Nan"; lastchar.type = "Nan";
lastchar.value = ""; lastchar.value = "";
calc = ""; calc = "";
$("#historyBox").val($("#historyBox").val()+historyTrunk+"\n= "+updateDisplay(result)+"\n\n"); $("#historyBox").val($("#historyBox").val()+historyTrunk+"\n= "+updateDisplay(result)+"\n\n");
$("#historyBox").scrollTop(99999); $("#historyBox").scrollTop(99999);
displayTrunk = ""; displayTrunk = "";
historyTrunk = ""; historyTrunk = "";
if(window.sankore){ if(window.sankore){
window.sankore.setPreference('historyTxt', $("#historyBox").val()); window.sankore.setPreference('historyTxt', $("#historyBox").val());
}; };
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();
if (!numString) if (!numString)
return "0"; return "0";
var dot = numString.indexOf(gDecimalSeparator); var dot = numString.indexOf(gDecimalSeparator);
if (dot == -1) if (dot == -1)
dot = numString.length; dot = numString.length;
var stop = numString.length-dot; var stop = numString.length-dot;
var characteristic = numString.substr(0, dot); var characteristic = numString.substr(0, dot);
if (!parseInt(characteristic)) if (!parseInt(characteristic))
return numString; return numString;
// see if it's a negative number // see if it's a negative number
var numIsNegative = (parseInt(characteristic) < 0) var numIsNegative = (parseInt(characteristic) < 0)
var newNumber = ""; var newNumber = "";
var delimiterCount = Math.floor((characteristic.length-1) / 3); var delimiterCount = Math.floor((characteristic.length-1) / 3);
var extras = characteristic.length % 3; var extras = characteristic.length % 3;
if (!extras && characteristic.length > 2) if (!extras && characteristic.length > 2)
extras = 3; extras = 3;
if (extras) if (extras)
newNumber = newNumber + characteristic.substr(0, extras); newNumber = newNumber + characteristic.substr(0, extras);
for (var i=0;i< delimiterCount; i++) { for (var i=0;i< delimiterCount; i++) {
if ( (0 == i) && numIsNegative && (extras == 1)) if ( (0 == i) && numIsNegative && (extras == 1))
newNumber = newNumber + characteristic.substr(extras + (i * 3), 3); newNumber = newNumber + characteristic.substr(extras + (i * 3), 3);
else else
newNumber = newNumber + delimiter + characteristic.substr(extras + (i * 3), 3); newNumber = newNumber + delimiter + characteristic.substr(extras + (i * 3), 3);
} }
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;
var numString = number.toString(); var numString = number.toString();
if (!numString) if (!numString)
return "0"; return "0";
var num = new Number(numString); var num = new Number(numString);
var sci = num.toExponential(5); var sci = num.toExponential(5);
if (sci == "NaN") if (sci == "NaN")
sci = formatNumberWithDelimiters(numString); sci = formatNumberWithDelimiters(numString);
if (!sci) if (!sci)
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);
} }
else{ else{
number = number; number = number;
} }
return number; return number;
} }
function appendToDisplay(_char, v){ function appendToDisplay(_char, v){
var char = _char; var char = _char;
// Display // Display
if($("#historyBox").val() === "0"){ if($("#historyBox").val() === "0"){
$("#historyBox").val(""); $("#historyBox").val("");
}; };
if(char == "-" && lastchar.type == "NaN"){ if(char == "-" && lastchar.type == "NaN"){
char = "m"; char = "m";
}; };
// char is a number // char is a number
if(char <= 0 || char > 0 || char == "." || char == "m" || char == "(" || char == ")"){ if(char <= 0 || char > 0 || char == "." || char == "m" || char == "(" || char == ")"){
if(char == "m"){ if(char == "m"){
char = "-"; char = "-";
}; };
if(lastchar.type == "NaN"){ if(lastchar.type == "NaN"){
displayTrunk = ""; displayTrunk = "";
}; };
if(lastchar.value == "." && char == "."){ if(lastchar.value == "." && char == "."){
calc = calc.substr(0, calc.length-1); calc = calc.substr(0, calc.length-1);
displayTrunk = displayTrunk.substr(0, displayTrunk.length-1); displayTrunk = displayTrunk.substr(0, displayTrunk.length-1);
}; };
calc += String(char); calc += String(char);
displayTrunk += String(char); displayTrunk += String(char);
historyTrunk += String(char); historyTrunk += String(char);
lastchar.type = "Number"; lastchar.type = "Number";
} }
// char is an operator // char is an operator
else { else {
if(calc.length === 0){ if(calc.length === 0){
var endCalc = calc; var endCalc = calc;
calc = lastResult + endCalc; calc = lastResult + endCalc;
historyTrunk = updateDisplay(lastResult); historyTrunk = updateDisplay(lastResult);
} }
if(lastchar.type == "NaN"){ if(lastchar.type == "NaN"){
calc = calc.substr(0, calc.length-1); calc = calc.substr(0, calc.length-1);
calc += char; calc += char;
$("#historyBox").val($("#historyBox").val().substr(0, $("#historyBox").val().length-1)); $("#historyBox").val($("#historyBox").val().substr(0, $("#historyBox").val().length-1));
} }
else{ else{
try{ try{
calc = eval(calc) + String(char); calc = eval(calc) + String(char);
}catch(e){} }catch(e){}
} }
lastchar.type = "NaN"; lastchar.type = "NaN";
try{ try{
displayTrunk = eval(calc.substr(0, calc.length-1)); displayTrunk = eval(calc.substr(0, calc.length-1));
}catch(e){} }catch(e){}
$("#historyBox").val($("#historyBox").val()+historyTrunk+char); $("#historyBox").val($("#historyBox").val()+historyTrunk+char);
$("#historyBox").scrollTop(99999); $("#historyBox").scrollTop(99999);
historyTrunk = ""; historyTrunk = "";
} }
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();
}; };

@ -15,211 +15,218 @@
function init(){ function init(){
var ubwidget = $("#ubwidget").ubwidget({ var ubwidget = $("#ubwidget").ubwidget({
width:360, width:360,
height:240 height:240
}); });
var checkMinimize = false; var checkMinimize = false;
var text = ""; var text = "";
var winwidth; var winwidth;
var minimizedHeight; var minimizedHeight;
var winheight; var winheight;
var scroll = false; var scroll = false;
var defaultFontSize = 35; var defaultFontSize = 35;
var currentFontSize = defaultFontSize; var currentFontSize = defaultFontSize;
var header = $('<div id="head"><input id="headtitle" class="stickytitle" readonly="readonly"/></div>'); var header = $('<div id="head"><input id="headtitle" class="stickytitle" readonly="readonly"/></div>');
var fontUp = $('<img src="images/stick-but-aplus.png"/>'); var fontUp = $('<img src="images/stick-but-aplus.png"/>');
var fontDown = $('<img src="images/stick-but-aminus.png"/>'); var fontDown = $('<img src="images/stick-but-aminus.png"/>');
var minimize = $('<img src="images/stick-but-minimize.png"/>'); var minimize = $('<img src="images/stick-but-minimize.png"/>');
var maximize = $('<img src="images/stick-but-maximize.png"/>'); var maximize = $('<img src="images/stick-but-maximize.png"/>');
var title = $('<div id="menu"></div>'); var title = $('<div id="menu"></div>');
var textField = $('<div id="txt"></div>'); var textField = $('<div id="txt"></div>');
var shadow = $("<table width='100%' height='18' border='0' cellspacing='0' cellpadding='0'><tr><td id='sl' width='139'></td><td id='sc' style='background-image:url(images/shadowcenter.png)'>&nbsp;</td><td id='sr' width='139'></td></tr></table>") var shadow = $("<table width='100%' height='18' border='0' cellspacing='0' cellpadding='0'><tr><td id='sl' width='139'></td><td id='sc' style='background-image:url(images/shadowcenter.png)'>&nbsp;</td><td id='sr' width='139'></td></tr></table>")
.appendTo("body"); .appendTo("body");
var shadowleft = $("<img src='images/shadowleft.png'/>") var shadowleft = $("<img src='images/shadowleft.png'/>")
.appendTo($("#sl")); .appendTo($("#sl"));
var shadowright = $("<img src='images/shadowright.png'/>") var shadowright = $("<img src='images/shadowright.png'/>")
.appendTo($("#sr")); .appendTo($("#sr"));
$("#ubwidget")
.append(header)
.append(textField);
fontUp.addClass('menuElement'); $("#ubwidget")
fontDown.addClass('menuElement'); .append(header)
minimize.addClass('menuElement'); .append(textField);
maximize.addClass('menuElement')
.hide(); fontUp.addClass('menuElement');
fontDown.addClass('menuElement');
minimize.addClass('menuElement');
maximize.addClass('menuElement')
.hide();
header.append(maximize) header.append(maximize)
.append(minimize) .append(minimize)
.append(fontUp) .append(fontUp)
.append(fontDown); .append(fontDown);
var titletext = header.find('textarea'); var titletext = header.find('textarea');
titletext.click( titletext.click(
function(){ function(){
titletext.focus(); titletext.focus();
}); });
fontDown.click( fontDown.click(
function(){ function(){
var newFontSize = parseInt(currentFontSize) - 3; var newFontSize = parseInt(currentFontSize) - 3;
textField.css({ textField.css({
fontSize : newFontSize fontSize : newFontSize
}) })
controlTextField(); controlTextField();
if(window.sankore){ if(window.sankore){
window.sankore.setPreference("fontSize", newFontSize); window.sankore.setPreference("fontSize", newFontSize);
}; };
if(!checkMinimize) if(!checkMinimize)
textField.focus(); textField.focus();
}); });
fontUp.click( fontUp.click(
function(){ function(){
var newFontSize = parseInt(currentFontSize) + 3; var newFontSize = parseInt(currentFontSize) + 3;
textField.css({ textField.css({
fontSize : newFontSize fontSize : newFontSize
}) })
controlTextField(); controlTextField();
if(window.sankore){ if(window.sankore){
window.sankore.setPreference("fontSize", newFontSize); window.sankore.setPreference("fontSize", newFontSize);
}; };
if(!checkMinimize) if(!checkMinimize)
textField.focus(); textField.focus();
}); });
minimize.click( minimize.click(
function(){ function(){
$('.ubw-container').animate({height:"26px"},500); $('.ubw-container').animate({
minimizedHeight = $('.ubw-container').height(); height:"26px"
minimize.hide(); },500);
maximize.show(); minimizedHeight = $('.ubw-container').height();
controlTextField(); minimize.hide();
$('#headtitle').show(); maximize.show();
$('#headtitle').focus(); controlTextField();
//window.resizeTo($('.ubw-container').width(),0); $('#headtitle').show();
checkMinimize = true; $('#headtitle').focus();
//window.resizeTo($('.ubw-container').width(),0);
checkMinimize = true;
}); });
maximize.click( maximize.click(
function(){ function(){
var lastHeight = String(minimizedHeight)+'px'; var lastHeight = String(minimizedHeight)+'px';
$('.ubw-container').animate({height: lastHeight},500); $('.ubw-container').animate({
height: lastHeight
},500);
maximize.hide(); maximize.hide();
minimize.show(); minimize.show();
$('#headtitle').hide(); $('#headtitle').hide();
//textField.focus(); //textField.focus();
//window.resizeTo($('.ubw-container').width()+15,minimizedHeight+20); //window.resizeTo($('.ubw-container').width()+15,minimizedHeight+20);
checkMinimize = false; checkMinimize = false;
}); });
header header
.append(title); .append(title);
title title
.addClass('menu'); .addClass('menu');
header header
.addClass('head'); .addClass('head');
textField textField
.addClass("textField") .addClass("textField")
.css("fontSize",currentFontSize) .css("fontSize",currentFontSize)
.attr('contentEditable','true') .attr('contentEditable','true')
.keyup(function(){ .keyup(function(){
if(window.sankore){ if(window.sankore){
window.sankore.setPreference("noteText", textField.html()); window.sankore.setPreference("noteText", textField.html());
} }
controlTextField(); controlTextField();
//$('#headtitle').hide(); //$('#headtitle').hide();
}); });
if(textField.html().length === 0){ if(textField.html().length === 0){
textField.focus(); textField.focus();
} }
titletext titletext.attr('rows','1');
.attr('rows','1');
function controlTextField(){ function controlTextField(){
if(textField.text().length < 25) if(textField.text().length < 25)
$('#headtitle').val(textField.text()); $('#headtitle').val(textField.text());
else else
$('#headtitle').val(textField.text().substr(0,25) + "..."); $('#headtitle').val(textField.text().substr(0,25) + "...");
textField.css({ textField.css({
height : $('.ubw-container').height()-28, height : $('.ubw-container').height()-28
}) })
if(textField.text().length == 0){ if(textField.text().length == 0){
textField.css({ textField.css({
fontSize: defaultFontSize, fontSize: defaultFontSize
}); });
} }
currentFontSize = textField.css('fontSize').replace('px',''); currentFontSize = textField.css('fontSize').replace('px','');
} }
textField.bind('paste', function(e) { textField.bind('paste', function(e) {
controlTextField(); controlTextField();
}); });
$('#headtitle').hide(); $('#headtitle').hide();
if(window.sankore){ if(window.sankore){
text = window.sankore.preference('noteText', text); text = window.sankore.preference('noteText', text);
currentFontSize = window.sankore.preference('fontSize', defaultFontSize); currentFontSize = window.sankore.preference('fontSize', defaultFontSize);
$('.ubw-container').css({ $('.ubw-container').css({
width:window.innerWidth - 2, width:window.innerWidth - 2,
height:window.innerHeight - 20 height:window.innerHeight - 20
}); });
if(checkMinimize){ if(checkMinimize){
minimize.trigger("click"); minimize.trigger("click");
}; };
textField.css({ textField.css({
fontSize : parseInt(currentFontSize) fontSize : parseInt(currentFontSize)
}) })
textField.html(text); if(text)
} textField.html(text);
else
textField.html("Enter your notes here ...");
textField.focus();
}
window.onresize = function(){ window.onresize = function(){
winwidth = window.innerWidth; winwidth = window.innerWidth;
winheight = window.innerHeight; winheight = window.innerHeight;
if(winwidth <= 290) if(winwidth <= 290)
{ {
window.resizeTo(290,winheight); window.resizeTo(290,winheight);
} }
if(winheight <= 100) if(winheight <= 100)
{ {
window.resizeTo(winwidth,100); window.resizeTo(winwidth,100);
} }
if(winheight > 600) if(winheight > 600)
{ {
window.resizeTo(winwidth,600); window.resizeTo(winwidth,600);
} }
$('.ubw-container').width(winwidth-2); $('.ubw-container').width(winwidth-2);
if(checkMinimize) if(checkMinimize)
minimizedHeight = winheight-40; minimizedHeight = winheight-40;
else else
$('.ubw-container').height(winheight-40); $('.ubw-container').height(winheight-40);
controlTextField(); controlTextField();
} }
} }

@ -1,231 +1,226 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> "http://www.w3.org/TR/html4/loose.dtd">
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Video Picker</title> <title>Web Browser</title>
<link rel="stylesheet" type="text/css" href="css/main.css"> <link rel="stylesheet" type="text/css" href="css/main.css">
<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="scripts/jquery.oembed.js" type="text/javascript"></script> <!--DEFAULT FR-->
<!--DEFAULT FR--> </head>
</head>
<body> <body>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ var loadingState = false;
//var resizer; // Timer
//var resizerIndex; function changeLoadingState(){
var currentHistory = 0; loadingState = true;
var references = new Array(); }
var globalWidth = 850;
var globalHeight = 700; $(document).ready(function(){
var language; //var resizer; // Timer
var url = ""; //var resizerIndex;
var margins = { var currentHistory = 0;
top: cssToInt($("body").css("margin-top")), var references = new Array();
right: cssToInt($("body").css("margin-right")), var globalWidth = 850;
bottom: cssToInt($("body").css("margin-bottom")), var globalHeight = 700;
left: cssToInt($("body").css("margin-left")) var language;
}; var url = "";
var margins = {
top: cssToInt($("body").css("margin-top")),
right: cssToInt($("body").css("margin-right")),
bottom: cssToInt($("body").css("margin-bottom")),
left: cssToInt($("body").css("margin-left"))
};
//resizerIndex = 0; var resizer; // Timer
var resizerIndex;
resizerIndex = 0;
if(window.sankore){ if(window.sankore){
url = window.sankore.preference("url", ""); url = window.sankore.preference("url", "");
}else{ }else{
url = ""; url = "";
}; };
language = navigator.userAgent.split(";"); language = navigator.userAgent.split(";");
language = language[3].replace(/\s/g, "").substr(0, 2); language = language[3].replace(/\s/g, "").substr(0, 2);
$("#back-button") $("#back-button")
.click(function(){ .click(function(){
if((currentHistory - 1) > 0){ loadingState = false;
$("#textbox").val(references[--currentHistory-1]); if((currentHistory - 1) > 0){
frames['web-content'].location.href = references[currentHistory-1]; $("#textbox").val(references[--currentHistory-1]);
} $("#search-button").trigger("click");
}); }
});
$("#forward-button") $("#forward-button")
.click(function(){ .click(function(){
if(currentHistory < references.length) { loadingState = false;
$("#textbox").val(references[currentHistory++]); if(currentHistory < references.length) {
frames['web-content'].location.href = $("#textbox").val(); $("#textbox").val(references[currentHistory++]);
} $("#search-button").trigger("click");
}); }
});
$("#textbox").keypress(function(e) { $("#textbox").keypress(function(e) {
if(e.keyCode == 13) { if(e.keyCode == 13) {
$("#search-button").trigger("click"); $("#search-button").trigger("click");
} }
}); });
$("#search-button") $("#search-button").click(function(){
.click(function(){ if($("#textbox").val().length > 0){
if($("#textbox").val().length > 0){ loadingState = false;
var url = $("#textbox").val(); var url = $("#textbox").val();
var urlStart = url.split("://"); var urlStart = url.split("://");
if(urlStart[0]!="http"){ if(urlStart[0]!="http"){
url = "http://" + url; url = "http://" + url;
}; };
if(checkURLs(references, url)){ if(checkURLs(references, url)){
if(currentHistory == references.length) if(currentHistory == references.length)
references[currentHistory++] = url; references[currentHistory++] = url;
else else
references = insertInto(references, currentHistory++, url); references = insertInto(references, currentHistory++, url);
} }
window.resizeTo(globalWidth, globalHeight); window.resizeTo(globalWidth, globalHeight);
$("#container") $("#container").removeClass("welcome").removeClass("change")
.removeClass("welcome") .removeClass("error").addClass("load");
.removeClass("change") $("#container-shadow").hide();
.removeClass("error") $("#arrow").hide();
.addClass("load"); $("#embeded-content").hide();
$("#container-shadow").hide(); $("#web-content").show();
$("#arrow").hide(); $('#web-content').attr('src',url);
$("#embeded-content").hide();
$("#web-content").show();
frames['web-content'].location.href = url;
checkcontent(); checkcontent();
} else { checkLoading();
$("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations } else {
$("#container") $("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations
.addClass("welcome") $("#container")
.addClass("change") .addClass("welcome")
.addClass("error") .addClass("change")
.removeClass("load"); .addClass("error")
$("#container-shadow").show(); .removeClass("load");
$("#arrow").show(); $("#container-shadow").show();
$("#embeded-content").show(); $("#arrow").show();
$("#web-content").hide(); $("#embeded-content").show();
window.resizeTo(550, 280); $("#web-content").hide();
} window.resizeTo(550, 280);
}) }
.mouseenter(function(){ })
$(this) .mouseenter(function(){
.addClass("over"); $(this)
}) .addClass("over");
.mouseleave(function(){ })
$(this) .mouseleave(function(){
.removeClass("over"); $(this)
}); .removeClass("over");
});
if(url.length > 0){
$("#textbox").val(url);
$("#search-button").trigger("click");
}else{
$("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations
};
/*$("#show-inputfield-button")
.click(
function(){
$("#show-area").hide();
$("#inputfield").show();
$("#shadow").show();
$("#container")
.removeClass("show")
.addClass("change");
adaptWidgetSize(18, 82);
})
.mouseenter(function(){
$(this)
.addClass("over");
})
.mouseleave(function(){
$(this)
.removeClass("over");
});*/
$(window).resize(function(){ if(url.length > 0){
globalWidth = $(window).width(); $("#textbox").val(url);
globalHeight = $(window).height(); $("#search-button").trigger("click");
$("#web-content") }else{
.attr("width", globalWidth - 25) $("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations
.attr("height", globalHeight - 90); };
});
$(window).resize(function(){
globalWidth = $(window).width();
globalHeight = $(window).height();
$("#web-content")
.attr("width", globalWidth - 25)
.attr("height", globalHeight - 90);
});
function checkcontent(){ function checkcontent(){
//clearTimeout(resizer);
//resizerIndex = 0;
if(window.sankore){ if(window.sankore){
window.sankore.setPreference("url", $("#textbox").val()); window.sankore.setPreference("url", $("#textbox").val());
}; };
$("#embeded-content").hide(); $("#embeded-content").hide();
$("#container").removeClass("load").addClass("show"); $("#container").removeClass("load").addClass("show");
}; };
/*function adaptWidgetSize(adjustmentX, adjustmentY){ function checkLoading(){
var widgetWidth = $("#container").width() + margins.right + margins.left + adjustmentX; if(loadingState){
var widgetHeight = $("#container").position().top + $("#container").height() + margins.bottom + adjustmentY;
clearTimeout(resizer);
window.resizeTo(widgetWidth, $(window).height()); resizerIndex = 0;
window.resizeTo($(window).width(), widgetHeight); return false;
};*/ };
if(resizerIndex > 70){
resizerIndex = 0;
$("#textbox").val("http://www.google.com/search?q=" + $("#textbox").val().replace("http://", ""));
$("#search-button").trigger("click");
}else{
resizer = setTimeout(function(){checkLoading()}, 100);
resizerIndex++;
};
};
function cssToInt(cssvalue){ function cssToInt(cssvalue){
return(parseInt(cssvalue.replace("px", ""))); return(parseInt(cssvalue.replace("px", "")));
} }
function checkURLs(arr, value){ function checkURLs(arr, value){
for(var i = 0; i < arr.length; i++) for(var i = 0; i < arr.length; i++)
if(arr[i] == value) if(arr[i] == value)
return false; return false;
return true; return true;
} }
function insertInto(arr, index, url){ function insertInto(arr, index, url){
var newArr = new Array(); var newArr = new Array();
for(var i = 0, j = 0; i < arr.length; i++, j++) for(var i = 0, j = 0; i < arr.length; i++, j++)
if(i == index - 1){ if(i == index - 1){
newArr[j] = arr[i]; newArr[j] = arr[i];
newArr[++j] = url; newArr[++j] = url;
} else } else
newArr[j] = arr[i]; newArr[j] = arr[i];
return newArr; return newArr;
} }
}); });
</script> </script>
<div id="ubwidget"> <div id="ubwidget">
<div id="shadow"></div> <div id="shadow"></div>
<div id="inputfield">
<div id="back-button" class="button">Previous</div>
<div id="forward-button" class="button">Next</div>
<input id="textbox" type="text">
<div id="search-button" class="button">Show</div>
</div>
<div id="container" class="welcome"> <div id="inputfield">
<div id="arrow"><img src="imgs/arrow.png" alt="arrow-top"></div> <div id="back-button" class="button">Previous</div>
<div id="forward-button" class="button">Next</div>
<div id="show-container"> <input id="textbox" type="text">
<div id="embeded-content"></div> <div id="search-button" class="button">Show</div>
<iframe id="web-content" name="web-content" src="" scrolling=auto frameborder=1 ></iframe> </div>
</div>
<div id="container" class="welcome">
<table cellspacing="0" cellpadding="0" id="container-shadow"> <div id="arrow"><img src="imgs/arrow.png" alt="arrow-top"></div>
<tr>
<td id="shadow-left"></td> <div id="show-container">
<td id="shadow-center">&nbsp;</td> <div id="embeded-content"></div>
<td id="shadow-right"></td> <iframe id="web-content" name="web-content" src="" scrolling=auto frameborder=1 onload="changeLoadingState()"></iframe>
</tr> </div>
</table>
</div> <table cellspacing="0" cellpadding="0" id="container-shadow">
<tr>
</div> <td id="shadow-left"></td>
</body> <td id="shadow-center">&nbsp;</td>
<td id="shadow-right"></td>
</tr>
</table>
</div>
</div>
</body>
</html> </html>

@ -1,146 +0,0 @@
(function($) {
$.fn.oembed = function(url, options) {
options = $.extend({}, $.fn.oembed.defaults, options);
return this.each(function() {
var container = $(this),
target = (url != null) ? url : container.attr("href"),
provider;
if (target != null) {
provider = getOEmbedProvider(target);
if (provider != null) {
provider.maxWidth = options.maxWidth;
provider.maxHeight = options.maxHeight;
provider.embedCode(target, function(code) { container.html(code); });
}
}
});
};
// Plugin defaults
$.fn.oembed.defaults = {
maxWidth: 500,
maxHeight: 400
};
$.fn.oembed.getPhotoCode = function(url, data) {
var code = '<div><a href="' + url + '" target="_blank"><img src="' + data.url + '"/></a></div>';
if (data.html)
code += "<div>" + data.html + "</div>";
return code;
};
$.fn.oembed.getVideoCode = function(url, data) {
var code = data.html;
return code;
};
$.fn.oembed.getRichCode = function(url, data) {
var code = data.html;
return code;
};
$.fn.oembed.getGenericCode = function(url, data) {
var title = (data.title != null) ? data.title : url,
code = '<a href="' + url + '">' + title + '</a>';
if (data.html)
code += "<div>" + data.html + "</div>";
return code;
};
$.fn.oembed.isAvailable = function(url) {
var provider = getOEmbedProvider(url);
return (provider != null);
};
/* Private Methods */
function getOEmbedProvider(url) {
for (var i = 0; i < providers.length; i++) {
if (providers[i].matches(url))
return providers[i];
}
return null;
}
var providers = [
new OEmbedProvider("fivemin", "5min.com"),
new OEmbedProvider("amazon", "amazon.com"),
new OEmbedProvider("flickr", "flickr", "http://flickr.com/services/oembed", "jsoncallback"),
new OEmbedProvider("googlevideo", "video.google."),
new OEmbedProvider("hulu", "hulu.com"),
new OEmbedProvider("imdb", "imdb.com"),
new OEmbedProvider("metacafe", "metacafe.com"),
new OEmbedProvider("qik", "qik.com"),
new OEmbedProvider("revision3", "slideshare"),
new OEmbedProvider("slideshare", "5min.com"),
new OEmbedProvider("twitpic", "twitpic.com"),
new OEmbedProvider("viddler", "viddler.com"),
new OEmbedProvider("vimeo", "vimeo.com", "http://vimeo.com/api/oembed.json"),
new OEmbedProvider("wikipedia", "wikipedia.org"),
new OEmbedProvider("wordpress", "wordpress.com"),
new OEmbedProvider("youtube", "youtube.com")
];
function OEmbedProvider(name, urlPattern, oEmbedUrl, callbackparameter) {
this.name = name;
this.urlPattern = urlPattern;
this.oEmbedUrl = (oEmbedUrl != null) ? oEmbedUrl : "http://oohembed.com/oohembed/";
this.callbackparameter = (callbackparameter != null) ? callbackparameter : "callback";
this.maxWidth = 500;
this.maxHeight = 400;
this.matches = function(externalUrl) {
// TODO: Convert to Regex
return externalUrl.indexOf(this.urlPattern) >= 0;
};
this.getRequestUrl = function(externalUrl) {
var url = this.oEmbedUrl;
if (url.indexOf("?") <= 0)
url = url + "?";
url += "maxwidth=" + this.maxWidth +
"&maxHeight=" + this.maxHeight +
"&format=json" +
"&url=" + escape(externalUrl) +
"&" + this.callbackparameter + "=?";
return url;
}
this.embedCode = function(externalUrl, embedCallback) {
var request = this.getRequestUrl(externalUrl);
$.getJSON(request, function(data) {
var code, type = data.type;
switch (type) {
case "photo":
code = $.fn.oembed.getPhotoCode(externalUrl, data);
break;
case "video":
code = $.fn.oembed.getVideoCode(externalUrl, data);
break;
case "rich":
code = $.fn.oembed.getRichCode(externalUrl, data);
break;
default:
code = $.fn.oembed.getGenericCode(externalUrl, data);
break;
}
embedCallback(code);
});
}
}
})(jQuery);
Loading…
Cancel
Save