Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
global menu improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Beelink committed Oct 15, 2019
1 parent de089e2 commit 349213b
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 62 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<img src="https://img.shields.io/codacy/grade/6fac6a3440d7480281c19780ed37ce30">
</a>
<a alt="Trello roadmap" href="https://trello.com/b/cb5lXUgS/ferny">
<img src="https://img.shields.io/badge/board-trello-%230079BF">
<img src="https://img.shields.io/badge/planner-trello-%230079BF">
</a>
<a alt="Discord channel" href="https://discord.gg/9q4D8SJ">
<img alt="Discord" src="https://img.shields.io/discord/625641944105877504?color=%237289DA&label=discord">
Expand Down
3 changes: 3 additions & 0 deletions html/overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<button name="twitter" class="nav-btn search-engine" title="Search with Twitter"><img src="../imgs/engines/twitter.png"></button>
<button name="amazon" class="nav-btn search-engine" title="Search with Amazon"><img src="../imgs/engines/amazon.png"></button>
<button name="twitch" class="nav-btn search-engine" title="Search with Twitch"><img src="../imgs/engines/twitch.png"></button>
<button name="github" class="nav-btn search-engine" title="Search with GitHub"><img src="../imgs/engines/github.png"></button>
<button name="wolfram" class="nav-btn search-engine" title="Search with WolframAlpha"><img src="../imgs/engines/wolfram.png"></button>
<button name="ebay" class="nav-btn search-engine" title="Search with Ebay"><img src="../imgs/engines/ebay.png"></button>
</div>
</div>
</div>
Expand Down
15 changes: 15 additions & 0 deletions html/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@
<label>Twitch</label>
<input type="radio" onclick="requestSearchEngine(this.value)" class="checkbox" name="search-engine" value="twitch">
</div>
<div class="nav-checkbox">
<img src="../imgs/engines/github.png">
<label>GitHub</label>
<input type="radio" onclick="requestSearchEngine(this.value)" class="checkbox" name="search-engine" value="github">
</div>
<div class="nav-checkbox">
<img src="../imgs/engines/wolfram.png">
<label>WolframAlpha</label>
<input type="radio" onclick="requestSearchEngine(this.value)" class="checkbox" name="search-engine" value="wolfram">
</div>
<div class="nav-checkbox">
<img src="../imgs/engines/ebay.png">
<label>Ebay</label>
<input type="radio" onclick="requestSearchEngine(this.value)" class="checkbox" name="search-engine" value="ebay">
</div>
</div>

<div class="container" id="startup">
Expand Down
Binary file added imgs/engines/ebay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/engines/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/engines/wolfram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/icons16/tabs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 57 additions & 37 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1032,9 +1032,53 @@ function showMainWindow() {

function initMenu() {
sideMenu = Menu.buildFromTemplate([{
label: "New tab", icon: app.getAppPath() + "/imgs/icons16/create.png", accelerator: "CmdOrCtrl+T", click: () => {
tabManager.newTab();
} }, {
label: "Tabs", icon: app.getAppPath() + "/imgs/icons16/tabs.png", submenu: [{
label: "New tab", icon: app.getAppPath() + "/imgs/icons16/create.png", accelerator: "CmdOrCtrl+T", click: () => {
tabManager.newTab();
} }, { type: "separator" }, {
label: "Switch tab", icon: app.getAppPath() + "/imgs/icons16/numerical.png", submenu: [{
label: "Next tab", icon: app.getAppPath() + "/imgs/icons16/next.png", accelerator: "CmdOrCtrl+Tab", click: () => {
if(tabManager.hasActiveTab()) {
tabManager.getActiveTab().nextTab();
}
} }, {
label: "Previous tab", icon: app.getAppPath() + "/imgs/icons16/prev.png", accelerator: "CmdOrCtrl+Shift+Tab", click: () => {
if(tabManager.hasActiveTab()) {
tabManager.getActiveTab().prevTab();
}
} }, { type: "separator" }, {
label: "Tab 1", accelerator: "CmdOrCtrl+1", click: () => {
tabManager.switchTab(1);
} }, {
label: "Tab 2", accelerator: "CmdOrCtrl+2", click: () => {
tabManager.switchTab(2);
} }, {
label: "Tab 3", accelerator: "CmdOrCtrl+3", click: () => {
tabManager.switchTab(3);
} }, {
label: "Tab 4", accelerator: "CmdOrCtrl+4", click: () => {
tabManager.switchTab(4);
} }, {
label: "Tab 5", accelerator: "CmdOrCtrl+5", click: () => {
tabManager.switchTab(5);
} }, {
label: "Tab 6", accelerator: "CmdOrCtrl+6", click: () => {
tabManager.switchTab(6);
} }, {
label: "Tab 7", accelerator: "CmdOrCtrl+7", click: () => {
tabManager.switchTab(7);
} }, {
label: "Tab 8", accelerator: "CmdOrCtrl+8", click: () => {
tabManager.switchTab(8);
} }, {
label: "Tab 9", accelerator: "CmdOrCtrl+9", click: () => {
tabManager.switchTab(9);
} }
] }, { type: "separator" }, {
label: "Close all tabs", icon: app.getAppPath() + "/imgs/icons16/close.png", accelerator: "CmdOrCtrl+Q", click: () => {
tabManager.closeAllTabs();
} }
]}, {
label: "Active tab", icon: app.getAppPath() + "/imgs/icons16/tab.png", submenu: [{
label: "Back", accelerator: "Alt+Left", icon: app.getAppPath() + "/imgs/icons16/back.png", click: () => {
if(tabManager.hasActiveTab()) {
Expand Down Expand Up @@ -1120,7 +1164,7 @@ function initMenu() {
overlay.scrollToId("bookmarks-title");
}
} }, {
label: "Bookmark all tabs", icon: app.getAppPath() + "/imgs/icons16/tab.png", click: () => {
label: "Bookmark all tabs", icon: app.getAppPath() + "/imgs/icons16/tabs.png", click: () => {
if(tabManager.hasTabs()) {
mainWindow.webContents.send("notificationManager-addQuestNotif", { text: "Are you sure to bookmark all opened tabs?", ops: [{
text: "Bookmark tabs",
Expand Down Expand Up @@ -1252,43 +1296,19 @@ function initMenu() {
overlay.goToSearch();
}
} }, {
label: "Switch tab", icon: app.getAppPath() + "/imgs/icons16/numerical.png", submenu: [{
label: "Next tab", icon: app.getAppPath() + "/imgs/icons16/next.png", accelerator: "CmdOrCtrl+Tab", click: () => {
label: "Additional hotkeys", icon: app.getAppPath() + "/imgs/icons16/keyboard.png", submenu: [{
label: "New tab", icon: app.getAppPath() + "/imgs/icons16/create.png", accelerator: "CmdOrCtrl+N", click: () => {
tabManager.newTab();
} }, { type: "separator" }, {
label: "Reload", icon: app.getAppPath() + "/imgs/icons16/reload.png", accelerator: "CmdOrCtrl+R", click: () => {
if(tabManager.hasActiveTab()) {
tabManager.getActiveTab().nextTab();
}
tabManager.getActiveTab().reload();
}
} }, {
label: "Previous tab", icon: app.getAppPath() + "/imgs/icons16/prev.png", accelerator: "CmdOrCtrl+Shift+Tab", click: () => {
label: "Reload ignoring cache", icon: app.getAppPath() + "/imgs/icons16/database-reload.png", accelerator: "CmdOrCtrl+Shift+R", click: () => {
if(tabManager.hasActiveTab()) {
tabManager.getActiveTab().prevTab();
tabManager.getActiveTab().reloadIgnoringCache();
}
} }, { type: "separator" }, {
label: "Tab 1", accelerator: "CmdOrCtrl+1", click: () => {
tabManager.switchTab(1);
} }, {
label: "Tab 2", accelerator: "CmdOrCtrl+2", click: () => {
tabManager.switchTab(2);
} }, {
label: "Tab 3", accelerator: "CmdOrCtrl+3", click: () => {
tabManager.switchTab(3);
} }, {
label: "Tab 4", accelerator: "CmdOrCtrl+4", click: () => {
tabManager.switchTab(4);
} }, {
label: "Tab 5", accelerator: "CmdOrCtrl+5", click: () => {
tabManager.switchTab(5);
} }, {
label: "Tab 6", accelerator: "CmdOrCtrl+6", click: () => {
tabManager.switchTab(6);
} }, {
label: "Tab 7", accelerator: "CmdOrCtrl+7", click: () => {
tabManager.switchTab(7);
} }, {
label: "Tab 8", accelerator: "CmdOrCtrl+8", click: () => {
tabManager.switchTab(8);
} }, {
label: "Tab 9", accelerator: "CmdOrCtrl+9", click: () => {
tabManager.switchTab(9);
} }
] }, { type: "separator" }, {
label: "Developer [Danger]", icon: app.getAppPath() + "/imgs/icons16/developer.png", submenu: [{
Expand Down
55 changes: 32 additions & 23 deletions modules/SearchManager/SearchManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,7 @@ class SearchManager extends EventEmitter {
this.searchInput.oninput = () => {
this.getSuggestions();
}
this.searchInput.onkeyup = (event) => {
event.preventDefault();

this.updateClearSearchButton();

if (this.searchInput.value.length > 0) {
if (event.keyCode === 13) {
var suggestions = this.searchSuggestContainer.childNodes;
if(suggestions.length > 0) {
let i = 0;
while (i < suggestions.length && !suggestions[i].classList.contains("active")) {
i++;
}
this.navigateSuggest(suggestions[i].value);
} else {
this.navigateSuggest(this.searchInput.value);
}
}
}

this.searchInput.onkeydown = (event) => {
if (event.keyCode === 40) {
var suggestions = this.searchSuggestContainer.childNodes;
let i = 0;
Expand All @@ -100,8 +81,7 @@ class SearchManager extends EventEmitter {
suggestions[i].classList.remove("active");
suggestions[i].nextSibling.classList.add("active");
}
}
if (event.keyCode === 38) {
} else if (event.keyCode === 38) {
var suggestions = this.searchSuggestContainer.childNodes;
let i = 0;
while (i < suggestions.length && !suggestions[i].classList.contains("active")) {
Expand All @@ -113,7 +93,27 @@ class SearchManager extends EventEmitter {
suggestions[i].previousSibling.classList.add("active");
}
}
}
};
this.searchInput.onkeyup = (event) => {
event.preventDefault();

this.updateClearSearchButton();

if (this.searchInput.value.length > 0) {
if (event.keyCode === 13) {
var suggestions = this.searchSuggestContainer.childNodes;
if(suggestions.length > 0) {
let i = 0;
while (i < suggestions.length && !suggestions[i].classList.contains("active")) {
i++;
}
this.navigateSuggest(suggestions[i].value);
} else {
this.navigateSuggest(this.searchInput.value);
}
}
}
};

loadSearchEngineModule().then((searchEngine) => {
this.setSearchEngine(searchEngine);
Expand Down Expand Up @@ -225,6 +225,15 @@ class SearchManager extends EventEmitter {
case "twitch":
this.newTab("https://www.twitch.tv/search?term=" + text, background);
break;
case "github":
this.newTab("https://github.com/search?q=" + text, background);
break;
case "wolfram":
this.newTab("https://www.wolframalpha.com/input/?i=" + text, background);
break;
case "ebay":
this.newTab("https://www.ebay.com/sch/i.html?_nkw=asdf" + text, background);
break;
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/TabManager/TabManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ class TabManager extends EventEmitter {
m.append(new MenuItem({ type: "separator" }));
m.append(new MenuItem({
label: "Close all tabs",
accelerator: "CmdOrCtrl+Q",
icon: this.appPath + "/imgs/icons16/close.png",
enabled: this.hasTabs(),
click: () => {
Expand Down
3 changes: 2 additions & 1 deletion modules/loadSearchEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function loadSearchEngine() {
return new Promise((resolve, reject) => {
let defaultValue = "duckduckgo";
let possibleValues = ["duckduckgo", "google", "bing", "wikipedia", "yahoo", "yandex", "mailru",
"baidu", "naver", "qwant", "youtube", "youtube", "ecosia", "twitter", "amazon", "twitch"];
"baidu", "naver", "qwant", "youtube", "youtube", "ecosia", "twitter", "amazon", "twitch",
"github", "wolfram", "ebay"];
try {
fs.readFile(ppath + "/json/search-engine.json", (err, data) => {
if(err) {
Expand Down

0 comments on commit 349213b

Please sign in to comment.