From 44020de3b092cc93f2a9308547b3cb9ebdd5c6eb Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 16 Dec 2014 01:46:02 +0000 Subject: [PATCH] Use for search game select. --- _layouts/page.html | 3 +++ js/search.js | 22 +++++++++++++--------- search.html | 13 ++++++++++--- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/_layouts/page.html b/_layouts/page.html index 5abdedc..9cda7c7 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -16,12 +16,15 @@ + + + diff --git a/js/search.js b/js/search.js index f7a09ed..03c71d0 100644 --- a/js/search.js +++ b/js/search.js @@ -21,7 +21,7 @@ repos = [ var github = new Github(auth); var repoBranch = 'master'; //The repository branch to search. -var gameSelect = document.getElementById('gameSelect'); +var gameSelect = document.getElementById('gameSelectMenu'); var searchButton = document.getElementById('searchButton'); var searchBox = document.getElementById('searchBox'); var resultsDiv = document.getElementById('results'); @@ -84,7 +84,7 @@ function onSearchInit(evt) { return; } - var repo = github.getRepo("loot", gameSelect.value); + var repo = github.getRepo("loot", gameSelect.selected); repo.read(repoBranch, 'masterlist.yaml', readMasterlist); /* Clear any previous search results. */ @@ -102,9 +102,9 @@ function onSearchInit(evt) { /* Fill the drop-down games box with stuff. */ for (var i=0; i < repos.length; ++i) { - var option = document.createElement('option'); - option.innerText = repos[i][0]; - option.setAttribute('value', repos[i][1]); + var option = document.createElement('paper-item'); + option.textContent = repos[i][0]; + option.setAttribute('data-game', repos[i][1]); gameSelect.appendChild(option); } @@ -118,14 +118,18 @@ if (pos != -1) { searchBox.value = decodeURIComponent(document.URL.substring(pos2+8)); var game = decodeURIComponent(document.URL.substring(pos+6, pos2).toLowerCase()); if (game == "oblivion") { - gameSelect.value = repos[0][1]; + gameSelect.selected = repos[0][1]; } else if (game == "skyrim") { - gameSelect.value = repos[1][1]; + gameSelect.selected = repos[1][1]; } else if (game == "fallout3") { - gameSelect.value = repos[2][1]; + gameSelect.selected = repos[2][1]; } else if (game == "falloutnv") { - gameSelect.value = repos[3][1]; + gameSelect.selected = repos[3][1]; + } else { + gameSelect.selected = repos[0][1]; } searchButton.click(); +} else { + gameSelect.selected = repos[0][1]; } diff --git a/search.html b/search.html index a6c1c98..23e6fe9 100644 --- a/search.html +++ b/search.html @@ -24,13 +24,20 @@ permalink: /search/

- Search for + Search + for in the - - masterlist.
+ + + + + + + + masterlist.