mirror of
https://github.com/MatMoul/quickdial-webext.git
synced 2024-12-23 15:36:12 +00:00
Feature: Add Capture in a new Tab support for folder
This commit is contained in:
parent
30b432d1b8
commit
20ca231945
@ -404,6 +404,31 @@ core.GridNodes.getNode = function(gridNode, path){ // Return GridNode from RootG
|
|||||||
return core.GridNodes.getNode(child, path.substr(child.title.length + 1));
|
return core.GridNodes.getNode(child, path.substr(child.title.length + 1));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
core.GridNodes.getNodeWithParent = function(id){
|
||||||
|
|
||||||
|
var parents = [];
|
||||||
|
|
||||||
|
function findNode(gridNode){
|
||||||
|
if(gridNode.id == id){
|
||||||
|
parents.unshift(gridNode);
|
||||||
|
return gridNode;
|
||||||
|
}
|
||||||
|
if(gridNode.children){
|
||||||
|
for(var i=0; i<gridNode.children.length; i++){
|
||||||
|
var result = findNode(gridNode.children[i]);
|
||||||
|
if(result){
|
||||||
|
parents.unshift(gridNode);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
findNode(core.node, id);
|
||||||
|
if(parents.length>0) return parents;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
core.GridNodes.getChildNode = function(gridNode, id){ // Return child node by ID
|
core.GridNodes.getChildNode = function(gridNode, id){ // Return child node by ID
|
||||||
for(var child of gridNode.children) if(child.id == id) return child;
|
for(var child of gridNode.children) if(child.id == id) return child;
|
||||||
return null;
|
return null;
|
||||||
@ -498,6 +523,14 @@ core.GridNodes.deleteNode = function(gridNode, id, callback){ // Delete a GridNo
|
|||||||
core.GridNodes.refreshNode = function(gridNode, callback){ // Refresh content of a GridNode
|
core.GridNodes.refreshNode = function(gridNode, callback){ // Refresh content of a GridNode
|
||||||
if(gridNode.__isLoading == true) return;
|
if(gridNode.__isLoading == true) return;
|
||||||
gridNode.__isLoading = true;
|
gridNode.__isLoading = true;
|
||||||
|
switch(gridNode.type){
|
||||||
|
case core.GridNodes.GridNodeType.folder:
|
||||||
|
delete gridNode.image;
|
||||||
|
delete gridNode.__isLoading;
|
||||||
|
core.GridNodes.saveNode(gridNode);
|
||||||
|
if(callback) callback({ title: gridNode.title, screenshot: gridNode.image });
|
||||||
|
break;
|
||||||
|
case core.GridNodes.GridNodeType.bookmark:
|
||||||
core.SiteInfos.fromFrame(gridNode.url, function(infos){
|
core.SiteInfos.fromFrame(gridNode.url, function(infos){
|
||||||
if(infos){
|
if(infos){
|
||||||
gridNode.title = infos.title;
|
gridNode.title = infos.title;
|
||||||
@ -509,10 +542,31 @@ core.GridNodes.refreshNode = function(gridNode, callback){ // Refresh content of
|
|||||||
core.GridNodes.saveNode(gridNode);
|
core.GridNodes.saveNode(gridNode);
|
||||||
if(callback) callback(infos);
|
if(callback) callback(infos);
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
core.GridNodes.capturePage = function(gridNode, callback){
|
core.GridNodes.capturePage = function(gridNode, callback){
|
||||||
if(gridNode.__isLoading == true) return;
|
if(gridNode.__isLoading == true) return;
|
||||||
gridNode.__isLoading = true;
|
gridNode.__isLoading = true;
|
||||||
|
switch(gridNode.type){
|
||||||
|
case core.GridNodes.GridNodeType.folder:
|
||||||
|
var nodes = core.GridNodes.getNodeWithParent(gridNode.id);
|
||||||
|
if(nodes){
|
||||||
|
var path = '';
|
||||||
|
for(var i=1; i<nodes.length; i++) path = path + '/' + nodes[i].title;
|
||||||
|
core.SiteInfos.fromNewTab('/dial?path=' + path, function(infos){
|
||||||
|
if(infos){
|
||||||
|
gridNode.image = infos.screenshot;
|
||||||
|
} else {
|
||||||
|
delete gridNode.image;
|
||||||
|
}
|
||||||
|
delete gridNode.__isLoading;
|
||||||
|
core.GridNodes.saveNode(gridNode);
|
||||||
|
if(callback) callback({ title: gridNode.title, screenshot: gridNode.image });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case core.GridNodes.GridNodeType.bookmark:
|
||||||
core.SiteInfos.fromNewTab(gridNode.url, function(infos){
|
core.SiteInfos.fromNewTab(gridNode.url, function(infos){
|
||||||
if(infos){
|
if(infos){
|
||||||
gridNode.title = infos.title;
|
gridNode.title = infos.title;
|
||||||
@ -524,4 +578,6 @@ core.GridNodes.capturePage = function(gridNode, callback){
|
|||||||
core.GridNodes.saveNode(gridNode);
|
core.GridNodes.saveNode(gridNode);
|
||||||
if(callback) callback(infos);
|
if(callback) callback(infos);
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,8 @@ dial.populateGrid = function(){
|
|||||||
populateFolder = function(link, node){
|
populateFolder = function(link, node){
|
||||||
link.Node = node;
|
link.Node = node;
|
||||||
link.className = 'Folder';
|
link.className = 'Folder';
|
||||||
link.childNodes[0].style.backgroundImage = '';
|
if(node.image) link.childNodes[0].style.backgroundImage = 'url(' + node.image + ')';
|
||||||
|
else link.childNodes[0].style.backgroundImage = '';
|
||||||
link.childNodes[1].innerText = node.title;
|
link.childNodes[1].innerText = node.title;
|
||||||
if(dial.path) link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(dial.path + node.title);
|
if(dial.path) link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(dial.path + node.title);
|
||||||
else link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(node.title);
|
else link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(node.title);
|
||||||
|
Loading…
Reference in New Issue
Block a user