2016-01-15 03:30:25 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
// about:home JS
|
|
|
|
|
|
|
|
// XPCOM preferences integration
|
|
|
|
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
|
|
|
|
|
|
|
var aboutHomeAutofocus = prefs.getBoolPref("rzHome.autofocus");
|
|
|
|
var searchEngineURL = prefs.getCharPref("keyword.URL");
|
|
|
|
|
2016-01-17 01:57:13 +01:00
|
|
|
//check to see if custom search pref url exists
|
|
|
|
var prefServiceBranch = Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefService).getBranch("");
|
|
|
|
if(prefServiceBranch.getPrefType('rzHome.customsearch')){
|
|
|
|
//key exist!
|
|
|
|
var searchEngineURL = prefs.getCharPref("rzHome.customsearch");
|
|
|
|
} else {
|
|
|
|
// use Google
|
|
|
|
var searchEngineURL = "http://www.google.com/search?q=";
|
|
|
|
}
|
2016-01-10 01:53:48 +01:00
|
|
|
|
|
|
|
// autofocus function
|
|
|
|
function autoFocus() {
|
|
|
|
document.getElementById("rzSearch").focus();
|
|
|
|
}
|
|
|
|
|
2016-01-15 03:30:25 +01:00
|
|
|
// onload function (used to allow for autofocus)
|
2016-01-10 01:53:48 +01:00
|
|
|
window.onload = function() {
|
|
|
|
if (aboutHomeAutofocus == true) {
|
|
|
|
autoFocus();
|
|
|
|
}
|
2017-10-06 22:13:43 +02:00
|
|
|
// set current year
|
|
|
|
var d = new Date();
|
|
|
|
var cYear = d.getFullYear();
|
|
|
|
document.getElementById("currentYear").innerHTML = cYear;
|
2016-01-15 03:30:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// function that runs when the "Search" button is clicked
|
|
|
|
function rzSearch() {
|
|
|
|
var searchQuery = document.getElementById("rzSearch").value;
|
|
|
|
var searchURL = searchEngineURL + searchQuery;
|
2016-01-17 01:57:13 +01:00
|
|
|
//alert("Location: " + searchURL); // for debug purposes
|
2016-01-15 03:30:25 +01:00
|
|
|
window.location.replace(searchURL);
|
|
|
|
}
|