From 4a049008e2987ba127d4a16fde9e66d2c1a4e845 Mon Sep 17 00:00:00 2001 From: zombieFox Date: Wed, 10 Jun 2020 14:07:44 +0100 Subject: [PATCH] [feature] add search input name attribute control --- package-lock.json | 2 +- package.json | 2 +- src/css/form.css | 7 +++++++ src/html/menu/content/header/search.html | 8 ++++++++ src/js/control.js | 10 ++++++++++ src/js/header.js | 7 ++++++- src/js/state.js | 3 ++- src/js/update.js | 5 +++++ src/js/version.js | 2 +- src/manifest.json | 2 +- 10 files changed, 42 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index bf31761e..1025f7c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nightTab", - "version": "5.33.0", + "version": "5.34.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d822389e..49cd239c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nightTab", - "version": "5.33.0", + "version": "5.34.0", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.", "main": "index.js", "scripts": { diff --git a/src/css/form.css b/src/css/form.css index eebc8036..9ae9aea2 100755 --- a/src/css/form.css +++ b/src/css/form.css @@ -259,6 +259,13 @@ input[type="text"] { -moz-appearance: textfield; } +input[type="search"]::-webkit-search-decoration, +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-results-button, +input[type="search"]::-webkit-search-results-decoration { + -webkit-appearance: none; +} + input[type="number"] { text-align: center; } diff --git a/src/html/menu/content/header/search.html b/src/html/menu/content/header/search.html index c1a775c4..180db4c8 100644 --- a/src/html/menu/content/header/search.html +++ b/src/html/menu/content/header/search.html @@ -102,6 +102,14 @@

Enter a web address with the search parameters, eg: "https://vimeo.com/search?q="

nightTab will add the search term entered into the Search input at the end of the above URL.

+
+ + +
+
+

Sets the name attribute on the Search input field.

+

This defines the name passed to the search engine when submitting. If not sure leave blank.

+

diff --git a/src/js/control.js b/src/js/control.js index 99c0d069..eb0647bc 100644 --- a/src/js/control.js +++ b/src/js/control.js @@ -2224,6 +2224,14 @@ var control = (function() { func: function() { search.render.engine(); } + }, { + element: ".control-header-search-engine-custom-queryname", + path: "header.search.engine.custom.queryName", + type: "text", + func: function() { + console.log("hit"); + search.render.engine(); + } }, { element: ".control-header-search-text-justify-left", path: "header.search.text.justify", @@ -11197,6 +11205,8 @@ var control = (function() { ".control-header-search-engine-custom-name", "[for=control-header-search-engine-custom-url]", ".control-header-search-engine-custom-url", + "[for=control-header-search-engine-custom-queryname]", + ".control-header-search-engine-custom-queryname", ".control-header-search-engine-custom-helper" ]; } diff --git a/src/js/header.js b/src/js/header.js index 5e173991..30b1354d 100644 --- a/src/js/header.js +++ b/src/js/header.js @@ -372,7 +372,12 @@ var header = (function() { search: function() { var headerSearchBody = helper.node("div|class:search-wrapper"); var form = helper.node("form|class:search,action,method:get"); - var searchInput = helper.node("input|class:search-input,type:text,placeholder:Find or Search,name:q,autocomplete:off,autocorrect:off,autocapitalize:off,spellcheck:false,tabindex:1"); + var searchInput; + if (state.get.current().header.search.engine.custom.queryName != "") { + searchInput = helper.node("input|class:search-input,type:search,placeholder:Find or Search,name:" + state.get.current().header.search.engine.custom.queryName.trim() + ",autocomplete:off,autocorrect:off,autocapitalize:off,spellcheck:false,tabindex:1"); + } else { + searchInput = helper.node("input|class:search-input,type:search,placeholder:Find or Search,name:q,autocomplete:off,autocorrect:off,autocapitalize:off,spellcheck:false,tabindex:1"); + }; var hiddenInput = helper.node("input|type:submit,value:Search,class:is-hidden"); var clearButton = helper.node("button|class:search-clear search-clear button button-link,tabindex:1,disabled"); var clearButtonIcon = helper.node("span|class:icon-close"); diff --git a/src/js/state.js b/src/js/state.js index 4442c55c..79079358 100644 --- a/src/js/state.js +++ b/src/js/state.js @@ -113,7 +113,8 @@ var state = (function() { }, custom: { url: "", - name: "" + name: "", + queryName: "" } }, text: { diff --git a/src/js/update.js b/src/js/update.js index dbd7379b..83ad171a 100644 --- a/src/js/update.js +++ b/src/js/update.js @@ -1078,6 +1078,11 @@ var update = (function() { l: 0 }; return data; + }, + "5.34.0": function(data) { + console.log(data); + data.state.header.search.engine.custom.queryName = ""; + return data; } }; diff --git a/src/js/version.js b/src/js/version.js index fc41a1d6..62e8324b 100644 --- a/src/js/version.js +++ b/src/js/version.js @@ -1,6 +1,6 @@ var version = (function() { - var current = "5.33.0"; + var current = "5.34.0"; var name = "Zonked Tarsier"; diff --git a/src/manifest.json b/src/manifest.json index 2057bbd1..2a953ab6 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "name": "nightTab", "short_name": "nightTab", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.", - "version": "5.33.0", + "version": "5.34.0", "manifest_version": 2, "chrome_url_overrides": { "newtab": "index.html"