diff --git a/chrome/content/vimperator/bookmarks.js b/chrome/content/vimperator/bookmarks.js index 1c5f8f5d..a6d25182 100644 --- a/chrome/content/vimperator/bookmarks.js +++ b/chrome/content/vimperator/bookmarks.js @@ -197,11 +197,13 @@ function Bookmarks() //{{{ return keywords; } - // if the engine name is null, it uses the default search engine + // if @param engine_name is null, it uses the default search engine // @returns the url for the search string + // if the search also requires a postdata, [url, postdata] is returned this.getSearchURL = function(text, engine_name) { var url = null; + var postdata = null; if (!engine_name || engine_name == "") engine_name = vimperator.options["defsearch"]; @@ -210,7 +212,11 @@ function Bookmarks() //{{{ if (engine) { if (text) - url = engine.getSubmission(text, null).uri.spec; + { + var submission = engine.getSubmission(text, null); + url = submission.uri.spec; + postdata = submission.postData; + } else url = engine.searchForm; } @@ -232,7 +238,10 @@ function Bookmarks() //{{{ } // if we came here, the engine_name is neither a search engine or URL - return url; + if (postdata) + return [url, postdata]; + else + return url; // can be null } this.list = function(filter, fullmode) diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index 563cef9d..12c4c9a3 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -1207,6 +1207,7 @@ String.prototype.toURLArray = function() var urls = this.split(/\s*\,\s+/); begin: for (var url = 0; url < urls.length; url++) { + // FIXME: not really that good (doesn't handle .. in the middle), also problems with trailing slashes // check for ./ and ../ (or even .../) to go to a file in the upper directory if (urls[url].match(/^(\.$|\.\/\S*)/)) { @@ -1253,7 +1254,7 @@ String.prototype.toURLArray = function() text = matches[3]; var search_url = vimperator.bookmarks.getSearchURL(text, alias); - if (search_url && search_url.length >= 1) + if (search_url/* && search_url.length >= 1*/) { urls[url] = search_url; continue; @@ -1261,7 +1262,7 @@ String.prototype.toURLArray = function() else // the first word was not a search engine, search for the whole string in the default engine { search_url = vimperator.bookmarks.getSearchURL(urls[url], null); - if (search_url && search_url.length >= 1) + if (search_url/* && search_url.length >= 1*/) { urls[url] = search_url; continue; diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index bbdf02c7..f89f4cc1 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -252,6 +252,9 @@ const vimperator = (function() //{{{ // open one or more URLs // // @param urls: either a string or an array of urls + // The array can look like this: + // ["url1", "url2", "url3", ...] or: + // [["url1", postdata1], ["url2", postdata2], ...] // @param where: if ommited, CURRENT_TAB is assumed // @param callback: not implemented, will be allowed to specify a callback function // which is called, when the page finished loading @@ -269,17 +272,21 @@ const vimperator = (function() //{{{ if (!where) where = vimperator.CURRENT_TAB; + var url = typeof urls[0] == "string" ? urls[0] : urls[0][0]; + var postdata = typeof urls[0] == "string" ? null : urls[0][1]; + //alert(postdata); + // decide where to load the first tab if (where == vimperator.CURRENT_TAB) - getBrowser().loadURI(urls[0]); + /*getBrowser().*/loadURI(url, null, postdata); else if (where == vimperator.NEW_TAB) { - var firsttab = getBrowser().addTab(urls[0]); + var firsttab = getBrowser().addTab(url, null, null, postdata); getBrowser().selectedTab = firsttab; } else if (where == vimperator.NEW_BACKGROUND_TAB) { - getBrowser().addTab(urls[0]); + getBrowser().addTab(url, null, null, postdata); } else { @@ -288,8 +295,12 @@ const vimperator = (function() //{{{ } // all other URLs are always loaded in background - for (var url=1; url < urls.length; url++) - getBrowser().addTab(urls[url]); + for (var i=1; i < urls.length; i++) + { + url = typeof urls[i] == "string" ? urls[i] : urls[i][0]; + postdata = typeof urls[i] == "string" ? null : urls[i][1]; + getBrowser().addTab(url, null, null, postdata); + } // TODO: register callbacks