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

Improvement: Add bookmark without sheme add http://

This commit is contained in:
MatMoul 2017-10-15 12:04:40 +02:00
parent 325fdc8c83
commit 957f468c59

View File

@ -487,14 +487,16 @@ app.GridNodes.setNodeIndex = function(gridNode, index, newIndex, callback){ // S
} }
app.GridNodes.createBookmark = function(gridNode, url, title, callback){ // Create a new Bookmark in a GridNode. callback(gridNode, newGridNode) app.GridNodes.createBookmark = function(gridNode, url, title, callback){ // Create a new Bookmark in a GridNode. callback(gridNode, newGridNode)
browser.bookmarks.onCreated.removeListener(app.Bookmarks._onCreated); browser.bookmarks.onCreated.removeListener(app.Bookmarks._onCreated);
var prefix = '';
if(url.indexOf('://')<0) prefix = 'http://';
browser.bookmarks.create({ browser.bookmarks.create({
parentId: gridNode.id, parentId: gridNode.id,
title: title || url, title: title || url,
url: url url: prefix + url
}).then(function(bookmarkItem){ }).then(function(bookmarkItem){
if(!gridNode) return; // ??? Why this method are called a second time with gridNode = null ??? if(!gridNode) return; // ??? Why this method are called a second time with gridNode = null ???
browser.bookmarks.onCreated.addListener(app.Bookmarks._onCreated); browser.bookmarks.onCreated.addListener(app.Bookmarks._onCreated);
var newGridNode = { id: bookmarkItem.id, type: app.GridNodes.GridNodeType.bookmark, url: url, title }; var newGridNode = { id: bookmarkItem.id, type: app.GridNodes.GridNodeType.bookmark, url: prefix + url, title };
var EmptyCellFound = false; var EmptyCellFound = false;
for(var i=0; i<gridNode.children.length; i++){ for(var i=0; i<gridNode.children.length; i++){
if(gridNode.children[i].type == app.GridNodes.GridNodeType.empty){ if(gridNode.children[i].type == app.GridNodes.GridNodeType.empty){