Fix some JSHint warnings.

This commit is contained in:
Sébastien Lucas 2013-07-02 14:15:10 +02:00
parent 08445d0479
commit 1eb4217c01

35
util.js
View file

@ -3,7 +3,6 @@ var templatePage, templateBookDetail, templateMain, currentData, before, filterL
var cache = new LRUCache(30); var cache = new LRUCache(30);
var DEBUG = true; var DEBUG = true;
var isEink = /Kobo|Kindle|EBRD1101/i.test(navigator.userAgent);
var isPushStateEnabled = window.history && window.history.pushState && window.history.replaceState && var isPushStateEnabled = window.history && window.history.pushState && window.history.replaceState &&
// pushState isn't reliable on iOS until 5. // pushState isn't reliable on iOS until 5.
!navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]|WebApps\/.+CFNetwork)/); !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]|WebApps\/.+CFNetwork)/);
@ -43,8 +42,8 @@ function updateCookieFromCheckbox (id) {
} }
function elapsed () { function elapsed () {
var elapsed = new Date () - before; var elapsedTime = new Date () - before;
return "Elapsed : " + elapsed; return "Elapsed : " + elapsedTime;
} }
function retourMail(data, textStatus, jqXHR ) { function retourMail(data, textStatus, jqXHR ) {
@ -52,15 +51,16 @@ function retourMail(data, textStatus, jqXHR ) {
} }
function sendToMailAddress (component, dataid) { function sendToMailAddress (component, dataid) {
$toto = $.cookie ('email'); var email = $.cookie ('email');
if (!$.cookie ('email')) { if (!$.cookie ('email')) {
var email = window.prompt ("Please enter your email : ", ""); email = window.prompt ("Please enter your email : ", "");
$.cookie ('email', email); $.cookie ('email', email);
} }
email = $.cookie ('email');
var url = 'sendtomail.php'; var url = 'sendtomail.php';
if (currentData.databaseId) url = url + '?db=' + currentData.databaseId; if (currentData.databaseId) {
$.ajax ({url: url, type: 'post', data: { data: dataid, email: email }, success: retourMail}); url = url + '?db=' + currentData.databaseId;
}
$.ajax ({'url': url, 'type': 'post', 'data': { 'data': dataid, 'email': email }, 'success': retourMail});
} }
function strformat () { function strformat () {
@ -73,8 +73,8 @@ function strformat () {
} }
function isDefined(x) { function isDefined(x) {
var undefined; var undefinedVar;
return x !== undefined; return x !== undefinedVar;
} }
function getCurrentOption (option) { function getCurrentOption (option) {
@ -107,7 +107,7 @@ function getTagList () {
var taglist = $(this).text(); var taglist = $(this).text();
var tagarray = taglist.split (",") var tagarray = taglist.split (",")
for (i in tagarray) { for (var i in tagarray) {
var tag = tagarray [i].replace(/^\s+/g,'').replace(/\s+$/g,''); var tag = tagarray [i].replace(/^\s+/g,'').replace(/\s+$/g,'');
tagList [tag] = 1; tagList [tag] = 1;
} }
@ -180,8 +180,8 @@ function handleFilterEvents () {
filterList [filter] = false; filterList [filter] = false;
break; break;
case "filter-exclude" : case "filter-exclude" :
$(this).removeClass ("filter-exclude");; $(this).removeClass ("filter-exclude");
delete filterList [filter];; delete filterList [filter];
break; break;
default : default :
$(this).attr("class", "filter-include"); $(this).attr("class", "filter-include");
@ -192,7 +192,10 @@ function handleFilterEvents () {
}); });
} }
/************************************************
* Functions to handle Ajax navigation
************************************************
*/
function navigateTo (url) { function navigateTo (url) {
before = new Date (); before = new Date ();
@ -235,7 +238,7 @@ function updatePage (data) {
$("#sortForm").show (); $("#sortForm").show ();
$("#filter ul").empty (); $("#filter ul").empty ();
updateFilters (); updateFilters ();
handleFilterEvents () handleFilterEvents ();
} else { } else {
$("#sortForm").hide (); $("#sortForm").hide ();
} }
@ -318,7 +321,7 @@ function ajaxifyLinks () {
window.onpopstate = function(event) { window.onpopstate = function(event) {
before = new Date (); before = new Date ();
var data = cache.get (event.state) var data = cache.get (event.state);
updatePage (data); updatePage (data);
}; };