aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranekos2008-10-20 11:02:46 +0000
committeranekos2008-10-20 11:02:46 +0000
commitf50bc1b9efc0685e842b8b68370c26c17227f763 (patch)
tree83b656fef5a3209674cad34e3abe43d57ebaf701
parent1bbcbf14b54e8dc0d6b57ab0cc32836ee28b46cf (diff)
downloadvimperator-plugins-f50bc1b9efc0685e842b8b68370c26c17227f763.tar.bz2
Vimperator の仕様変更に対応。
for 69f699080c10 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@21699 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r--auto_detect_link.js13
-rw-r--r--command_menu.js30
-rw-r--r--plugin_loader.js12
-rw-r--r--readcatlater.js24
4 files changed, 46 insertions, 33 deletions
diff --git a/auto_detect_link.js b/auto_detect_link.js
index ed76a1e..f3f8576 100644
--- a/auto_detect_link.js
+++ b/auto_detect_link.js
@@ -2,7 +2,8 @@
// @name Auto Detect Link
// @description-ja (次|前)っぽいページへのリンクを探してジャンプ
// @license Creative Commons 2.1 (Attribution + Share Alike)
-// @version 1.1.0
+// @version 1.3
+// @author anekos (anekos@snca.net)
// ==/VimperatorPlugin==
//
// Usage:
@@ -160,7 +161,7 @@
// 開いたURIなどの表示
function displayOpened (link) {
let msg = 'open: ' + link.type + ' <' + link.text + '> ' + link.uri;
- setTimeout(function () liberator.echo(msg, liberator.commandline.FORCE_SINGLELINE), 1000);
+ setTimeout(function () liberator.echo(msg, commandline.FORCE_SINGLELINE), 1000);
liberator.log(msg);
}
@@ -441,8 +442,8 @@
////////////////////////////////////////////////////////////////
if (gv().nextMappings.length) {
- liberator.mappings.addUserMap(
- [liberator.modes.NORMAL],
+ mappings.addUserMap(
+ [modes.NORMAL],
gv().nextMappings,
'Go next',
function () go(true)
@@ -451,8 +452,8 @@
if (gv().backMappings.length) {
- liberator.mappings.addUserMap(
- [liberator.modes.NORMAL],
+ mappings.addUserMap(
+ [modes.NORMAL],
gv().backMappings,
'Go back',
function () go(false)
diff --git a/command_menu.js b/command_menu.js
index b701ca4..4c95088 100644
--- a/command_menu.js
+++ b/command_menu.js
@@ -2,7 +2,8 @@
// @name Command-MainMenu
// @description-ja メインメニューとツールバーをコマンドで実行できる
// @license Creative Commons 2.1 (Attribution + Share Alike)
-// @version 1.3
+// @version 1.5
+// @author anekos (anekos@snca.net)
// ==/VimperatorPlugin==
//
// Usage:
@@ -20,7 +21,7 @@
// http://creativecommons.org/licenses/by-sa/2.1/jp/
// http://creativecommons.org/licenses/by-sa/2.1/jp/deed.en_CA
-(function(){ try{
+(function(){
const migemo = Components
.classes['@piro.sakura.ne.jp/xmigemo/factory;1']
@@ -34,13 +35,13 @@
function cloneArray (src) src.map(id);
function matchPath (elem, path, getName) {
- for (var i = 0; i < path.length; i++) {
+ for (let i = 0; i < path.length; i++) {
if (!path[i](getName(elem)))
break;
}
if (i) {
- var res = [];
- for (var j = i; j < path.length; j++)
+ let res = [];
+ for (let j = i; j < path.length; j++)
res.push(path[j]);
return res;
}
@@ -49,10 +50,11 @@
function getElementsByPath (elem, path, getName, isTarget, isEnabled) {
try{
function get (point, elem, path) {
+ let m = path[0](getName(elem, true));
+
if (isTarget(elem)) {
if (!isEnabled(elem))
return [];
- var m = path[0](getName(elem, true));
if (m) {
if (path.length == 1)
return [[point + m, elem]];
@@ -63,9 +65,9 @@
}
//elem.containerOpen = true;
- var res, cs = elem.childNodes, result = [];
+ let res, cs = elem.childNodes, result = [];
if (cs && cs.length) {
- for (var i = 0; i < cs.length; i++) {
+ for (let i = 0; i < cs.length; i++) {
if (res = get(m + point, cs[i], path))
res.map(function(it) it && result.push(it));
}
@@ -95,7 +97,7 @@
}
function getPathString (elem, isRoot, getName, isTarget) {
- var res = [];
+ let res = [];
while (!isRoot(elem)) {
isTarget(elem) && res.unshift(getName(elem));
elem = elem.parentNode;
@@ -135,7 +137,7 @@
function addCommand(cmds, name, root, action) {
function _find (args, single) {
- var result = getElementsByPath(root,
+ let result = getElementsByPath(root,
getPathMatchers(args),
getElementName,
isClickable,
@@ -152,11 +154,14 @@
};
}
- liberator.commands.addUserCommand(
+ commands.addUserCommand(
cmds,
name,
function (args, _, num, extra) {
- var res = _find(args.replace(/-\s*$/,''), true);
+ // for HEAD (2)
+ if (args.string != undefined)
+ args = args.string;
+ let res = _find(args.replace(/-\s*$/,''), true);
if (!(res && action(res)))
liberator.echoerr('menu not found');
},
@@ -184,6 +189,5 @@
}
);
-}catch(e){ liberator.log(e);}
})();
diff --git a/plugin_loader.js b/plugin_loader.js
index c9c36b0..7cdd96c 100644
--- a/plugin_loader.js
+++ b/plugin_loader.js
@@ -2,7 +2,7 @@
// @name Plugin Loader
// @description-ja 指定(ディレクトリ|プラグイン)を起動時にロードする
// @license Creative Commons 2.1 (Attribution + Share Alike)
-// @version 2.2
+// @version 2.3
// @author anekos
// ==/VimperatorPlugin==
//
@@ -23,22 +23,22 @@
: obj.toString().split(/[,| \t\r\n]+/);
}
- let roots = toArray(globalVariables.plugin_loader_roots);
- let plugins = toArray(globalVariables.plugin_loader_plugins);
+ let roots = toArray(liberator.globalVariables.plugin_loader_roots);
+ let plugins = toArray(liberator.globalVariables.plugin_loader_plugins);
let filter = new RegExp('[\\\\/](?:' +
plugins.map(function (plugin) plugin.replace(/(?=[\\^$.+*?|(){}\[\]])/g, '\\'))
.join('|') +
')\\.(?:js|vimp)$');
- log('plugin_loader: loading');
+ liberator.log('plugin_loader: loading');
roots.forEach(function (root) {
let files = io.readDirectory(io.getFile(root), true);
files.forEach(function (file) {
if (filter.test(file.path))
- liberator.io.source(file.path, false);
+ io.source(file.path, false);
});
});
- log('plugin_loader: loaded');
+ liberator.log('plugin_loader: loaded');
}
diff --git a/readcatlater.js b/readcatlater.js
index b7b467f..0d0c2ca 100644
--- a/readcatlater.js
+++ b/readcatlater.js
@@ -2,7 +2,7 @@
// @name Read Cat Later
// @description-ja Read It Later 的な物
// @license Creative Commons 2.1 (Attribution + Share Alike)
-// @version 0.1
+// @version 0.2
// ==/VimperatorPlugin==
//
// Usage:
@@ -26,10 +26,12 @@
liberator.log('readcatlater.js loading');
// このプラグインでブックマークしたときに必ずつくタグ
- RCL_TAG = 'readcatlater';
+ const RCL_TAG = 'readcatlater';
// このプラグインが保存するブックマークのフォルダ名
// 変更しても良いし、場所を移動しても平気である。
- FOLDER_NAME = 'L';
+ const FOLDER_NAME = 'L';
+ // 逆順表示
+ const REVERSE = eval(liberator.globalVariables.readcatlater_reverse || 'false');
var prefs = {
prefix: 'extensions.vimperator.plugins.readcatlater.',
@@ -192,7 +194,7 @@
if (closeOriginally)
folderNode.containerOpen = false;
- return result;
+ return liberator.globalVariables.readcatlater_reverse ? result.reverse() : result;
}catch(e){ liberator.log(e); }}
function completer (args) {
@@ -216,11 +218,14 @@
* Add Command
********************************************************************************/
- liberator.commands.addUserCommand(
+ commands.addUserCommand(
['readcatlater', 'rcl'],
'read cat later',
function (args, _, num, extra) {
- var res = addEntry(window.content.document, splitBySpaces(args));
+ // for HEAD
+ if (args.string != undefined)
+ args = args.string;
+ var res = addEntry(window.content.document, splitBySpaces(args)); // FIXME
if (res)
liberator.echo('"' + title + '" was added');
else
@@ -229,10 +234,13 @@
{}
);
- liberator.commands.addUserCommand(
+ commands.addUserCommand(
['readcatnow', 'rcn'],
'read cat now',
function (uri, bang, num, extra) {
+ // for HEAD
+ if (uri.string != undefined)
+ uri = uri.string;
openURI(uri);
if (!bang && removeItems(uri))
liberator.echo('"' + uri + '" was removed.');
@@ -242,7 +250,7 @@
}
);
- liberator.commands.addUserCommand(
+ commands.addUserCommand(
['deletecatnow', 'dcn'],
'delete cat now',
function (uri, bang, num, extra) {