Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
etacarinaea committed May 10, 2021
2 parents 981f84a + 8d5d439 commit f39d9ef
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 76 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/),
and this project adheres to [Semantic Versioning](https://semver.org/).

## [1.11.4] - 2021-5-10
### Fixed
* Fixed arrow keys not working

## [1.11.3] - 2021-4-10
### Fixed
* Fixes an error when `searchsquare` is undefined and `alwaysopen == true`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "startpage",
"version": "1.11.3",
"version": "1.11.4",
"description": "Overrides the browsers newtab page with a custom startpage.",
"main": "src/index.js",
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions src/js/load-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function applyConfig(data, callback) {
container.removeChild(container.firstChild);
}
let normalSquares = [];
let searchsquare = undefined;
let searchSquare = undefined;
for(let i = 0; i < data.squares.length; i++) {
if(data.squares[i].links) {
normalSquares[i] = new Square(data.squares[i].name,
Expand All @@ -389,16 +389,16 @@ function applyConfig(data, callback) {
}
} else {
// otherwise expect this to be a search square
searchsquare = new Square(data.squares[i].name,
searchSquare = new Square(data.squares[i].name,
{
isSearch: true,
prefix: data.squares[i].prefix,
options: data.squares[i].options,
},
data.bool, data.style);
searchsquare.prefix = data.squares[i].prefix;
searchSquare.prefix = data.squares[i].prefix;
if(data.bool.alwaysopen) {
searchsquare.expand();
searchSquare.expand();
}
}
}
Expand All @@ -419,8 +419,8 @@ function applyConfig(data, callback) {
maxHeight = normalSquares[i].maxHeight();
}
}
if(searchsquare) {
let sMaxHeight = searchsquare.maxHeight();
if(searchSquare) {
let sMaxHeight = searchSquare.maxHeight();
if(sMaxHeight > maxHeight) {
maxHeight = sMaxHeight;
}
Expand Down Expand Up @@ -479,7 +479,7 @@ function applyConfig(data, callback) {
}

if(typeof callback === "function") {
callback();
callback({normal: normalSquares, search: searchSquare});
}
}

134 changes: 67 additions & 67 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,119 +33,119 @@ function search(query, popup) {
let focusedSquare = -1;
let focusedLink = 0;

function globalKeyListener(e) {
if(typeof searchsquare !== "undefined") {
if(searchsquare.searchinput === document.activeElement
&& !(searchsquare.searchinput.value === ""
|| searchsquare.searchinput.value === null)) {
function globalKeyListener(squares, e) {
if(typeof squares.search !== "undefined") {
if(squares.search.searchinput === document.activeElement
&& !(squares.search.searchinput.value === ""
|| squares.search.searchinput.value === null)) {
return;
}
}

let n = 0;
if(typeof searchsquare === "undefined") n = 1;
if(typeof squares.search === "undefined") n = 1;

let key = e.keyCode;
if(key == 27) {
// esc
if(typeof searchsquare !== "undefined") {
searchsquare.searchinput.blur();
searchsquare.contract();
if(typeof squares.search !== "undefined") {
squares.search.searchinput.blur();
squares.search.contract();
}
if(typeof normalSquares[focusedSquare] !== "undefined") {
normalSquares[focusedSquare].unfocus(focusedLink);
normalSquares[focusedSquare].contract();
if(typeof squares.normal[focusedSquare] !== "undefined") {
squares.normal[focusedSquare].unfocus(focusedLink);
squares.normal[focusedSquare].contract();
}
focusedSquare = -1;
focusedLink = 0;
} else if(key == 9 && typeof searchsquare !== "undefined") {
} else if(key == 9 && typeof squares.search !== "undefined") {
// tab
if(typeof normalSquares[focusedSquare] !== "undefined") {
normalSquares[focusedSquare].unfocus(focusedLink);
normalSquares[focusedSquare].contract();
if(typeof squares.normal[focusedSquare] !== "undefined") {
squares.normal[focusedSquare].unfocus(focusedLink);
squares.normal[focusedSquare].contract();
}
focusedSquare = normalSquares.length;
searchsquare.expand();
searchsquare.searchinput.focus();
focusedSquare = squares.normal.length;
squares.search.expand();
squares.search.searchinput.focus();
} else if(key == 37) {
// left arrow
if(focusedSquare > 0) {
if(typeof searchsquare !== "undefined") {
if(searchsquare.searchinput == document.activeElement
&& (searchsquare.searchinput.value == ""
|| searchsquare.searchinput.value == null)) {
searchsquare.searchinput.blur();
searchsquare.contract();
} else if(focusedSquare < normalSquares.length) {
normalSquares[focusedSquare].unfocus(focusedLink);
normalSquares[focusedSquare].contract();
if(typeof squares.search !== "undefined") {
if(squares.search.searchinput == document.activeElement
&& (squares.search.searchinput.value == ""
|| squares.search.searchinput.value == null)) {
squares.search.searchinput.blur();
squares.search.contract();
} else if(focusedSquare < squares.normal.length) {
squares.normal[focusedSquare].unfocus(focusedLink);
squares.normal[focusedSquare].contract();
}
} else if(focusedSquare < normalSquares.length) {
normalSquares[focusedSquare].unfocus(focusedLink);
normalSquares[focusedSquare].contract();
} else if(focusedSquare < squares.normal.length) {
squares.normal[focusedSquare].unfocus(focusedLink);
squares.normal[focusedSquare].contract();
}
focusedSquare--;
focusedLink = 0;
normalSquares[focusedSquare].expand();
normalSquares[focusedSquare].focus(focusedLink);
squares.normal[focusedSquare].expand();
squares.normal[focusedSquare].focus(focusedLink);
}
} else if(key == 38 && focusedSquare >= 0) {
// up arrow
if(typeof searchsquare !== "undefined") {
if(searchsquare.searchinput == document.activeElement) return;
if(typeof squares.search !== "undefined") {
if(squares.search.searchinput == document.activeElement) return;
}
if(focusedLink > 0) {
normalSquares[focusedSquare].unfocus(focusedLink);
squares.normal[focusedSquare].unfocus(focusedLink);
focusedLink--;
normalSquares[focusedSquare].focus(focusedLink);
squares.normal[focusedSquare].focus(focusedLink);
}
} else if(key == 39) {
// right arrow
if(focusedSquare < normalSquares.length - 1) {
if(focusedSquare < squares.normal.length - 1) {
if(focusedSquare >= 0) {
normalSquares[focusedSquare].unfocus(focusedLink);
normalSquares[focusedSquare].contract();
squares.normal[focusedSquare].unfocus(focusedLink);
squares.normal[focusedSquare].contract();
}
focusedSquare++;
focusedLink = 0;
normalSquares[focusedSquare].expand();
normalSquares[focusedSquare].focus(focusedLink);
} else if(focusedSquare < normalSquares.length - n) {
if(typeof searchsquare !== "undefined") {
if(searchsquare.searchinput == document.activeElement
&& (searchsquare.searchinput.value == ""
|| searchsquare.searchinput.value == null)) {
searchsquare.searchinput.blur();
searchsquare.contract();
} else if(focusedSquare < normalSquares.length) {
normalSquares[focusedSquare].unfocus(focusedLink);
normalSquares[focusedSquare].contract();
squares.normal[focusedSquare].expand();
squares.normal[focusedSquare].focus(focusedLink);
} else if(focusedSquare < squares.normal.length - n) {
if(typeof squares.search !== "undefined") {
if(squares.search.searchinput == document.activeElement
&& (squares.search.searchinput.value == ""
|| squares.search.searchinput.value == null)) {
squares.search.searchinput.blur();
squares.search.contract();
} else if(focusedSquare < squares.normal.length) {
squares.normal[focusedSquare].unfocus(focusedLink);
squares.normal[focusedSquare].contract();
}
} else {
normalSquares[focusedSquare].unfocus(focusedLink);
normalSquares[focusedSquare].contract();
squares.normal[focusedSquare].unfocus(focusedLink);
squares.normal[focusedSquare].contract();
}
focusedSquare++;
if(typeof searchsquare !== "undefined") {
searchsquare.expand();
searchsquare.searchinput.focus();
if(typeof squares.search !== "undefined") {
squares.search.expand();
squares.search.searchinput.focus();
}
}
} else if(key == 40 && focusedSquare >= 0) {
// down arrow
if(typeof searchsquare !== "undefined") {
if(searchsquare.searchinput == document.activeElement) return;
if(typeof squares.search !== "undefined") {
if(squares.search.searchinput == document.activeElement) return;
}
if(focusedLink < normalSquares[focusedSquare].links.length - 1) {
normalSquares[focusedSquare].unfocus(focusedLink);
if(focusedLink < squares.normal[focusedSquare].props.links.length - 1) {
squares.normal[focusedSquare].unfocus(focusedLink);
focusedLink++;
normalSquares[focusedSquare].focus(focusedLink);
squares.normal[focusedSquare].focus(focusedLink);
}
} else if(key == 13) {
// enter
if(searchsquare.searchinput !== document.activeElement &&
normalSquares[focusedSquare] !== undefined) {
window.location = normalSquares[focusedSquare].links[focusedLink].url;
if(squares.search.searchinput !== document.activeElement &&
squares.normal[focusedSquare] !== undefined) {
window.location = squares.normal[focusedSquare].props.links[focusedLink].url;
}
}

Expand All @@ -155,12 +155,12 @@ function globalKeyListener(e) {
}


function main() {
function main(squares) {
const container = document.getElementById("container");
const gearContainer = document.getElementById("gearContainer");

gearContainer.addEventListener("click", configmenuInit);
document.addEventListener("keydown", globalKeyListener);
document.addEventListener("keydown", globalKeyListener.bind(undefined, squares));
}


Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "startpage",
"short_name": "startpage",
"version": "1.11.3",
"version": "1.11.4",
"description": "Overrides the browsers newtab page with a custom startpage.",
"author": "etacarinaea",

Expand Down

0 comments on commit f39d9ef

Please sign in to comment.