From 6e947a2493d57626b9fed74068dacef5d3f9aa06 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 19 Dec 2008 14:58:45 +0000 Subject: plugiinManager対応 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27088 d0d07461-0603-4401-acd4-de1884942a52 --- copy.js | 133 +++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 72 insertions(+), 61 deletions(-) (limited to 'copy.js') diff --git a/copy.js b/copy.js index 6b0906d..008e64c 100644 --- a/copy.js +++ b/copy.js @@ -1,63 +1,74 @@ -/** - * ==VimperatorPlugin== - * @name copy.js - * @description enable to copy strings from a template (like CopyURL+) - * @description-ja テンプレートから文字列のコピーを可能にします(CopyURL+みたなもの) - * @minVersion 1.1 - * @author teramako teramako@gmail.com - * @version 0.5a - * ==/VimperatorPlugin== - * - * Usage: - * :copy {copyString} -> copy the argument replaced some certain string - * :copy! {expr} -> evaluate the argument and copy the result - * - * e.g.) - * :copy %TITLE% -> copied the title of the current page - * :copy title -> same as `:copy %TITLE%' by default - * :copy! liberator.version -> copy the value of liberator.version - * - * If non-argument, used `default' - * - * label: template name which is command argument - * value: copy string - * the certian string is replace to ... - * %TITTLE% -> to the title of the current page - * %URL% -> to the URL of the current page - * %SEL% -> to the string of selection - * %HTMLSEL% -> to the html string of selection - * - * map: key map (optional) - * - * custom: {function} or {Array} (optional) - * {function}: - * execute the function and copy return value, if specified. - * - * {Array}: - * replaced to the {value} by normal way at first. - * and replace words matched {Array}[0] in the replaced string to {Array}[1]. - * {Array}[0] is string or regexp - * {Array}[1] is string or function - * see http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String:replace - * - * The copy_templates is a string variable which can set on - * vimperatorrc as following. - * - * let copy_templates = "[{ label: 'titleAndURL', value: '%TITLE%\n%URL%' }, { label: 'title', value: '%TITLE%' }]" - * - * or your can set it using inline JavaScript. - * - * javascript <%TITLE%' }, - * { label: 'selanchor', value: '%SEL%' }, - * { label: 'htmlblockquote', value: '
%HTMLSEL%
' } - * { label: 'ASIN', value: 'copy ASIN code from Amazon', custom: function(){return content.document.getElementById('ASIN').value;} }, - * ]; - * EOM - */ +var PLUGIN_INFO = + +{NAME} +enable to copy strings from a template (like CopyURL+) +テンプレートから文字列のコピーを可能にします(CopyURL+みたいなもの) +1.1 +2.0pre +teramako +MPL 1.1/GPL 2.0/LGPL 2.1 +0.5 +|| +javascript <%TITLE%' }, + { label: 'selanchor', value: '%SEL%' }, + { label: 'htmlblockquote', value: '
%HTMLSEL%
' } + { label: 'ASIN', value: 'copy ASIN code from Amazon', custom: function(){return content.document.getElementById('ASIN').value;} }, +]; +EOM +||< +label: + template name which is command argument +value: + copy string + the certain string is replace to ... +map: + key map (optional) +custom: + {function} or {Array} (optional) + {function}: + execute the function and copy return value, if specified. + {Array}: + replaced to the {value} by normal way at first. + then replace words matched {Array}[0] in the replaced string to {Array}[1]. + {Array}[0]: + String or RegExp + {Array}[1]: + String or Function + see http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String:replace +]]>
+
; + liberator.plugins.exCopy = (function(){ if (!liberator.globalVariables.copy_templates){ liberator.globalVariables.copy_templates = [ @@ -193,7 +204,7 @@ var exCopyManager = { if (typeof template.custom == 'function'){ copyString = template.custom.call(this, template.value); } else if (template.custom instanceof Array){ - copyString = replaceVariable(template.value).replace(tempalte.custom[0], template.custom[1]); + copyString = replaceVariable(template.value).replace(template.custom[0], template.custom[1]); } else { copyString = replaceVariable(template.value); } -- cgit v1.2.3