Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Claudio Valerio 13 years ago
commit d8b0d44b7f
  1. 42
      resources/library/interactive/Calculator.wgt/index.html
  2. 897
      resources/library/interactive/Calculator.wgt/js/ubw-main.js
  3. 417
      resources/library/interactive/Notes.wgt/js/ubw-main.js
  4. 445
      resources/library/interactive/WebBrowser.wgt/index.html
  5. 146
      resources/library/interactive/WebBrowser.wgt/scripts/jquery.oembed.js
  6. 56
      src/transition/UniboardSankoreTransition.cpp
  7. 2
      src/transition/UniboardSankoreTransition.h

@ -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>")
.css({ var historyTab = $("<div></div>")
height:h, .css({
marginRight:0, height:h,
width:20, marginRight:0,
float:"left", width:20,
backgroundImage:"url(images/historytab.png)", float:"left",
backgroundRepeat:"no-repeat" backgroundImage:"url(images/historytab.png)",
}) backgroundRepeat:"no-repeat"
.toggle( })
function(){ .toggle(
resizeWidget(370, 294); function(){
historyPanel.show(); resizeWidget(370, 294);
$(".ubw-container").css({ historyPanel.show();
backgroundImage:"url(images/back.png)", $(".ubw-container").css({
width:328 backgroundImage:"url(images/back.png)",
}); width:328
if(window.sankore){ });
window.sankore.setPreference('historyTab', "visible"); if(window.sankore){
}; window.sankore.setPreference('historyTab', "visible");
}, };
function(){ },
resizeWidget(200, 294); function(){
historyPanel.hide(); resizeWidget(200, 294);
$(".ubw-container").css({ historyPanel.hide();
backgroundImage:"url(images/back_small.png)", $(".ubw-container").css({
width:160 backgroundImage:"url(images/back_small.png)",
}); width:160
if(window.sankore){ });
window.sankore.setPreference('historyTab', "hidden"); if(window.sankore){
}; window.sankore.setPreference('historyTab', "hidden");
} };
) }
.hover( )
function(){ .hover(
$(this).css({ function(){
backgroundImage:"url(images/historytabOver.png)" $(this).css({
}); backgroundImage:"url(images/historytabOver.png)"
}, });
function(){ },
$(this).css({ function(){
backgroundImage:"url(images/historytab.png)" $(this).css({
}); backgroundImage:"url(images/historytab.png)"
} });
) }
.appendTo($("body")); )
.appendTo($("body"));
var space = $("<div></div>");
space.css({width:5, height:1, float:"left"}); var space = $("<div></div>");
space.css({
var keysPanel = $("<div id='keysPanel'></div>").css({float:"left"}); width:5,
var mode = "standard"; height:1,
var calc = ""; float:"left"
var displayTrunk = ""; });
var historyTrunk = "";
var lastHistory = ""; var keysPanel = $("<div id='keysPanel'></div>").css({
var subtrunk = 0; float:"left"
var itrunk = 0; });
var trunkpos = 0; var mode = "standard";
var lastchar = {type:"NaN", value:"null"}; var calc = "";
var inparenthesis = false; var displayTrunk = "";
var erase = false; var historyTrunk = "";
var abtn; var lastHistory = "";
var readyToCompute = false; var subtrunk = 0;
var lastResult = "0"; var itrunk = 0;
var gDecimalSeparator = ""; var trunkpos = 0;
var gThousandsSeparator = ""; var lastchar = {
var gDecimalCode = 0; type:"NaN",
var gDecimalString = ""; value:"null"
var gError = false; };
var inparenthesis = false;
var historyTxt = "0"; var erase = false;
var abtn;
var display = $("<div id='display'>0</div>") var readyToCompute = false;
.addClass("ubw-inputbox") var lastResult = "0";
.css({ var gDecimalSeparator = "";
padding:"12px", var gThousandsSeparator = "";
marginLeft:"2px", var gDecimalCode = 0;
marginBottom:"9px", var gDecimalString = "";
marginTop:7, var gError = false;
backgroundImage:"url(images/display.png)",
fontSize:"22px", var historyTxt = "0";
fontFamily:"Arial, Helvetica, Sans-serif",
color:"#777788", var display = $("<div id='display'>0</div>")
width:118, .addClass("ubw-inputbox")
height:28, .css({
overflow:"hidden", padding:"12px",
textAlign:"right", marginLeft:"2px",
}); marginBottom:"9px",
marginTop:7,
var standardPanel = $("<div></div>").css({float:"left"}); backgroundImage:"url(images/display.png)",
fontSize:"22px",
var cKeySize = {w:33, h:36}; fontFamily:"Arial, Helvetica, Sans-serif",
color:"#777788",
var btn7 = $("<div><img src='images/touche7.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) width:118,
.mousedown(function(){appendToDisplay("7", 1)}); height:28,
var btn8 = $("<div><img src='images/touche8.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) overflow:"hidden",
.mousedown(function(){appendToDisplay("8", 1)}); textAlign:"right",
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}) var standardPanel = $("<div></div>").css({
.mousedown(function(){appendToDisplay("/", 0)}); float:"left"
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}) var cKeySize = {
.mousedown(function(){appendToDisplay("5", 1)}); w:33,
var btn6 = $("<div><img src='images/touche6.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) h:36
.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 btn7 = $("<div><img src='images/touche7.png'/></div>").ubwbutton({
var btn1 = $("<div><img src='images/touche1.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) w:cKeySize.w,
.mousedown(function(){appendToDisplay("1", 1)}); h:cKeySize.h
var btn2 = $("<div><img src='images/touche2.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) })
.mousedown(function(){appendToDisplay("2", 1)}); .mousedown(function(){
var btn3 = $("<div><img src='images/touche3.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) appendToDisplay("7", 1)
.mousedown(function(){appendToDisplay("3", 1)}); });
var btnSou = $("<div><img src='images/touchem.png'/></div>").ubwbutton({w:68, h:34}) var btn8 = $("<div><img src='images/touche8.png'/></div>").ubwbutton({
.mousedown(function(){appendToDisplay("-", 0)}); w:cKeySize.w,
var btn0 = $("<div><img src='images/touche0.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) 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(){
.mousedown(function(){appendToDisplay(".", 1)}); appendToDisplay("8", 1)
var btnC = $("<div><img src='images/touchec.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) });
.mousedown(function(){reset()}); var btn9 = $("<div><img src='images/touche9.png'/></div>").ubwbutton({
var btnAdd = $("<div><img src='images/touchep.png'/></div>").ubwbutton({w:68, h:34}) w:cKeySize.w,
.mousedown(function(){appendToDisplay("+", 0)}); h:cKeySize.h
var btnPaL = $("<div><img src='images/touchepg.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) })
.mousedown(function(){appendToDisplay("(", 1)}); .mousedown(function(){
var btnPaR = $("<div><img src='images/touchepd.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) appendToDisplay("9", 1)
.mousedown(function(){appendToDisplay(")", 1)}); });
var btnEqu = $("<div><img src='images/toucheeq.png'/></div>").ubwbutton({w:cKeySize.w, h:cKeySize.h}) var btnDiv = $("<div><img src='images/touchediv.png'/></div>").ubwbutton({
.mousedown(function(){compute()}); w:cKeySize.w,
h:cKeySize.h
var historyPanel = $("<div id='historyPanel'></div>") })
.css({ .mousedown(function(){
backgroundImage:"url(images/historyback.png)", appendToDisplay("/", 0)
width:"auto", });
height:"auto", var btn4 = $("<div><img src='images/touche4.png'/></div>").ubwbutton({
float:"left", w:cKeySize.w,
marginLeft:3, h:cKeySize.h
marginRight:2, })
marginTop:6 .mousedown(function(){
}) appendToDisplay("4", 1)
.hide(); });
var btn5 = $("<div><img src='images/touche5.png'/></div>").ubwbutton({
var historyBox = $("<textarea id='historyBox'></textarea>") w:cKeySize.w,
.css({ h:cKeySize.h
padding:10, })
fontSize:"20px", .mousedown(function(){
fontFamily:"Arial, Helvetica, Sans-serif", appendToDisplay("5", 1)
width:143, });
height:236, var btn6 = $("<div><img src='images/touche6.png'/></div>").ubwbutton({
backgroundColor:"transparent", w:cKeySize.w,
resize:"none", h:cKeySize.h
border:"none", })
overlay:"none", .mousedown(function(){
color:"#eeeeee" appendToDisplay("6", 1)
}) });
.val("0"); var btnMul = $("<div><img src='images/touchef.png'/></div>").ubwbutton({
w:cKeySize.w,
historyPanel.append(historyBox); h:cKeySize.h
})
var stop = $("<div></div>"); .mousedown(function(){
var sleft = $("<div></div>"); appendToDisplay("*", 0)
var sright = $("<div></div>"); });
var btn1 = $("<div><img src='images/touche1.png'/></div>").ubwbutton({
stop.css({width:140}) w:cKeySize.w,
.append(btnAdd).append(btnSou) h:cKeySize.h
.append(btn7).append(btn8).append(btn9).append(btnMul) })
.append(btn4).append(btn5).append(btn6).append(btnDiv); .mousedown(function(){
appendToDisplay("1", 1)
sleft.css({width:105, float:"left"}) });
.append(btn1).append(btn2).append(btn3) var btn2 = $("<div><img src='images/touche2.png'/></div>").ubwbutton({
.append(btn0).append(btnDot).append(btnC); w:cKeySize.w,
h:cKeySize.h
sright.css({width:45, float:"left"}) })
.append(btnEqu); .mousedown(function(){
appendToDisplay("2", 1)
});
standardPanel.css({width:150}) var btn3 = $("<div><img src='images/touche3.png'/></div>").ubwbutton({
.append(stop) w:cKeySize.w,
.append(sleft).append(sright); h:cKeySize.h
})
keysPanel .mousedown(function(){
.append(display) appendToDisplay("3", 1)
.append(standardPanel); });
var btnSou = $("<div><img src='images/touchem.png'/></div>").ubwbutton({
ubwidget w:68,
.append(historyPanel) h:34
.append(keysPanel); })
.mousedown(function(){
if(window.sankore){ appendToDisplay("-", 0)
historyTxt = window.sankore.preference('historyTxt', historyTxt); });
var ht = window.sankore.preference('historyTab', "hidden"); var btn0 = $("<div><img src='images/touche0.png'/></div>").ubwbutton({
$("#historyBox").val(historyTxt); w:cKeySize.w,
if(ht === "visible"){ h:cKeySize.h
historyTab.trigger("click"); })
}; .mousedown(function(){
} appendToDisplay("0", 1)
});
function resizeWidget(w, h){ var btnDot = $("<div><img src='images/touchedot.png'/></div>").ubwbutton({
window.sankore.resize(w+2, h+2); w:cKeySize.w,
$("#indicator").remove(); h:cKeySize.h
var indicator = $("<div id='indicator'></div>") })
.css({ .mousedown(function(){
width:w, appendToDisplay(".", 1)
height:h, });
position:"absolute", var btnC = $("<div><img src='images/touchec.png'/></div>").ubwbutton({
left:0, w:cKeySize.w,
top:0, h:cKeySize.h
border:"1px solid #ff0000" })
}); .mousedown(function(){
} reset()
});
function compute(){ var btnAdd = $("<div><img src='images/touchep.png'/></div>").ubwbutton({
var result = eval(calc) w:68,
h:34
$("#display").text(updateDisplay(result)); })
lastResult = result; .mousedown(function(){
lastchar.type = "Nan"; appendToDisplay("+", 0)
lastchar.value = ""; });
calc = ""; var btnPaL = $("<div><img src='images/touchepg.png'/></div>").ubwbutton({
w:cKeySize.w,
$("#historyBox").val($("#historyBox").val()+historyTrunk+"\n= "+updateDisplay(result)+"\n\n"); h:cKeySize.h
$("#historyBox").scrollTop(99999); })
.mousedown(function(){
displayTrunk = ""; appendToDisplay("(", 1)
historyTrunk = ""; });
var btnPaR = $("<div><img src='images/touchepd.png'/></div>").ubwbutton({
if(window.sankore){ w:cKeySize.w,
window.sankore.setPreference('historyTxt', $("#historyBox").val()); h:cKeySize.h
}; })
.mousedown(function(){
lastHistory = $("#historyBox").val(); appendToDisplay(")", 1)
} });
var btnEqu = $("<div><img src='images/toucheeq.png'/></div>").ubwbutton({
function reset(){ w:cKeySize.w,
$("#display").text("0"); h:cKeySize.h
calc=""; })
displayTrunk=""; .mousedown(function(){
historyTrunk=""; compute()
$("#historyBox").val(lastHistory); });
$("#historyBox").scrollTop(99999);
} var historyPanel = $("<div id='historyPanel'></div>")
.css({
function formatNumberWithDelimiters(number) { backgroundImage:"url(images/historyback.png)",
var delimiter = gThousandsSeparator; width:"auto",
var numString = number.toString(); height:"auto",
float:"left",
if (!numString) marginLeft:3,
return "0"; marginRight:2,
marginTop:6
var dot = numString.indexOf(gDecimalSeparator); })
if (dot == -1) .hide();
dot = numString.length;
var historyBox = $("<textarea id='historyBox'></textarea>")
var stop = numString.length-dot; .css({
var characteristic = numString.substr(0, dot); padding:10,
if (!parseInt(characteristic)) fontSize:"20px",
return numString; fontFamily:"Arial, Helvetica, Sans-serif",
width:143,
// see if it's a negative number height:236,
var numIsNegative = (parseInt(characteristic) < 0) backgroundColor:"transparent",
resize:"none",
var newNumber = ""; border:"none",
var delimiterCount = Math.floor((characteristic.length-1) / 3); overlay:"none",
var extras = characteristic.length % 3; color:"#eeeeee"
if (!extras && characteristic.length > 2) })
extras = 3; .val("0");
if (extras) historyPanel.append(historyBox);
newNumber = newNumber + characteristic.substr(0, extras);
var stop = $("<div></div>");
for (var i=0;i< delimiterCount; i++) { var sleft = $("<div></div>");
var sright = $("<div></div>");
if ( (0 == i) && numIsNegative && (extras == 1))
newNumber = newNumber + characteristic.substr(extras + (i * 3), 3); stop.css({
else width:140
newNumber = newNumber + delimiter + characteristic.substr(extras + (i * 3), 3); })
} .append(btnAdd).append(btnSou)
.append(btn7).append(btn8).append(btn9).append(btnMul)
return (dot ? (newNumber + numString.substr(dot, stop)) : newNumber); .append(btn4).append(btn5).append(btn6).append(btnDiv);
}
sleft.css({
width:105,
function formatNumberWithScientificNotation(number) { float:"left"
if (number == 0) })
return number; .append(btn1).append(btn2).append(btn3)
.append(btn0).append(btnDot).append(btnC);
var numString = number.toString();
if (!numString) sright.css({
return "0"; width:45,
float:"left"
var num = new Number(numString); })
var sci = num.toExponential(5); .append(btnEqu);
if (sci == "NaN")
sci = formatNumberWithDelimiters(numString);
if (!sci) standardPanel.css({
return "0"; width:150
})
return sci; .append(stop)
} .append(sleft).append(sright);
function updateDisplay(number){ keysPanel
if(String(number).length > 8){ .append(display)
number = formatNumberWithScientificNotation(number); .append(standardPanel);
}
else{ ubwidget
number = number; .append(historyPanel)
} .append(keysPanel);
return number; if(window.sankore){
} historyTxt = window.sankore.preference('historyTxt', historyTxt);
var ht = window.sankore.preference('historyTab', "hidden");
function appendToDisplay(_char, v){ $("#historyBox").val(historyTxt);
var char = _char; if(ht === "visible"){
historyTab.trigger("click");
// Display };
if($("#historyBox").val() === "0"){ }
$("#historyBox").val("");
}; function resizeWidget(w, h){
window.sankore.resize(w+2, h+2);
if(char == "-" && lastchar.type == "NaN"){ }
char = "m";
}; function compute(){
var result = eval(calc)
// char is a number
if(char <= 0 || char > 0 || char == "." || char == "m" || char == "(" || char == ")"){ $("#display").text(updateDisplay(result));
if(char == "m"){ lastResult = result;
char = "-"; lastchar.type = "Nan";
}; lastchar.value = "";
calc = "";
if(lastchar.type == "NaN"){
displayTrunk = ""; $("#historyBox").val($("#historyBox").val()+historyTrunk+"\n= "+updateDisplay(result)+"\n\n");
}; $("#historyBox").scrollTop(99999);
if(lastchar.value == "." && char == "."){ displayTrunk = "";
calc = calc.substr(0, calc.length-1); historyTrunk = "";
displayTrunk = displayTrunk.substr(0, displayTrunk.length-1);
}; if(window.sankore){
window.sankore.setPreference('historyTxt', $("#historyBox").val());
calc += String(char); };
displayTrunk += String(char);
historyTrunk += String(char); lastHistory = $("#historyBox").val();
lastchar.type = "Number"; }
}
// char is an operator function reset(){
else { $("#display").text("0");
if(calc.length === 0){ calc="";
var endCalc = calc; displayTrunk="";
calc = lastResult + endCalc; historyTrunk="";
historyTrunk = updateDisplay(lastResult); $("#historyBox").val(lastHistory);
} $("#historyBox").scrollTop(99999);
}
if(lastchar.type == "NaN"){
calc = calc.substr(0, calc.length-1); function formatNumberWithDelimiters(number) {
calc += char; var delimiter = gThousandsSeparator;
$("#historyBox").val($("#historyBox").val().substr(0, $("#historyBox").val().length-1)); var numString = number.toString();
}
else{ if (!numString)
try{ return "0";
calc = eval(calc) + String(char);
}catch(e){} var dot = numString.indexOf(gDecimalSeparator);
} if (dot == -1)
dot = numString.length;
lastchar.type = "NaN";
try{ var stop = numString.length-dot;
displayTrunk = eval(calc.substr(0, calc.length-1)); var characteristic = numString.substr(0, dot);
}catch(e){} if (!parseInt(characteristic))
$("#historyBox").val($("#historyBox").val()+historyTrunk+char); return numString;
$("#historyBox").scrollTop(99999);
historyTrunk = ""; // see if it's a negative number
} var numIsNegative = (parseInt(characteristic) < 0)
lastchar.value = char; var newNumber = "";
$("#display").text(updateDisplay(displayTrunk)); var delimiterCount = Math.floor((characteristic.length-1) / 3);
} var extras = characteristic.length % 3;
if (!extras && characteristic.length > 2)
extras = 3;
if (extras)
newNumber = newNumber + characteristic.substr(0, extras);
for (var i=0;i< delimiterCount; i++) {
if ( (0 == i) && numIsNegative && (extras == 1))
newNumber = newNumber + characteristic.substr(extras + (i * 3), 3);
else
newNumber = newNumber + delimiter + characteristic.substr(extras + (i * 3), 3);
}
return (dot ? (newNumber + numString.substr(dot, stop)) : newNumber);
}
function formatNumberWithScientificNotation(number) {
if (number == 0)
return number;
var numString = number.toString();
if (!numString)
return "0";
var num = new Number(numString);
var sci = num.toExponential(5);
if (sci == "NaN")
sci = formatNumberWithDelimiters(numString);
if (!sci)
return "0";
return sci;
}
function updateDisplay(number){
if(String(number).length > 8){
number = formatNumberWithScientificNotation(number);
}
else{
number = number;
}
return number;
}
function appendToDisplay(_char, v){
var char = _char;
// Display
if($("#historyBox").val() === "0"){
$("#historyBox").val("");
};
if(char == "-" && lastchar.type == "NaN"){
char = "m";
};
// char is a number
if(char <= 0 || char > 0 || char == "." || char == "m" || char == "(" || char == ")"){
if(char == "m"){
char = "-";
};
if(lastchar.type == "NaN"){
displayTrunk = "";
};
if(lastchar.value == "." && char == "."){
calc = calc.substr(0, calc.length-1);
displayTrunk = displayTrunk.substr(0, displayTrunk.length-1);
};
calc += String(char);
displayTrunk += String(char);
historyTrunk += String(char);
lastchar.type = "Number";
}
// char is an operator
else {
if(calc.length === 0){
var endCalc = calc;
calc = lastResult + endCalc;
historyTrunk = updateDisplay(lastResult);
}
if(lastchar.type == "NaN"){
calc = calc.substr(0, calc.length-1);
calc += char;
$("#historyBox").val($("#historyBox").val().substr(0, $("#historyBox").val().length-1));
}
else{
try{
calc = eval(calc) + String(char);
}catch(e){}
}
lastchar.type = "NaN";
try{
displayTrunk = eval(calc.substr(0, calc.length-1));
}catch(e){}
$("#historyBox").val($("#historyBox").val()+historyTrunk+char);
$("#historyBox").scrollTop(99999);
historyTrunk = "";
}
lastchar.value = char;
$("#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 text = "";
var winwidth;
var minimizedHeight;
var winheight;
var scroll = false;
var defaultFontSize = 35;
var currentFontSize = defaultFontSize;
var header = $('<div id="head"><input id="headtitle" class="stickytitle" readonly="readonly"/></div>');
var fontUp = $('<img src="images/stick-but-aplus.png"/>');
var fontDown = $('<img src="images/stick-but-aminus.png"/>');
var minimize = $('<img src="images/stick-but-minimize.png"/>');
var maximize = $('<img src="images/stick-but-maximize.png"/>');
var title = $('<div id="menu"></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>")
.appendTo("body");
var shadowleft = $("<img src='images/shadowleft.png'/>")
.appendTo($("#sl"));
var shadowright = $("<img src='images/shadowright.png'/>")
.appendTo($("#sr"));
$("#ubwidget")
.append(header)
.append(textField);
fontUp.addClass('menuElement');
fontDown.addClass('menuElement');
minimize.addClass('menuElement');
maximize.addClass('menuElement')
.hide();
header.append(maximize)
.append(minimize)
.append(fontUp)
.append(fontDown);
var titletext = header.find('textarea');
titletext.click(
function(){
titletext.focus();
});
fontDown.click(
function(){
var newFontSize = parseInt(currentFontSize) - 3;
textField.css({
fontSize : newFontSize
})
controlTextField();
if(window.sankore){
window.sankore.setPreference("fontSize", newFontSize);
};
if(!checkMinimize)
textField.focus();
});
fontUp.click(
function(){
var newFontSize = parseInt(currentFontSize) + 3;
textField.css({
fontSize : newFontSize
})
controlTextField();
if(window.sankore){
window.sankore.setPreference("fontSize", newFontSize);
};
if(!checkMinimize)
textField.focus();
});
minimize.click(
function(){
$('.ubw-container').animate({height:"26px"},500);
minimizedHeight = $('.ubw-container').height();
minimize.hide();
maximize.show();
controlTextField();
$('#headtitle').show();
$('#headtitle').focus();
//window.resizeTo($('.ubw-container').width(),0);
checkMinimize = true;
});
maximize.click(
function(){
var lastHeight = String(minimizedHeight)+'px';
$('.ubw-container').animate({height: lastHeight},500);
maximize.hide();
minimize.show();
$('#headtitle').hide();
//textField.focus();
//window.resizeTo($('.ubw-container').width()+15,minimizedHeight+20);
checkMinimize = false;
});
header
.append(title);
title
.addClass('menu');
header
.addClass('head');
textField
.addClass("textField")
.css("fontSize",currentFontSize)
.attr('contentEditable','true')
.keyup(function(){
if(window.sankore){
window.sankore.setPreference("noteText", textField.html());
}
controlTextField();
//$('#headtitle').hide();
});
if(textField.html().length === 0){
textField.focus();
}
titletext
.attr('rows','1');
function controlTextField(){
if(textField.text().length < 25)
$('#headtitle').val(textField.text());
else
$('#headtitle').val(textField.text().substr(0,25) + "...");
textField.css({
height : $('.ubw-container').height()-28,
})
if(textField.text().length == 0){
textField.css({
fontSize: defaultFontSize,
});
}
currentFontSize = textField.css('fontSize').replace('px','');
}
textField.bind('paste', function(e) {
controlTextField();
}); });
$('#headtitle').hide(); var checkMinimize = false;
var text = "";
if(window.sankore){ var winwidth;
text = window.sankore.preference('noteText', text); var minimizedHeight;
currentFontSize = window.sankore.preference('fontSize', defaultFontSize); var winheight;
$('.ubw-container').css({ var scroll = false;
width:window.innerWidth - 2, var defaultFontSize = 35;
height:window.innerHeight - 20 var currentFontSize = defaultFontSize;
}); var header = $('<div id="head"><input id="headtitle" class="stickytitle" readonly="readonly"/></div>');
var fontUp = $('<img src="images/stick-but-aplus.png"/>');
if(checkMinimize){ var fontDown = $('<img src="images/stick-but-aminus.png"/>');
minimize.trigger("click"); var minimize = $('<img src="images/stick-but-minimize.png"/>');
}; var maximize = $('<img src="images/stick-but-maximize.png"/>');
var title = $('<div id="menu"></div>');
textField.css({ var textField = $('<div id="txt"></div>');
fontSize : parseInt(currentFontSize) 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");
textField.html(text); var shadowleft = $("<img src='images/shadowleft.png'/>")
} .appendTo($("#sl"));
var shadowright = $("<img src='images/shadowright.png'/>")
window.onresize = function(){ .appendTo($("#sr"));
winwidth = window.innerWidth;
winheight = window.innerHeight; $("#ubwidget")
.append(header)
if(winwidth <= 290) .append(textField);
{
window.resizeTo(290,winheight); fontUp.addClass('menuElement');
} fontDown.addClass('menuElement');
if(winheight <= 100) minimize.addClass('menuElement');
{ maximize.addClass('menuElement')
window.resizeTo(winwidth,100); .hide();
}
if(winheight > 600) header.append(maximize)
{ .append(minimize)
window.resizeTo(winwidth,600); .append(fontUp)
} .append(fontDown);
var titletext = header.find('textarea');
$('.ubw-container').width(winwidth-2);
titletext.click(
if(checkMinimize) function(){
minimizedHeight = winheight-40; titletext.focus();
else
$('.ubw-container').height(winheight-40); });
controlTextField(); fontDown.click(
} function(){
var newFontSize = parseInt(currentFontSize) - 3;
textField.css({
fontSize : newFontSize
})
controlTextField();
if(window.sankore){
window.sankore.setPreference("fontSize", newFontSize);
};
if(!checkMinimize)
textField.focus();
});
fontUp.click(
function(){
var newFontSize = parseInt(currentFontSize) + 3;
textField.css({
fontSize : newFontSize
})
controlTextField();
if(window.sankore){
window.sankore.setPreference("fontSize", newFontSize);
};
if(!checkMinimize)
textField.focus();
});
minimize.click(
function(){
$('.ubw-container').animate({
height:"26px"
},500);
minimizedHeight = $('.ubw-container').height();
minimize.hide();
maximize.show();
controlTextField();
$('#headtitle').show();
$('#headtitle').focus();
//window.resizeTo($('.ubw-container').width(),0);
checkMinimize = true;
});
maximize.click(
function(){
var lastHeight = String(minimizedHeight)+'px';
$('.ubw-container').animate({
height: lastHeight
},500);
maximize.hide();
minimize.show();
$('#headtitle').hide();
//textField.focus();
//window.resizeTo($('.ubw-container').width()+15,minimizedHeight+20);
checkMinimize = false;
});
header
.append(title);
title
.addClass('menu');
header
.addClass('head');
textField
.addClass("textField")
.css("fontSize",currentFontSize)
.attr('contentEditable','true')
.keyup(function(){
if(window.sankore){
window.sankore.setPreference("noteText", textField.html());
}
controlTextField();
//$('#headtitle').hide();
});
if(textField.html().length === 0){
textField.focus();
}
titletext.attr('rows','1');
function controlTextField(){
if(textField.text().length < 25)
$('#headtitle').val(textField.text());
else
$('#headtitle').val(textField.text().substr(0,25) + "...");
textField.css({
height : $('.ubw-container').height()-28
})
if(textField.text().length == 0){
textField.css({
fontSize: defaultFontSize
});
}
currentFontSize = textField.css('fontSize').replace('px','');
}
textField.bind('paste', function(e) {
controlTextField();
});
$('#headtitle').hide();
if(window.sankore){
text = window.sankore.preference('noteText', text);
currentFontSize = window.sankore.preference('fontSize', defaultFontSize);
$('.ubw-container').css({
width:window.innerWidth - 2,
height:window.innerHeight - 20
});
if(checkMinimize){
minimize.trigger("click");
};
textField.css({
fontSize : parseInt(currentFontSize)
})
if(text)
textField.html(text);
else
textField.html("Enter your notes here ...");
textField.focus();
}
window.onresize = function(){
winwidth = window.innerWidth;
winheight = window.innerHeight;
if(winwidth <= 290)
{
window.resizeTo(290,winheight);
}
if(winheight <= 100)
{
window.resizeTo(winwidth,100);
}
if(winheight > 600)
{
window.resizeTo(winwidth,600);
}
$('.ubw-container').width(winwidth-2);
if(checkMinimize)
minimizedHeight = winheight-40;
else
$('.ubw-container').height(winheight-40);
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">
var loadingState = false;
$(document).ready(function(){
//var resizer; // Timer function changeLoadingState(){
//var resizerIndex; loadingState = true;
var currentHistory = 0; }
var references = new Array();
var globalWidth = 850; $(document).ready(function(){
var globalHeight = 700; //var resizer; // Timer
var language; //var resizerIndex;
var url = ""; var currentHistory = 0;
var margins = { var references = new Array();
top: cssToInt($("body").css("margin-top")), var globalWidth = 850;
right: cssToInt($("body").css("margin-right")), var globalHeight = 700;
bottom: cssToInt($("body").css("margin-bottom")), var language;
left: cssToInt($("body").css("margin-left")) var url = "";
}; var margins = {
top: cssToInt($("body").css("margin-top")),
//resizerIndex = 0; right: cssToInt($("body").css("margin-right")),
bottom: cssToInt($("body").css("margin-bottom")),
if(window.sankore){ left: cssToInt($("body").css("margin-left"))
url = window.sankore.preference("url", ""); };
}else{
url = ""; var resizer; // Timer
}; var resizerIndex;
language = navigator.userAgent.split(";");
language = language[3].replace(/\s/g, "").substr(0, 2); resizerIndex = 0;
$("#back-button") if(window.sankore){
.click(function(){ url = window.sankore.preference("url", "");
if((currentHistory - 1) > 0){ }else{
$("#textbox").val(references[--currentHistory-1]); url = "";
frames['web-content'].location.href = references[currentHistory-1]; };
}
}); language = navigator.userAgent.split(";");
language = language[3].replace(/\s/g, "").substr(0, 2);
$("#forward-button")
.click(function(){ $("#back-button")
if(currentHistory < references.length) { .click(function(){
$("#textbox").val(references[currentHistory++]); loadingState = false;
frames['web-content'].location.href = $("#textbox").val(); if((currentHistory - 1) > 0){
} $("#textbox").val(references[--currentHistory-1]);
}); $("#search-button").trigger("click");
}
$("#textbox").keypress(function(e) { });
if(e.keyCode == 13) {
$("#search-button").trigger("click"); $("#forward-button")
} .click(function(){
}); loadingState = false;
if(currentHistory < references.length) {
$("#search-button") $("#textbox").val(references[currentHistory++]);
.click(function(){ $("#search-button").trigger("click");
if($("#textbox").val().length > 0){ }
var url = $("#textbox").val(); });
var urlStart = url.split("://");
$("#textbox").keypress(function(e) {
if(urlStart[0]!="http"){ if(e.keyCode == 13) {
url = "http://" + url; $("#search-button").trigger("click");
}; }
});
if(checkURLs(references, url)){
if(currentHistory == references.length) $("#search-button").click(function(){
references[currentHistory++] = url; if($("#textbox").val().length > 0){
else loadingState = false;
references = insertInto(references, currentHistory++, url); var url = $("#textbox").val();
} var urlStart = url.split("://");
window.resizeTo(globalWidth, globalHeight);
if(urlStart[0]!="http"){
$("#container") url = "http://" + url;
.removeClass("welcome") };
.removeClass("change")
.removeClass("error") if(checkURLs(references, url)){
.addClass("load"); if(currentHistory == references.length)
$("#container-shadow").hide(); references[currentHistory++] = url;
$("#arrow").hide(); else
$("#embeded-content").hide(); references = insertInto(references, currentHistory++, url);
$("#web-content").show(); }
window.resizeTo(globalWidth, globalHeight);
frames['web-content'].location.href = url;
$("#container").removeClass("welcome").removeClass("change")
checkcontent(); .removeClass("error").addClass("load");
} else { $("#container-shadow").hide();
$("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations $("#arrow").hide();
$("#container") $("#embeded-content").hide();
.addClass("welcome") $("#web-content").show();
.addClass("change") $('#web-content').attr('src',url);
.addClass("error")
.removeClass("load"); checkcontent();
$("#container-shadow").show(); checkLoading();
$("#arrow").show(); } else {
$("#embeded-content").show(); $("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations
$("#web-content").hide(); $("#container")
window.resizeTo(550, 280); .addClass("welcome")
} .addClass("change")
}) .addClass("error")
.mouseenter(function(){ .removeClass("load");
$(this) $("#container-shadow").show();
.addClass("over"); $("#arrow").show();
}) $("#embeded-content").show();
.mouseleave(function(){ $("#web-content").hide();
$(this) window.resizeTo(550, 280);
.removeClass("over"); }
}); })
.mouseenter(function(){
if(url.length > 0){ $(this)
$("#textbox").val(url); .addClass("over");
$("#search-button").trigger("click"); })
}else{ .mouseleave(function(){
$("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations $(this)
}; .removeClass("over");
});
/*$("#show-inputfield-button")
.click( if(url.length > 0){
function(){ $("#textbox").val(url);
$("#show-area").hide(); $("#search-button").trigger("click");
$("#inputfield").show(); }else{
$("#shadow").show(); $("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations
$("#container") };
.removeClass("show")
.addClass("change"); $(window).resize(function(){
adaptWidgetSize(18, 82); globalWidth = $(window).width();
}) globalHeight = $(window).height();
.mouseenter(function(){ $("#web-content")
$(this) .attr("width", globalWidth - 25)
.addClass("over"); .attr("height", globalHeight - 90);
}) });
.mouseleave(function(){
$(this) function checkcontent(){
.removeClass("over");
});*/ if(window.sankore){
window.sankore.setPreference("url", $("#textbox").val());
$(window).resize(function(){ };
globalWidth = $(window).width();
globalHeight = $(window).height(); $("#embeded-content").hide();
$("#web-content") $("#container").removeClass("load").addClass("show");
.attr("width", globalWidth - 25) };
.attr("height", globalHeight - 90);
}); function checkLoading(){
if(loadingState){
function checkcontent(){
//clearTimeout(resizer); clearTimeout(resizer);
//resizerIndex = 0; resizerIndex = 0;
return false;
if(window.sankore){ };
window.sankore.setPreference("url", $("#textbox").val()); if(resizerIndex > 70){
}; resizerIndex = 0;
$("#textbox").val("http://www.google.com/search?q=" + $("#textbox").val().replace("http://", ""));
$("#embeded-content").hide(); $("#search-button").trigger("click");
$("#container").removeClass("load").addClass("show"); }else{
}; resizer = setTimeout(function(){checkLoading()}, 100);
resizerIndex++;
/*function adaptWidgetSize(adjustmentX, adjustmentY){ };
var widgetWidth = $("#container").width() + margins.right + margins.left + adjustmentX; };
var widgetHeight = $("#container").position().top + $("#container").height() + margins.bottom + adjustmentY;
function cssToInt(cssvalue){
window.resizeTo(widgetWidth, $(window).height()); return(parseInt(cssvalue.replace("px", "")));
window.resizeTo($(window).width(), widgetHeight); }
};*/
function checkURLs(arr, value){
function cssToInt(cssvalue){ for(var i = 0; i < arr.length; i++)
return(parseInt(cssvalue.replace("px", ""))); if(arr[i] == value)
} return false;
return true;
function checkURLs(arr, value){ }
for(var i = 0; i < arr.length; i++)
if(arr[i] == value) function insertInto(arr, index, url){
return false; var newArr = new Array();
return true; for(var i = 0, j = 0; i < arr.length; i++, j++)
} if(i == index - 1){
newArr[j] = arr[i];
function insertInto(arr, index, url){ newArr[++j] = url;
var newArr = new Array(); } else
for(var i = 0, j = 0; i < arr.length; i++, j++) newArr[j] = arr[i];
if(i == index - 1){ return newArr;
newArr[j] = arr[i]; }
newArr[++j] = url;
} else });
newArr[j] = arr[i]; </script>
return newArr;
} <div id="ubwidget">
<div id="shadow"></div>
});
</script> <div id="inputfield">
<div id="back-button" class="button">Previous</div>
<div id="ubwidget"> <div id="forward-button" class="button">Next</div>
<div id="shadow"></div> <input id="textbox" type="text">
<div id="search-button" class="button">Show</div>
<div id="inputfield"> </div>
<div id="back-button" class="button">Previous</div>
<div id="forward-button" class="button">Next</div> <div id="container" class="welcome">
<input id="textbox" type="text"> <div id="arrow"><img src="imgs/arrow.png" alt="arrow-top"></div>
<div id="search-button" class="button">Show</div>
</div> <div id="show-container">
<div id="embeded-content"></div>
<div id="container" class="welcome"> <iframe id="web-content" name="web-content" src="" scrolling=auto frameborder=1 onload="changeLoadingState()"></iframe>
<div id="arrow"><img src="imgs/arrow.png" alt="arrow-top"></div> </div>
<div id="show-container"> <table cellspacing="0" cellpadding="0" id="container-shadow">
<div id="embeded-content"></div> <tr>
<iframe id="web-content" name="web-content" src="" scrolling=auto frameborder=1 ></iframe> <td id="shadow-left"></td>
</div> <td id="shadow-center">&nbsp;</td>
<td id="shadow-right"></td>
<table cellspacing="0" cellpadding="0" id="container-shadow"> </tr>
<tr> </table>
<td id="shadow-left"></td> </div>
<td id="shadow-center">&nbsp;</td>
<td id="shadow-right"></td> </div>
</tr> </body>
</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);

@ -105,16 +105,35 @@ bool UniboardSankoreTransition::checkPage(QString& sankorePagePath)
; ;
sankoreDirectory = QUrl::fromLocalFile(sankoreDirectory).toString(); sankoreDirectory = QUrl::fromLocalFile(sankoreDirectory).toString();
QString documentString(documentByteArray); QString documentString(documentByteArray);
qDebug() << documentString;
documentString.replace("xlink:href=\"videos/","xlink:href=\"" + sankoreDirectory + "/videos/");
documentString.replace("xlink:href=\"widgets/","xlink:href=\"" + sankoreDirectory + "/widgets/"); documentString.replace("xlink:href=\"videos/","xlink:href=\"" + sankoreDirectory + "/videos/");
documentString.replace("xlink:href=\"objects/","xlink:href=\"" + sankoreDirectory + "/objects/"); documentString.replace("xlink:href=\"objects/","xlink:href=\"" + sankoreDirectory + "/objects/");
documentString.replace("xlink:href=\"audios/","xlink:href=\"" + sankoreDirectory + "/audios/"); documentString.replace("xlink:href=\"audios/","xlink:href=\"" + sankoreDirectory + "/audios/");
qDebug() << documentString; if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
file.write(documentString.toAscii());
file.close();
return true;
}
bool UniboardSankoreTransition::checkWidget(QString& sankoreWidgetIndexPath)
{
QFile file(sankoreWidgetIndexPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
QByteArray documentByteArray = file.readAll();
file.close();
QString documentString(documentByteArray);
documentString.replace("/Uniboard/interactive content","/Sankore/interactive content");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false; return false;
@ -125,6 +144,28 @@ bool UniboardSankoreTransition::checkPage(QString& sankorePagePath)
return true; return true;
} }
bool UniboardSankoreTransition::updateIndexWidget(QString& sankoreWidgetPath)
{
bool result = true;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(sankoreWidgetPath);
QFileInfoList::iterator fileInfo;
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) {
if (fileInfo->fileName().endsWith("wgt")){
QString path = fileInfo->absolutePath() + "/" + fileInfo->fileName() + "/index.html";
if (QFile(path).exists())
result = checkWidget(path);
path = fileInfo->absolutePath() + "/" + fileInfo->fileName() + "/index.htm";
if (QFile(path).exists())
result &= checkWidget(path);
}
}
return result;
}
bool UniboardSankoreTransition::updateSankoreHRef(QString& sankoreDocumentPath) bool UniboardSankoreTransition::updateSankoreHRef(QString& sankoreDocumentPath)
{ {
bool result = true; bool result = true;
@ -135,7 +176,6 @@ bool UniboardSankoreTransition::updateSankoreHRef(QString& sankoreDocumentPath)
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) { for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) {
if (fileInfo->fileName().endsWith("svg")){ if (fileInfo->fileName().endsWith("svg")){
qDebug() << fileInfo->absolutePath();
QString path = fileInfo->absolutePath() + "/" + fileInfo->fileName(); QString path = fileInfo->absolutePath() + "/" + fileInfo->fileName();
result = checkPage(path); result = checkPage(path);
} }
@ -166,6 +206,8 @@ void UniboardSankoreTransition::executeTransition()
QString sankoreDocumentPath = sankoreDocumentDirectory + "/" + sankoreDocumentName; QString sankoreDocumentPath = sankoreDocumentDirectory + "/" + sankoreDocumentName;
result = UBFileSystemUtils::copyDir(fileInfo->filePath(),sankoreDocumentPath); result = UBFileSystemUtils::copyDir(fileInfo->filePath(),sankoreDocumentPath);
result &= updateSankoreHRef(sankoreDocumentPath); result &= updateSankoreHRef(sankoreDocumentPath);
QString sankoreWidgetPath = sankoreDocumentDirectory + "/" + sankoreDocumentName + "/widgets";
result &= updateIndexWidget(sankoreWidgetPath);
} }
} }
@ -175,6 +217,10 @@ void UniboardSankoreTransition::executeTransition()
UBFileSystemUtils::deleteDir(backupDestinationPath); UBFileSystemUtils::deleteDir(backupDestinationPath);
} }
else{ else{
QString sankoreInteractiveAppPath = sankoreDocumentDirectory;
sankoreInteractiveAppPath = sankoreInteractiveAppPath.replace("document","") + "interactive content/";
UBFileSystemUtils::copyDir(mOldSankoreDirectory + "/interactive content", sankoreInteractiveAppPath);
UBFileSystemUtils::copyDir(mUniboardSourceDirectory + "/interactive content", sankoreInteractiveAppPath);
UBFileSystemUtils::deleteDir(mOldSankoreDirectory); UBFileSystemUtils::deleteDir(mOldSankoreDirectory);
UBFileSystemUtils::deleteDir(mUniboardSourceDirectory); UBFileSystemUtils::deleteDir(mUniboardSourceDirectory);
} }

@ -41,6 +41,8 @@ public:
void documentTransition(); void documentTransition();
bool checkPage(QString& sankorePagePath); bool checkPage(QString& sankorePagePath);
bool updateSankoreHRef(QString &sankoreDocumentPath); bool updateSankoreHRef(QString &sankoreDocumentPath);
bool checkWidget(QString& sankoreWidgetPath);
bool updateIndexWidget(QString& sankoreWidgetPath);
void executeTransition(); void executeTransition();

Loading…
Cancel
Save