From e6517db98a0a03a0430ccca8d23afbeb7d30a0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Apr 2013 13:16:01 +0200 Subject: [PATCH] More javascript cleanup, more fixes of === / !=== --- js/config.js | 8 +++---- js/date.js | 30 ++++++++++++------------ js/db_operations.js | 2 +- js/functions.js | 16 ++++++------- js/makegrid.js | 46 ++++++++++++++++++------------------- js/navigation.js | 32 +++++++++++++------------- js/pmd/history.js | 4 ++-- js/pmd/move.js | 4 ++-- js/server_privileges.js | 44 +++++++++++++++++------------------ js/server_status_monitor.js | 4 ++-- js/sql.js | 6 ++--- js/tbl_chart.js | 6 ++--- js/tbl_gis_visualization.js | 2 +- js/tbl_relation.js | 2 +- js/tbl_structure.js | 2 +- js/tbl_zoom_plot_jqplot.js | 16 ++++++------- 16 files changed, 112 insertions(+), 112 deletions(-) diff --git a/js/config.js b/js/config.js index 9d24473921..50d0f99379 100644 --- a/js/config.js +++ b/js/config.js @@ -62,16 +62,16 @@ function setFieldValue(field, field_type, value) switch (field_type) { case 'text': //TODO: replace to .val() - field.attr('value', (value != undefined ? value : field.attr('defaultValue'))); + field.attr('value', (value !== undefined ? value : field.attr('defaultValue'))); break; case 'checkbox': //TODO: replace to .prop() - field.attr('checked', (value != undefined ? value : field.attr('defaultChecked'))); + field.attr('checked', (value !== undefined ? value : field.attr('defaultChecked'))); break; case 'select': var options = field.prop('options'); var i, imax = options.length; - if (value == undefined) { + if (value === undefined) { for (i = 0; i < imax; i++) { options[i].selected = options[i].defaultSelected; } @@ -598,7 +598,7 @@ AJAX.registerOnload('config.js', function() { function restoreField(field_id) { var field = $('#'+field_id); - if (field.length === 0 || defaultValues[field_id] == undefined) { + if (field.length === 0 || defaultValues[field_id] === undefined) { return; } setFieldValue(field, getFieldType(field), defaultValues[field_id]); diff --git a/js/date.js b/js/date.js index 47253a0b11..fe86d1a312 100644 --- a/js/date.js +++ b/js/date.js @@ -69,7 +69,7 @@ function LZ(x) {return(x<0||x>9?"":"0")+x} // ------------------------------------------------------------------ function isDate(val,format) { var date=getDateFromFormat(val,format); - if (date==0) { return false; } + if (date === 0) { return false; } return true; } @@ -84,7 +84,7 @@ function isDate(val,format) { function compareDates(date1,dateformat1,date2,dateformat2) { var d1=getDateFromFormat(date1,dateformat1); var d2=getDateFromFormat(date2,dateformat2); - if (d1==0 || d2==0) { + if (d1 === 0 || d2 === 0) { return -1; } else if (d1 > d2) { @@ -128,7 +128,7 @@ function formatDate(date,format) { value["EE"]=DAY_NAMES[E]; value["H"]=H; value["HH"]=LZ(H); - if (H==0){value["h"]=12;} + if (H === 0){value["h"]=12;} else if (H>12){value["h"]=H-12;} else {value["h"]=H;} value["hh"]=LZ(value["h"]); @@ -148,7 +148,7 @@ function formatDate(date,format) { while ((format.charAt(i_format)==c) && (i_format < format.length)) { token += format.charAt(i_format++); } - if (value[token] != null) { result=result + value[token]; } + if (value[token] !== null) { result=result + value[token]; } else { result=result + token; } } return result; @@ -211,7 +211,7 @@ function getDateFromFormat(val,format) { if (token=="yy") { x=2;y=2; } if (token=="y") { x=2;y=4; } year=_getInt(val,i_val,x,y); - if (year==null) { return 0; } + if (year === null) { return 0; } i_val += year.length; if (year.length==2) { if (year > 70) { year=1900+(year-0); } @@ -244,35 +244,35 @@ function getDateFromFormat(val,format) { } else if (token=="MM"||token=="M") { month=_getInt(val,i_val,token.length,2); - if (month==null||(month<1)||(month>12)){return 0;} + if (month === null||(month<1)||(month>12)){return 0;} i_val+=month.length;} else if (token=="dd"||token=="d") { date=_getInt(val,i_val,token.length,2); - if (date==null||(date<1)||(date>31)){return 0;} + if (date === null||(date<1)||(date>31)){return 0;} i_val+=date.length;} else if (token=="hh"||token=="h") { hh=_getInt(val,i_val,token.length,2); - if (hh==null||(hh<1)||(hh>12)){return 0;} + if (hh === null||(hh<1)||(hh>12)){return 0;} i_val+=hh.length;} else if (token=="HH"||token=="H") { hh=_getInt(val,i_val,token.length,2); - if (hh==null||(hh<0)||(hh>23)){return 0;} + if (hh === null||(hh<0)||(hh>23)){return 0;} i_val+=hh.length;} else if (token=="KK"||token=="K") { hh=_getInt(val,i_val,token.length,2); - if (hh==null||(hh<0)||(hh>11)){return 0;} + if (hh === null||(hh<0)||(hh>11)){return 0;} i_val+=hh.length;} else if (token=="kk"||token=="k") { hh=_getInt(val,i_val,token.length,2); - if (hh==null||(hh<1)||(hh>24)){return 0;} + if (hh === null||(hh<1)||(hh>24)){return 0;} i_val+=hh.length;hh--;} else if (token=="mm"||token=="m") { mm=_getInt(val,i_val,token.length,2); - if (mm==null||(mm<0)||(mm>59)){return 0;} + if (mm === null||(mm<0)||(mm>59)){return 0;} i_val+=mm.length;} else if (token=="ss"||token=="s") { ss=_getInt(val,i_val,token.length,2); - if (ss==null||(ss<0)||(ss>59)){return 0;} + if (ss === null||(ss<0)||(ss>59)){return 0;} i_val+=ss.length;} else if (token=="a") { if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";} @@ -289,7 +289,7 @@ function getDateFromFormat(val,format) { // Is date valid for month? if (month==2) { // Check for leap year - if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year + if ( ( (year%4 === 0)&&(year%100 !== 0) ) || (year%400 === 0) ) { // leap year if (date > 29){ return 0; } } else { if (date > 28) { return 0; } } @@ -328,7 +328,7 @@ function parseDate(val) { var l=window[checkList[i]]; for (var j=0; j").prependTo("#page_content"); $("#sqlqueryresults").html(data.sql_query); @@ -2841,7 +2841,7 @@ function indexEditorDialog(url, title, callback_success, callback_failure) }; var $msgbox = PMA_ajaxShowMessage(); $.get("tbl_indexes.php", url, function(data) { - if (data.success == false) { + if (data.success === false) { //in the case of an error, show the error message returned. PMA_ajaxShowMessage(data.error, false); } else { @@ -2901,7 +2901,7 @@ function indexEditorDialog(url, title, callback_success, callback_failure) **/ function PMA_showHints($div) { - if ($div == undefined || ! $div instanceof jQuery || $div.length === 0) { + if ($div === undefined || ! $div instanceof jQuery || $div.length === 0) { $div = $("body"); } $div.find('.pma_hint').each(function () { @@ -3276,11 +3276,11 @@ AJAX.registerTeardown('functions.js', function() { */ function PMA_slidingMessage(msg, $obj) { - if (msg == undefined || msg.length === 0) { + if (msg === undefined || msg.length === 0) { // Don't show an empty message return false; } - if ($obj == undefined || ! $obj instanceof jQuery || $obj.length === 0) { + if ($obj === undefined || ! $obj instanceof jQuery || $obj.length === 0) { // If the second argument was not supplied, // we might have to create a new DOM node. if ($('#PMA_slidingMessage').length === 0) { diff --git a/js/makegrid.js b/js/makegrid.js index c6237886a3..60b0fef045 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -361,7 +361,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi * Send column preferences (column order and visibility) to the server. */ sendColPrefs: function() { - if ($(g.t).is('.ajax')) { // only send preferences if ajax class + if ($(g.t).is('.ajax')) { // only send preferences if ajax class var post_params = { ajax_request: true, db: g.db, @@ -378,7 +378,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $.extend(post_params, {col_visib: g.colVisib.toString()}); } $.post('sql.php', post_params, function(data) { - if (data.success != true) { + if (data.success !== true) { var $temp_div = $(document.createElement('div')); $temp_div.html(data.error); $temp_div.addClass("error"); @@ -604,7 +604,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi } // cancel any previous request - if (g.lastXHR != null) { + if (g.lastXHR !== null) { g.lastXHR.abort(); g.lastXHR = null; } @@ -613,7 +613,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi if (g.currentEditCell) { // save value of currently edited cell // replace current edited field with the new value var $this_field = $(g.currentEditCell); - var is_null = $this_field.data('value') == null; + var is_null = $this_field.data('value') === null; if (is_null) { $this_field.find('span').html('NULL'); $this_field.addClass('null'); @@ -630,13 +630,13 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $this_field.find('span').text(new_html); } } - if (data.transformations != undefined) { + if (data.transformations !== undefined) { $.each(data.transformations, function(cell_index, value) { var $this_field = $(g.t).find('.to_be_saved:eq(' + cell_index + ')'); $this_field.find('span').html(value); }); } - if (data.relations != undefined) { + if (data.relations !== undefined) { $.each(data.relations, function(cell_index, value) { var $this_field = $(g.t).find('.to_be_saved:eq(' + cell_index + ')'); $this_field.find('span').html(value); @@ -931,7 +931,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi }, function(data) { g.lastXHR = null; $editArea.removeClass('edit_area_loading'); - if (data.success == true) { + if (data.success === true) { if ($td.is('.truncated')) { // get the truncated data length g.maxTruncatedLen = $(g.currentEditCell).text().length - 3; @@ -983,13 +983,13 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi // force to restore modified $input_field value after adding datepicker // (after adding a datepicker, the input field doesn't display the time anymore, only the date) - if (is_null - || current_datetime_value == '0000-00-00' + if (is_null + || current_datetime_value == '0000-00-00' || current_datetime_value == '0000-00-00 00:00:00' ) { $input_field.val(current_datetime_value); } else { - $editArea.datetimepicker('setDate', current_datetime_value); + $editArea.datetimepicker('setDate', current_datetime_value); } $editArea.append('
' + g.cellEditHint + '
'); @@ -1210,9 +1210,9 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $('div.save_edited').removeClass('saving_edited_data') .find('input').removeProp('disabled'); // enable the save button back } - if (data.success == true) { + if (data.success === true) { PMA_ajaxShowMessage(data.message); - + // update where_clause related data in each edited row $('td.to_be_saved').parents('tr').each(function() { var new_clause = $(this).data('new_clause'); @@ -1589,7 +1589,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi function startGridEditing(e, cell) { if (g.isCellEditActive) { - g.saveOrPostEditedCell(); + g.saveOrPostEditedCell(); } else { g.showEditCell(cell); } @@ -1627,17 +1627,17 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $(t).find('td.data.click2') .click(function(e) { $cell = $(this); - // In the case of relational link, We want single click on the link + // In the case of relational link, We want single click on the link // to goto the link and double click to start grid-editing. var $link = $(e.target); if ($link.is('.grid_edit.relation a')) { e.preventDefault(); // get the click count and increase var clicks = $cell.data('clicks'); - clicks = (clicks == null) ? 1 : clicks + 1; + clicks = (clicks === null) ? 1 : clicks + 1; if (clicks == 1) { - // if there are no previous clicks, + // if there are no previous clicks, // start the single click timer timer = setTimeout(function() { // temporarily remove ajax class so the page loader will not handle it, @@ -1709,7 +1709,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $(g.gDiv).append(g.cEdit); // add hint for grid editing feature when hovering "Edit" link in each table row - if (PMA_messages['strGridEditFeatureHint'] != undefined) { + if (PMA_messages['strGridEditFeatureHint'] !== undefined) { PMA_tooltip( $(g.t).find('.edit_row_anchor a'), 'a', @@ -1773,10 +1773,10 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $(g.gDiv).append(t); // FEATURES - enableResize = enableResize == undefined ? true : enableResize; - enableReorder = enableReorder == undefined ? true : enableReorder; - enableVisib = enableVisib == undefined ? true : enableVisib; - enableGridEdit = enableGridEdit == undefined ? true : enableGridEdit; + enableResize = enableResize === undefined ? true : enableResize; + enableReorder = enableReorder === undefined ? true : enableReorder; + enableVisib = enableVisib === undefined ? true : enableVisib; + enableGridEdit = enableGridEdit === undefined ? true : enableGridEdit; if (enableResize) { g.initColResize(); } @@ -1807,13 +1807,13 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi g.showSortHint = true; $(t).find("th.draggable").tooltip("option", { content: g.updateHint() - }); + }); }) .mouseleave(function(e) { g.showSortHint = false; $(t).find("th.draggable").tooltip("option", { content: g.updateHint() - }); + }); }); // register events for dragging-related feature diff --git a/js/navigation.js b/js/navigation.js index 256fd12695..4e4f68bf97 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -114,7 +114,7 @@ $(function() { $('#pma_navigation_tree.highlight li:not(.fast_filter)').live( 'mouseover', function () { - if ($('li:visible', this).length == 0) { + if ($('li:visible', this).length === 0) { $(this).addClass('activePointer'); } } @@ -130,7 +130,7 @@ $(function() { * Jump to recent table */ $('#recentTable').live('change', function() { - if (this.value != '') { + if (this.value !== '') { var arr = jQuery.parseJSON(this.value); var $form = $(this).closest('form'); $form.find('input[name=db]').val(arr['db']); @@ -210,7 +210,7 @@ $(function() { /** * Reloads the whole navigation tree while preserving its state * - * @param function the callback function + * @param function the callback function * @return void */ function PMA_reloadNavigation(callback) { @@ -227,7 +227,7 @@ function PMA_reloadNavigation(callback) { var count = 0; $('#pma_navigation_tree').find('a.expander:visible').each(function () { if ($(this).find('img').is('.ic_b_minus') - && $(this).closest('li').find('div.list_container .ic_b_minus').length == 0 + && $(this).closest('li').find('div.list_container .ic_b_minus').length === 0 ) { params['n' + count + '_aPath'] = $(this).find('span.aPath').text(); params['n' + count + '_vPath'] = $(this).find('span.vPath').text(); @@ -424,13 +424,13 @@ var ResizeHandler = function () { */ this.getSymbol = function (width) { if (this.left == 'left') { - if (width == 0) { + if (width === 0) { return '→'; } else { return '←'; } } else { - if (width == 0) { + if (width === 0) { return '←'; } else { return '→'; @@ -559,8 +559,8 @@ var PMA_fastFilter = { this.timeout = null; var $filterInput = $this.find('li.fast_filter input.searchClause'); - if ( $filterInput.length != 0 - && $filterInput.val() != '' + if ( $filterInput.length !== 0 + && $filterInput.val() !== '' && $filterInput.val() != $filterInput[0].defaultValue ) { this.request(); @@ -590,7 +590,7 @@ var PMA_fastFilter = { var $filterContainer = $this.closest('div.list_container'); var $filterInput = $([]); while (1) { - if ($filterContainer.find('li.fast_filter:not(.db_fast_filter) input.searchClause').length != 0) { + if ($filterContainer.find('li.fast_filter:not(.db_fast_filter) input.searchClause').length !== 0) { $filterInput = $filterContainer.find('li.fast_filter:not(.db_fast_filter) input.searchClause'); break; } else if (! $filterContainer.is('div.list_container')) { @@ -601,7 +601,7 @@ var PMA_fastFilter = { .closest('div.list_container'); } var searchClause2 = ''; - if ($filterInput.length != 0 + if ($filterInput.length !== 0 && $filterInput.first().val() != $filterInput[0].defaultValue ) { searchClause2 = $filterInput.val(); @@ -628,7 +628,7 @@ var PMA_fastFilter = { } }, blur: function (event) { - if ($(this).val() == '') { + if ($(this).val() === '') { $(this).val(this.defaultValue); } var $obj = $(this).closest('div.list_container'); @@ -639,7 +639,7 @@ var PMA_fastFilter = { keyup: function (event) { var $obj = $(this).closest('div.list_container'); var str = ''; - if ($(this).val() != this.defaultValue && $(this).val() != '') { + if ($(this).val() != this.defaultValue && $(this).val() !== '') { $obj.find('div.pageselector').hide(); str = $(this).val().toLowerCase(); } @@ -657,13 +657,13 @@ var PMA_fastFilter = { container_filter($group); // recursive } $group.parent().show().removeClass('hidden'); - if ($group.children().not('.hidden').length == 0) { + if ($group.children().not('.hidden').length === 0) { $group.parent().hide().addClass('hidden'); } }); }; container_filter($obj, str); - if ($(this).val() != this.defaultValue && $(this).val() != '') { + if ($(this).val() != this.defaultValue && $(this).val() !== '') { if (! $obj.data('fastFilter')) { $obj.data( 'fastFilter', @@ -713,7 +713,7 @@ PMA_fastFilter.filter.prototype.request = function () { var self = this; clearTimeout(self.timeout); - if (self.$this.find('li.fast_filter').find('img.throbber').length == 0) { + if (self.$this.find('li.fast_filter').find('img.throbber').length === 0) { self.$this.find('li.fast_filter').append( $('
').append( $('#pma_navigation_content') @@ -730,7 +730,7 @@ PMA_fastFilter.filter.prototype.request = function () var url = $('#pma_navigation').find('a.navigation_url').attr('href'); var results = self.$this.find('li:not(.hidden):not(.fast_filter):not(.navGroup)').not('[class^=new]').length; var params = self.$this.find('> ul > li > form.fast_filter').first().serialize() + "&results=" + results; - if (self.$this.find('> ul > li > form.fast_filter:first input[name=searchClause]').length == 0) { + if (self.$this.find('> ul > li > form.fast_filter:first input[name=searchClause]').length === 0) { var $input = $('#pma_navigation_tree').find('li.fast_filter.db_fast_filter input.searchClause'); if ($input.length && $input.val() != $input[0].defaultValue) { params += '&searchClause=' + encodeURIComponent($input.val()); diff --git a/js/pmd/history.js b/js/pmd/history.js index 15e765422d..f45e4262b7 100644 --- a/js/pmd/history.js +++ b/js/pmd/history.js @@ -236,14 +236,14 @@ function edit(type) document.getElementById('query_Aggregate').style.visibility = 'hidden'; } if (type == "Where") { - if (document.getElementById('erel_opt').value != '--' && document.getElementById('eQuery').value !="") { + if (document.getElementById('erel_opt').value != '--' && document.getElementById('eQuery').value !== "") { history_array[g_index].get_obj().setquery(document.getElementById('eQuery').value); history_array[g_index].get_obj().setrelation_operator(document.getElementById('erel_opt').value); } document.getElementById('query_where').style.visibility = 'hidden'; } if (type == "Having") { - if (document.getElementById('hrel_opt').value != '--' && document.getElementById('hQuery').value !="") { + if (document.getElementById('hrel_opt').value != '--' && document.getElementById('hQuery').value !== "") { history_array[g_index].get_obj().setquery(document.getElementById('hQuery').value); history_array[g_index].get_obj().setrelation_operator(document.getElementById('hrel_opt').value); history_array[g_index].get_obj().set_operator(document.getElementById('hoperator').value); diff --git a/js/pmd/move.js b/js/pmd/move.js index ef52e91bba..3474de442c 100644 --- a/js/pmd/move.js +++ b/js/pmd/move.js @@ -1057,7 +1057,7 @@ function getColorByTarget( target ) } - if (color.length==0) { + if (color.length === 0) { var i = TargetColors.length+1; var d = i % 6; var j = (i - d) / 6; @@ -1216,7 +1216,7 @@ function add_object() rel.value = '--'; p.value = ""; } - if (document.getElementById('new_name').value !="") { + if (document.getElementById('new_name').value !== "") { var rename_obj = new rename(document.getElementById('new_name').value);//make Rename object history_array.push(new history(col_name,rename_obj,tab_name,h_tabs[downer + '.' + tab_name],"Rename")); sum = sum + 1; diff --git a/js/server_privileges.js b/js/server_privileges.js index f6c05999f1..c2b5c37810 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -16,13 +16,13 @@ */ function checkAddUser(the_form) { - if (the_form.elements['pred_hostname'].value == 'userdefined' && the_form.elements['hostname'].value == '') { + if (the_form.elements['pred_hostname'].value == 'userdefined' && the_form.elements['hostname'].value === '') { alert(PMA_messages['strHostEmpty']); the_form.elements['hostname'].focus(); return false; } - if (the_form.elements['pred_username'].value == 'userdefined' && the_form.elements['username'].value == '') { + if (the_form.elements['pred_username'].value == 'userdefined' && the_form.elements['username'].value === '') { alert(PMA_messages['strUserEmpty']); the_form.elements['username'].focus(); return false; @@ -88,7 +88,7 @@ function addUser($form) //We also need to post the value of the submit button in order to get this to work correctly $.post($form.attr('action'), $form.serialize() + "&adduser_submit=" + $("input[name=adduser_submit]").val(), function(data) { - if (data.success == true) { + if (data.success === true) { // Refresh navigation, if we created a database with the name // that is the same as the username of the new user if ($('#add_user_dialog #createdb-1:checked').length) { @@ -107,7 +107,7 @@ function addUser($form) //Remove the empty notice div generated due to a NULL query passed to PMA_getMessage() var $notice_class = $("#result_query").find('.notice'); - if ($notice_class.text() == '') { + if ($notice_class.text() === '') { $notice_class.remove(); } if ($('#fieldset_add_user a.ajax').attr('name') == 'db_specific') { @@ -124,12 +124,12 @@ function addUser($form) $.post($form.attr('action'), url, function(priv_data) { /*Remove the old userForm table*/ - if ($('#userFormDiv').length != 0) { + if ($('#userFormDiv').length !== 0) { $('#userFormDiv').remove(); } else { $("#usersForm").remove(); } - if (priv_data.success == true) { + if (priv_data.success === true) { $('
') .html(priv_data.user_form) .insertAfter('#result_query'); @@ -194,10 +194,10 @@ AJAX.registerOnload('server_privileges.js', function() { var $msgbox = PMA_ajaxShowMessage(); $.get($(this).attr("href"), {'ajax_request':true}, function(data) { - if (data.success == true) { + if (data.success === true) { $('#page_content').hide(); var $div = $('#add_user_dialog'); - if ($div.length == 0) { + if ($div.length === 0) { $div = $('
') .insertBefore('#page_content'); } else { @@ -237,7 +237,7 @@ AJAX.registerOnload('server_privileges.js', function() { var $msgbox = PMA_ajaxShowMessage(PMA_messages['strReloadingPrivileges']); $.get($(this).attr("href"), {'ajax_request': true}, function(data) { - if (data.success == true) { + if (data.success === true) { PMA_ajaxRemoveMessage($msgbox); } else { PMA_ajaxShowMessage(data.error, false); @@ -261,7 +261,7 @@ AJAX.registerOnload('server_privileges.js', function() { var $form = $("#usersForm"); $.post($form.attr('action'), $form.serialize() + "&delete=" + $(this).val() + "&ajax_request=true", function(data) { - if (data.success == true) { + if (data.success === true) { PMA_ajaxShowMessage(data.message); // Refresh navigation, if we droppped some databases with the name // that is the same as the username of the deleted user @@ -274,7 +274,7 @@ AJAX.registerOnload('server_privileges.js', function() { $(this).remove(); //If this is the last user with this_user_initial, remove the link from #initials_table - if ($("#tableuserrights").find('input:checkbox[value^=' + this_user_initial + ']').length == 0) { + if ($("#tableuserrights").find('input:checkbox[value^=' + this_user_initial + ']').length === 0) { $("#initials_table").find('td > a:contains(' + this_user_initial + ')').parent('td').html(this_user_initial); } @@ -324,10 +324,10 @@ AJAX.registerOnload('server_privileges.js', function() { 'token': token }, function(data) { - if (data.success == true) { + if (data.success === true) { $('#page_content').hide(); var $div = $('#edit_user_dialog'); - if ($div.length == 0) { + if ($div.length === 0) { $div = $('
') .insertBefore('#page_content'); } else { @@ -375,7 +375,7 @@ AJAX.registerOnload('server_privileges.js', function() { */ var curr_submit_value = $t.find('.tblFooters').find('input:submit').val(); - // If any option other than 'keep the old one'(option 4) is chosen, we need to remove + // If any option other than 'keep the old one'(option 4) is chosen, we need to remove // the old one from the table. var $row_to_remove; if (curr_submit_name == 'change_copy' @@ -393,7 +393,7 @@ AJAX.registerOnload('server_privileges.js', function() { } $.post($t.attr('action'), $t.serialize() + '&' + curr_submit_name + '=' + curr_submit_value, function(data) { - if (data.success == true) { + if (data.success === true) { $('#page_content').show(); $("#edit_user_dialog").remove(); @@ -406,13 +406,13 @@ AJAX.registerOnload('server_privileges.js', function() { 'margin-top' : '0.5em' }); var $notice_class = $("#result_query").find('.notice'); - if ($notice_class.text() == '') { + if ($notice_class.text() === '') { $notice_class.remove(); } } //Show SQL Query that was executed // Remove the old row if the old user is deleted - if ($row_to_remove != null) { + if ($row_to_remove !== null) { $row_to_remove.remove(); } @@ -427,7 +427,7 @@ AJAX.registerOnload('server_privileges.js', function() { // and on the global page when adjusting global privileges, // but not on the global page when adjusting db-specific privileges. var reload_privs = false; - if (data.db_specific_privs == false || (db_priv_page == data.db_specific_privs)) { + if (data.db_specific_privs === false || (db_priv_page == data.db_specific_privs)) { reload_privs = true; } if (data.db_wildcard_privs) { @@ -462,7 +462,7 @@ AJAX.registerOnload('server_privileges.js', function() { $("button.mult_submit[value=export]").live('click', function(event) { event.preventDefault(); // can't export if no users checked - if ($(this.form).find("input:checked").length == 0) { + if ($(this.form).find("input:checked").length === 0) { return; } var $msgbox = PMA_ajaxShowMessage(); @@ -474,7 +474,7 @@ AJAX.registerOnload('server_privileges.js', function() { $(this.form).prop('action'), $(this.form).serialize() + '&submit_mult=export&ajax_request=true', function(data) { - if (data.success == true) { + if (data.success === true) { var $ajaxDialog = $('
') .append(data.message) .dialog({ @@ -530,7 +530,7 @@ AJAX.registerOnload('server_privileges.js', function() { $(this).dialog("close"); }; $.get($(this).attr('href'), {'ajax_request': true}, function(data) { - if (data.success == true) { + if (data.success === true) { var $ajaxDialog = $('
') .append(data.message) .dialog({ @@ -571,7 +571,7 @@ AJAX.registerOnload('server_privileges.js', function() { event.preventDefault(); var $msgbox = PMA_ajaxShowMessage(); $.get($(this).attr('href'), {'ajax_request' : true}, function(data) { - if (data.success == true) { + if (data.success === true) { PMA_ajaxRemoveMessage($msgbox); // This form is not on screen when first entering Privileges // if there are more than 50 users diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js index 379c4e0a5e..dde7381299 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -1289,7 +1289,7 @@ AJAX.registerOnload('server_status_monitor.js', function() { if (! drawTimeSpan) { return; } - if (selectionStartX != undefined) { + if (selectionStartX !== undefined) { $('#selection_box') .css({ width: Math.ceil(ev.pageX - selectionStartX) @@ -1504,7 +1504,7 @@ AJAX.registerOnload('server_status_monitor.js', function() { } // Set y value, if defined - if (value != undefined) { + if (value !== undefined) { elem.chart.series[j].data.push([chartData.x, value]); if (value > elem.maxYLabel) { elem.maxYLabel = value; diff --git a/js/sql.js b/js/sql.js index a54c244d80..e0925b86ca 100644 --- a/js/sql.js +++ b/js/sql.js @@ -320,7 +320,7 @@ AJAX.registerOnload('sql.js', function() { } } } - } else if (data.success == false ) { + } else if (data.success === false ) { // show an error message that stays on screen $('#sqlqueryform').before(data.error); $sqlqueryresults.hide(); @@ -386,7 +386,7 @@ AJAX.registerOnload('sql.js', function() { $.get($form.attr('action'), $form.serialize()+"&ajax_request=true&submit_mult=row_edit", function(data) { //in the case of an error, show the error message returned. - if (data.success != undefined && data.success == false) { + if (data.success !== undefined && data.success === false) { $div .append(data.error) .dialog({ @@ -536,7 +536,7 @@ function PMA_changeClassForColumn($this_th, newclass, isAddClass) th_index--; } var $tds = $this_th.closest('table').find('tbody tr').find('td.data:eq('+th_index+')'); - if (isAddClass == undefined) { + if (isAddClass === undefined) { $tds.toggleClass(newclass); } else { $tds.toggleClass(newclass, isAddClass); diff --git a/js/tbl_chart.js b/js/tbl_chart.js index 70a6734999..e07237ea10 100644 --- a/js/tbl_chart.js +++ b/js/tbl_chart.js @@ -195,7 +195,7 @@ function drawChart() { currentSettings.height = $('#resizer').height() - 20; // todo: a better way using .redraw() ? - if (currentChart != null) { + if (currentChart !== null) { currentChart.destroy(); } @@ -225,12 +225,12 @@ function extractDate(dateString) { var dateRegExp = /[0-9]{4}-[0-9]{2}-[0-9]{2}/; matches = dateTimeRegExp.exec(dateString); - if (matches != null && matches.length > 0) { + if (matches !== null && matches.length > 0) { match = matches[0]; return new Date(match.substr(0, 4), match.substr(5, 2), match.substr(8, 2), match.substr(11, 2), match.substr(14, 2), match.substr(17, 2)); } else { matches = dateRegExp.exec(dateString); - if (matches != null && matches.length > 0) { + if (matches !== null && matches.length > 0) { match = matches[0]; return new Date(match.substr(0, 4), match.substr(5, 2), match.substr(8, 2)); } diff --git a/js/tbl_gis_visualization.js b/js/tbl_gis_visualization.js index 5e8d63814a..d5d156c804 100644 --- a/js/tbl_gis_visualization.js +++ b/js/tbl_gis_visualization.js @@ -205,7 +205,7 @@ AJAX.registerOnload('tbl_gis_visualization.js', function() { } $('#choice').live('click', function() { - if ($(this).prop('checked') == false) { + if ($(this).prop('checked') === false) { $('#placeholder').show(); $('#openlayersmap').hide(); } else { diff --git a/js/tbl_relation.js b/js/tbl_relation.js index 4ce39854b6..32711902b2 100644 --- a/js/tbl_relation.js +++ b/js/tbl_relation.js @@ -8,7 +8,7 @@ function show_hide_clauses($thisDropdown) // here, one span contains the label and the clause dropdown // and we have one span for ON DELETE and one for ON UPDATE // - if ($thisDropdown.val() != '') { + if ($thisDropdown.val() !== '') { $thisDropdown.parent().nextAll('span').show(); } else { $thisDropdown.parent().nextAll('span').hide(); diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 22ffe77634..2ceb187c49 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -247,7 +247,7 @@ AJAX.registerOnload('tbl_structure.js', function() { } $.post($form.prop("action"), serialized + "&ajax_request=true", function (data) { - if (data.success == false) { + if (data.success === false) { PMA_ajaxRemoveMessage($msgbox); $this .clone() diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js index 83c7db5273..320b3bdaf2 100644 --- a/js/tbl_zoom_plot_jqplot.js +++ b/js/tbl_zoom_plot_jqplot.js @@ -236,7 +236,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() { * Input form validation **/ $('#inputFormSubmitId').click(function() { - if ($('#tableid_0').get(0).selectedIndex == 0 || $('#tableid_1').get(0).selectedIndex == 0) { + if ($('#tableid_0').get(0).selectedIndex === 0 || $('#tableid_1').get(0).selectedIndex === 0) { PMA_ajaxShowMessage(PMA_messages['strInputNull']); } else if (xLabel == yLabel) { PMA_ajaxShowMessage(PMA_messages['strSameInputs']); @@ -352,17 +352,17 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() { var value = newValues[key]; // null - if (value == null) { + if (value === null) { sql_query += 'NULL, '; // empty - } else if ($.trim(value) == '') { + } else if ($.trim(value) === '') { sql_query += "'', "; // other } else { // type explicitly identified - if (sqlTypes[key] != null) { + if (sqlTypes[key] !== null) { if (sqlTypes[key] == 'bit') { sql_query += "b'" + value + "', "; } @@ -387,7 +387,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() { 'sql_query' : sql_query, 'inline_edit' : false }, function(data) { - if (data.success == true) { + if (data.success === true) { $('#sqlqueryresults').html(data.sql_query); $("#sqlqueryresults").trigger('appendAnchor'); } else { @@ -429,7 +429,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() { * Generate plot using jqplot */ - if (searchedData != null) { + if (searchedData !== null) { $('#zoom_search_form') .slideToggle() .hide(); @@ -483,7 +483,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() { }; // If data label is not set, do not show tooltips - if (dataLabel == '') { + if (dataLabel === '') { options.highlighter.show = false; } @@ -590,7 +590,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() { for (key in data.row_info) { $field = $('#edit_fieldID_' + field_id); $field_null = $('#edit_fields_null_id_' + field_id); - if (data.row_info[key] == null) { + if (data.row_info[key] === null) { $field_null.prop('checked', true); $field.val(''); } else {