aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--uaSwitch.js46
1 files changed, 20 insertions, 26 deletions
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])]
+ });
})();