From e30b5abae0c3b233550c312d94c46d1e867a929c Mon Sep 17 00:00:00 2001 From: kovacsv Date: Tue, 18 Dec 2018 07:37:23 +0100 Subject: [PATCH] Use IsSet function to detect if a parameter has a valid value. --- website/include/importermenu.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/website/include/importermenu.js b/website/include/importermenu.js index c998672..7931017 100644 --- a/website/include/importermenu.js +++ b/website/include/importermenu.js @@ -1,3 +1,8 @@ +function IsSet (val) +{ + return val !== undefined && val !== null; +} + InfoTable = function (parent) { this.table = $('').addClass ('infotable').appendTo (parent); @@ -47,11 +52,11 @@ ImporterMenuItem.prototype.Initialize = function (name) var menuItemClickHandler = null; var menuContent = null; - if (this.parameters !== undefined && this.parameters !== null) { - if (this.parameters.id !== undefined && this.parameters.id !== null) { + if (IsSet (this.parameters)) { + if (IsSet (this.parameters.id)) { menuItemDiv.attr ('id', this.parameters.id); } - if (this.parameters.openCloseButton !== undefined && this.parameters.openCloseButton !== null) { + if (IsSet (this.parameters.openCloseButton)) { this.contentDiv = $('
').addClass ('menugroup').hide ().appendTo (this.parentDiv); this.isOpen = false; this.openCloseImage = $('').addClass ('menubutton').attr ('title', this.parameters.openCloseButton.title).appendTo (menuItemDiv); @@ -60,19 +65,19 @@ ImporterMenuItem.prototype.Initialize = function (name) this.openCloseImage.click (menuItemClickHandler); } - if (this.parameters.userButton !== undefined && this.parameters.userButton !== null) { + if (IsSet (this.parameters.userButton)) { var userImage = $('').addClass ('menubutton').attr ('title', this.parameters.userButton.title).appendTo (menuItemDiv); - if (this.parameters.userButton.id !== undefined && this.parameters.userButton.id !== null) { + if (IsSet (this.parameters.userButton.id)) { userImage.attr ('id', this.parameters.userButton.id); } - if (this.parameters.userButton.onCreate !== undefined && this.parameters.userButton.onCreate !== null) { + if (IsSet (this.parameters.userButton.onCreate)) { this.parameters.userButton.onCreate (userImage, this.parameters.userButton.userData); } - userImage.click (function () { - if (myThis.parameters.userButton.onClick !== undefined && myThis.parameters.userButton.onClick !== null) { + if (IsSet (myThis.parameters.userButton.onClick)) { + userImage.click (function () { myThis.parameters.userButton.onClick (userImage, myThis.parameters.userButton.userData); - } - }); + }); + } } } @@ -97,11 +102,11 @@ ImporterMenuItem.prototype.OnOpenCloseClick = function () { this.isOpen = !this.isOpen; if (this.isOpen) { - if (this.parameters.openCloseButton.onOpen !== undefined && this.parameters.openCloseButton.onOpen !== null) { + if (IsSet (this.parameters.openCloseButton.onOpen)) { this.parameters.openCloseButton.onOpen (this.contentDiv, this.parameters.openCloseButton.userData); } } else { - if (this.parameters.openCloseButton.onClose !== undefined && this.parameters.openCloseButton.onClose !== null) { + if (IsSet (this.parameters.openCloseButton.onClose)) { this.parameters.openCloseButton.onClose (this.contentDiv, this.parameters.openCloseButton.userData); } }