Changeset 24339
- Timestamp:
- 11/19/08 22:41:15 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/branches/1.2/multi_requester.js
r24329 r24339 45 45 * EOM 46 46 * 47 * other siteinfo by Wedata.47 * other siteinfo by wedata. 48 48 * @see http://wedata.net/databases/Multi%20Requester/items 49 49 * … … 54 54 * [',ml', 'ex'], // == :mr ex 55 55 * [',mg', 'goo', '!'], // == :mr! goo 56 * [',ma', 'alc', , 'args'], // == :mr alc args (however, it use a selected_text with precedence.)56 * [',ma', 'alc', , 'args'], // == :mr alc args (however, it uses a selected_text with precedence.) 57 57 * ]; 58 58 * EOM 59 59 * 60 60 * [OTHER OPTIONS] 61 * let g:multi_requester_use_wedata = "false" // default true61 * let g:multi_requester_use_wedata = "false" // true by default 62 62 * 63 63 * 64 64 * TODO: 65 * - Wedata からのデータ取得を非同期に。66 * - Wedata local cache.65 * - wedata からのデータ取得を非同期に。 66 * - wedata local cache. 67 67 * - 複数リクエスト対応。 68 68 */ … … 124 124 eval: function(text) { 125 125 var fnc = window.eval; 126 var sandbox; 126 127 try { 127 varsandbox = new Components.utils.Sandbox(window);128 sandbox = new Components.utils.Sandbox(window); 128 129 if (Components.utils.evalInSandbox("true", sandbox) === true) { 129 fnc = function(text) { return Components.utils.evalInSandbox(text, sandbox); } 130 fnc = function(text) { return Components.utils.evalInSandbox(text, sandbox); }; 130 131 } 131 } catch (e) { $U.log('warning: multi_requester.js is working with unsafe sandbox.'); }132 } catch (e) { $U.log('warning: multi_requester.js is working with unsafe sandbox.'); } 132 133 133 134 return fnc(text); 134 135 }, 135 136 // via. sbmcommentsviwer.js 136 evalJson: function(str, toRemove){ 137 evalJson: function(str, toRemove) { 138 var json; 137 139 try { 138 varjson = Components.classes['@mozilla.org/dom/json;1'].getService(Components.interfaces.nsIJSON);140 json = Components.classes['@mozilla.org/dom/json;1'].getService(Components.interfaces.nsIJSON); 139 141 if (toRemove) str = str.substring(1, str.length - 1); 140 142 return json.decode(str); … … 416 418 if (useWedata) { 417 419 $U.log('use Wedata'); 418 this.getWe Data(function(site) {420 this.getWedata(function(site) { 419 421 if (!ret[site.name]) ret[site.name] = {}; 420 422 $U.extend(ret[site.name], site); … … 440 442 return result; 441 443 }, 442 getWe Data: function(func) {444 getWedata: function(func) { 443 445 var req = new Request( 444 446 'http://wedata.net/databases/Multi%20Requester/items.json', … … 506 508 507 509 var isOptS = args.hasOwnProperty('-s'); 508 if ( (isOptS && args.arguments.length < 1)&& args.arguments.length < 2) return null;510 if (isOptS && args.arguments.length < 1 && args.arguments.length < 2) return null; 509 511 510 512 var siteName = args.arguments.shift(); 511 var str = (isOptS ? $U.getSelectedString() : args.arguments.join()).replace(/[\n\r] /g, '');513 var str = (isOptS ? $U.getSelectedString() : args.arguments.join()).replace(/[\n\r]+/g, ''); 512 514 var siteinfo = this.getSite(siteName); 513 515 … … 523 525 }, 524 526 onSuccess: function(res) { 525 527 var url, escapedUrl, xpath, doc, html; 528 526 529 try { 527 530 528 531 if (!res.isSuccess || res.responseText == '') throw 'response is fail or null'; 529 532 530 varurl = res.request.url;531 varescapedUrl = liberator.util.escapeHTML(url);532 varxpath = res.request.options.siteinfo.resultXpath;533 vardoc = res.getHTMLDocument(xpath);534 if (!doc) throw ' xpath result is undefined or null.: xpath -> ' + xpath;535 536 var html = '<div style="white-space:normal;"><base href="' + escapedUrl + '"/>' +537 '<a href="' + escapedUrl + '" class="hl-Title" target="_self">' + escapedUrl + '</a>' +538 (new XMLSerializer()).serializeToString(doc).replace(/<[^>]+>/g, function(all) all.toLowerCase()) +539 '</div>';533 url = res.request.url; 534 escapedUrl = liberator.util.escapeHTML(url); 535 xpath = res.request.options.siteinfo.resultXpath; 536 doc = res.getHTMLDocument(xpath); 537 if (!doc) throw 'XPath result is undefined or null.: XPath -> ' + xpath; 538 539 html = '<div style="white-space:normal;"><base href="' + escapedUrl + '"/>' + 540 '<a href="' + escapedUrl + '" class="hl-Title" target="_self">' + escapedUrl + '</a>' + 541 (new XMLSerializer()).serializeToString(doc).replace(/<[^>]+>/g, function(all) all.toLowerCase()) + 542 '</div>'; 540 543 $U.echo(new XMLList(html)); 541 544 542 545 } catch (e) { 543 546 $U.echoerr('error!!: ' + e);
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)