1
0
mirror of https://github.com/MatMoul/quickdial-webext.git synced 2024-12-23 23:46:11 +00:00

small improvements

This commit is contained in:
MatMoul 2017-09-30 02:33:58 +02:00
parent b9fb4adc33
commit bae64a63b1
3 changed files with 9 additions and 6 deletions

View File

@ -1 +1 @@
<!DOCTYPE html><html><head id="head"><meta charset="utf-8" /><link rel="shortcut icon" type="image/png" href="img/24.png" /><script type="text/javascript" src="js/dial.js"></script></head><body id="body"></body></html> <!DOCTYPE html><html><head id="head"><meta charset="utf-8" /><link rel="shortcut icon" type="image/png" href="img/24.png" /><title id="title"></title><script type="text/javascript" src="js/dial.js"></script></head><body id="body"></body></html>

View File

@ -112,7 +112,7 @@ core.Bookmarks.getItem = function(bookmarkItem, path){ // Return BookmarkItem fr
core.SiteInfos = {} // Siteinfos helper object core.SiteInfos = {} // Siteinfos helper object
core.SiteInfos.loadInfos = function(url, args, callback){ // args: { icon: false; screenshot: false }, callback( { url, title, (/!\ Not handled now)icon, screenshot } || error: {} ) core.SiteInfos.loadInfos = function(url, args, callback){ // args: { icon: false; screenshot: false }, callback( { url, title, (/!\ Not handled now)icon, screenshot } || error: {} )
function pageLoaded(){ function pageLoaded(last){
var docTitle = iframe.contentWindow.document.title; var docTitle = iframe.contentWindow.document.title;
var docIcon = null; var docIcon = null;
var docScreenshot = null; var docScreenshot = null;
@ -134,7 +134,7 @@ core.SiteInfos.loadInfos = function(url, args, callback){ // args: { icon: false
docScreenshot = canvas.toDataURL(); docScreenshot = canvas.toDataURL();
} }
document.body.removeChild(iframe); if(last) document.body.removeChild(iframe);
if(callback) callback({ url: url, title: docTitle, icon: docIcon, screenshot:docScreenshot }); if(callback) callback({ url: url, title: docTitle, icon: docIcon, screenshot:docScreenshot });
} }
@ -150,14 +150,15 @@ core.SiteInfos.loadInfos = function(url, args, callback){ // args: { icon: false
xmlHttp.open('GET', url, true); xmlHttp.open('GET', url, true);
xmlHttp.onload = function(){ xmlHttp.onload = function(){
document.body.appendChild(iframe); document.body.appendChild(iframe);
iframe.contentWindow.document.write(xmlHttp.responseText.replace('<head>', '<head><base href="' + url + '">')); iframe.srcdoc = xmlHttp.responseText.replace('<head>', '<head><base href="' + url + '">');
//iframe.contentWindow.document.write(xmlHttp.responseText.replace('<head>', '<head><base href="' + url + '"><script>window.top = window;</script>')); //iframe.srcdoc = xmlHttp.responseText.replace('<head>', '<head><base href="' + url + '"><script>window.top = window;</script>');
setTimeout(function(){ pageLoaded(); }, 2000); // /!\ Caution function can be shortcuted and sendtimeout is not the best way setTimeout(function(){ pageLoaded(); }, 2000); // /!\ Caution function can be shortcuted and sendtimeout is not the best way
setTimeout(function(){ pageLoaded(true); }, 6000); // /!\ Caution function can be shortcuted and sendtimeout is not the best way
} }
xmlHttp.onabort = function(){ if(callback) callback(); } xmlHttp.onabort = function(){ if(callback) callback(); }
xmlHttp.onerror = function(){ if(callback) callback(); } xmlHttp.onerror = function(){ if(callback) callback(); }
xmlHttp.ontimeout = function(){ if(callback) callback(); } xmlHttp.ontimeout = function(){ if(callback) callback(); }
xmlHttp.send(null); xmlHttp.send();
} }
core.GridNodes = {}; // GridNodes helper object core.GridNodes = {}; // GridNodes helper object

View File

@ -47,6 +47,7 @@ window.onwheel = function(ev){
dial.initUI = function(){ dial.initUI = function(){
dial.Head = document.getElementById('head'); dial.Head = document.getElementById('head');
dial.Title = document.getElementById('title');
dial.Body = document.getElementById('body'); dial.Body = document.getElementById('body');
dial.Body.setAttribute('contextmenu', 'page'); dial.Body.setAttribute('contextmenu', 'page');
dial.Body.setAttribute('contextmenu', 'page'); dial.Body.setAttribute('contextmenu', 'page');
@ -60,6 +61,7 @@ dial.initUI = function(){
} else { } else {
dial.Node = app.getNode(app.settings.grid.node, '/'); dial.Node = app.getNode(app.settings.grid.node, '/');
} }
dial.Title.innerText = dial.Node.title;
dial.populateGrid(dial.Grid, app.settings.grid, dial.Node); dial.populateGrid(dial.Grid, app.settings.grid, dial.Node);
} }