From 01f814fe7707e5cb1890bd46663377750fad9309 Mon Sep 17 00:00:00 2001 From: drry Date: Fri, 5 Sep 2008 17:09:27 +0000 Subject: * fixed a regexp. * et cetera. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@18907 d0d07461-0603-4401-acd4-de1884942a52 --- param_editor.js | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'param_editor.js') diff --git a/param_editor.js b/param_editor.js index 3a3fe13..6291c5e 100644 --- a/param_editor.js +++ b/param_editor.js @@ -8,14 +8,14 @@ var snap = doc.evaluate(query, node, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); var res = []; - for(var i = 0; i < snap.snapshotLength; i++){ + for(let i = 0, l = snap.snapshotLength; i < l; i++){ res.push(snap.snapshotItem(i)); } return res; }; var Form = function(form, i){ - this.uid = i; + this.uid = i; this.method = (form.method.length) ? form.method.toUpperCase() : "GET"; this.action = form.action; this.name = (form.name.length) ? form.name : this.uid; @@ -29,8 +29,8 @@ if(!e.type) return; var type = e.type.toLowerCase(); if(type == "radio" || type == "checkbox"){ - var mg = null; - for(var i = 0; i < this.member.length; i++){ + let mg = null; + for(let i = 0, l = this.member.length; i < l; i++){ if(this.member[i].constructor == FormMemberGroup && this.member[i].name == e.name){ mg = this.member[i]; @@ -93,7 +93,7 @@ } }; - for(var i = 0; i < this.elems.length; i++){ + for(let i = 0, l = this.elems.length; i < l; i++){ if(this.elems[i].value == v){ check.call(this, i); return; @@ -106,20 +106,20 @@ FormMemberGroup.prototype.add_elem = function(e){ this.elems.push(e); - } + }; var form2html = function(form){ var html = [ - '', '', '', - '']; + '']; form.member.forEach(function(e){ var uid = (e.uid < 10) ? e.uid + " " : e.uid; @@ -134,18 +134,17 @@ }; var get_forms = function(){ - var count = 0; var r = []; var f = doc.forms; - for(var i = 0; i < f.length; i++){ - r.push(new Form(f[i], count++)); + for(let i = 0, l = f.length; i < l; i++){ + r.push(new Form(f[i], i)); } return r; }; var select = function(a, q){ var cand = []; - for(var i = 0; i < a.length; i++){ + for(let i = 0, l = a.length; i < l; i++){ if(a[i].name == q || a[i].uid == q){ cand.push(a[i]); break; @@ -169,16 +168,16 @@ var html = null; if(q){ - var form = select(forms, q); + let form = select(forms, q); if(form) html = form.html; }else if(forms.length){ html = ""; forms.forEach(function(f){ html += f.html; - html += "
"; + html += "
"; }); } - + if(html){ liberator.commandline.echo(html, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); @@ -203,15 +202,12 @@ ["pe[dit]"], "Edit value of a form element", function(q, submit){ - var _ = q.match(/^\s*([^\.\s]+)\.([^=\s]+)\s*=\s*(.*)$/); - try{ - var f = _[1], m = _[2], v = _[3]; - }catch(e){ - if(!f || !m || !v){ - liberator.echoerr("Failed to parse query"); - return; - } + var _ = q.match(/^\s*([^.\s]+)\.([^=\s]+)\s*=\s*(.*)$/); + if(!_){ + liberator.echoerr("Failed to parse query"); + return; } + var [, f, m, v] = _; //liberator.log([f, m, v], 9); doc = window.content.document; -- cgit v1.2.3
' + form.method + ' name:' + form.name + ' =>' + form.action + '
Name Type Value
Name Type Value