Skip to content

Commit

Permalink
Make search buttons anchors so they can be middle-clicked en masse
Browse files Browse the repository at this point in the history
  • Loading branch information
xdpirate committed Nov 28, 2023
1 parent e3cfe90 commit f1f8dc6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
8 changes: 2 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@
$numrows = mysqli_num_rows($resGamesUnreleased);
for($i = 0; $i < $numrows; $i++) {
$gameID = mysqli_result($resGamesUnreleased,$i,"ID");
$gameTitle = mysqli_result($resGamesUnreleased,$i,"GameName");
$bareGameTitle = $gameTitle;
$gameTitle = htmlentities($gameTitle);
$gameTitle = htmlentities(mysqli_result($resGamesUnreleased,$i,"GameName"));
$releaseDate = mysqli_result($resGamesUnreleased,$i,"ReleaseDate");
$platforms = explode("|", mysqli_result($resGamesUnreleased,$i,"Platforms"));

Expand Down Expand Up @@ -225,9 +223,7 @@
}
}

$searchString = urlencode($bareGameTitle);

$outputstring .= "</td><td><span onclick='editGame(\"unreleased\", $gameID, this);' title='Edit' class='editButton'><img src='$editImage' width='24' height='24'></span><span class='searchButton' onclick='doSearch(\"$searchString\")' title='Search the web for this game'><img src='$searchImage' width='24' height='24' /></span><span onclick='deleteGame($gameID, \"unreleased\");'; title='Delete' class='deleteButton'><img src='$deleteImage' width='24' height='24'></span></td></tr>";
$outputstring .= "</td><td><span onclick='editGame(\"unreleased\", $gameID, this);' title='Edit' class='editButton'><img src='$editImage' width='24' height='24'></span><a class='searchButton' href='' title='Search the web for this game' target='_blank'><img src='$searchImage' width='24' height='24' /></a><span onclick='deleteGame($gameID, \"unreleased\");'; title='Delete' class='deleteButton'><img src='$deleteImage' width='24' height='24'></span></td></tr>";

print $outputstring;
}
Expand Down
1 change: 1 addition & 0 deletions js/endscripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,4 @@ if(switchTable) {

document.getElementById("customSearchEngineBox").value = searchEngineCustomURL;
searchEngineHandler();
applySearchEngine();
2 changes: 1 addition & 1 deletion js/optionsbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ optionsBox.innerHTML = `
<option disabled>----------</option>
<option value="custom"${searchEngine == "custom" ? " selected" : ""}>Custom</option>
</select><br />
<input type="text" id="customSearchEngineBox" name="customSearchEngineBox" onkeyup="saveSettings();" placeholder="URL - use %s in place of search terms"></input>
<input type="text" id="customSearchEngineBox" name="customSearchEngineBox" oninput="saveSettings();" placeholder="URL - use %s in place of search terms"></input>
<hr>
<input type="checkbox" onchange="saveSettings();" id="hideAddGameCheckbox"${hideAddGame == 1 ? " checked" : ""}><label for="hideAddGameCheckbox">Hide the Add Game area by default</label>
Expand Down
11 changes: 10 additions & 1 deletion js/startscripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ function saveSettings() {
document.cookie = "hideAddGame=" + hideAddGame + ";" + expires + ";SameSite=Lax;path=/";
document.cookie = "searchEngine=" + searchEngine + ";" + expires + ";SameSite=Lax;path=/";
document.cookie = "searchEngineCustomURL=" + encodeURIComponent(searchEngineCustomURL) + ";" + expires + ";SameSite=Lax;path=/";

applySearchEngine();
}

function doSearch(gameName) {
Expand Down Expand Up @@ -264,7 +266,7 @@ function applyTheme(themeName) {
cursor: pointer;
}
.editButton, .deleteButton, .searchButton {
.editButton, .deleteButton {
cursor: pointer;
}
Expand Down Expand Up @@ -325,6 +327,13 @@ function applyTheme(themeName) {
</style>`;
}

function applySearchEngine() {
let searchBtns = document.querySelectorAll(".searchButton");
for(let i = 0; i < searchBtns.length; i++) {
searchBtns[i].href = searchEngines[searchEngine].replace("%s", searchBtns[i].closest("tr").firstElementChild.innerText.trim());
}
}

if(!themes[currentTheme]) {
currentTheme = "nord";
}
Expand Down
3 changes: 3 additions & 0 deletions php/quotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
["Do a barrel roll!", "Peppy"],
["If you keep going the way you are now... you're gonna have a bad time", "Sans"],
["You put the wit in twit, sir", "Lawrence"],
["I shall let you live, little alien... Psych! Mr. Zurkon lives only to kill", "Mr. Zurkon"],
["Mr. Zurkon conducts a symphony of pain", "Mr. Zurkon"],
["You are a disease, and Mr. Zurkon is the cure!", "Mr. Zurkon"],
];

$pick = rand(0,sizeof($quotes)-1);
Expand Down

0 comments on commit f1f8dc6

Please sign in to comment.