From 25ce55c6fb5f80c0a7644d45dcee5b50a817c29a Mon Sep 17 00:00:00 2001 From: drry Date: Thu, 2 Oct 2008 11:36:08 +0000 Subject: * '''REGIST''' * et cetera. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@20516 d0d07461-0603-4401-acd4-de1884942a52 --- uaSwitch.js | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) (limited to 'uaSwitch.js') diff --git a/uaSwitch.js b/uaSwitch.js index 53ce980..f759fd1 100644 --- a/uaSwitch.js +++ b/uaSwitch.js @@ -11,33 +11,27 @@ if (typeof useragentswitcher_reset != 'function') return; // activate user agent siwtcher - useragentswitcher_displayUserAgentSwitcherMenu(document.getElementById("useragentswitcher-popup-menu"), 'menu'); + useragentswitcher_displayUserAgentSwitcherMenu(document.getElementById('useragentswitcher-popup-menu'), 'menu'); // return user agent list - function getItems() { - return Array.map( - document.getElementById("useragentswitcher-menu") - .getElementsByAttribute("type", "radio"), - function(n) { - return { - label : n.getAttribute('label'), - oncommand : n.getAttribute('oncommand'), - checked : n.getAttribute('checked') - } - } - ); - } - - // regist vimperator command - liberator.commands.addUserCommand(['ua'],'Switch User Agent', - function(arg, special){ - if (special) useragentswitcher_options(); - else if (!arg) liberator.echo("UserAgent: " + getItems().filter(function(n) {return n.checked})[0].label); - else window.eval(getItems().filter(function(n) {return n.label == arg})[0].oncommand); - },{ - completer: function(filter, special){ - return [0, getItems().map(function(n) { return [n.label, n.label] })]; + function getItems() + Array.map(document.getElementById('useragentswitcher-menu') + .getElementsByAttribute('type', 'radio'), + function(n) { + return { + label : n.getAttribute('label'), + oncommand : n.getAttribute('oncommand'), + checked : n.getAttribute('checked') } - } - ); + }); + + // register Vimperator command + liberator.commands.addUserCommand(['ua'], 'Switch User Agent', function(arg, special){ + if (special) useragentswitcher_options(); + else if (!arg) liberator.echo('UserAgent: ' + getItems().filter(function(n) n.checked)[0].label); + else window.eval(getItems().filter(function(n) n.label == arg)[0].oncommand); + }, { + completer: function(filter, special) + [0, getItems().map(function(n) [n.label, n.label])] + }); })(); -- cgit v1.2.3