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

preferencesAboutTextFull
Claudio Valerio 13 years ago
commit d8b0d44b7f
  1. 8
      resources/library/interactive/Calculator.wgt/index.html
  2. 267
      resources/library/interactive/Calculator.wgt/js/ubw-main.js
  3. 19
      resources/library/interactive/Notes.wgt/js/ubw-main.js
  4. 89
      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,7 +1,7 @@
<!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>
@ -16,9 +16,9 @@
<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(){
@ -28,6 +28,6 @@
<div id="ubwidget"></div> <div id="ubwidget"></div>
</body> </body>
</html> </html>

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

@ -103,7 +103,9 @@ function init(){
minimize.click( minimize.click(
function(){ function(){
$('.ubw-container').animate({height:"26px"},500); $('.ubw-container').animate({
height:"26px"
},500);
minimizedHeight = $('.ubw-container').height(); minimizedHeight = $('.ubw-container').height();
minimize.hide(); minimize.hide();
maximize.show(); maximize.show();
@ -118,7 +120,9 @@ function init(){
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();
@ -149,8 +153,7 @@ function init(){
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)
@ -159,12 +162,12 @@ function init(){
$('#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
}); });
} }
@ -193,7 +196,11 @@ function init(){
textField.css({ textField.css({
fontSize : parseInt(currentFontSize) fontSize : parseInt(currentFontSize)
}) })
if(text)
textField.html(text); textField.html(text);
else
textField.html("Enter your notes here ...");
textField.focus();
} }
window.onresize = function(){ window.onresize = function(){

@ -3,18 +3,23 @@
<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;
function changeLoadingState(){
loadingState = true;
}
$(document).ready(function(){ $(document).ready(function(){
//var resizer; // Timer //var resizer; // Timer
//var resizerIndex; //var resizerIndex;
@ -31,7 +36,11 @@
left: cssToInt($("body").css("margin-left")) 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", "");
@ -44,17 +53,19 @@
$("#back-button") $("#back-button")
.click(function(){ .click(function(){
loadingState = false;
if((currentHistory - 1) > 0){ if((currentHistory - 1) > 0){
$("#textbox").val(references[--currentHistory-1]); $("#textbox").val(references[--currentHistory-1]);
frames['web-content'].location.href = references[currentHistory-1]; $("#search-button").trigger("click");
} }
}); });
$("#forward-button") $("#forward-button")
.click(function(){ .click(function(){
loadingState = false;
if(currentHistory < references.length) { if(currentHistory < references.length) {
$("#textbox").val(references[currentHistory++]); $("#textbox").val(references[currentHistory++]);
frames['web-content'].location.href = $("#textbox").val(); $("#search-button").trigger("click");
} }
}); });
@ -64,9 +75,9 @@
} }
}); });
$("#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("://");
@ -82,19 +93,16 @@
} }
window.resizeTo(globalWidth, globalHeight); window.resizeTo(globalWidth, globalHeight);
$("#container") $("#container").removeClass("welcome").removeClass("change")
.removeClass("welcome") .removeClass("error").addClass("load");
.removeClass("change")
.removeClass("error")
.addClass("load");
$("#container-shadow").hide(); $("#container-shadow").hide();
$("#arrow").hide(); $("#arrow").hide();
$("#embeded-content").hide(); $("#embeded-content").hide();
$("#web-content").show(); $("#web-content").show();
$('#web-content').attr('src',url);
frames['web-content'].location.href = url;
checkcontent(); checkcontent();
checkLoading();
} else { } else {
$("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations $("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations
$("#container") $("#container")
@ -125,26 +133,6 @@
$("#embeded-content").load("locales/" + "en" + "/howto.html"); // Welcome screen with some explanations $("#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(){ $(window).resize(function(){
globalWidth = $(window).width(); globalWidth = $(window).width();
globalHeight = $(window).height(); globalHeight = $(window).height();
@ -154,8 +142,6 @@
}); });
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());
@ -165,13 +151,22 @@
$("#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;
window.resizeTo(widgetWidth, $(window).height()); clearTimeout(resizer);
window.resizeTo($(window).width(), widgetHeight); resizerIndex = 0;
};*/ 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", "")));
@ -213,7 +208,7 @@
<div id="show-container"> <div id="show-container">
<div id="embeded-content"></div> <div id="embeded-content"></div>
<iframe id="web-content" name="web-content" src="" scrolling=auto frameborder=1 ></iframe> <iframe id="web-content" name="web-content" src="" scrolling=auto frameborder=1 onload="changeLoadingState()"></iframe>
</div> </div>
<table cellspacing="0" cellpadding="0" id="container-shadow"> <table cellspacing="0" cellpadding="0" id="container-shadow">
@ -226,6 +221,6 @@
</div> </div>
</div> </div>
</body> </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