From fbcc3eb3a2d1f33f8a6d3e0f89f06ec82ab2d94c Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Sep 2011 18:04:40 +0530 Subject: [PATCH 1/9] Added missing semicolons --- js/tbl_zoom_plot.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index b8c4259640..663d26010c 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -23,7 +23,7 @@ function displayHelp() { **/ Array.max = function (array) { return Math.max.apply( Math, array ); -} +}; /** ** Extend the array object for min function @@ -31,7 +31,7 @@ Array.max = function (array) { **/ Array.min = function (array) { return Math.min.apply( Math, array ); -} +}; /** ** Checks if a string contains only numeric value @@ -60,13 +60,13 @@ function isEmpty(obj) { **/ function getDate(val,type) { if(type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) { - return Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', val) + return Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', val); } else if(type.toString().search(/time/i) != -1) { - return Highcharts.dateFormat('%H:%M:%S', val) + return Highcharts.dateFormat('%H:%M:%S', val); } else if (type.toString().search(/date/i) != -1) { - return Highcharts.dateFormat('%Y-%m-%e', val) + return Highcharts.dateFormat('%Y-%m-%e', val); } } @@ -77,13 +77,13 @@ function getDate(val,type) { **/ function getTimeStamp(val,type) { if(type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) { - return getDateFromFormat(val,'yyyy-MM-dd HH:mm:ss', val) + return getDateFromFormat(val,'yyyy-MM-dd HH:mm:ss', val); } else if(type.toString().search(/time/i) != -1) { - return getDateFromFormat('1970-01-01 ' + val,'yyyy-MM-dd HH:mm:ss') + return getDateFromFormat('1970-01-01 ' + val,'yyyy-MM-dd HH:mm:ss'); } else if (type.toString().search(/date/i) != -1) { - return getDateFromFormat(val,'yyyy-MM-dd') + return getDateFromFormat(val,'yyyy-MM-dd'); } } @@ -197,19 +197,19 @@ $(document).ready(function() { **/ $('#tableid_0').change(function() { $('#zoom_search_form').submit(); - }) + }); $('#tableid_1').change(function() { $('#zoom_search_form').submit(); - }) + }); $('#tableid_2').change(function() { $('#zoom_search_form').submit(); - }) + }); $('#tableid_3').change(function() { $('#zoom_search_form').submit(); - }) + }); /** * Input form validation @@ -286,7 +286,7 @@ $(document).ready(function() { } } } - it++ + it++; }//End data update //Update the chart series and replot @@ -323,11 +323,11 @@ $(document).ready(function() { }); currentSettings.xAxis.labels = { formatter : function() { if(tempX[1][this.value] && tempX[1][this.value].length > 10) - return tempX[1][this.value].substring(0,10) + return tempX[1][this.value].substring(0,10); else return tempX[1][this.value]; } - } + }; currentSettings.series = newSeries; currentChart = PMA_createChart(currentSettings); } @@ -360,11 +360,11 @@ $(document).ready(function() { }); currentSettings.yAxis.labels = { formatter : function() { if(tempY[1][this.value] && tempY[1][this.value].length > 10) - return tempY[1][this.value].substring(0,10) + return tempY[1][this.value].substring(0,10); else return tempY[1][this.value]; } - } + }; currentSettings.series = newSeries; currentChart = PMA_createChart(currentSettings); } @@ -403,7 +403,7 @@ $(document).ready(function() { } else PMA_ajaxShowMessage(data.error); - })//End $.post + }); //End $.post }//End database update $("#dataDisplay").dialog("close"); });//End submit handler @@ -417,7 +417,7 @@ $(document).ready(function() { .slideToggle() .hide(); $('#togglesearchformlink') - .text(PMA_messages['strShowSearchCriteria']) + .text(PMA_messages['strShowSearchCriteria']); $('#togglesearchformdiv').show(); var selectedRow; var colorCodes = ['#FF0000','#00FFFF','#0000FF','#0000A0','#FF0080','#800080','#FFFF00','#00FF00','#FF00FF']; @@ -438,7 +438,7 @@ $(document).ready(function() { type: 'scatter', //zoomType: 'xy', width:$('#resizer').width() -3, - height:$('#resizer').height()-20 + height:$('#resizer').height()-20 }, credits: { enabled: false From a61891560ff97a98a8339e1151330203dc0ccafd Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Sep 2011 18:09:55 +0530 Subject: [PATCH 2/9] Proper indentation --- js/tbl_zoom_plot.js | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index 663d26010c..1eaf2eab70 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -264,30 +264,29 @@ $(document).ready(function() { //Prevent default submission of form event.preventDefault(); - //Find changed values by comparing form values with selectedRow Object - var newValues = new Array();//Stores the values changed from original + //Find changed values by comparing form values with selectedRow Object + var newValues = new Array();//Stores the values changed from original var it = 4; var xChange = false; var yChange = false; - for (key in selectedRow) { - if (key != 'where_clause'){ - var oldVal = selectedRow[key]; - var newVal = ($('#fields_null_id_' + it).attr('checked')) ? null : $('#fieldID_' + it).val(); - if (oldVal != newVal){ - selectedRow[key] = newVal; - newValues[key] = newVal; - if(key == xLabel) { - xChange = true; - data[currentData][xLabel] = newVal; + for (key in selectedRow) { + if (key != 'where_clause') { + var oldVal = selectedRow[key]; + var newVal = ($('#fields_null_id_' + it).attr('checked')) ? null : $('#fieldID_' + it).val(); + if (oldVal != newVal) { + selectedRow[key] = newVal; + newValues[key] = newVal; + if(key == xLabel) { + xChange = true; + data[currentData][xLabel] = newVal; + } else if(key == yLabel) { + yChange = true; + data[currentData][yLabel] = newVal; + } + } } - else if(key == yLabel) { - yChange = true; - data[currentData][yLabel] = newVal; - } - } - } - it++; - }//End data update + it++; + } //End data update //Update the chart series and replot if (xChange || yChange) { From 3936aab8804630a31afc98802afad3f7b27a28f7 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Sep 2011 18:24:36 +0530 Subject: [PATCH 3/9] More indentation problems fixed --- js/tbl_zoom_plot.js | 138 +++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 71 deletions(-) diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index 1eaf2eab70..2a0aa489d9 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -278,7 +278,7 @@ $(document).ready(function() { newValues[key] = newVal; if(key == xLabel) { xChange = true; - data[currentData][xLabel] = newVal; + data[currentData][xLabel] = newVal; } else if(key == yLabel) { yChange = true; data[currentData][yLabel] = newVal; @@ -288,89 +288,85 @@ $(document).ready(function() { it++; } //End data update - //Update the chart series and replot + //Update the chart series and replot if (xChange || yChange) { - var newSeries = new Array(); - newSeries[0] = new Object(); + var newSeries = new Array(); + newSeries[0] = new Object(); newSeries[0].marker = { symbol: 'circle' }; - //Logic similar to plot generation, replot only if xAxis changes or yAxis changes. Code includes a lot of checks so as to replot only when necessary + //Logic similar to plot generation, replot only if xAxis changes or yAxis changes. Code includes a lot of checks so as to replot only when necessary if(xChange) { - xCord[currentData] = selectedRow[xLabel]; - if(xType == 'numeric') { - currentChart.series[0].data[currentData].update({ x : selectedRow[xLabel] }); - currentChart.xAxis[0].setExtremes(Array.min(xCord) - 6,Array.max(xCord) + 6); - } - else if(xType == 'time') { - currentChart.series[0].data[currentData].update({ x : getTimeStamp(selectedRow[xLabel],$('#types_0').val())}); - } - else { - var tempX = getCord(xCord); - var tempY = getCord(yCord); - var i = 0; - newSeries[0].data = new Array(); - xCord = tempX[2]; - yCord = tempY[2]; - - $.each(data,function(key,value) { - if(yType != 'text') - newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: value[yLabel], marker: {fillColor: colorCodes[i % 8]} , id: i } ); - else + xCord[currentData] = selectedRow[xLabel]; + if(xType == 'numeric') { + currentChart.series[0].data[currentData].update({ x : selectedRow[xLabel] }); + currentChart.xAxis[0].setExtremes(Array.min(xCord) - 6,Array.max(xCord) + 6); + } else if(xType == 'time') { + currentChart.series[0].data[currentData].update({ x : getTimeStamp(selectedRow[xLabel],$('#types_0').val())}); + } else { + var tempX = getCord(xCord); + var tempY = getCord(yCord); + var i = 0; + newSeries[0].data = new Array(); + xCord = tempX[2]; + yCord = tempY[2]; + + $.each(data,function(key,value) { + if(yType != 'text') + newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: value[yLabel], marker: {fillColor: colorCodes[i % 8]} , id: i } ); + else newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } ); - i++; + i++; }); - currentSettings.xAxis.labels = { formatter : function() { - if(tempX[1][this.value] && tempX[1][this.value].length > 10) - return tempX[1][this.value].substring(0,10); - else - return tempX[1][this.value]; + currentSettings.xAxis.labels = { + formatter : function() { + if(tempX[1][this.value] && tempX[1][this.value].length > 10) + return tempX[1][this.value].substring(0,10); + else + return tempX[1][this.value]; } - }; - currentSettings.series = newSeries; - currentChart = PMA_createChart(currentSettings); - } - - } + }; + currentSettings.series = newSeries; + currentChart = PMA_createChart(currentSettings); + } + + } if(yChange) { - - yCord[currentData] = selectedRow[yLabel]; - if(yType == 'numeric') { - currentChart.series[0].data[currentData].update({ y : selectedRow[yLabel] }); - currentChart.yAxis[0].setExtremes(Array.min(yCord) - 6,Array.max(yCord) + 6); - } - else if(yType =='time') { - currentChart.series[0].data[currentData].update({ y : getTimeStamp(selectedRow[yLabel],$('#types_1').val())}); - } - else { - var tempX = getCord(xCord); - var tempY = getCord(yCord); - var i = 0; - newSeries[0].data = new Array(); - xCord = tempX[2]; - yCord = tempY[2]; - - $.each(data,function(key,value) { - if(xType != 'text' ) + yCord[currentData] = selectedRow[yLabel]; + if(yType == 'numeric') { + currentChart.series[0].data[currentData].update({ y : selectedRow[yLabel] }); + currentChart.yAxis[0].setExtremes(Array.min(yCord) - 6,Array.max(yCord) + 6); + } else if(yType =='time') { + currentChart.series[0].data[currentData].update({ y : getTimeStamp(selectedRow[yLabel],$('#types_1').val())}); + } else { + var tempX = getCord(xCord); + var tempY = getCord(yCord); + var i = 0; + newSeries[0].data = new Array(); + xCord = tempX[2]; + yCord = tempY[2]; + + $.each(data,function(key,value) { + if(xType != 'text' ) newSeries[0].data.push({ name: value[dataLabel], x: value[xLabel], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } ); - else + else newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } ); - i++; + i++; }); - currentSettings.yAxis.labels = { formatter : function() { - if(tempY[1][this.value] && tempY[1][this.value].length > 10) - return tempY[1][this.value].substring(0,10); - else - return tempY[1][this.value]; + currentSettings.yAxis.labels = { + formatter : function() { + if(tempY[1][this.value] && tempY[1][this.value].length > 10) + return tempY[1][this.value].substring(0,10); + else + return tempY[1][this.value]; } - }; - currentSettings.series = newSeries; - currentChart = PMA_createChart(currentSettings); - } - } - currentChart.series[0].data[currentData].select(); - } - //End plot update + }; + currentSettings.series = newSeries; + currentChart = PMA_createChart(currentSettings); + } + } + currentChart.series[0].data[currentData].select(); + } //End plot update //Generate SQL query for update if (!isEmpty(newValues)) { From b8815ca7669feddb50dfb670f97281e87c3d9b62 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Sep 2011 18:30:46 +0530 Subject: [PATCH 4/9] Always use curly braces with 'if' and 'else' --- js/tbl_zoom_plot.js | 57 +++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index 2a0aa489d9..95c67f6277 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -312,18 +312,20 @@ $(document).ready(function() { yCord = tempY[2]; $.each(data,function(key,value) { - if(yType != 'text') + if(yType != 'text') { newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: value[yLabel], marker: {fillColor: colorCodes[i % 8]} , id: i } ); - else + } else { newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } ); + } i++; }); currentSettings.xAxis.labels = { formatter : function() { - if(tempX[1][this.value] && tempX[1][this.value].length > 10) + if(tempX[1][this.value] && tempX[1][this.value].length > 10) { return tempX[1][this.value].substring(0,10); - else - return tempX[1][this.value]; + } else { + return tempX[1][this.value]; + } } }; currentSettings.series = newSeries; @@ -347,18 +349,20 @@ $(document).ready(function() { yCord = tempY[2]; $.each(data,function(key,value) { - if(xType != 'text' ) + if(xType != 'text' ) { newSeries[0].data.push({ name: value[dataLabel], x: value[xLabel], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } ); - else + } else { newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } ); + } i++; }); currentSettings.yAxis.labels = { formatter : function() { - if(tempY[1][this.value] && tempY[1][this.value].length > 10) + if(tempY[1][this.value] && tempY[1][this.value].length > 10) { return tempY[1][this.value].substring(0,10); - else - return tempY[1][this.value]; + } else { + return tempY[1][this.value]; + } } }; currentSettings.series = newSeries; @@ -375,11 +379,12 @@ $(document).ready(function() { if(key != 'where_clause') { sql_query += '`' + key + '`=' ; var value = newValues[key]; - if(!isNumeric(value) && value != null) + if(!isNumeric(value) && value != null) { sql_query += '\'' + value + '\' ,'; - else + } else { sql_query += value + ' ,'; } + } } sql_query = sql_query.substring(0, sql_query.length - 1); sql_query += ' WHERE ' + PMA_urldecode(data[currentData]['where_clause']); @@ -396,8 +401,9 @@ $(document).ready(function() { $('#sqlqueryresults').html(data.sql_query); $("#sqlqueryresults").trigger('appendAnchor'); } - else + else { PMA_ajaxShowMessage(data.error); + } }); //End $.post }//End database update $("#dataDisplay").dialog("close"); @@ -466,10 +472,11 @@ $(document).ready(function() { $.post('tbl_zoom_select.php', post_params, function(data) { // Row is contained in data.row_info, now fill the displayResultForm with row values for ( key in data.row_info) { - if (data.row_info[key] == null) + if (data.row_info[key] == null) { $('#fields_null_id_' + fid).attr('checked', true); - else + } else { $('#fieldID_' + fid).val(data.row_info[key]); + } fid++; } selectedRow = new Object(); @@ -578,10 +585,11 @@ $(document).ready(function() { }); currentSettings.xAxis.labels = { formatter : function() { - if(tempX[1][this.value] && tempX[1][this.value].length > 10) + if(tempX[1][this.value] && tempX[1][this.value].length > 10) { return tempX[1][this.value].substring(0,10) - else + } else { return tempX[1][this.value]; + } } } if(yType == 'numeric') { @@ -617,12 +625,13 @@ $(document).ready(function() { }} } currentSettings.yAxis.labels = { formatter : function() { - if(tempY[1][this.value] && tempY[1][this.value].length > 10) + if(tempY[1][this.value] && tempY[1][this.value].length > 10) { return tempY[1][this.value].substring(0,10) - else + } else { return tempY[1][this.value]; } } + } yCord = tempY[2]; } @@ -638,18 +647,20 @@ $(document).ready(function() { it++; }); currentSettings.xAxis.labels = { formatter : function() { - if(tempX[1][this.value] && tempX[1][this.value].length > 10) + if(tempX[1][this.value] && tempX[1][this.value].length > 10) { return tempX[1][this.value].substring(0,10) - else + } else { return tempX[1][this.value]; } } + } currentSettings.yAxis.labels = { formatter : function() { - if(tempY[1][this.value] && tempY[1][this.value].length > 10) + if(tempY[1][this.value] && tempY[1][this.value].length > 10) { return tempY[1][this.value].substring(0,10) - else + } else { return tempY[1][this.value]; } + } } xCord = tempX[2]; yCord = tempY[2]; From 5c03bd90e1466b2bad378e5400193a593535bb10 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Sep 2011 18:46:09 +0530 Subject: [PATCH 5/9] Fixing indentation --- js/tbl_zoom_plot.js | 177 ++++++++++++++++++++++---------------------- 1 file changed, 87 insertions(+), 90 deletions(-) diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index 95c67f6277..48676dbec8 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -140,23 +140,21 @@ function includePan(currentChart) { $('#querychart').mousemove(function(e) { if (mouseDown == 1) { if (e.pageX > lastX) { - var xExtremes = currentChart.xAxis[0].getExtremes(); + var xExtremes = currentChart.xAxis[0].getExtremes(); var diff = (e.pageX - lastX) * (xExtremes.max - xExtremes.min) / chartWidth; currentChart.xAxis[0].setExtremes(xExtremes.min - diff, xExtremes.max - diff); - } - else if (e.pageX < lastX) { - var xExtremes = currentChart.xAxis[0].getExtremes(); + } else if (e.pageX < lastX) { + var xExtremes = currentChart.xAxis[0].getExtremes(); var diff = (lastX - e.pageX) * (xExtremes.max - xExtremes.min) / chartWidth; currentChart.xAxis[0].setExtremes(xExtremes.min + diff, xExtremes.max + diff); } if (e.pageY > lastY) { - var yExtremes = currentChart.yAxis[0].getExtremes(); + var yExtremes = currentChart.yAxis[0].getExtremes(); var ydiff = 1.0 * (e.pageY - lastY) * (yExtremes.max - yExtremes.min) / chartHeight; currentChart.yAxis[0].setExtremes(yExtremes.min + ydiff, yExtremes.max + ydiff); - } - else if (e.pageY < lastY) { - var yExtremes = currentChart.yAxis[0].getExtremes(); + } else if (e.pageY < lastY) { + var yExtremes = currentChart.yAxis[0].getExtremes(); var ydiff = 1.0 * (lastY - e.pageY) * (yExtremes.max - yExtremes.min) / chartHeight; currentChart.yAxis[0].setExtremes(yExtremes.min - ydiff, yExtremes.max - ydiff); } @@ -249,7 +247,7 @@ $(document).ready(function() { **/ $("#dataDisplay").dialog({ autoOpen: false, - title: 'Data point content', + title: 'Data point content', modal: false, //false otherwise other dialogues like timepicker may not function properly height: $('#dataDisplay').height() + 80, width: $('#dataDisplay').width() + 80 @@ -372,40 +370,39 @@ $(document).ready(function() { currentChart.series[0].data[currentData].select(); } //End plot update - //Generate SQL query for update - if (!isEmpty(newValues)) { + //Generate SQL query for update + if (!isEmpty(newValues)) { var sql_query = 'UPDATE `' + window.parent.table + '` SET '; - for (key in newValues) { - if(key != 'where_clause') { - sql_query += '`' + key + '`=' ; - var value = newValues[key]; - if(!isNumeric(value) && value != null) { - sql_query += '\'' + value + '\' ,'; - } else { - sql_query += value + ' ,'; - } - } - } - sql_query = sql_query.substring(0, sql_query.length - 1); - sql_query += ' WHERE ' + PMA_urldecode(data[currentData]['where_clause']); - - //Post SQL query to sql.php - $.post('sql.php', { - 'token' : window.parent.token, - 'db' : window.parent.db, - 'ajax_request' : true, - 'sql_query' : sql_query, - 'inline_edit' : false - }, function(data) { - if(data.success == true) { - $('#sqlqueryresults').html(data.sql_query); - $("#sqlqueryresults").trigger('appendAnchor'); + for (key in newValues) { + if(key != 'where_clause') { + sql_query += '`' + key + '`=' ; + var value = newValues[key]; + if(!isNumeric(value) && value != null) { + sql_query += '\'' + value + '\' ,'; + } else { + sql_query += value + ' ,'; + } } - else { - PMA_ajaxShowMessage(data.error); - } - }); //End $.post - }//End database update + } + sql_query = sql_query.substring(0, sql_query.length - 1); + sql_query += ' WHERE ' + PMA_urldecode(data[currentData]['where_clause']); + + //Post SQL query to sql.php + $.post('sql.php', { + 'token' : window.parent.token, + 'db' : window.parent.db, + 'ajax_request' : true, + 'sql_query' : sql_query, + 'inline_edit' : false + }, function(data) { + if(data.success == true) { + $('#sqlqueryresults').html(data.sql_query); + $("#sqlqueryresults").trigger('appendAnchor'); + } else { + PMA_ajaxShowMessage(data.error); + } + }); //End $.post + }//End database update $("#dataDisplay").dialog("close"); });//End submit handler @@ -419,13 +416,13 @@ $(document).ready(function() { .hide(); $('#togglesearchformlink') .text(PMA_messages['strShowSearchCriteria']); - $('#togglesearchformdiv').show(); + $('#togglesearchformdiv').show(); var selectedRow; var colorCodes = ['#FF0000','#00FFFF','#0000FF','#0000A0','#FF0080','#800080','#FFFF00','#00FF00','#FF00FF']; var series = new Array(); var xCord = new Array(); var yCord = new Array(); - var tempX, tempY; + var tempX, tempY; var it = 0; var xMax; // xAxis extreme max var xMin; // xAxis extreme min @@ -437,67 +434,67 @@ $(document).ready(function() { chart: { renderTo: 'querychart', type: 'scatter', - //zoomType: 'xy', - width:$('#resizer').width() -3, + //zoomType: 'xy', + width:$('#resizer').width() -3, height:$('#resizer').height()-20 - }, - credits: { + }, + credits: { enabled: false }, - exporting: { enabled: false }, + exporting: { enabled: false }, label: { text: $('#dataLabel').val() }, - plotOptions: { - series: { - allowPointSelect: true, + plotOptions: { + series: { + allowPointSelect: true, cursor: 'pointer', - showInLegend: false, + showInLegend: false, dataLabels: { - enabled: false, + enabled: false }, - point: { + point: { events: { click: function() { - var id = this.id; - var fid = 4; - currentData = id; - // Make AJAX request to tbl_zoom_select.php for getting the complete row info - var post_params = { + var id = this.id; + var fid = 4; + currentData = id; + // Make AJAX request to tbl_zoom_select.php for getting the complete row info + var post_params = { 'ajax_request' : true, 'get_data_row' : true, 'db' : window.parent.db, 'table' : window.parent.table, 'where_clause' : data[id]['where_clause'], - 'token' : window.parent.token, + 'token' : window.parent.token } $.post('tbl_zoom_select.php', post_params, function(data) { - // Row is contained in data.row_info, now fill the displayResultForm with row values - for ( key in data.row_info) { - if (data.row_info[key] == null) { - $('#fields_null_id_' + fid).attr('checked', true); - } else { - $('#fieldID_' + fid).val(data.row_info[key]); - } - fid++; - } - selectedRow = new Object(); - selectedRow = data.row_info; + // Row is contained in data.row_info, now fill the displayResultForm with row values + for ( key in data.row_info) { + if (data.row_info[key] == null) { + $('#fields_null_id_' + fid).attr('checked', true); + } else { + $('#fieldID_' + fid).val(data.row_info[key]); + } + fid++; + } + selectedRow = new Object(); + selectedRow = data.row_info; }); - - $("#dataDisplay").dialog("open"); - }, + + $("#dataDisplay").dialog("open"); + } } + } } - } - }, - tooltip: { - formatter: function() { - return this.point.name; - } - }, + }, + tooltip: { + formatter: function() { + return this.point.name; + } + }, title: { text: 'Query Results' }, - xAxis: { - title: { text: $('#tableid_0').val() }, - events: { + xAxis: { + title: { text: $('#tableid_0').val() }, + events: { setExtremes: function(e){ this.resetZoom.show(); } @@ -505,16 +502,16 @@ $(document).ready(function() { }, yAxis: { - min: null, - title: { text: $('#tableid_1').val() }, - endOnTick: false, + min: null, + title: { text: $('#tableid_1').val() }, + endOnTick: false, startOnTick: false, - events: { - setExtremes: function(e){ + events: { + setExtremes: function(e) { this.resetZoom.show(); } } - }, + } } $('#resizer').resizable({ From 5643a33596f72a3a9b354a9ebd079ed36cd824ec Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Sep 2011 18:48:45 +0530 Subject: [PATCH 6/9] Adding missing semicolons --- js/tbl_zoom_plot.js | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index 48676dbec8..c261bdc9eb 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -465,7 +465,7 @@ $(document).ready(function() { 'table' : window.parent.table, 'where_clause' : data[id]['where_clause'], 'token' : window.parent.token - } + }; $.post('tbl_zoom_select.php', post_params, function(data) { // Row is contained in data.row_info, now fill the displayResultForm with row values for ( key in data.row_info) { @@ -512,7 +512,7 @@ $(document).ready(function() { } } } - } + }; $('#resizer').resizable({ resize: function() { @@ -548,22 +548,22 @@ $(document).ready(function() { it++; }); if(xType == 'numeric') { - currentSettings.xAxis.max = Array.max(xCord) + 6 - currentSettings.xAxis.min = Array.min(xCord) - 6 + currentSettings.xAxis.max = Array.max(xCord) + 6; + currentSettings.xAxis.min = Array.min(xCord) - 6; } else { currentSettings.xAxis.labels = { formatter : function() { return getDate(this.value, $('#types_0').val()); - }} + }}; } if(yType == 'numeric') { - currentSettings.yAxis.max = Array.max(yCord) + 6 - currentSettings.yAxis.min = Array.min(yCord) - 6 + currentSettings.yAxis.max = Array.max(yCord) + 6; + currentSettings.yAxis.min = Array.min(yCord) - 6; } else { currentSettings.yAxis.labels = { formatter : function() { return getDate(this.value, $('#types_1').val()); - }} + }}; } } @@ -583,20 +583,20 @@ $(document).ready(function() { currentSettings.xAxis.labels = { formatter : function() { if(tempX[1][this.value] && tempX[1][this.value].length > 10) { - return tempX[1][this.value].substring(0,10) + return tempX[1][this.value].substring(0,10); } else { return tempX[1][this.value]; } } - } + }; if(yType == 'numeric') { - currentSettings.yAxis.max = Array.max(yCord) + 6 - currentSettings.yAxis.min = Array.min(yCord) - 6 + currentSettings.yAxis.max = Array.max(yCord) + 6; + currentSettings.yAxis.min = Array.min(yCord) - 6; } else { currentSettings.yAxis.labels = { formatter : function() { return getDate(this.value, $('#types_1').val()); - }} + }}; } xCord = tempX[2]; } @@ -613,22 +613,22 @@ $(document).ready(function() { it++; }); if(xType == 'numeric') { - currentSettings.xAxis.max = Array.max(xCord) + 6 - currentSettings.xAxis.min = Array.min(xCord) - 6 + currentSettings.xAxis.max = Array.max(xCord) + 6; + currentSettings.xAxis.min = Array.min(xCord) - 6; } else { currentSettings.xAxis.labels = { formatter : function() { return getDate(this.value, $('#types_0').val()); - }} + }}; } currentSettings.yAxis.labels = { formatter : function() { if(tempY[1][this.value] && tempY[1][this.value].length > 10) { - return tempY[1][this.value].substring(0,10) + return tempY[1][this.value].substring(0,10); } else { return tempY[1][this.value]; } } - } + }; yCord = tempY[2]; } @@ -645,20 +645,20 @@ $(document).ready(function() { }); currentSettings.xAxis.labels = { formatter : function() { if(tempX[1][this.value] && tempX[1][this.value].length > 10) { - return tempX[1][this.value].substring(0,10) + return tempX[1][this.value].substring(0,10); } else { return tempX[1][this.value]; } } - } + }; currentSettings.yAxis.labels = { formatter : function() { if(tempY[1][this.value] && tempY[1][this.value].length > 10) { - return tempY[1][this.value].substring(0,10) + return tempY[1][this.value].substring(0,10); } else { return tempY[1][this.value]; } } - } + }; xCord = tempX[2]; yCord = tempY[2]; @@ -702,9 +702,9 @@ $(document).ready(function() { display: 'none' }) .click(function(){ - currentChart.xAxis[0].setExtremes(null, null) - currentChart.yAxis[0].setExtremes(null, null) - this.style.display = 'none' + currentChart.xAxis[0].setExtremes(null, null); + currentChart.yAxis[0].setExtremes(null, null); + this.style.display = 'none'; }); scrollToChart(); } From edeba16cd76a6b48f22867dd6d6c2bbc9ed85d44 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Sep 2011 19:06:18 +0530 Subject: [PATCH 7/9] Proper indentation --- js/tbl_zoom_plot.js | 280 ++++++++++++++++++++++---------------------- 1 file changed, 140 insertions(+), 140 deletions(-) diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index c261bdc9eb..78bc445c6b 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -524,188 +524,188 @@ $(document).ready(function() { } }); - // Classify types as either numeric,time,text - xType = getType(xType); - yType = getType(yType); + // Classify types as either numeric,time,text + xType = getType(xType); + yType = getType(yType); - //Set the axis type based on the field - currentSettings.xAxis.type = (xType == 'time') ? 'datetime' : 'linear'; - currentSettings.yAxis.type = (yType == 'time') ? 'datetime' : 'linear'; + //Set the axis type based on the field + currentSettings.xAxis.type = (xType == 'time') ? 'datetime' : 'linear'; + currentSettings.yAxis.type = (yType == 'time') ? 'datetime' : 'linear'; // Formulate series data for plot series[0] = new Object(); series[0].data = new Array(); - series[0].marker = { + series[0].marker = { symbol: 'circle' }; - if (xType != 'text' && yType != 'text') { - $.each(data,function(key,value) { - var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val()); - var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val()); + if (xType != 'text' && yType != 'text') { + $.each(data,function(key,value) { + var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val()); + var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val()); series[0].data.push({ name: value[dataLabel], x: xVal, y: yVal, marker: {fillColor: colorCodes[it % 8]} , id: it } ); - xCord.push(value[xLabel]); - yCord.push(value[yLabel]); - it++; + xCord.push(value[xLabel]); + yCord.push(value[yLabel]); + it++; }); - if(xType == 'numeric') { - currentSettings.xAxis.max = Array.max(xCord) + 6; - currentSettings.xAxis.min = Array.min(xCord) - 6; - } - else { - currentSettings.xAxis.labels = { formatter : function() { - return getDate(this.value, $('#types_0').val()); - }}; + if(xType == 'numeric') { + currentSettings.xAxis.max = Array.max(xCord) + 6; + currentSettings.xAxis.min = Array.min(xCord) - 6; + } else { + currentSettings.xAxis.labels = { formatter : function() { + return getDate(this.value, $('#types_0').val()); + }}; } - if(yType == 'numeric') { - currentSettings.yAxis.max = Array.max(yCord) + 6; - currentSettings.yAxis.min = Array.min(yCord) - 6; - } - else { - currentSettings.yAxis.labels = { formatter : function() { - return getDate(this.value, $('#types_1').val()); - }}; + if(yType == 'numeric') { + currentSettings.yAxis.max = Array.max(yCord) + 6; + currentSettings.yAxis.min = Array.min(yCord) - 6; + } else { + currentSettings.yAxis.labels = { formatter : function() { + return getDate(this.value, $('#types_1').val()); + }}; } - } - - else if (xType =='text' && yType !='text') { - $.each(data,function(key,value) { - xCord.push(value[xLabel]); - yCord.push(value[yLabel]); - }); - - tempX = getCord(xCord); - $.each(data,function(key,value) { - var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val()); - series[0].data.push({ name: value[dataLabel], x: tempX[0][it], y: yVal, marker: {fillColor: colorCodes[it % 8]} , id: it } ); - it++; + } else if (xType =='text' && yType !='text') { + $.each(data,function(key,value) { + xCord.push(value[xLabel]); + yCord.push(value[yLabel]); }); - - currentSettings.xAxis.labels = { formatter : function() { - if(tempX[1][this.value] && tempX[1][this.value].length > 10) { - return tempX[1][this.value].substring(0,10); - } else { - return tempX[1][this.value]; - } + + tempX = getCord(xCord); + $.each(data,function(key,value) { + var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val()); + series[0].data.push({ name: value[dataLabel], x: tempX[0][it], y: yVal, marker: {fillColor: colorCodes[it % 8]} , id: it } ); + it++; + }); + + currentSettings.xAxis.labels = { + formatter : function() { + if(tempX[1][this.value] && tempX[1][this.value].length > 10) { + return tempX[1][this.value].substring(0,10); + } else { + return tempX[1][this.value]; + } } }; - if(yType == 'numeric') { - currentSettings.yAxis.max = Array.max(yCord) + 6; - currentSettings.yAxis.min = Array.min(yCord) - 6; - } - else { - currentSettings.yAxis.labels = { formatter : function() { - return getDate(this.value, $('#types_1').val()); - }}; + if(yType == 'numeric') { + currentSettings.yAxis.max = Array.max(yCord) + 6; + currentSettings.yAxis.min = Array.min(yCord) - 6; + } else { + currentSettings.yAxis.labels = { + formatter : function() { + return getDate(this.value, $('#types_1').val()); + } + }; } - xCord = tempX[2]; - } - - else if (xType !='text' && yType =='text') { - $.each(data,function(key,value) { - xCord.push(value[xLabel]); - yCord.push(value[yLabel]); - }); - tempY = getCord(yCord); - $.each(data,function(key,value) { - var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val()); + xCord = tempX[2]; + + } else if (xType !='text' && yType =='text') { + $.each(data,function(key,value) { + xCord.push(value[xLabel]); + yCord.push(value[yLabel]); + }); + tempY = getCord(yCord); + $.each(data,function(key,value) { + var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val()); series[0].data.push({ name: value[dataLabel], y: tempY[0][it], x: xVal, marker: {fillColor: colorCodes[it % 8]} , id: it } ); - it++; + it++; }); - if(xType == 'numeric') { - currentSettings.xAxis.max = Array.max(xCord) + 6; - currentSettings.xAxis.min = Array.min(xCord) - 6; - } - else { - currentSettings.xAxis.labels = { formatter : function() { - return getDate(this.value, $('#types_0').val()); - }}; - } - currentSettings.yAxis.labels = { formatter : function() { - if(tempY[1][this.value] && tempY[1][this.value].length > 10) { - return tempY[1][this.value].substring(0,10); + if(xType == 'numeric') { + currentSettings.xAxis.max = Array.max(xCord) + 6; + currentSettings.xAxis.min = Array.min(xCord) - 6; } else { - return tempY[1][this.value]; - } + currentSettings.xAxis.labels = { + formatter : function() { + return getDate(this.value, $('#types_0').val()); + } + }; } + currentSettings.yAxis.labels = { + formatter : function() { + if(tempY[1][this.value] && tempY[1][this.value].length > 10) { + return tempY[1][this.value].substring(0,10); + } else { + return tempY[1][this.value]; + } + } }; - yCord = tempY[2]; - } - - else if (xType =='text' && yType =='text') { - $.each(data,function(key,value) { - xCord.push(value[xLabel]); - yCord.push(value[yLabel]); - }); - tempX = getCord(xCord); - tempY = getCord(yCord); - $.each(data,function(key,value) { + yCord = tempY[2]; + + } else if (xType =='text' && yType =='text') { + $.each(data,function(key,value) { + xCord.push(value[xLabel]); + yCord.push(value[yLabel]); + }); + tempX = getCord(xCord); + tempY = getCord(yCord); + $.each(data,function(key,value) { series[0].data.push({ name: value[dataLabel], x: tempX[0][it], y: tempY[0][it], marker: {fillColor: colorCodes[it % 8]} , id: it } ); - it++; + it++; }); - currentSettings.xAxis.labels = { formatter : function() { - if(tempX[1][this.value] && tempX[1][this.value].length > 10) { - return tempX[1][this.value].substring(0,10); - } else { - return tempX[1][this.value]; - } - } + currentSettings.xAxis.labels = { + formatter : function() { + if(tempX[1][this.value] && tempX[1][this.value].length > 10) { + return tempX[1][this.value].substring(0,10); + } else { + return tempX[1][this.value]; + } + } }; - currentSettings.yAxis.labels = { formatter : function() { - if(tempY[1][this.value] && tempY[1][this.value].length > 10) { - return tempY[1][this.value].substring(0,10); - } else { - return tempY[1][this.value]; - } - } - }; - xCord = tempX[2]; - yCord = tempY[2]; + currentSettings.yAxis.labels = { + formatter : function() { + if(tempY[1][this.value] && tempY[1][this.value].length > 10) { + return tempY[1][this.value].substring(0,10); + } else { + return tempY[1][this.value]; + } + } + }; + xCord = tempX[2]; + yCord = tempY[2]; + } - } - - currentSettings.series = series; + currentSettings.series = series; currentChart = PMA_createChart(currentSettings); - xMin = currentChart.xAxis[0].getExtremes().min; + xMin = currentChart.xAxis[0].getExtremes().min; xMax = currentChart.xAxis[0].getExtremes().max; yMin = currentChart.yAxis[0].getExtremes().min; yMax = currentChart.yAxis[0].getExtremes().max; - includePan(currentChart); //Enable panning feature + includePan(currentChart); //Enable panning feature var setZoom = function() { - var newxm = xMin + (xMax - xMin) * (1 - zoomRatio) / 2; - var newxM = xMax - (xMax - xMin) * (1 - zoomRatio) / 2; - var newym = yMin + (yMax - yMin) * (1 - zoomRatio) / 2; - var newyM = yMax - (yMax - yMin) * (1 - zoomRatio) / 2; + var newxm = xMin + (xMax - xMin) * (1 - zoomRatio) / 2; + var newxM = xMax - (xMax - xMin) * (1 - zoomRatio) / 2; + var newym = yMin + (yMax - yMin) * (1 - zoomRatio) / 2; + var newyM = yMax - (yMax - yMin) * (1 - zoomRatio) / 2; currentChart.xAxis[0].setExtremes(newxm,newxM); currentChart.yAxis[0].setExtremes(newym,newyM); - }; - //Enable zoom feature - $("#querychart").mousewheel(function(objEvent, intDelta) { + }; + + //Enable zoom feature + $("#querychart").mousewheel(function(objEvent, intDelta) { if (intDelta > 0) { if (zoomRatio > 0.1) { zoomRatio = zoomRatio - 0.1; setZoom(); } - } - else if (intDelta < 0) { + } else if (intDelta < 0) { zoomRatio = zoomRatio + 0.1; setZoom(); } }); + //Add reset zoom feature currentChart.yAxis[0].resetZoom = currentChart.xAxis[0].resetZoom = $('Reset zoom') - .appendTo(currentChart.container) - .css({ - position: 'absolute', - top: 10, - right: 20, - display: 'none' - }) - .click(function(){ - currentChart.xAxis[0].setExtremes(null, null); - currentChart.yAxis[0].setExtremes(null, null); - this.style.display = 'none'; - }); - scrollToChart(); + .appendTo(currentChart.container) + .css({ + position: 'absolute', + top: 10, + right: 20, + display: 'none' + }) + .click(function(){ + currentChart.xAxis[0].setExtremes(null, null); + currentChart.yAxis[0].setExtremes(null, null); + this.style.display = 'none'; + }); + scrollToChart(); } }); From 472350cf97095c70c163d70539b5f963d4ce1cbb Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Sep 2011 19:28:35 +0530 Subject: [PATCH 8/9] Spaces to make the code more readable --- js/tbl_zoom_plot.js | 207 ++++++++++++++++++++++---------------------- 1 file changed, 104 insertions(+), 103 deletions(-) diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index 78bc445c6b..f478b52536 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -11,7 +11,7 @@ ** Display Help/Info **/ function displayHelp() { - var msgbox = PMA_ajaxShowMessage(PMA_messages['strDisplayHelp'],10000); + var msgbox = PMA_ajaxShowMessage(PMA_messages['strDisplayHelp'], 10000); msgbox.click(function() { PMA_ajaxRemoveMessage(msgbox); }); @@ -58,11 +58,11 @@ function isEmpty(obj) { ** @param val Integer Timestamp ** @param type String Field type(datetime/timestamp/time/date) **/ -function getDate(val,type) { - if(type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) { - return Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', val); +function getDate(val, type) { + if (type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) { + return Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', val); } - else if(type.toString().search(/time/i) != -1) { + else if (type.toString().search(/time/i) != -1) { return Highcharts.dateFormat('%H:%M:%S', val); } else if (type.toString().search(/date/i) != -1) { @@ -75,15 +75,15 @@ function getDate(val,type) { ** @param val String Date ** @param type Sring Field type(datetime/timestamp/time/date) **/ -function getTimeStamp(val,type) { - if(type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) { - return getDateFromFormat(val,'yyyy-MM-dd HH:mm:ss', val); +function getTimeStamp(val, type) { + if (type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) { + return getDateFromFormat(val, 'yyyy-MM-dd HH:mm:ss', val); } - else if(type.toString().search(/time/i) != -1) { - return getDateFromFormat('1970-01-01 ' + val,'yyyy-MM-dd HH:mm:ss'); + else if (type.toString().search(/time/i) != -1) { + return getDateFromFormat('1970-01-01 ' + val, 'yyyy-MM-dd HH:mm:ss'); } else if (type.toString().search(/date/i) != -1) { - return getDateFromFormat(val,'yyyy-MM-dd'); + return getDateFromFormat(val, 'yyyy-MM-dd'); } } @@ -92,25 +92,25 @@ function getTimeStamp(val,type) { ** @param field: field type (as in database structure) **/ function getType(field) { - if(field.toString().search(/int/i) != -1 || field.toString().search(/decimal/i) != -1 || field.toString().search(/year/i) != -1) + if (field.toString().search(/int/i) != -1 || field.toString().search(/decimal/i) != -1 || field.toString().search(/year/i) != -1) return 'numeric'; - else if(field.toString().search(/time/i) != -1 || field.toString().search(/date/i) != -1) + else if (field.toString().search(/time/i) != -1 || field.toString().search(/date/i) != -1) return 'time'; else return 'text'; } -/** +/** ** Converts a categorical array into numeric array ** @param array categorical values array **/ function getCord(arr) { var newCord = new Array(); - var original = $.extend(true,[],arr); + var original = $.extend(true, [], arr); var arr = jQuery.unique(arr).sort(); - $.each(original, function(index,value) { - newCord.push(jQuery.inArray(value,arr)); + $.each(original, function(index, value) { + newCord.push(jQuery.inArray(value, arr)); }); - return [newCord,arr,original]; + return [newCord, arr, original]; } /** @@ -213,10 +213,11 @@ $(document).ready(function() { * Input form validation **/ $('#inputFormSubmitId').click(function() { - if ($('#tableid_0').get(0).selectedIndex == 0 || $('#tableid_1').get(0).selectedIndex == 0) - PMA_ajaxShowMessage(PMA_messages['strInputNull']); - else if (xLabel == yLabel) + 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']); + } }); /** @@ -224,9 +225,9 @@ $(document).ready(function() { ** after a couple of clicks **/ $('
') - .insertAfter('#zoom_search_form') - // don't show it until we have results on-screen - .hide(); + .insertAfter('#zoom_search_form') + // don't show it until we have results on-screen + .hide(); $('#togglesearchformlink') .html(PMA_messages['strShowSearchCriteria']) @@ -241,8 +242,8 @@ $(document).ready(function() { // avoid default click action return false; }); - - /** + + /** ** Set dialog properties for the data display form **/ $("#dataDisplay").dialog({ @@ -256,12 +257,12 @@ $(document).ready(function() { /* * Handle submit of zoom_display_form */ - + $("#submitForm").click(function(event) { - + //Prevent default submission of form event.preventDefault(); - + //Find changed values by comparing form values with selectedRow Object var newValues = new Array();//Stores the values changed from original var it = 4; @@ -274,10 +275,10 @@ $(document).ready(function() { if (oldVal != newVal) { selectedRow[key] = newVal; newValues[key] = newVal; - if(key == xLabel) { + if (key == xLabel) { xChange = true; data[currentData][xLabel] = newVal; - } else if(key == yLabel) { + } else if (key == yLabel) { yChange = true; data[currentData][yLabel] = newVal; } @@ -285,7 +286,7 @@ $(document).ready(function() { } it++; } //End data update - + //Update the chart series and replot if (xChange || yChange) { var newSeries = new Array(); @@ -294,13 +295,13 @@ $(document).ready(function() { symbol: 'circle' }; //Logic similar to plot generation, replot only if xAxis changes or yAxis changes. Code includes a lot of checks so as to replot only when necessary - if(xChange) { + if (xChange) { xCord[currentData] = selectedRow[xLabel]; - if(xType == 'numeric') { + if (xType == 'numeric') { currentChart.series[0].data[currentData].update({ x : selectedRow[xLabel] }); - currentChart.xAxis[0].setExtremes(Array.min(xCord) - 6,Array.max(xCord) + 6); - } else if(xType == 'time') { - currentChart.series[0].data[currentData].update({ x : getTimeStamp(selectedRow[xLabel],$('#types_0').val())}); + currentChart.xAxis[0].setExtremes(Array.min(xCord) - 6, Array.max(xCord) + 6); + } else if (xType == 'time') { + currentChart.series[0].data[currentData].update({ x : getTimeStamp(selectedRow[xLabel], $('#types_0').val())}); } else { var tempX = getCord(xCord); var tempY = getCord(yCord); @@ -308,19 +309,19 @@ $(document).ready(function() { newSeries[0].data = new Array(); xCord = tempX[2]; yCord = tempY[2]; - - $.each(data,function(key,value) { - if(yType != 'text') { + + $.each(data, function(key, value) { + if (yType != 'text') { newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: value[yLabel], marker: {fillColor: colorCodes[i % 8]} , id: i } ); } else { newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } ); } - i++; + i++; }); currentSettings.xAxis.labels = { formatter : function() { - if(tempX[1][this.value] && tempX[1][this.value].length > 10) { - return tempX[1][this.value].substring(0,10); + if (tempX[1][this.value] && tempX[1][this.value].length > 10) { + return tempX[1][this.value].substring(0, 10); } else { return tempX[1][this.value]; } @@ -329,15 +330,15 @@ $(document).ready(function() { currentSettings.series = newSeries; currentChart = PMA_createChart(currentSettings); } - + } - if(yChange) { + if (yChange) { yCord[currentData] = selectedRow[yLabel]; - if(yType == 'numeric') { + if (yType == 'numeric') { currentChart.series[0].data[currentData].update({ y : selectedRow[yLabel] }); - currentChart.yAxis[0].setExtremes(Array.min(yCord) - 6,Array.max(yCord) + 6); - } else if(yType =='time') { - currentChart.series[0].data[currentData].update({ y : getTimeStamp(selectedRow[yLabel],$('#types_1').val())}); + currentChart.yAxis[0].setExtremes(Array.min(yCord) - 6, Array.max(yCord) + 6); + } else if (yType == 'time') { + currentChart.series[0].data[currentData].update({ y : getTimeStamp(selectedRow[yLabel], $('#types_1').val())}); } else { var tempX = getCord(xCord); var tempY = getCord(yCord); @@ -345,19 +346,19 @@ $(document).ready(function() { newSeries[0].data = new Array(); xCord = tempX[2]; yCord = tempY[2]; - - $.each(data,function(key,value) { - if(xType != 'text' ) { + + $.each(data, function(key, value) { + if (xType != 'text' ) { newSeries[0].data.push({ name: value[dataLabel], x: value[xLabel], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } ); } else { newSeries[0].data.push({ name: value[dataLabel], x: tempX[0][i], y: tempY[0][i], marker: {fillColor: colorCodes[i % 8]} , id: i } ); } - i++; + i++; }); currentSettings.yAxis.labels = { formatter : function() { - if(tempY[1][this.value] && tempY[1][this.value].length > 10) { - return tempY[1][this.value].substring(0,10); + if (tempY[1][this.value] && tempY[1][this.value].length > 10) { + return tempY[1][this.value].substring(0, 10); } else { return tempY[1][this.value]; } @@ -368,16 +369,16 @@ $(document).ready(function() { } } currentChart.series[0].data[currentData].select(); - } //End plot update + } //End plot update //Generate SQL query for update if (!isEmpty(newValues)) { var sql_query = 'UPDATE `' + window.parent.table + '` SET '; for (key in newValues) { - if(key != 'where_clause') { + if (key != 'where_clause') { sql_query += '`' + key + '`=' ; var value = newValues[key]; - if(!isNumeric(value) && value != null) { + if (!isNumeric(value) && value != null) { sql_query += '\'' + value + '\' ,'; } else { sql_query += value + ' ,'; @@ -386,8 +387,8 @@ $(document).ready(function() { } sql_query = sql_query.substring(0, sql_query.length - 1); sql_query += ' WHERE ' + PMA_urldecode(data[currentData]['where_clause']); - - //Post SQL query to sql.php + + //Post SQL query to sql.php $.post('sql.php', { 'token' : window.parent.token, 'db' : window.parent.db, @@ -395,7 +396,7 @@ $(document).ready(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 { @@ -403,7 +404,7 @@ $(document).ready(function() { } }); //End $.post }//End database update - $("#dataDisplay").dialog("close"); + $("#dataDisplay").dialog("close"); });//End submit handler /* @@ -418,7 +419,7 @@ $(document).ready(function() { .text(PMA_messages['strShowSearchCriteria']); $('#togglesearchformdiv').show(); var selectedRow; - var colorCodes = ['#FF0000','#00FFFF','#0000FF','#0000A0','#FF0080','#800080','#FFFF00','#00FF00','#FF00FF']; + var colorCodes = ['#FF0000', '#00FFFF', '#0000FF', '#0000A0', '#FF0080', '#800080', '#FFFF00', '#00FF00', '#FF00FF']; var series = new Array(); var xCord = new Array(); var yCord = new Array(); @@ -435,8 +436,8 @@ $(document).ready(function() { renderTo: 'querychart', type: 'scatter', //zoomType: 'xy', - width:$('#resizer').width() -3, - height:$('#resizer').height()-20 + width:$('#resizer').width() - 3, + height:$('#resizer').height() - 20 }, credits: { enabled: false @@ -479,7 +480,7 @@ $(document).ready(function() { selectedRow = new Object(); selectedRow = data.row_info; }); - + $("#dataDisplay").dialog("open"); } } @@ -495,7 +496,7 @@ $(document).ready(function() { xAxis: { title: { text: $('#tableid_0').val() }, events: { - setExtremes: function(e){ + setExtremes: function(e) { this.resetZoom.show(); } } @@ -517,13 +518,13 @@ $(document).ready(function() { $('#resizer').resizable({ resize: function() { currentChart.setSize( - this.offsetWidth -3, - this.offsetHeight -20, + this.offsetWidth - 3, + this.offsetHeight - 20, false ); } }); - + // Classify types as either numeric,time,text xType = getType(xType); yType = getType(yType); @@ -539,15 +540,15 @@ $(document).ready(function() { symbol: 'circle' }; if (xType != 'text' && yType != 'text') { - $.each(data,function(key,value) { - var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val()); - var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val()); + $.each(data, function(key, value) { + var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel], $('#types_0').val()); + var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel], $('#types_1').val()); series[0].data.push({ name: value[dataLabel], x: xVal, y: yVal, marker: {fillColor: colorCodes[it % 8]} , id: it } ); xCord.push(value[xLabel]); yCord.push(value[yLabel]); - it++; + it++; }); - if(xType == 'numeric') { + if (xType == 'numeric') { currentSettings.xAxis.max = Array.max(xCord) + 6; currentSettings.xAxis.min = Array.min(xCord) - 6; } else { @@ -555,7 +556,7 @@ $(document).ready(function() { return getDate(this.value, $('#types_0').val()); }}; } - if(yType == 'numeric') { + if (yType == 'numeric') { currentSettings.yAxis.max = Array.max(yCord) + 6; currentSettings.yAxis.min = Array.min(yCord) - 6; } else { @@ -564,29 +565,29 @@ $(document).ready(function() { }}; } - } else if (xType =='text' && yType !='text') { - $.each(data,function(key,value) { + } else if (xType == 'text' && yType != 'text') { + $.each(data, function(key, value) { xCord.push(value[xLabel]); yCord.push(value[yLabel]); }); - + tempX = getCord(xCord); - $.each(data,function(key,value) { - var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel],$('#types_1').val()); + $.each(data, function(key, value) { + var yVal = (yType == 'numeric') ? value[yLabel] : getTimeStamp(value[yLabel], $('#types_1').val()); series[0].data.push({ name: value[dataLabel], x: tempX[0][it], y: yVal, marker: {fillColor: colorCodes[it % 8]} , id: it } ); - it++; + it++; }); - + currentSettings.xAxis.labels = { formatter : function() { - if(tempX[1][this.value] && tempX[1][this.value].length > 10) { - return tempX[1][this.value].substring(0,10); + if (tempX[1][this.value] && tempX[1][this.value].length > 10) { + return tempX[1][this.value].substring(0, 10); } else { return tempX[1][this.value]; } } }; - if(yType == 'numeric') { + if (yType == 'numeric') { currentSettings.yAxis.max = Array.max(yCord) + 6; currentSettings.yAxis.min = Array.min(yCord) - 6; } else { @@ -598,18 +599,18 @@ $(document).ready(function() { } xCord = tempX[2]; - } else if (xType !='text' && yType =='text') { - $.each(data,function(key,value) { + } else if (xType != 'text' && yType == 'text') { + $.each(data, function(key, value) { xCord.push(value[xLabel]); yCord.push(value[yLabel]); }); tempY = getCord(yCord); - $.each(data,function(key,value) { - var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel],$('#types_0').val()); + $.each(data, function(key, value) { + var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel], $('#types_0').val()); series[0].data.push({ name: value[dataLabel], y: tempY[0][it], x: xVal, marker: {fillColor: colorCodes[it % 8]} , id: it } ); it++; }); - if(xType == 'numeric') { + if (xType == 'numeric') { currentSettings.xAxis.max = Array.max(xCord) + 6; currentSettings.xAxis.min = Array.min(xCord) - 6; } else { @@ -621,8 +622,8 @@ $(document).ready(function() { } currentSettings.yAxis.labels = { formatter : function() { - if(tempY[1][this.value] && tempY[1][this.value].length > 10) { - return tempY[1][this.value].substring(0,10); + if (tempY[1][this.value] && tempY[1][this.value].length > 10) { + return tempY[1][this.value].substring(0, 10); } else { return tempY[1][this.value]; } @@ -630,21 +631,21 @@ $(document).ready(function() { }; yCord = tempY[2]; - } else if (xType =='text' && yType =='text') { - $.each(data,function(key,value) { + } else if (xType == 'text' && yType == 'text') { + $.each(data, function(key, value) { xCord.push(value[xLabel]); yCord.push(value[yLabel]); }); tempX = getCord(xCord); tempY = getCord(yCord); - $.each(data,function(key,value) { + $.each(data, function(key, value) { series[0].data.push({ name: value[dataLabel], x: tempX[0][it], y: tempY[0][it], marker: {fillColor: colorCodes[it % 8]} , id: it } ); it++; }); currentSettings.xAxis.labels = { formatter : function() { - if(tempX[1][this.value] && tempX[1][this.value].length > 10) { - return tempX[1][this.value].substring(0,10); + if (tempX[1][this.value] && tempX[1][this.value].length > 10) { + return tempX[1][this.value].substring(0, 10); } else { return tempX[1][this.value]; } @@ -652,8 +653,8 @@ $(document).ready(function() { }; currentSettings.yAxis.labels = { formatter : function() { - if(tempY[1][this.value] && tempY[1][this.value].length > 10) { - return tempY[1][this.value].substring(0,10); + if (tempY[1][this.value] && tempY[1][this.value].length > 10) { + return tempY[1][this.value].substring(0, 10); } else { return tempY[1][this.value]; } @@ -675,8 +676,8 @@ $(document).ready(function() { var newxM = xMax - (xMax - xMin) * (1 - zoomRatio) / 2; var newym = yMin + (yMax - yMin) * (1 - zoomRatio) / 2; var newyM = yMax - (yMax - yMin) * (1 - zoomRatio) / 2; - currentChart.xAxis[0].setExtremes(newxm,newxM); - currentChart.yAxis[0].setExtremes(newym,newyM); + currentChart.xAxis[0].setExtremes(newxm, newxM); + currentChart.yAxis[0].setExtremes(newym, newyM); }; //Enable zoom feature @@ -701,7 +702,7 @@ $(document).ready(function() { right: 20, display: 'none' }) - .click(function(){ + .click(function() { currentChart.xAxis[0].setExtremes(null, null); currentChart.yAxis[0].setExtremes(null, null); this.style.display = 'none'; From 1371398618fceb23db86e35252e1062c2c359bc7 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Sep 2011 19:36:59 +0530 Subject: [PATCH 9/9] Remove trailing white spaces --- js/tbl_zoom_plot.js | 78 ++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index f478b52536..788ca6396c 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -35,7 +35,7 @@ Array.min = function (array) { /** ** Checks if a string contains only numeric value - ** @param n: String (to be checked) + ** @param n: String (to be checked) **/ function isNumeric(n) { return !isNaN(parseFloat(n)) && isFinite(n); @@ -43,7 +43,7 @@ function isNumeric(n) { /** ** Checks if an object is empty - ** @param n: Object (to be checked) + ** @param n: Object (to be checked) **/ function isEmpty(obj) { var name; @@ -61,13 +61,13 @@ function isEmpty(obj) { function getDate(val, type) { if (type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) { return Highcharts.dateFormat('%Y-%m-%e %H:%M:%S', val); - } + } else if (type.toString().search(/time/i) != -1) { return Highcharts.dateFormat('%H:%M:%S', val); - } + } else if (type.toString().search(/date/i) != -1) { return Highcharts.dateFormat('%Y-%m-%e', val); - } + } } /** @@ -78,19 +78,19 @@ function getDate(val, type) { function getTimeStamp(val, type) { if (type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) { return getDateFromFormat(val, 'yyyy-MM-dd HH:mm:ss', val); - } + } else if (type.toString().search(/time/i) != -1) { return getDateFromFormat('1970-01-01 ' + val, 'yyyy-MM-dd HH:mm:ss'); - } + } else if (type.toString().search(/date/i) != -1) { return getDateFromFormat(val, 'yyyy-MM-dd'); - } + } } /** ** Classifies the field type into numeric,timeseries or text ** @param field: field type (as in database structure) - **/ + **/ function getType(field) { if (field.toString().search(/int/i) != -1 || field.toString().search(/decimal/i) != -1 || field.toString().search(/year/i) != -1) return 'numeric'; @@ -174,7 +174,7 @@ $(document).ready(function() { cache: 'false' }); - var cursorMode = ($("input[name='mode']:checked").val() == 'edit') ? 'crosshair' : 'pointer'; + var cursorMode = ($("input[name='mode']:checked").val() == 'edit') ? 'crosshair' : 'pointer'; var currentChart = null; var currentData = null; var xLabel = $('#tableid_0').val(); @@ -187,7 +187,7 @@ $(document).ready(function() { var zoomRatio = 1; - // Get query result + // Get query result var data = jQuery.parseJSON($('#querydata').html()); /** @@ -211,9 +211,9 @@ $(document).ready(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']); @@ -221,7 +221,7 @@ $(document).ready(function() { }); /** - ** Prepare a div containing a link, otherwise it's incorrectly displayed + ** Prepare a div containing a link, otherwise it's incorrectly displayed ** after a couple of clicks **/ $('
') @@ -255,7 +255,7 @@ $(document).ready(function() { }); /* - * Handle submit of zoom_display_form + * Handle submit of zoom_display_form */ $("#submitForm").click(function(event) { @@ -284,7 +284,7 @@ $(document).ready(function() { } } } - it++; + it++; } //End data update //Update the chart series and replot @@ -318,12 +318,12 @@ $(document).ready(function() { } i++; }); - currentSettings.xAxis.labels = { + currentSettings.xAxis.labels = { formatter : function() { if (tempX[1][this.value] && tempX[1][this.value].length > 10) { return tempX[1][this.value].substring(0, 10); } else { - return tempX[1][this.value]; + return tempX[1][this.value]; } } }; @@ -355,17 +355,17 @@ $(document).ready(function() { } i++; }); - currentSettings.yAxis.labels = { + currentSettings.yAxis.labels = { formatter : function() { if (tempY[1][this.value] && tempY[1][this.value].length > 10) { return tempY[1][this.value].substring(0, 10); } else { - return tempY[1][this.value]; + return tempY[1][this.value]; } } }; currentSettings.series = newSeries; - currentChart = PMA_createChart(currentSettings); + currentChart = PMA_createChart(currentSettings); } } currentChart.series[0].data[currentData].select(); @@ -405,11 +405,11 @@ $(document).ready(function() { }); //End $.post }//End database update $("#dataDisplay").dialog("close"); - });//End submit handler + });//End submit handler /* * Generate plot using Highcharts - */ + */ if (data != null) { $('#zoom_search_form') @@ -425,10 +425,10 @@ $(document).ready(function() { var yCord = new Array(); var tempX, tempY; var it = 0; - var xMax; // xAxis extreme max - var xMin; // xAxis extreme min - var yMax; // yAxis extreme max - var yMin; // yAxis extreme min + var xMax; // xAxis extreme max + var xMin; // xAxis extreme min + var yMax; // yAxis extreme max + var yMin; // yAxis extreme min // Set the basic plot settings var currentSettings = { @@ -440,7 +440,7 @@ $(document).ready(function() { height:$('#resizer').height() - 20 }, credits: { - enabled: false + enabled: false }, exporting: { enabled: false }, label: { text: $('#dataLabel').val() }, @@ -469,7 +469,7 @@ $(document).ready(function() { }; $.post('tbl_zoom_select.php', post_params, function(data) { // Row is contained in data.row_info, now fill the displayResultForm with row values - for ( key in data.row_info) { + for ( key in data.row_info) { if (data.row_info[key] == null) { $('#fields_null_id_' + fid).attr('checked', true); } else { @@ -481,7 +481,7 @@ $(document).ready(function() { selectedRow = data.row_info; }); - $("#dataDisplay").dialog("open"); + $("#dataDisplay").dialog("open"); } } } @@ -578,20 +578,20 @@ $(document).ready(function() { it++; }); - currentSettings.xAxis.labels = { + currentSettings.xAxis.labels = { formatter : function() { if (tempX[1][this.value] && tempX[1][this.value].length > 10) { return tempX[1][this.value].substring(0, 10); } else { return tempX[1][this.value]; } - } + } }; if (yType == 'numeric') { currentSettings.yAxis.max = Array.max(yCord) + 6; currentSettings.yAxis.min = Array.min(yCord) - 6; } else { - currentSettings.yAxis.labels = { + currentSettings.yAxis.labels = { formatter : function() { return getDate(this.value, $('#types_1').val()); } @@ -608,19 +608,19 @@ $(document).ready(function() { $.each(data, function(key, value) { var xVal = (xType == 'numeric') ? value[xLabel] : getTimeStamp(value[xLabel], $('#types_0').val()); series[0].data.push({ name: value[dataLabel], y: tempY[0][it], x: xVal, marker: {fillColor: colorCodes[it % 8]} , id: it } ); - it++; + it++; }); if (xType == 'numeric') { currentSettings.xAxis.max = Array.max(xCord) + 6; currentSettings.xAxis.min = Array.min(xCord) - 6; } else { - currentSettings.xAxis.labels = { + currentSettings.xAxis.labels = { formatter : function() { return getDate(this.value, $('#types_0').val()); } }; } - currentSettings.yAxis.labels = { + currentSettings.yAxis.labels = { formatter : function() { if (tempY[1][this.value] && tempY[1][this.value].length > 10) { return tempY[1][this.value].substring(0, 10); @@ -636,13 +636,13 @@ $(document).ready(function() { xCord.push(value[xLabel]); yCord.push(value[yLabel]); }); - tempX = getCord(xCord); + tempX = getCord(xCord); tempY = getCord(yCord); $.each(data, function(key, value) { series[0].data.push({ name: value[dataLabel], x: tempX[0][it], y: tempY[0][it], marker: {fillColor: colorCodes[it % 8]} , id: it } ); it++; }); - currentSettings.xAxis.labels = { + currentSettings.xAxis.labels = { formatter : function() { if (tempX[1][this.value] && tempX[1][this.value].length > 10) { return tempX[1][this.value].substring(0, 10); @@ -651,7 +651,7 @@ $(document).ready(function() { } } }; - currentSettings.yAxis.labels = { + currentSettings.yAxis.labels = { formatter : function() { if (tempY[1][this.value] && tempY[1][this.value].length > 10) { return tempY[1][this.value].substring(0, 10);