diff options
author | teramako | 2008-12-19 14:58:45 +0000 |
---|---|---|
committer | teramako | 2008-12-19 14:58:45 +0000 |
commit | 6e947a2493d57626b9fed74068dacef5d3f9aa06 (patch) | |
tree | a31407244fae1bfa95aaf106d2fe03b59b045bc0 /copy.js | |
parent | ab0d9800a3eaca564f1baa02f9f505bb95a1b256 (diff) | |
download | vimperator-plugins-6e947a2493d57626b9fed74068dacef5d3f9aa06.tar.bz2 |
plugiinManager対応
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27088 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'copy.js')
-rw-r--r-- | copy.js | 133 |
1 files changed, 72 insertions, 61 deletions
@@ -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 <<EOM - * liberator.globalVariables.copy_templates = [ - * { label: 'titleAndURL', value: '%TITLE%\n%URL%' }, - * { label: 'title', value: '%TITLE%', map: ',y' }, - * { label: 'anchor', value: '<a href="%URL%">%TITLE%</a>' }, - * { label: 'selanchor', value: '<a href="%URL%" title="%TITLE%">%SEL%</a>' }, - * { label: 'htmlblockquote', value: '<blockquote cite="%URL%" title="%TITLE%">%HTMLSEL%</blockquote>' } - * { label: 'ASIN', value: 'copy ASIN code from Amazon', custom: function(){return content.document.getElementById('ASIN').value;} }, - * ]; - * EOM - */ +var PLUGIN_INFO = +<VimperatorPlugin> +<name>{NAME}</name> +<description>enable to copy strings from a template (like CopyURL+)</description> +<description lang="ja">テンプレートから文字列のコピーを可能にします(CopyURL+みたいなもの)</description> +<minVersion>1.1</minVersion> +<maxVersion>2.0pre</maxVersion> +<author mail="teramako@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/teramako/">teramako</author> +<license>MPL 1.1/GPL 2.0/LGPL 2.1</license> +<version>0.5</version> +<detail><![CDATA[ +== Command == +:copy {copyString}: + copy the argument replaced some certain string +:copy! {expr}: + evaluate the argument and copy the result + +=== Example === +:copy %TITLE%: + copied the title of the current page +:copy title: + some as `:copy %TITLE%' by default +:copy! liberator.version: + copy the value of `liberator.version' + +== Keyword == +%TITLE%: + 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 + +== How to create template == +you can set your own template using inline JavaScript. +>|| +javascript <<EOM +liberator.globalVariables.copy_templates = [ + { label: 'titleAndURL', value: '%TITLE%\n%URL%' }, + { label: 'title', value: '%TITLE%', map: ',y' }, + { label: 'anchor', value: '<a href="%URL%">%TITLE%</a>' }, + { label: 'selanchor', value: '<a href="%URL%" title="%TITLE%">%SEL%</a>' }, + { label: 'htmlblockquote', value: '<blockquote cite="%URL%" title="%TITLE%">%HTMLSEL%</blockquote>' } + { 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 +]]></detail> +</VimperatorPlugin>; + 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); } |