#62: Multi-record editor: clean JS code
----------------------+-----------------------------------------------------
Reporter: simko | Owner: jmartinm
Type: defect | Status: assigned
Priority: minor | Milestone: v1.0
Component: BibEdit | Version:
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Changes (by simko):
* status: in_merge => assigned
Comment:
git branch jmartinm/clean-js-code
Thanks, but some errors/warnings still remain. Can you please have a
look?
* jslint2java finds:
{{{
jslint4java ./bibeditmulti.js
jslint:./bibeditmulti.js:107:9:The body of a for in should be wrapped in
an if statement to filter unwanted properties from the prototype.
jslint:./bibeditmulti.js:101:5:The body of a for in should be wrapped in
an if statement to filter unwanted properties from the prototype.
jslint:./bibeditmulti.js:345:20:Use '===' to compare with 'null'.
jslint:./bibeditmulti.js:384:20:Use '===' to compare with 'null'.
jslint:./bibeditmulti.js:512:5:The body of a for in should be wrapped in
an if statement to filter unwanted properties from the prototype.
}}}
* jslint finds:
{{{
Lint at line 91 character 5: '$' is not defined.
$("#displayTemplates").hide();
Lint at line 94 character 30: Missing space after ')'.
function createCommandsList(){
Lint at line 98 character 20: Missing 'new' prefix when invoking a
constructor.
var commands = Array();
Lint at line 100 character 9: Too many var statements.
var fieldID = "";
Lint at line 102 character 13: Too many var statements.
var currentField = gFields[fieldID];
Lint at line 104 character 9: 'subfieldsList' is not defined.
subfieldsList = Array();
Lint at line 104 character 25: Missing 'new' prefix when invoking a
constructor.
subfieldsList = Array();
Lint at line 105 character 9: 'subfields' is not defined.
subfields = currentField.subfields;
Lint at line 106 character 13: Too many var statements.
var subfieldID = "";
Lint at line 107 character 28: 'subfields' is not defined.
for (subfieldID in subfields) {
Lint at line 108 character 13: 'currentSubfield' is not defined.
currentSubfield = subfields[subfieldID];
Lint at line 108 character 31: 'subfields' is not defined.
currentSubfield = subfields[subfieldID];
Lint at line 109 character 13: 'subfieldsList' is not defined.
subfieldsList.push(currentSubfield);
Lint at line 109 character 32: 'currentSubfield' is not defined.
subfieldsList.push(currentSubfield);
Lint at line 107 character 9: The body of a for in should be wrapped in an
if statement to filter unwanted properties from the prototype.
for (subfieldID in subfields) {
Lint at line 112 character 13: Too many var statements.
var field = {
Lint at line 117 character 25: 'subfieldsList' is not defined.
subfields : subfieldsList
Lint at line 101 character 5: The body of a for in should be wrapped in an
if statement to filter unwanted properties from the prototype.
for (fieldID in gFields) {
Lint at line 127 character 38: Missing space after ')'.
function onButtonGoToFirstPageClick(){
Lint at line 131 character 41: Missing space after ')'.
function onButtonGoToPreviousPageClick(){
Lint at line 132 character 18: Unexpected use of '--'.
gPageToDiplay--;
Lint at line 135 character 37: Missing space after ')'.
function onButtonGoToNextPageClick(){
Lint at line 136 character 18: Unexpected use of '++'.
gPageToDiplay++;
Lint at line 140 character 44: Missing space after ')'.
function onButtonOutputFormatMarcXMLClick(){
Lint at line 143 character 46: Missing space after ')'.
function onButtonOutputFormatHTMLBriefClick(){
Lint at line 146 character 49: Missing space after ')'.
function onButtonOutputFormatHTMLDetailedClick(){
Lint at line 149 character 41: Missing space after ')'.
function onButtonOutputFormatMARCClick(){
Lint at line 178 character 26: Expected '===' and instead saw '=='.
if (gActionToPerform == gActionTypes.displayDetailedRecord) {
Lint at line 185 character 37: Missing space after ')'.
function onButtonGoToNextPageClick(){
Lint at line 186 character 18: Unexpected use of '++'.
gPageToDiplay++;
Lint at line 190 character 38: Missing space after ')'.
function onButtonSubmitChangesClick(){
Lint at line 205 character 5: '$' is not defined.
$("#buttonTestSearch").bind("click", onButtonTestSearchClick);
Lint at line 206 character 5: '$' is not defined.
$("#buttonPreviewResults").bind("click", onButtonPreviewResultsClick);
Lint at line 207 character 5: '$' is not defined.
$("#buttonSubmitChanges").bind("click", onButtonSubmitChangesClick);
Lint at line 208 character 5: '$' is not defined.
$(".buttonBackToResults").bind("click", onButtonBackToResultsClick);
Lint at line 209 character 5: '$' is not defined.
$(".buttonOutputFormatMarcXML").bind("click",
onButtonOutputFormatMarcXMLClick);
Lint at line 210 character 5: '$' is not defined.
$(".buttonOutputFormatHTMLBrief").bind("click",
onButtonOutputFormatHTMLBriefClick);
Lint at line 211 character 5: '$' is not defined.
$(".buttonOutputFormatHTMLDetailed").bind("click",
onButtonOutputFormatHTMLDetailedClick);
Lint at line 212 character 5: '$' is not defined.
$(".buttonOutputFormatMARC").bind("click", onButtonOutputFormatMARCClick);
Lint at line 214 character 5: '$' is not defined.
$(".buttonGoToFirstPage").bind("click", onButtonGoToFirstPageClick);
Lint at line 215 character 5: '$' is not defined.
$(".buttonGoToPreviousPage").bind("click", onButtonGoToPreviousPageClick);
Lint at line 216 character 5: '$' is not defined.
$(".buttonGoToNextPage").bind("click", onButtonGoToNextPageClick);
Lint at line 220 character 5: '$' is not defined.
$("#preview_area").html(data);
Lint at line 230 character 26: '$' is not defined.
var searchCriteria = $("#textBoxSearchCriteria").val();
Lint at line 231 character 9: Too many var statements.
var outputTags = $("#textBoxOutputTags").val();
Lint at line 231 character 22: '$' is not defined.
var outputTags = $("#textBoxOutputTags").val();
Lint at line 232 character 9: Too many var statements.
var language = $("#language").val();
Lint at line 232 character 20: '$' is not defined.
var language = $("#language").val();
Lint at line 233 character 9: Too many var statements.
var actionType = gActionToPerform;
Lint at line 234 character 9: Too many var statements.
var currentRecordID = gCurrentRecordID;
Lint at line 235 character 9: Too many var statements.
var outputFormat = gOutputFormat;
Lint at line 236 character 9: Too many var statements.
var pageToDisplay = gPageToDiplay;
Lint at line 237 character 3: Expected 'var' to have an indentation at 5
instead at 3.
var collection = $("#collection").val();
Lint at line 237 character 7: Too many var statements.
var collection = $("#collection").val();
Lint at line 237 character 20: '$' is not defined.
var collection = $("#collection").val();
Lint at line 238 character 9: Too many var statements.
var commands = createCommandsList();
Lint at line 240 character 9: Too many var statements.
var data = {
Lint at line 265 character 5: 'error_message' is not defined.
error_message = 'Request completed with status ' + textStatus +
Lint at line 268 character 27: 'error_message' is not defined.
displayResultsPreview(error_message);
Lint at line 276 character 5: '$' is not defined.
$.ajax( {
Lint at line 276 character 13: Unexpected space after '('.
$.ajax( {
Lint at line 288 character 39: Missing space after ')'.
function setOutputFormat(outputFormat){
Lint at line 292 character 26: Expected '===' and instead saw '=='.
if (gActionToPerform == gActionTypes.testSearch || gActionToPerform ==
gActionTypes.previewResults ){
Lint at line 292 character 73: Expected '===' and instead saw '=='.
if (gActionToPerform == gActionTypes.testSearch || gActionToPerform ==
gActionTypes.previewResults ){
Lint at line 292 character 104: Unexpected space after 'previewResults'.
if (gActionToPerform == gActionTypes.testSearch || gActionToPerform ==
gActionTypes.previewResults ){
Lint at line 292 character 105: Missing space after ')'.
if (gActionToPerform == gActionTypes.testSearch || gActionToPerform ==
gActionTypes.previewResults ){
Lint at line 295 character 9: Missing space after 'else'.
else{
Lint at line 301 character 27: Missing space after 'gActionToPerform'.
if (gActionToPerform!=""){
Lint at line 301 character 27: Missing space after '!='.
if (gActionToPerform!=""){
Lint at line 301 character 25: Expected '!==' and instead saw '!='.
if (gActionToPerform!=""){
Lint at line 301 character 30: Missing space after ')'.
if (gActionToPerform!=""){
Lint at line 307 character 1: '$' is not defined.
$(document).ready( function() {
Lint at line 307 character 3: 'document' is not defined.
$(document).ready( function() {
Lint at line 307 character 20: Unexpected space after '('.
$(document).ready( function() {
Lint at line 307 character 28: Missing space after 'function'.
$(document).ready( function() {
Lint at line 320 character 31: Missing space after ')'.
function getFieldID(displayID){
Lint at line 325 character 34: Missing space after ')'.
function getSubfieldID(displayID){
Lint at line 337 character 35: Expected '!==' and instead saw '!='.
var cleanedValue = (indicator != "_" && indicator != "") ? indicator : "
";
Lint at line 337 character 55: Expected '!==' and instead saw '!='.
var cleanedValue = (indicator != "_" && indicator != "") ? indicator : "
";
Lint at line 345 character 20: Expected '===' and instead saw '=='.
if (actionType == null){
Lint at line 345 character 28: Missing space after ')'.
if (actionType == null){
Lint at line 349 character 8: Missing space after 'if'.
if(actionType != gSubfieldActionTypes.deleteSubfield) {
Lint at line 349 character 19: Expected '!==' and instead saw '!='.
if(actionType != gSubfieldActionTypes.deleteSubfield) {
Lint at line 353 character 8: Missing space after 'if'.
if(actionType == gSubfieldActionTypes.replaceText) {
Lint at line 353 character 19: Expected '===' and instead saw '=='.
if(actionType == gSubfieldActionTypes.replaceText) {
Lint at line 360 character 9: Too many var statements.
var fieldID = getFieldID(subfieldDisplayID);
Lint at line 361 character 9: Too many var statements.
var field = gFields[fieldID];
Lint at line 363 character 8: Missing space after 'if'.
if(field.action == gFieldActionTypes.addField){
Lint at line 363 character 21: Expected '===' and instead saw '=='.
if(field.action == gFieldActionTypes.addField){
Lint at line 363 character 51: Missing space after ')'.
if(field.action == gFieldActionTypes.addField){
Lint at line 373 character 55: Missing space after '+'.
var fieldDisplayID = gFieldDisplayIDPrefix + "_" +gCurrentFieldID;
Lint at line 374 character 20: Unexpected use of '++'.
gCurrentFieldID++;
Lint at line 384 character 20: Expected '===' and instead saw '=='.
if (subfieldID == null){
Lint at line 384 character 28: Missing space after ')'.
if (subfieldID == null){
Lint at line 386 character 27: Unexpected use of '++'.
gCurrentSubfieldID++;
Lint at line 395 character 20: Expected '!==' and instead saw '!='.
if (actionText != "Delete field") {
Lint at line 396 character 27: '$' is not defined.
var templateMsg = $("#displayTemplates .templateMsg").clone();
Lint at line 401 character 9: '$' is not defined.
$("#actionsDisplayArea .lastRow").before(templateMsg);
Lint at line 409 character 5: '$' is not defined.
$(msgID).remove();
Lint at line 412 character 44: Missing space after ')'.
function createSubfield(templateNewSubield){
Lint at line 420 character 9: Too many var statements.
var value = templateNewSubield.find(".textBoxValue").eq(0).val();
Lint at line 421 character 9: Too many var statements.
var newValue = templateNewSubield.find(".textBoxNewValue").eq(0).val();
Lint at line 422 character 9: Too many var statements.
var action = templateNewSubield.find(".subfieldActionType").eq(0).val();
Lint at line 424 character 9: Too many var statements.
var subfield = {
Lint at line 442 character 9: Too many var statements.
var ind1 = jqueryElement.find(".textBoxFieldInd1").eq(0).val();
Lint at line 443 character 9: Too many var statements.
var ind2 = jqueryElement.find(".textBoxFieldInd2").eq(0).val();
Lint at line 444 character 9: Too many var statements.
var action = jqueryElement.find(".fieldActionType").eq(0).val();
Lint at line 449 character 9: Too many var statements.
var subfields = {};
Lint at line 452 character 9: Too many var statements.
var field = {
Lint at line 464 character 25: '$' is not defined.
var parentElement = $(this).parents(".templateNewSubfield").eq(0);
Lint at line 471 character 25: '$' is not defined.
var templateField = $(this).parents(".templateDisplayField");
Lint at line 472 character 9: Too many var statements.
var fieldDisplayID = templateField.attr("id");
Lint at line 473 character 9: Too many var statements.
var fieldID = getFieldID(fieldDisplayID);
Lint at line 476 character 9: Too many var statements.
var subfieldDisplayID = generateSubfieldDisplayID(fieldID);
Lint at line 479 character 9: Too many var statements.
var templateNewSubfield = $("#displayTemplates
.templateNewSubfield").clone();
Lint at line 479 character 31: '$' is not defined.
var templateNewSubfield = $("#displayTemplates
.templateNewSubfield").clone();
Lint at line 488 character 5: '$' is not defined.
$(this).parents(".templateNewSubfield").remove();
Lint at line 492 character 28: '$' is not defined.
var templateNewField = $("#displayTemplates .templateNewField").clone();
Lint at line 494 character 5: '$' is not defined.
$("#actionsDisplayArea .lastRow").before(templateNewField);
Lint at line 500 character 5: '$' is not defined.
$(this).parents(".templateNewField").remove();
Lint at line 504 character 24: '$' is not defined.
var fieldElement = $(this).parents(".templateDisplayField");
Lint at line 506 character 9: Too many var statements.
var fieldDisplayID = fieldElement.attr("id");
Lint at line 508 character 9: Too many var statements.
var fieldID = getFieldID(fieldDisplayID);
Lint at line 511 character 9: Too many var statements.
var subfieldID = "";
Lint at line 512 character 51: Missing space after ')'.
for (subfieldID in gFields[fieldID].subfields){
Lint at line 513 character 13: Too many var statements.
var subfieldSelector = "#" + generateSubfieldDisplayID(fieldID,
subfieldID);
Lint at line 514 character 9: '$' is not defined.
$(subfieldSelector).remove();
Lint at line 512 character 5: The body of a for in should be wrapped in an
if statement to filter unwanted properties from the prototype.
for (subfieldID in gFields[fieldID].subfields){
Lint at line 525 character 35: '$' is not defined.
var templateDisplaySubfield = $("#displayTemplates
.templateDisplaySubfield").clone();
Lint at line 527 character 9: Too many var statements.
var templateNewSubfield = $(this).parents(".templateNewSubfield");
Lint at line 527 character 31: '$' is not defined.
var templateNewSubfield = $(this).parents(".templateNewSubfield");
Lint at line 529 character 9: Too many var statements.
var subfieldDisplayID = templateNewSubfield.attr("id");
Lint at line 530 character 9: Too many var statements.
var fieldID = getFieldID(subfieldDisplayID);
Lint at line 531 character 9: Too many var statements.
var subfieldID = getSubfieldID(subfieldDisplayID);
Lint at line 533 character 9: Too many var statements.
var currentSubfield = createSubfield(templateNewSubfield);
Lint at line 534 character 9: Too many var statements.
var field = gFields[fieldID];
Lint at line 538 character 9: Too many var statements.
var actionText =
templateNewSubfield.find(".subfieldActionType").eq(0).find('option').filter(':selected').text();
Lint at line 548 character 61: Unexpected space after
'templateDisplaySubfield'.
templateNewSubfield.replaceWith(templateDisplaySubfield );
Lint at line 555 character 27: '$' is not defined.
var subfieldElement = $(this).parents(".templateDisplaySubfield");
Lint at line 557 character 9: Too many var statements.
var subfieldDisplayID = subfieldElement.attr("id");
Lint at line 559 character 9: Too many var statements.
var fieldID = getFieldID(subfieldDisplayID);
Lint at line 560 character 9: Too many var statements.
var subfieldID = getSubfieldID(subfieldDisplayID);
Lint at line 568 character 32: '$' is not defined.
var templateDisplayField = $("#displayTemplates
.templateDisplayField").clone();
Lint at line 571 character 9: Too many var statements.
var templateNewField = $(this).parents(".templateNewField");
Lint at line 571 character 28: '$' is not defined.
var templateNewField = $(this).parents(".templateNewField");
Lint at line 573 character 9: Too many var statements.
var field = createField(templateNewField);
Lint at line 575 character 9: Too many var statements.
var fieldDisplayID = templateNewField.attr("id");
Lint at line 576 character 9: Too many var statements.
var fieldID = getFieldID(fieldDisplayID);
Lint at line 581 character 9: Too many var statements.
var actionText =
templateNewField.find(".fieldActionType").eq(0).find('option').filter(':selected').text();
Lint at line 590 character 8: Missing space after 'if'.
if(field.action == gFieldActionTypes.deleteField){
Lint at line 590 character 21: Expected '===' and instead saw '=='.
if(field.action == gFieldActionTypes.deleteField){
Lint at line 590 character 54: Missing space after ')'.
if(field.action == gFieldActionTypes.deleteField){
Lint at line 605 character 5: '$' is not defined.
$(".buttonNewField").bind("click", onButtonNewFieldClick);
Lint at line 606 character 5: '$' is not defined.
$("#buttonSaveNewField").bind("click", onButtonSaveNewFieldClick);
Lint at line 607 character 5: '$' is not defined.
$("#buttonCancelNewField").bind("click", onButtonCancelNewFieldClick);
Lint at line 608 character 5: '$' is not defined.
$(".buttonDeleteField").bind("click", onButtonDeleteFieldClick);
Lint at line 610 character 5: '$' is not defined.
$(".buttonNewSubfield").bind("click", onButtonNewSubfieldClick);
Lint at line 611 character 5: '$' is not defined.
$("#buttonSaveNewSubfield").bind("click", onButtonSaveNewSubfieldClick);
Lint at line 612 character 5: '$' is not defined.
$("#buttonCancelNewSubfield").bind("click",
onButtonCancelNewSubfieldClick);
Lint at line 613 character 5: '$' is not defined.
$(".buttonDeleteSubfield").bind("click", onButtonDeleteSubfieldClick);
Lint at line 614 character 5: '$' is not defined.
$(".subfieldActionType").bind("change", onSubfieldActionTypeChange);
Lint at line 617 character 43: Missing space after ')'.
function onSelectOutputFormatChange(value){
Lint at line 618 character 15: Expected '===' and instead saw '=='.
if (value == "Marc"){
Lint at line 618 character 25: Missing space after ')'.
if (value == "Marc"){
Lint at line 621 character 9: Missing space after 'else'.
else{
Lint at line 626 character 45: Missing space after ')'.
function onSelectSubfieldActionChange(value){
Lint at line 627 character 15: Expected '===' and instead saw '=='.
if (value == "0"){
Lint at line 627 character 22: Missing space after ')'.
if (value == "0"){
Lint at line 632 character 22: Missing space after ')'.
function onEnter(evt){
Lint at line 634 character 9: Missing space after 'if'.
if( evt.which ) {
Lint at line 634 character 9: Unexpected space after '('.
if( evt.which ) {
Lint at line 634 character 19: Unexpected space after 'which'.
if( evt.which ) {
Lint at line 636 character 16: Missing space after 'if'.
} else if( evt.keyCode ) {
Lint at line 636 character 16: Unexpected space after '('.
} else if( evt.keyCode ) {
Lint at line 636 character 28: Unexpected space after 'keyCode'.
} else if( evt.keyCode ) {
Lint at line 638 character 6: Expected 'if' to have an indentation at 5
instead at 6.
}if( 13 == keyCode ) {
Lint at line 638 character 10: Missing space after 'if'.
}if( 13 == keyCode ) {
Lint at line 638 character 10: Unexpected space after '('.
}if( 13 == keyCode ) {
Lint at line 638 character 13: Expected '===' and instead saw '=='.
}if( 13 == keyCode ) {
Lint at line 638 character 24: Unexpected space after 'keyCode'.
}if( 13 == keyCode ) {
}}}
--
Ticket URL: <http://invenio-software.org/ticket/62#comment:2>
Invenio <http://invenio-software.org>