mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 16:28:38 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
42
mobile/ios/Client/Assets/CustomSearchHelper.js
Normal file
42
mobile/ios/Client/Assets/CustomSearchHelper.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
if (!window.__firefox__) {
|
||||
Object.defineProperty(window, '__firefox__', {
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: {}
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(window.__firefox__, 'searchQueryForField', {
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: function() {
|
||||
var input = document.activeElement;
|
||||
if (input.tagName.toLowerCase() !== 'input') return null;
|
||||
var form = input.form;
|
||||
if (!form || form.method.toLowerCase() != 'get') return null;
|
||||
|
||||
var inputs = form.getElementsByTagName('input');
|
||||
inputs = Array.prototype.slice.call(inputs, 0);
|
||||
var params = inputs.map(function(element) {
|
||||
if (element.name == input.name) return [element.name, '{searchTerms}'].join('=');
|
||||
return [element.name, element.value].map(encodeURIComponent).join('=');
|
||||
});
|
||||
|
||||
var selectFields = form.getElementsByTagName('select');
|
||||
selectFields = Array.prototype.slice.call(selectFields, 0);
|
||||
var selectParams = selectFields.map(function(e){
|
||||
return [e.name, e.options[e.selectedIndex].value].map(encodeURIComponent).join('=');
|
||||
});
|
||||
params = params.concat(selectParams);
|
||||
if (!form.action) return null; //an invalid form.
|
||||
var url = [form.action, params.join('&')].join('?');
|
||||
return url;
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue