Skip to content

Commit

Permalink
uploaded wikipedia search 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
corbindavenport committed Feb 14, 2015
1 parent 660a296 commit 8fb553a
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 25 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Wikipedia Search is free to use in any browser extension, but I would like a lin
__Wikipedia is a trademark of the Wikimedia Foundation. OmniProxy icon from the [Faenza](http://tiheum.deviantart.com/art/Faenza-Icons-173323228) icon pack.__

---------------------------------------------------------
__New in Wikipedia Search 6.1:__
* __HTTPS by default:__ Wikipedia Search added support for HTTPS search in version 6.0, but now it's default.
* __New Language:__ Wikipedia Search now supports Ellīniká as a language.
* __Easier options access:__ You can now get to the extensions options straight from the OmniBar while searching!.
* __Bug fixes:__ This release contains various bug fixes.

__New in Wikipedia Search 6.0:__
* __ANTP Widget:__ Wikipedia Search now includes a widget for the popular New Tab Page replacement, Awesome New Tab Page. If you have ANTP installed, just drag the Wikipedia Search widget to an empty slot.
* __HTTPS Search:__ You can now enable searching with HTTPS from the options, which makes your searches more secure and private.
Expand Down
35 changes: 22 additions & 13 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ You should have received a copy of the GNU General Public License along with thi
chrome.runtime.onInstalled.addListener(function(details){
if(details.reason == "update" || "install"){
if(localStorage.getItem("language") === null){
var language = "en";
localStorage["language"] = language;
console.log("no language selected, defaulting to english");
localStorage["language"] = "en";
}
if(localStorage.getItem("protocol") === null){
var protocol = "https://";
localStorage["protocol"] = protocol;
console.log("no protocol selected, defaulting to https (secure)");
localStorage["protocol"] = "https://";
}
if(localStorage.getItem("donation") === null){
localStorage["donation"] = "yes";
}
}
if(localStorage.getItem("version") != chrome.runtime.getManifest().version){
chrome.tabs.create({'url': chrome.extension.getURL('welcome.html')});
localStorage["version"] = chrome.runtime.getManifest().version
localStorage["version"] = chrome.runtime.getManifest().version;
}
});

Expand Down Expand Up @@ -68,14 +67,15 @@ function onSearch(info, tab) {
}
var id = chrome.contextMenus.create({ "title": "Wikipedia Search", "contexts": ["selection"],
"onclick": onSearch
});
});

// Omnibox Search
// Derived from OmniWiki (github.com/hamczu/OmniWiki)

var currentRequest = null;

chrome.omnibox.onInputChanged.addListener(function(text, suggest) {

if (currentRequest != null) {
currentRequest.onreadystatechange = null;
currentRequest.abort();
Expand All @@ -87,32 +87,37 @@ chrome.omnibox.onInputChanged.addListener(function(text, suggest) {
if(text.length > 0){
currentRequest = suggests(text, function(data) {
var results = [];
for(var i = 0; i < data[1].length; i++){
for(var i = 0; i < 4; i++){
results.push({
content: data[1][i],
description: data[1][i]
});
}
results.push({
content: "options",
description: "Open Wikipedia Search options"
});
suggest(results);
});
} else {
}

});

function resetDefaultSuggestion() {
chrome.omnibox.setDefaultSuggestion({
description: ' '
});
}
};

resetDefaultSuggestion();
var searchLabel = chrome.i18n.getMessage('search_label');
function updateDefaultSuggestion(text) {
chrome.omnibox.setDefaultSuggestion({
description: searchLabel + ': %s'
description: searchLabel + 'Search on Wikipedia: %s'
});

}
};

chrome.omnibox.onInputStarted.addListener(function() {
updateDefaultSuggestion('');
Expand Down Expand Up @@ -149,5 +154,9 @@ function suggests(query, callback) {
chrome.omnibox.onInputEntered.addListener(function(text) {
var language = localStorage["language"];
var protocol = localStorage["protocol"];
chrome.tabs.update(null, {url: protocol + language + ".wikipedia.org/w/index.php?search=" + text});
if (text == "options") {
chrome.tabs.update(null, {url: chrome.extension.getURL('options.html')});
} else {
chrome.tabs.update(null, {url: protocol + language + ".wikipedia.org/w/index.php?search=" + text});
}
});
5 changes: 3 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"manifest_version": 2,
"name": "Wikipedia Search",
"version": "6.0",
"version": "6.1",
"description": "Search Wikipedia in every language from the search bar.",
"options_page": "options.html",
"omnibox": {
"keyword": "wiki"
},
"web_accessible_resources": [
"widget.html"
"widget.html",
"options.html"
],
"permissions": [
"contextMenus",
Expand Down
14 changes: 11 additions & 3 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
<body>
<section id="wrapper" class="wrapper enabled">
<h1>Wikipedia Search - Settings</h1>
<article>
<h2>Donate</h2>
<p>If you find Wikipedia Search useful, please donate to support continued development. It would mean a lot!</p>
<section id="settings-buttons" class="buttons" style="display: block;">
<input class="g-button g-button-submit" type="button" value="Donate via PayPal">
</section>
</article>
<article>
<section class="settings-card">
<h2>Settings</h2>
Expand All @@ -35,6 +42,7 @@ <h2>Settings</h2>
<option value="cs" lang="cs">Česky</option>
<option value="da" lang="da">Dansk</option>
<option value="de" lang="de">Deutsch</option>
<option value="el" lang="el">Ελληνικά</option><!-- Ellīniká -->
<option value="en" lang="en" selected="selected">English</option>
<option value="es" lang="es">Español</option>
<option value="eo" lang="eo">Esperanto</option>
Expand All @@ -54,20 +62,20 @@ <h2>Settings</h2>
<option value="lt" lang="lt">Lietuvių</option>
<option value="hu" lang="hu">Magyar</option>
<option value="ms" lang="ms">Bahasa Melayu</option>
<option value="min" lang="min">Baso Minangkabau</option>
<option value="min" lang="min">Bahaso Minangkabau</option>
<option value="nl" lang="nl">Nederlands</option>
<option value="ja" lang="ja">日本語</option><!-- Nihongo -->
<option value="no" lang="nb">Norsk (bokmål)</option>
<option value="nn" lang="nn">Norsk (nynorsk)</option>
<option value="uz" lang="uz">Oʻzbekcha</option>
<option value="uz" lang="uz">Oʻzbekcha / Ўзбекча</option>
<option value="pl" lang="pl">Polski</option>
<option value="pt" lang="pt">Português</option>
<option value="kk" lang="kk">Қазақша / Qazaqşa / قازاقشا</option>
<option value="ro" lang="ro">Română</option>
<option value="ru" lang="ru">Русский</option><!-- Russkiy -->
<option value="sah" lang="sah">Саха Тыла</option><!-- Saxa Tyla -->
<option value="simple" lang="en">Simple English</option>
<option value="ceb" lang="ceb">Sinugboanong</option><!-- Cebuano -->
<option value="ceb" lang="ceb">Sinugboanong Binisaya</option><!-- Cebuano -->
<option value="sk" lang="sk">Slovenčina</option>
<option value="sl" lang="sl">Slovenščina</option>
<option value="sr" lang="sr">Српски / Srpski</option>
Expand Down
6 changes: 5 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ header, hgroup, menu, nav, section {
html {
background: #fff;
color: #333;
font: 81.25% arial, sans-serif;
font: 18px arial, sans-serif;
line-height: 1;
-webkit-text-size-adjust: none;
}
Expand Down Expand Up @@ -584,4 +584,8 @@ input {

.search {
width: 520px;
}

#disabled {
color: #FF0000;
}
9 changes: 4 additions & 5 deletions welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
</head>
<body>
<section id="wrapper" class="wrapper enabled">
<h1>Welcome to Wikipedia Search 6.0!</h1>
<h1>Welcome to Wikipedia Search 6.1!</h1>
<article>
<h2>What's New?</h2>
<p><b>ANTP Widget:</b> Wikipedia Search now includes a widget for the popular New Tab Page replacement, <a href="https://chrome.google.com/webstore/detail/mgmiemnjjchgkmgbeljfocdjjnpjnmcg">Awesome New Tab Page</a>. If you have ANTP installed, just drag the Wikipedia Search widget to an empty slot.</p>
<p><b>HTTPS Search:</b> You can now enable searching with HTTPS from the options, which makes your searches more secure and private.</p>
<p><b>New Icon:</b> Wikipedia Search now has a new icon from the <a href="http://tiheum.deviantart.com/art/Faenza-Icons-173323228">Faenza</a> icon pack.</p>
<p><b>New Language:</b> Wikipedia Search now supports Azərbaycanca as a language.</p>
<p><b>HTTPS by default:</b> Wikipedia Search added support for HTTPS search in version 6.0, but now it's default.</p>
<p><b>New Language:</b> Wikipedia Search now supports Ellīniká as a language.</p>
<p><b>Bug fixes:</b> This release contains various bug fixes.</p>
</article>
<article>
<h2>Getting Started</h2>
Expand Down
10 changes: 9 additions & 1 deletion wikipedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ function restore_options() {
}
}

function doDonation(){
chrome.tabs.create({ url: "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4SZVSMJKDS35J&lc=US&item_name=Corbin%20Davenport&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted" });
}

window.addEventListener('load',function(){
var select1 = document.getElementById("language");
for (var i = 0; i < select1.children.length; i++) {
Expand All @@ -58,4 +62,8 @@ window.addEventListener('load',function(){

function startSearch(event) {document.getElementById("searchform").submit(); }

window.onload = function(){document.querySelector('input[value="Save"]').onclick=save_options;}
window.onload = function(){
document.querySelector('input[value="Save"]').onclick=save_options;
document.querySelector('input[value="Donate via PayPal"]').onclick=doDonation;
\\
}

0 comments on commit 8fb553a

Please sign in to comment.