From 7b190f3ab488ba57dcb03fe9e3eaf9e2e3c9d4ac Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 19 Oct 2020 18:32:18 +0000 Subject: [PATCH] Bug 25353: Correct eslint errors in additems.js This patch makes minor changes to additem.js to correct errors highlighted by eslint: - Consistent indentation - Notation of global and exported variables and functions - Consistent use of the "var" declaration for all new variables - Remove variables from function calls which aren't used To test, apply the patch and use your preferred eslint-enabled tool to check for errors. There should be none. If you don't have eslint integrated in your development environment you could use the online ESLint demo at https://eslint.org/demo. The demo isn't configured to assume a browser environment with jQuery present, so you'll have to modify the top line after pasting the contents of additem.js: /* global $ alert window __ */ --- koha-tmpl/intranet-tmpl/prog/js/additem.js | 52 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/additem.js b/koha-tmpl/intranet-tmpl/prog/js/additem.js index d6f95772a6..960ffc36dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/additem.js +++ b/koha-tmpl/intranet-tmpl/prog/js/additem.js @@ -1,4 +1,5 @@ /* global __ */ +/* exported addItem checkCount showItem deleteItemBlock clearItemBlock check_additem */ function addItem( node, unique_item_fields ) { var index = $(node).closest("div").attr('id'); var current_qty = parseInt($("#quantity").val()); @@ -36,15 +37,15 @@ function addMulti( count, node, unique_item_fields){ $("#procModal").modal('show'); $("#" + index).hide(); for(var i=0;i " + ( __("Delete") ) + ""; result += "" + edit_link + " " + del_link + ""; - for(i in fields) { + for(var i in fields) { var field = fields[i]; var field_elt = $("#" + index) .find("[name='kohafield'][value='items."+field+"']") @@ -154,8 +154,8 @@ function cloneItemBlock(index, unique_item_fields, callback) { } var dont_copy_fields = new Array(); if(unique_item_fields) { - var dont_copy_fields = unique_item_fields.split('|'); - for(i in dont_copy_fields) { + dont_copy_fields = unique_item_fields.split('|'); + for(var i in dont_copy_fields) { dont_copy_fields[i] = "items." + dont_copy_fields[i]; } } @@ -166,7 +166,7 @@ function cloneItemBlock(index, unique_item_fields, callback) { data: { frameworkcode: 'ACQ' }, - success: function(data, textStatus, jqXHR) { + success: function(data) { /* Create the item block */ var random = Math.floor(Math.random()*100000); // get a random itemid. var clone = $("
", { id: 'itemblock'+random }); @@ -178,15 +178,15 @@ function cloneItemBlock(index, unique_item_fields, callback) { }); /* Add buttons + and Clear */ var buttonPlus = "
"; - buttonPlus += ''; - buttonPlus += ''; - buttonPlus += ''; - buttonPlus += ''; - buttonPlus += "
"; + buttonPlus += ''; + buttonPlus += ''; + buttonPlus += ''; + buttonPlus += ''; + buttonPlus += ""; $(clone).append(buttonPlus); /* Copy values from the original block (input) */ $(original).find("input[name='field_value']").each(function(){ @@ -227,7 +227,7 @@ function BindPluginEvents(data) { for(var i=0; i