Fix variable name, default per page set to 3, lint.

This commit is contained in:
Kasen IO 2020-03-11 13:21:26 -04:00
parent e3198abf68
commit 202a8dc458
2 changed files with 25 additions and 15 deletions

View file

@ -60,7 +60,7 @@
function onMoreAppWebEventReceived(eventz) {
if (typeof eventz === "string") {
eventzget = JSON.parse(eventz);
var eventzget = JSON.parse(eventz);
//print("EVENT ACTION: " + eventzget.action);
//print("EVENT SCRIPT: " + eventzget.script);

View file

@ -16,6 +16,10 @@
<head>
<meta charset="UTF-8">
<script>
//Defaults
DEFAULT_PER_PAGE = 3;
DEFAULT_OFFSET = 0;
//Paths
var currentPath = window.location.protocol + "//" + window.location.host + window.location.pathname;
var rootPath;
@ -46,22 +50,28 @@
}
var offset = findGetParameter("offset");
if(offset === null){offset = 0;}
if (offset === null) {
offset = DEFAULT_OFFSET;
}
offset = parseInt(offset);
var perpage = findGetParameter("perpage");
if(perpage === null){perpage = 25;}
if (perpage === null) {
perpage = DEFAULT_PER_PAGE;
}
perpage = parseInt(perpage);
var search = findGetParameter("search");
if(search === null){search = "";}
if (search === null) {
search = "";
}
//Search
function doSearch(keyword){
function doSearch(keyword) {
location.href = "more.html?offset=0&search=" + encodeURI(keyword);
}
function clearSearch(){
function clearSearch() {
location.href = "more.html?offset=0";
}
@ -181,15 +191,15 @@
var needNext = false;
var pageContent = "";
for (index = 0; index < metadata.applications.length; index++){
for (index = 0; index < metadata.applications.length; index++) {
lowItem = metadata.applications[index].name.toLowerCase();
if (lowItem.indexOf(search.toLowerCase()) != -1 && metadata.applications[index].isActive == true){
if (lowItem.indexOf(search.toLowerCase()) != -1 && metadata.applications[index].isActive == true) {
counterDir = counterDir + 1;
if ((counterDir >= offset) && (counterDir < (offset + perpage))){
if ((counterDir >= offset) && (counterDir < (offset + perpage))) {
DisplayApp(metadata.applications[index]);
counterDisp = counterDisp + 1;
}
if (counterDir >= (offset + perpage)){
if (counterDir >= (offset + perpage)) {
needNext = true;
break;
}
@ -200,7 +210,7 @@
function pagetoPrevious(){
offset = offset - perpage;
if (offset < 0){
if (offset < 0) {
offset = 0;
}
location.href = "more.html?offset=" + offset + "&perpage=" + perpage + "&search=" + encodeURI(search);
@ -212,12 +222,12 @@
}
var pagerPrevious = "<a href='#' onclick='pagetoPrevious();'><img src='minus-16.png'></a>";
if (offset <= 0){
if (offset <= 0) {
pagerPrevious = "<img src='blank_minus-16.png'>";
}
var pagerNext = "<a href='#' onclick='pagetoNext();'><img src='plus-16.png'></a>";
if (needNext == false){
if (needNext == false) {
pagerNext = "<img src='blank_plus-16.png'>";
}
@ -227,11 +237,11 @@
var pagerHtml = pagerPrevious + "<font class='pager'>&nbsp;&nbsp;" + countA + " - " + countB + "&nbsp;&nbsp;</font>" + pagerNext;
if (counterDisp > 0 ){
if (counterDisp > 0 ) {
document.getElementById("pager_top").innerHTML = pagerHtml;
document.getElementById("data").innerHTML = pageContent;
document.getElementById("pager_footer").innerHTML = pagerHtml;
}else{
} else {
document.getElementById("data").innerHTML = "<hr><div align='center'><font class='noresult'><br><br><br><br>Sorry, no result found.<br><br><br><br><br><br></font></div><hr>";
}