jenkins-bot has submitted this change and it was merged.
Change subject: Fix jslint errors
......................................................................
Fix jslint errors
Ignores files we carnt edit directly due to copied files from other
places.
Change-Id: I39967507230112977d54cae3b866160b3a52da7b
---
A .jshintignore
A .jshintrc
M scripts/OfflineImportLexicon.js
M scripts/OfflineImportLexiconSecond.js
4 files changed, 83 insertions(+), 68 deletions(-)
Approvals:
Siebrand: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..2be6951
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1,3 @@
+/* Ignore js files we carnt edit direct */
+scripts/jquery.ezpz_tooltip.js
+scripts/jquery.ezpz_tooltip.min.js
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..7e35c38
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "-W041": false
+}
diff --git a/scripts/OfflineImportLexicon.js b/scripts/OfflineImportLexicon.js
index f5a343a..8c3c926 100644
--- a/scripts/OfflineImportLexicon.js
+++ b/scripts/OfflineImportLexicon.js
@@ -9,14 +9,14 @@
var hasVolumeVar=false;
var page = "";
-var currentLexicon = new Array();
-var textObj=new Array();
-var selectedProp= new Array();
+var currentLexicon = [];
+var textObj= [];
+var selectedProp= [];
var flag = false;
var from = 0;
var index = 0;
var queryText ="";
-var selected = new Array();
+var selected = [];
var $j=jQuery.noConflict();
function initGlobals()
@@ -89,7 +89,7 @@
// Retrieve lexicons when application starts
jQuery(document).ready(function() {
// init status bar
- var status = "Click on New Lexicon ..."
+ var status = "Click on New Lexicon ...";
_statusbar = new StatusBar(null,{showCloseButton:
true,additive:true,afterTimeoutText: status });
_statusbar.show(status);
var query = wgServer+wgScript+jsonGeneralLink+jsonLink;
@@ -98,12 +98,12 @@
jQuery("#selectLexicon").change(function (event) {
jQuery("#lexiconList li").remove();
- if(jQuery("#selectLexicon option:selected").val()!="" ||
jQuery("#selectLexicon option:selected").val()!=undefined)
+ if(jQuery("#selectLexicon option:selected").val()!=="" ||
jQuery("#selectLexicon option:selected").val()!==undefined)
{
jQuery("#selectVolume option").remove();
var temp = trim(jQuery("#selectLexicon
option:selected").attr('title'));
var query = wgServer+wgScript+jsonGeneralLink;
- if(temp!="")
+ if(temp!=="")
{
query += jsonLinkVolume.replace('@@@',jQuery("#selectLexicon
option:selected").val().replace(/-/g,'-2D').replace(/ /g,'-20'));
getJsonProperties('volume', query);
@@ -120,12 +120,12 @@
jQuery("#selectVolume").change(function (event) {
jQuery("#lexiconList li").remove();
- if(jQuery("#selectVolume option:selected").val()!="" ||
jQuery("#selectVolume option:selected").val()!=undefined)
+ if(jQuery("#selectVolume option:selected").val()!=="" ||
jQuery("#selectVolume option:selected").val()!==undefined)
{
var temp = trim(jQuery("#selectVolume option:selected").text());
var lexicon = trim(jQuery("#selectLexicon option:selected").text());
var query = wgServer+wgScript+jsonGeneralLink;
- if(temp!="")
+ if(temp!=="")
{
query +=
jsonLinkArticle.replace('@@@',temp.replace(/-/g,'-2D').replace(/
/g,'-20').replace(/\//g,'-2F'));
}
@@ -349,32 +349,32 @@
{
// alert("aici+++");
var temp = item.title;
- if(temp!="" && temp!=undefined)
+ if(temp!=="" && temp!==undefined)
{
res += "| Title = "+temp+"\n";
jQuery("#lemmataTitle").val(temp);
}
temp = item.subtitle;
- if(temp!="" && temp!=undefined)
+ if(temp!=="" && temp!==undefined)
{
res += "| Subtitle = "+temp+"\n";
jQuery("#lemmataSubtitle").val(temp);
}
temp = item.part_of_lexicon;
- if(temp!="" && temp!=undefined)
+ if(temp!=="" && temp!==undefined)
{
res += "| Part of Lexicon = "+temp+"\n";
}
temp = item.part_of_volume;
- if(temp!="" && temp!=undefined)
+ if(temp!=="" && temp!==undefined)
res += "| Part of Volume = "+temp+"\n";
res += "| Has Digitized = ";
var obj = item.has_digitized;
jQuery("#lemmataImages").text(obj);
res += obj;
res += "\n{{Authors \n| Author = ";
- var obj = item.author;
- jQuery("#lemmataAuthor").val(obj);
+ var object = item.author;
+ jQuery("#lemmataAuthor").val(object);
// res += page+'; \n';
temp = item.first_page;
if(temp!="" && temp!=undefined)
@@ -984,52 +984,55 @@
function hasVolume()
{
- var res = "";
- var short = jQuery("input#metadataShortTitle").val();
- //var hasvol = jQuery("input#metadataHasVolume").val();
- var hasvol = jQuery("#selectoutput option:selected").text();
- // alert('hasvol '+hasvol);
- if(hasvol.indexOf(";")!=-1)
+ var res = "";
+ var short = jQuery("input#metadataShortTitle").val();
+ // var hasvol = jQuery("input#metadataHasVolume").val();
+ var hasvol = jQuery("#selectoutput option:selected").text();
+ // alert('hasvol '+hasvol);
+ if(hasvol.indexOf(";")!=-1)
+ {
+ var arrCreators = hasvol.split(';');
+ var countItems = 0;
+ res += "| Has Volume = ";
+ for(var i in arrCreators)
+ {
+ countItems +=1;
+ res +=short+'/Volume '+zeroPad(arrCreators[i],2);
+ if(countItems< arrCreators.length){
+ res += ";";
+ }
+ }
+ hasVolumeVar = true;
+ }
+ else
{
- var arrCreators = hasvol.split(';');
- var countItems = 0;
+ // alert(jQuery("#selectoutput option:selected").text());
+ // if(hasvol=="1" && jQuery("#selectoutput
option:selected").text()=='1') res ='| Has Volume =' + short+'/Volume
'+zeroPad(1,2);
+ if(hasvol=="1"){
+ res ='| Has Volume =';
+
+ }
+ else
+ {
res += "| Has Volume = ";
- for(var i in arrCreators)
- {
- countItems +=1;
- res +=short+'/Volume
'+zeroPad(arrCreators[i],2);
- if(countItems< arrCreators.length){
+ hasVolumeVar = true;
+ var ii = parseInt(jQuery("#selectoutput
option:selected").text());
+ alert("ii "+ii);
+ /*jshint -W038 */
+ for(i=1; i<=ii; i++)
+ {
+ /*jshint -W038 */
+ res +=short+'/Volume '+zeroPad(i,2);
+ /*jshint -W038 */
+ if(i < ii)
+ {
res += ";";
}
}
- hasVolumeVar = true;
- }
- else
- {
- // alert(jQuery("#selectoutput option:selected").text());
- // if(hasvol=="1" && jQuery("#selectoutput
option:selected").text()=='1') res ='| Has Volume =' + short+'/Volume
'+zeroPad(1,2);
- if(hasvol=="1"){
- res ='| Has Volume =';
-
- }
- else
- {
- res += "| Has Volume = ";
- hasVolumeVar = true;
- var ii = parseInt(jQuery("#selectoutput option:selected").text());
- alert("ii "+ii);
- for(i=1; i<=ii; i++)
- {
- res +=short+'/Volume '+zeroPad(i,2);
- if(i < ii)
- {
- res += ";";
- }
- }
- }
- }
- alert(res);
- return res;
+ }
+ }
+ alert(res);
+ return res;
}
function zeroPad(num, places)
{
@@ -1052,6 +1055,7 @@
function initImagesData(data)
{
+ /*jslint evil: true */
var obj = eval(data);
alert(obj[0].id);
alert(fixedDecodeURI(obj[0].name));
@@ -1146,6 +1150,7 @@
function renderList(data) {
// JAX-RS serializes an empty list as null, and a 'collection of one'
as an object (not an 'array of one')
+ /*jslint evil: true */
var obj = eval(data);
alert(obj[0].id);
alert(obj[1].name);
@@ -1276,12 +1281,12 @@
},
timeout);
}
- }
+ };
this.release = function()
{
if(_statusbar)
jQuery(_statusbar).remove();
- }
+ };
}
// use this as a global instance to customize constructor
// or do nothing and get a default status bar
@@ -1294,6 +1299,7 @@
}
function romanize (num) {
+ /* jshint -W018 */
if (!+num)
return false;
var digits = String(+num).split(""),
@@ -1308,6 +1314,7 @@
}
function deromanize (str) {
+ /*jshint -W004 */
var str = str.toUpperCase(),
validator =
/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/,
token = /[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,
diff --git a/scripts/OfflineImportLexiconSecond.js
b/scripts/OfflineImportLexiconSecond.js
index 0c66901..053a617 100644
--- a/scripts/OfflineImportLexiconSecond.js
+++ b/scripts/OfflineImportLexiconSecond.js
@@ -65,8 +65,9 @@
console.log([xhr, res]);
callback(null);
- }
+ };
+ /*jshint -W002 */
/* Try to get a new XmlHttpRequest
*
* @return {XmlHttpRequest}
@@ -128,7 +129,7 @@
else
callback(res);
}
- }
+ };
}
/* Make a callback request to a remote api.php. Restricted as per api.php
documentation.
@@ -150,7 +151,7 @@
on_error(null, callback, res);
else
callback(res);
- }
+ };
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
@@ -213,9 +214,10 @@
}
// Make JSON.parse work
- var JSON = (typeof JSON == 'undefined' ? new Object() : JSON);
+ var JSON = (typeof JSON == 'undefined' ? {} : JSON);
if (typeof JSON.parse != 'function')
+ /*jshint -W061 */
JSON.parse = function (json) { return eval('(' + json + ')'); };
// Allow .prototype. extensions
@@ -307,7 +309,7 @@
edit_function(text, save_function, res);
});
- }
+ };
/* A thin wrapper around the API's parse function. Set's the pst flag to
* make subst: work, and returns all parse information
@@ -331,8 +333,8 @@
callback(null, res);
else
callback(res.parse.text['*'], res);
- })
- }
+ });
+ };
/* A thin wrapper around .parse that forces the text to be parsed without
* any <p> tags that might otherwise get added.
@@ -345,11 +347,11 @@
call_with_page.parse("<div>\n" + to_parse + "</div>", function
(parsed, res)
{
callback(parsed ?
parsed.replace(/^<div>\n?/,'').replace(/(\s*\n)?<\/div>\n*(<!--[^>]*-->\s*)?$/,'')
: parsed, res);
- })
- }
+ });
+ };
return call_with_page;
-}
+};
/* API usage:
function edit_function(text, save_function, edit_res)
{
--
To view, visit https://gerrit.wikimedia.org/r/239120
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I39967507230112977d54cae3b866160b3a52da7b
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/OfflineImportLexicon
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Liaveja <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits