From 742e7408299ac7550936d394690a6238d4ce4f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20POIRET?= Date: Sat, 5 Mar 2022 19:26:18 +0100 Subject: [PATCH 1/6] Add startpage search engine (#44) * Added Startpage as search engine * Added more engines * Removed non-search engines --- js/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 08c9ba4..0bba74d 100644 --- a/js/main.js +++ b/js/main.js @@ -36,7 +36,11 @@ searchEngines = { "DuckDuckGo": "https://duckduckgo.com/?q=", "Bing": "https://www.bing.com/search?q=", "Yahoo": "https://search.yahoo.com/search?p=", - "Ecosia": "https://www.ecosia.org/search?q=" + "Ecosia": "https://www.ecosia.org/search?q=", + "Startpage": "https://startpage.com/do/search?query=", + "Yandex": "https://yandex.com/search/?text=", + "Qwant": "https://www.qwant.com/?q=", + "Baidu": "https://www.baidu.com/s?wd=" } validWeatherUnit = [ "fah", "cel" From da6b9bf85c53a95853fd40dcd57fd31036f5c5f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20POIRET?= Date: Tue, 8 Mar 2022 12:32:23 +0100 Subject: [PATCH 2/6] Added default quickLinks for convenience (#45) --- config.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/config.json b/config.json index 7ee263e..84f9923 100644 --- a/config.json +++ b/config.json @@ -64,6 +64,17 @@ "quickLinks": { "r": "https://reddit.com", "g": "https://github.com", - "y": "https://youtube.com" + "y": "https://youtube.com", + "d": { + "URL": "https://duckduckgo.com", + "Search": "/?q=" + }, + "b": "https://bing.com", + "p": "https://startpage.com", + "s": "https://stackoverflow.com", + "w": { + "URL":"https://wikipedia.org/wiki", + "Search": "/Special:Search?search=" + } } } From 29ae29c4669f19d45f2192ed1dc9ed4d072b6d93 Mon Sep 17 00:00:00 2001 From: Deepjyoti Barman Date: Fri, 1 Jul 2022 21:25:17 +0530 Subject: [PATCH 3/6] Add init changes to support per link new tab --- js/main.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 0bba74d..71f09c2 100644 --- a/js/main.js +++ b/js/main.js @@ -320,7 +320,7 @@ function parseAndCreate(jsonData) { extractQuickLinks(sqrs, jsonData["style"]); } -function createSqr(sqrData, index) { +function createSqr(sqrData, index, globalNewTabEnabled) { // Create a new square division with the passed element name = sqrData["name"]; link = sqrData["url"]; @@ -352,10 +352,29 @@ function createSqr(sqrData, index) { links.forEach(element => { aName = element["name"] aHref = element["url"] + + // Idea is to give preference to + // link specific newTab field over the global + // one. + // + // As a fallback, the global value will be used. + isNewTab = globalNewTabEnabled + newTabValue = element["newTab"] + + if (newTab != undefined) { + isNewTab = newTab + } a = document.createElement("a") attrHref = document.createAttribute("href") attrHref.value = aHref + + if (isNewTab) { + attrTarget = document.createAttribute("target") + attrTarget.value = "_blank" + a.setAttributeNode(attrTarget) + } + a.setAttributeNode(attrHref) a.textContent = aName From c6842d013c439cdf643e1debd0db84cd395f5f46 Mon Sep 17 00:00:00 2001 From: Deepjyoti Barman Date: Fri, 1 Jul 2022 21:26:43 +0530 Subject: [PATCH 4/6] Make changes to read the global new tab flag --- js/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 71f09c2..300f0b6 100644 --- a/js/main.js +++ b/js/main.js @@ -264,8 +264,14 @@ function parseAndCreate(jsonData) { sqrs = jsonData["squares"] + globalNewTabEnabled = false + passedNewTab = jsonData["linkInNewTab"] + if (passedNewTab != undefined) { + globalNewTabEnabled = passedNewTab + } + sqrs.forEach((element, index) => { - sqr = createSqr(element, index) + sqr = createSqr(element, index, globalNewTabEnabled) document.getElementById(otherContentId).appendChild(sqr) }) From 89cf15a8b78b6f90db37699efbb6847f0eba19ca Mon Sep 17 00:00:00 2001 From: Deepjyoti Barman Date: Fri, 1 Jul 2022 21:31:28 +0530 Subject: [PATCH 5/6] Add some changes to support global and local setting for newTab --- config.json | 1 + js/main.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 84f9923..64c606c 100644 --- a/config.json +++ b/config.json @@ -35,6 +35,7 @@ ] } ], + "linkInNewTab": true, "title": "startpage", "searchEngine":"DuckDuckGo", "user": "Deepjyoti", diff --git a/js/main.js b/js/main.js index 300f0b6..5c877ff 100644 --- a/js/main.js +++ b/js/main.js @@ -367,8 +367,8 @@ function createSqr(sqrData, index, globalNewTabEnabled) { isNewTab = globalNewTabEnabled newTabValue = element["newTab"] - if (newTab != undefined) { - isNewTab = newTab + if (newTabValue != undefined) { + isNewTab = newTabValue } a = document.createElement("a") From 8543c0ec4f565ee7f920cfc79f8217a91209ee71 Mon Sep 17 00:00:00 2001 From: Deepjyoti Barman Date: Fri, 1 Jul 2022 21:31:59 +0530 Subject: [PATCH 6/6] Add an example to show how newTab on links are respected --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 64c606c..d9f0c03 100644 --- a/config.json +++ b/config.json @@ -4,7 +4,7 @@ "color": "red", "links": [ { "name": "Spotify", "url": "https://open.spotify.com/" }, - { "name": "YoutubeMusic", "url": "https://music.youtube.com/" }, + { "name": "YoutubeMusic", "url": "https://music.youtube.com/", "newTab": false }, { "name": "Netflix", "url": "https://netflix.com" }, { "name": "Youtube", "url": "https://youtube.com" } ]