aboutsummaryrefslogtreecommitdiffstats
path: root/copy.js
diff options
context:
space:
mode:
authorsuVene2009-01-26 10:26:22 +0000
committersuVene2009-01-26 10:26:22 +0000
commite3e145b4d14d4ee1bb958f133b18871ad39709c4 (patch)
tree685297812af1669f500d9274786bb0dfebe64c2d /copy.js
parentfe9b753d35f5060d9e780f50def33ccd783fa894 (diff)
downloadvimperator-plugins-e3e145b4d14d4ee1bb958f133b18871ad39709c4.tar.bz2
何度も :source 可能に
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@29079 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'copy.js')
-rw-r--r--copy.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/copy.js b/copy.js
index 92a059b..353e1f8 100644
--- a/copy.js
+++ b/copy.js
@@ -91,6 +91,7 @@ wedata から読込まない label のリストを定義します。
liberator.plugins.exCopy = (function(){
var excludeLabelsMap = {};
+var copy_templates = [];
if (!liberator.globalVariables.copy_templates){
liberator.globalVariables.copy_templates = [
{ label: 'titleAndURL', value: '%TITLE%\n%URL%' },
@@ -101,7 +102,11 @@ if (!liberator.globalVariables.copy_templates){
];
}
-liberator.globalVariables.copy_templates.forEach(function(template){
+copy_templates = liberator.globalVariables.copy_templates.map(function(t){
+ return { label: t.label, value: t.value, custom: t.custom, map: t.map }
+});
+
+copy_templates.forEach(function(template){
if (typeof template.map == 'string')
addUserMap(template.label, [template.map]);
else if (template.map instanceof Array)
@@ -120,7 +125,7 @@ commands.addUserCommand(['copy'],'Copy to clipboard',
return;
}
context.title = ['Template','Value'];
- var templates = liberator.globalVariables.copy_templates.map(function(template)
+ var templates = copy_templates.map(function(template)
[template.label, liberator.modules.util.escapeString(template.value, '"')]
);
if (!context.filter){ context.completions = templates; return; }
@@ -129,7 +134,8 @@ commands.addUserCommand(['copy'],'Copy to clipboard',
context.completions = templates.filter(function(template) template[0].toLowerCase().indexOf(filter) == 0);
},
bang: true
- }
+ },
+ true
);
function addUserMap(label, map){
@@ -141,7 +147,7 @@ function addUserMap(label, map){
}
function getCopyTemplate(label){
var ret = null;
- liberator.globalVariables.copy_templates.some(function(template)
+ copy_templates.some(function(template)
template.label == label ? (ret = template) && true : false);
return ret;
}
@@ -254,7 +260,7 @@ function wedataRegister(item){
var exCopyManager = {
add: function(label, value, custom, map){
var template = {label: label, value: value, custom: custom, map: map};
- liberator.globalVariables.copy_templates.unshift(template);
+ copy_templates.unshift(template);
if (map) addUserMap(label, map);
return template;
@@ -288,7 +294,7 @@ var exCopyManager = {
copyString = e.toString();
}
} else {
- if (!arg) arg = liberator.globalVariables.copy_templates[0].label;
+ if (!arg) arg = copy_templates[0].label;
var template = getCopyTemplate(arg) || {value: arg};
if (typeof template.custom == 'function'){
@@ -318,7 +324,7 @@ if (liberator.globalVariables.copy_use_wedata){
}
var libly = liberator.plugins.libly;
- liberator.globalVariables.copy_templates.forEach(function(item) excludeLabelsMap[item.label] = item.value);
+ copy_templates.forEach(function(item) excludeLabelsMap[item.label] = item.value);
if (liberator.globalVariables.copy_wedata_exclude_labels)
liberator.globalVariables.copy_wedata_exclude_labels.forEach(function(item) excludeLabelsMap[item] = 1);
var wedata = new libly.Wedata("vimp%20copy");