Skip to content

Commit

Permalink
Merge pull request #180 from gardejo/master
Browse files Browse the repository at this point in the history
bmany: Support Firefox 40
  • Loading branch information
mooz committed Oct 24, 2015
2 parents 847f42d + e7f22e1 commit 813a991
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions plugins/bmany.ks.js
Expand Up @@ -265,7 +265,7 @@ var bmany =
function getBookmarks(aItemId) {
return filterBookmarks(
aItemId,
function (childNode, parentNode) [childNode.itemId,
function (childNode, parentNode) [childNode,
folderIconGetter,
parentNode.title || "",
getFaviconPath(childNode.icon),
Expand All @@ -278,11 +278,14 @@ var bmany =
return filterBookmarks(
aItemId,
function (childNode, parentNode) {
let keyword = bmService.getKeywordForURI(ioService.newURI(childNode.uri, null, null));
let keyword;
try {
keyword = bmService.getKeywordForURI(ioService.newURI(childNode.uri, null, null));
} catch (x) {}

if (keyword)
{
return [childNode.itemId,
return [childNode,
folderIconGetter,
parentNode.title || "",
keyword || "",
Expand All @@ -304,7 +307,7 @@ var bmany =

if (tags.length)
{
return [childNode.itemId,
return [childNode,
folderIconGetter,
parentNode.title || "",
tags || "",
Expand All @@ -324,8 +327,11 @@ var bmany =
function (childNode, parentNode) {
if (childNode.uri.indexOf("javascript:") === 0)
{
let keyword = bmService.getKeywordForURI(ioService.newURI(childNode.uri, null, null));
return [childNode.itemId,
let keyword;
try {
keyword = bmService.getKeywordForURI(ioService.newURI(childNode.uri, null, null));
} catch (x) {}
return [childNode,
folderIconGetter,
parentNode.title || "",
keyword || "",
Expand All @@ -342,22 +348,22 @@ var bmany =
// Misc values {{ =========================================================== //

var actions = [
[function (url, id) { self.go(url, "current"); },
[function (url, node) { self.go(url, "current"); },
M({en: "Open link in current tab", ja: "現在のタブで開く"}),
"open-current-tab"],
[function (url, id) { self.go(url, "tab"); },
[function (url, node) { self.go(url, "tab"); },
M({en: "Open link in new tab (foreground)", ja: "新しいタブを前面に開く"}),
"open-foreground-tab"],
[function (url, id) { self.go(url, "tabshifted"); },
[function (url, node) { self.go(url, "tabshifted"); },
M({en: "Open link in new tab (background)", ja: "新しいタブを背面に開く"}),
"open-background-tab"],
[function (url, id) { self.go(url, "window"); },
[function (url, node) { self.go(url, "window"); },
M({en: "Open link in new window", ja: "新しいウィンドウで開く"}),
"open-new-window"],
[function (url, id) { self.go(url, "unique"); },
[function (url, node) { self.go(url, "unique"); },
M({en: "Open link in unique tab", ja: "既に開いていればそのタブを選択し、いなければ現在のタブで開く"}),
"open-unique-tab"],
[function (url, id) { PlacesUIUtils.showBookmarkDialog({ itemId:id }, window); },
[function (url, node) { PlacesUIUtils.showBookmarkDialog({ action:"edit", node }, window); },
M({en: "Edit selected bookmark item", ja: "選択中のブックマークを編集"}),
"edit-bookmark"]
];
Expand Down Expand Up @@ -407,7 +413,7 @@ var bmany =
prompt.selector({
message : "pattern:",
collection : cache.bookmarks,
// : id, icon, folder, icon, title, uri
// : node, icon, folder, icon, title, uri
flags : [hid, ico, 0, ico, 0, 0],
header : ["Folder", "Title", "URL / Script"],
width : [17, 45, 38],
Expand All @@ -421,13 +427,13 @@ var bmany =
},

listToolbarBookmarks: function (arg, openType) {
if (arg || !cache.bookmarks)
if (arg || !cache.toolbarBookmarks)
cache.toolbarBookmarks = getBookmarks(PlacesUtils.toolbarFolderId);

prompt.selector({
message : "pattern:",
collection : cache.toolbarBookmarks,
// : id, icon, folder, icon, title, uri
// : node, icon, folder, icon, title, uri
flags : [hid, ico, 0, ico, 0, 0],
header : ["Title", "URL / Script"],
width : [17, 45, 38],
Expand All @@ -454,7 +460,7 @@ var bmany =
prompt.selector({
message : "pattern:",
collection : cache.bookmarksWithKeywords,
// : id, folder, keyword, (icon), title, uri
// : node, folder, keyword, (icon), title, uri
flags : [hid, ico, 0, 0, ico, 0, 0],
header : ["Folder", "Keyword", "Title", "URL / Script"],
width : [15, 15, 35, 35],
Expand Down Expand Up @@ -482,7 +488,7 @@ var bmany =
prompt.selector({
message : "pattern:",
collection : cache.bookmarksWithTags,
// : id, folder, tag, (icon), title, uri
// : node, folder, tag, (icon), title, uri
flags : [hid, ico, 0, 0, ico, 0, 0],
header : ["Folder", "Tag", "Title", "URL / Script"],
width : [15, 15, 35, 35],
Expand All @@ -505,7 +511,7 @@ var bmany =
prompt.selector({
message : "pattern:",
collection : cache.bookmarklets,
// : id, folder, keyword, icon, title, uri
// : node, folder, keyword, icon, title, uri
flags : [hid, ico, 0, 0, ico, 0, 0],
header : ["Folder", "Keyword", "Title", "Script"],
style : [getOption("folder_style"), getOption("keyword_style"),
Expand All @@ -520,19 +526,10 @@ var bmany =
},

getShortcutOrURIThen: function (aQuery, aCallback) {
if (typeof getShortcutOrURI === "undefined") {
// Firefox 25 ~
Task.spawn(function () {
let data = yield getShortcutOrURIAndPostData(aQuery,
// Firefox 31 ~
function (data) aCallback(data.url));
// ~ Firefox 30
if (data) aCallback(data.url);
});
} else {
// ~ Firefox 24
aCallback(getShortcutOrURI(aQuery));
}
Task.spawn(function () {
let data = yield getShortcutOrURIAndPostData(aQuery);
if (data) aCallback(data.url);
});
},

executeBookmarklet: function (aBookmarkletURL) {
Expand Down

0 comments on commit 813a991

Please sign in to comment.