diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 8028412..20e8ca0 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -34,6 +34,11 @@ "description": "Text of the add folder prompt." }, + "menuProperties": { + "message": "Properties", + "description": "Text of properties menu item." + }, + "menuRefreshItem": { "message": "Refresh", "description": "Text of refresh menu item." diff --git a/src/_locales/fr/messages.json b/src/_locales/fr/messages.json index dfcce5b..0dad204 100644 --- a/src/_locales/fr/messages.json +++ b/src/_locales/fr/messages.json @@ -34,6 +34,11 @@ "description": "Text of the add folder prompt." }, + "menuProperties": { + "message": "Propriétés", + "description": "Text of properties menu item." + }, + "menuRefreshItem": { "message": "Actualiser", "description": "Text of refresh menu item." diff --git a/src/html/properties.html b/src/html/properties.html new file mode 100644 index 0000000..5e734bb --- /dev/null +++ b/src/html/properties.html @@ -0,0 +1,71 @@ + + + + + + Quick Dial Node Propoerties + + + + +
+ + + + + + +
Main
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Title :
Url :
Image : + + + + +
+
+ +
+
+ +
+ + + +
+ + \ No newline at end of file diff --git a/src/js/background.js b/src/js/background.js index cddb7f2..9d37dcc 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -20,12 +20,14 @@ core.Messages.Commands = { getSettings: 0, setSettings: 1, getNode: 2, - setNodeIndex: 3, - createBookmark: 4, - createFolder: 5, - deleteNode: 6, - refreshNode: 7, - capturePage: 8, + getNodeByID: 3, + updateNode: 4, + setNodeIndex: 5, + createBookmark: 6, + createFolder: 7, + deleteNode: 8, + refreshNode: 9, + capturePage: 10, settingsChanged: 100, gridNodesLoaded: 101 }; @@ -42,6 +44,16 @@ core.Messages.init = function(){ // Init Messages Listeners browser.runtime.sendMessage( { cmd: core.Messages.Commands.settingsChanged } ); browser.runtime.sendMessage( { cmd: core.Messages.Commands.gridNodesLoaded } ); break; + case core.Messages.Commands.getNodeByID: + var nodes = core.GridNodes.getNodeWithParents(request.id); + if(nodes) sendResponse(nodes[nodes.length-1]); + else sendResponse(null); + break; + case core.Messages.Commands.updateNode: + core.GridNodes.updateNode(core.GridNodes.getNodeById(request.id), request.value, function(){ + browser.runtime.sendMessage( { cmd: core.Messages.Commands.gridNodesLoaded } ); + }); + break; case core.Messages.Commands.getNode: sendResponse(core.GridNodes.getNode(core.node, request.path.substr(1))); break; @@ -404,7 +416,12 @@ core.GridNodes.getNode = function(gridNode, path){ // Return GridNode from RootG return core.GridNodes.getNode(child, path.substr(child.title.length + 1)); return null; } -core.GridNodes.getNodeWithParent = function(id){ +core.GridNodes.getNodeById = function(id){ + var nodes = core.GridNodes.getNodeWithParents(id); + if(nodes) return nodes[nodes.length-1]; + return null; +} +core.GridNodes.getNodeWithParents = function(id){ var parents = []; @@ -429,6 +446,18 @@ core.GridNodes.getNodeWithParent = function(id){ if(parents.length>0) return parents; return null; } +core.GridNodes.updateNode = function(gridNode, value, callback){ + if(value){ + if(value.title) gridNode.title = value.title; + if(gridNode.type == core.GridNodes.GridNodeType.bookmark && value.url && gridNode.url != value.url){ + gridNode.url = value.url; + delete gridNode.image; + } + //gridNode.image = infos.screenshot; + core.GridNodes.saveNode(gridNode); + } + if(callback) callback(gridNode); +} core.GridNodes.getChildNode = function(gridNode, id){ // Return child node by ID for(var child of gridNode.children) if(child.id == id) return child; return null; @@ -550,7 +579,7 @@ core.GridNodes.capturePage = function(gridNode, callback){ gridNode.__isLoading = true; switch(gridNode.type){ case core.GridNodes.GridNodeType.folder: - var nodes = core.GridNodes.getNodeWithParent(gridNode.id); + var nodes = core.GridNodes.getNodeWithParents(gridNode.id); if(nodes){ var path = ''; for(var i=1; i