Skip to content

Commit

Permalink
Update welcome and settings pages, remove HTTP/HTTPS switch
Browse files Browse the repository at this point in the history
  • Loading branch information
corbindavenport committed Mar 26, 2019
1 parent 953abfa commit e3e17a2
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 62 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ __Wikipedia is a trademark of the Wikimedia Foundation. Wikipedia Search is in n

__New in Wikipedia Search 9.1:__

* Add more languages
* Remove Awesome New Tab Page (ANTP) support, because the project is abandoned
* Switch toolbar button to pageAction, to reduce background memory usage
* Remove browserAction toolbar button, to reduce background memory usage
* Remove option to disable HTTPS
* Add Patreon donate link

---------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ chrome.runtime.onInstalled.addListener(function(details){
if (localStorage.getItem("full-language") === null) {
localStorage["full-language"] = detailArray[langArray.indexOf(localStorage["language"])];
}
if (localStorage.getItem("protocol") === null) {
localStorage["protocol"] = "https://";
}
localStorage["protocol"] = "https://"; // We'll remove this option later
if (localStorage.getItem("settings-modified") === null) {
localStorage["settings-modified"] = "false";
}
Expand Down
44 changes: 21 additions & 23 deletions js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@ var langArray= ["ar","az","bg","nan","be","ca","cs","da","de","et","el","en","si
var detailArray = ["العربية","Azərbaycanca","Български","Bân-lâm-gú / Hō-ló-oē","Беларуская (Акадэмічная)","Català","Čeština","Dansk","Deutsch","Eesti","Ελληνικά","English","Simple English","Español","Esperanto","Euskara","فارسی","Français","Galego","한국어","Հայերեն","हिन्दी","Hrvatski","Bahasa Indonesia","Italiano","עברית","ქართული","Latina","Lietuvių","Magyar","Bahasa Melayu","Bahaso Minangkabau","Nederlands","日本語","Norsk (Bokmål)","Norsk (Nynorsk)","Нохчийн","Oʻzbekcha / Ўзбекча","Polski","Português","Қазақша / Qazaqşa / قازاقشا","Română","Русский","Sinugboanong Binisaya","Slovenčina","Slovenščina","Српски / Srpski","Srpskohrvatski / Српскохрватски","Suomi","Svenska","தமிழ்","ภาษาไทย","Türkçe","Українська","اردو","Tiếng Việt","Volapük","Winaray","中文"];

// Load settings
$(window).on('load', function() {
// Populate languages menu
langArray.forEach(function callback(currentValue, index, array) {
$('#language').append($('<option>', {
value: currentValue,
text: detailArray[langArray.indexOf(currentValue)]
}));
});
// Remove loading option
$("#language option[value='loading'").remove();
// Set to current language
$("#language").val(localStorage["language"]);
if (localStorage.getItem("protocol") === "https://") {
$("input[name='protocol']").prop("checked", true);
} else {
$("input[name='protocol']").prop("checked", true);
}
$("input[name='shortcut']").prop("checked", $.parseJSON(localStorage.getItem("shortcut")));
langArray.forEach(function callback(currentValue, index, array) {
$('#language').append($('<option>', {
value: currentValue,
text: detailArray[langArray.indexOf(currentValue)]
}));
});
// Remove loading option
$("#language option[value='loading'").remove();
// Set to current language
$("#language").val(localStorage["language"]);
$("input[name='shortcut']").prop("checked", $.parseJSON(localStorage.getItem("shortcut")));

// Show instructions for leaving a review based on the browser being used
var useragent = navigator.userAgent

// Opera has to be checked before Chrome, because Opera has both "Chrome" and "OPR" in the user agent string
if (useragent.includes("OPR")) {
document.querySelector('.review-info').innerHTML = 'Leaving a review on the <a href="https://addons.opera.com/en/extensions/details/wikipedia-search/" target="_blank">Opera add-ons site</a> is also greatly appreciated!'
} else if (useragent.includes("Chrome")) {
document.querySelector('.review-info').innerHTML = 'Leaving a review on the <a href="https://chrome.google.com/webstore/detail/wikipedia-search/lipakennkogpodadpikgipnogamhklmk" target="_blank">Chrome Web Store</a> is also greatly appreciated!'
}

// Reset language button
$(document).on('click', ".reset-language", function() {
Expand All @@ -46,10 +48,6 @@ $(document).on('change', "input,select", function() {
localStorage["settings-modified"] = "true";
localStorage["language"] = $("#language").val();
localStorage["full-language"] = detailArray[langArray.indexOf($("#language").val())];
if ($("input[name='protocol']").is(":checked")) {
localStorage["protocol"] = "https://";
} else {
localStorage["protocol"] = "http://";
}
localStorage["protocol"] = "https://"; // We'll remove this option later, but at least it's not user-visible anymore
localStorage.setItem("shortcut", $("input[name='shortcut']").is(":checked"));
});
36 changes: 16 additions & 20 deletions js/welcome.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
$(document).ready(function() {
// Add version number to welcome page
document.querySelector('.version').innerHTML = chrome.runtime.getManifest().version

// Add version number to welcome page
$(".version").html(" " + chrome.runtime.getManifest().version);
// Add language to welcome page
if (JSON.parse(localStorage.getItem("settings-modified")) == false) {
document.querySelector(".language-warning").innerHTML = 'The search language has been auto-detected as <b>' + localStorage["full-language"] + ' (' + localStorage["language"] + ')</b>.<a class="btn btn-primary" href="settings.html" role="button">Change language</a>'
} else {
document.querySelector(".language-warning").innerHTML = 'The search language is currently set to <b>' + localStorage["full-language"] + ' (' + localStorage["language"] + ')</b>.<a class="btn btn-primary" href="settings.html" role="button">Change language</a>'
}

// Add language to welcome page
if ($.parseJSON(localStorage.getItem("settings-modified")) == false) {
$(".language-warning").html('The search language has been auto-detected as <b>' + localStorage["full-language"] + ' (' + localStorage["language"] + ')</b>.<a class="btn btn-primary" href="settings.html" role="button">Change language</a>');
} else {
$(".language-warning").html('The search language is currently set to <b>' + localStorage["full-language"] + ' (' + localStorage["language"] + ')</b>.<a class="btn btn-primary" href="settings.html" role="button">Change language</a>');
}
// Show instructions for leaving a review based on the browser being used
var useragent = navigator.userAgent

//Show instructions for leaving a review based on the browser being used
var useragent = navigator.userAgent;

// Opera has to be checked before Chrome, because Opera has both "Chrome" and "OPR" in the user agent string
if (useragent.includes("OPR")) {
$('.review-info').html('Also please leave a review on the <a href="https://addons.opera.com/en/extensions/details/wikipedia-search/" target="_blank">Opera add-ons site</a> if you can.');
} else if (useragent.includes("Chrome")) {
$('.review-info').html('Also please leave a review on the <a href="https://chrome.google.com/webstore/detail/wikipedia-search/lipakennkogpodadpikgipnogamhklmk" target="_blank">Chrome Web Store</a> if you can.');
}

});
// Opera has to be checked before Chrome, because Opera has both "Chrome" and "OPR" in the user agent string
if (useragent.includes("OPR")) {
document.querySelector('.review-info').innerHTML = 'Leaving a review on the <a href="https://addons.opera.com/en/extensions/details/wikipedia-search/" target="_blank">Opera add-ons site</a> is also greatly appreciated!'
} else if (useragent.includes("Chrome")) {
document.querySelector('.review-info').innerHTML = 'Leaving a review on the <a href="https://chrome.google.com/webstore/detail/wikipedia-search/lipakennkogpodadpikgipnogamhklmk" target="_blank">Chrome Web Store</a> is also greatly appreciated!'
}
3 changes: 0 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
"http://*.wikipedia.org/*",
"https://*.wikipedia.org/*"
],
"page_action": {
"default_title": "Click the icon to open Wikipedia Search settings."
},
"background": {
"scripts": ["js/background.js"]
},
Expand Down
11 changes: 3 additions & 8 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ <h3>Language</h3>
<div class="row">
<div class="col-md-12">
<h3>Other settings</h3>
<div class="checkbox">
<label>
<input type="checkbox" name="protocol">
Enable HTTPS for searches (recommended)
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="shortcut">
Expand All @@ -67,8 +61,9 @@ <h2>Having issues?</h2>
<div class="col-md-4">
<h2>Donate</h2>
<p>If you find Wikipedia Search useful, please donate to support continued development. It would mean a lot!</p>
<p><a class="btn btn-warning" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4SZVSMJKDS35J&lc=US&item_name=Wikipedia%20Search%20Donation&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" role="button">Donate via PayPal</a></p>
<p><b>Note:</b> Wikipedia Search is not affliated with Wikipedia or the Wikimedia Foundation. If you wish to donate to the Wikimedia Foundation, you can do it from their website <a href="https://donate.wikimedia.org/w/index.php?title=Special:LandingPage&country=US&uselang=en&utm_medium=sidebar&utm_source=donate&utm_campaign=C13_wikimediafoundation.org" target="_blank">here</a>.</p>
<p><a class="btn btn-success" href="https://www.patreon.com/corbindavenport" target="_blank" role="button" style="width: 100%">Donate via Patreon</a></p>
<p><a class="btn btn-success" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4SZVSMJKDS35J&lc=US&item_name=Wikipedia%20Search%20Donation&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" role="button" style="width: 100%">Donate via PayPal</a></p>
<p><b>Note:</b> Wikipedia Search is not affliated with Wikipedia or the Wikimedia Foundation. If you wish to donate to the Wikimedia Foundation, you can do so from their website <a href="https://donate.wikimedia.org" target="_blank">here</a>.</p>
<p class="review-info"></p>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="jumbotron">
<div class="container">
<h1>Welcome to Wikipedia Search <span class="version"></span>!</h1>
<p>You have been updated to the latest version of the Wikipedia Search extension. This version includes language auto-detection, improved support for Opera, bug fixes, and more.</p>
<p>You have been updated to the latest version of the Wikipedia Search extension. This version includes more languages, a new way to support development, and more.</p>
</div>
</div>

Expand All @@ -44,8 +44,9 @@ <h2>Having issues?</h2>
<div class="col-md-4">
<h2>Donate</h2>
<p>If you find Wikipedia Search useful, please donate to support continued development. It would mean a lot!</p>
<p><a class="btn btn-warning" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4SZVSMJKDS35J&lc=US&item_name=Wikipedia%20Search%20Donation&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" role="button">Donate via PayPal</a></p>
<p><b>Note:</b> Wikipedia Search is not affliated with Wikipedia or the Wikimedia Foundation. If you wish to donate to the Wikimedia Foundation, you can do it from their website <a href="https://donate.wikimedia.org/w/index.php?title=Special:LandingPage&country=US&uselang=en&utm_medium=sidebar&utm_source=donate&utm_campaign=C13_wikimediafoundation.org" target="_blank">here</a>.</p>
<p><a class="btn btn-success" href="https://www.patreon.com/corbindavenport" target="_blank" role="button" style="width: 100%">Donate via Patreon</a></p>
<p><a class="btn btn-success" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4SZVSMJKDS35J&lc=US&item_name=Wikipedia%20Search%20Donation&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" role="button" style="width: 100%">Donate via PayPal</a></p>
<p><b>Note:</b> Wikipedia Search is not affliated with Wikipedia or the Wikimedia Foundation. If you wish to donate to the Wikimedia Foundation, you can do so from their website <a href="https://donate.wikimedia.org" target="_blank">here</a>.</p>
<p class="review-info"></p>
</div>
</div>
Expand All @@ -57,7 +58,6 @@ <h2>Donate</h2>
</footer>
</div>

<script src="js/jquery-3.2.1.slim.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/welcome.js"></script>
</body>
Expand Down

0 comments on commit e3e17a2

Please sign in to comment.