Skip to content

Commit

Permalink
Coding style, function definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Aug 5, 2011
1 parent 6205d41 commit 1ec0b69
Show file tree
Hide file tree
Showing 80 changed files with 710 additions and 432 deletions.
33 changes: 22 additions & 11 deletions js/common.js
Expand Up @@ -19,7 +19,8 @@ var query_to_load = '';
* *
* @param string db name * @param string db name
*/ */
function setDb(new_db) { function setDb(new_db)
{
//alert('setDb(' + new_db + ')'); //alert('setDb(' + new_db + ')');
if (new_db != db) { if (new_db != db) {
// db has changed // db has changed
Expand Down Expand Up @@ -51,7 +52,8 @@ function setDb(new_db) {
* *
* @param string table name * @param string table name
*/ */
function setTable(new_table) { function setTable(new_table)
{
//alert('setTable(' + new_table + ')'); //alert('setTable(' + new_table + ')');
if (new_table != table) { if (new_table != table) {
// table has changed // table has changed
Expand Down Expand Up @@ -86,7 +88,8 @@ function setTable(new_table) {
* @uses encodeURIComponent() * @uses encodeURIComponent()
* @param string url name of page to be loaded * @param string url name of page to be loaded
*/ */
function refreshMain(url) { function refreshMain(url)
{
if (! url) { if (! url) {
if (db) { if (db) {
url = opendb_url; url = opendb_url;
Expand Down Expand Up @@ -117,7 +120,8 @@ function refreshMain(url) {
* @uses encodeURIComponent() * @uses encodeURIComponent()
* @param boolean force force reloading * @param boolean force force reloading
*/ */
function refreshNavigation(force) { function refreshNavigation(force)
{
// The goTo() function won't refresh in case the target // The goTo() function won't refresh in case the target
// url is the same as the url given as parameter, but sometimes // url is the same as the url given as parameter, but sometimes
// we want to refresh anyway. // we want to refresh anyway.
Expand Down Expand Up @@ -174,7 +178,8 @@ function markDbTable(db, table)
/** /**
* sets current selected server, table and db (called from libraries/footer.inc.php) * sets current selected server, table and db (called from libraries/footer.inc.php)
*/ */
function setAll( new_lang, new_collation_connection, new_server, new_db, new_table, new_token ) { function setAll( new_lang, new_collation_connection, new_server, new_db, new_table, new_token )
{
//alert('setAll( ' + new_lang + ', ' + new_collation_connection + ', ' + new_server + ', ' + new_db + ', ' + new_table + ', ' + new_token + ' )'); //alert('setAll( ' + new_lang + ', ' + new_collation_connection + ', ' + new_server + ', ' + new_db + ', ' + new_table + ', ' + new_token + ' )');
if (new_server != server || new_lang != lang if (new_server != server || new_lang != lang
|| new_collation_connection != collation_connection) { || new_collation_connection != collation_connection) {
Expand Down Expand Up @@ -257,7 +262,8 @@ function focus_querywindow(sql_query)
* inserts query string into query window textarea * inserts query string into query window textarea
* called from script tag in querywindow * called from script tag in querywindow
*/ */
function insertQuery() { function insertQuery()
{
if (query_to_load != '' && querywindow.document && querywindow.document.getElementById && querywindow.document.getElementById('sqlquery')) { if (query_to_load != '' && querywindow.document && querywindow.document.getElementById && querywindow.document.getElementById('sqlquery')) {
querywindow.document.getElementById('sqlquery').value = query_to_load; querywindow.document.getElementById('sqlquery').value = query_to_load;
query_to_load = ''; query_to_load = '';
Expand All @@ -266,7 +272,8 @@ function insertQuery() {
return false; return false;
} }


function open_querywindow( url ) { function open_querywindow( url )
{
if ( ! url ) { if ( ! url ) {
url = 'querywindow.php?' + common_query + '&db=' + encodeURIComponent(db) + '&table=' + encodeURIComponent(table); url = 'querywindow.php?' + common_query + '&db=' + encodeURIComponent(db) + '&table=' + encodeURIComponent(table);
} }
Expand All @@ -293,7 +300,8 @@ function open_querywindow( url ) {
return true; return true;
} }


function refreshQuerywindow( url ) { function refreshQuerywindow( url )
{


if ( ! querywindow.closed && querywindow.location ) { if ( ! querywindow.closed && querywindow.location ) {
if ( ! querywindow.document.sqlform.LockFromUpdate if ( ! querywindow.document.sqlform.LockFromUpdate
Expand All @@ -310,7 +318,8 @@ function refreshQuerywindow( url ) {
* @param string targeturl new url to load * @param string targeturl new url to load
* @param string target frame where to load the new url * @param string target frame where to load the new url
*/ */
function goTo(targeturl, target) { function goTo(targeturl, target)
{
//alert(targeturl); //alert(targeturl);
if ( target == 'main' ) { if ( target == 'main' ) {
target = window.frame_content; target = window.frame_content;
Expand Down Expand Up @@ -339,15 +348,17 @@ function goTo(targeturl, target) {
} }


// opens selected db in main frame // opens selected db in main frame
function openDb(new_db) { function openDb(new_db)
{
//alert('opendb(' + new_db + ')'); //alert('opendb(' + new_db + ')');
setDb(new_db); setDb(new_db);
setTable(''); setTable('');
refreshMain(opendb_url); refreshMain(opendb_url);
return true; return true;
} }


function updateTableTitle( table_link_id, new_title ) { function updateTableTitle( table_link_id, new_title )
{
//alert('updateTableTitle'); //alert('updateTableTitle');
if ( window.parent.frame_navigation.document && window.parent.frame_navigation.document.getElementById(table_link_id) ) { if ( window.parent.frame_navigation.document && window.parent.frame_navigation.document.getElementById(table_link_id) ) {
var left = window.parent.frame_navigation.document; var left = window.parent.frame_navigation.document;
Expand Down
48 changes: 32 additions & 16 deletions js/config.js
Expand Up @@ -14,7 +14,8 @@ var PMA_messages = {};
* *
* @param {Element} field * @param {Element} field
*/ */
function getFieldType(field) { function getFieldType(field)
{
field = $(field); field = $(field);
var tagName = field.prop('tagName'); var tagName = field.prop('tagName');
if (tagName == 'INPUT') { if (tagName == 'INPUT') {
Expand All @@ -40,7 +41,8 @@ function getFieldType(field) {
* @param {String} field_type see {@link #getFieldType} * @param {String} field_type see {@link #getFieldType}
* @param {String|Boolean} [value] * @param {String|Boolean} [value]
*/ */
function setFieldValue(field, field_type, value) { function setFieldValue(field, field_type, value)
{
field = $(field); field = $(field);
switch (field_type) { switch (field_type) {
case 'text': case 'text':
Expand Down Expand Up @@ -78,7 +80,8 @@ function setFieldValue(field, field_type, value) {
* @param {String} field_type returned by {@link #getFieldType} * @param {String} field_type returned by {@link #getFieldType}
* @type Boolean|String|String[] * @type Boolean|String|String[]
*/ */
function getFieldValue(field, field_type) { function getFieldValue(field, field_type)
{
field = $(field); field = $(field);
switch (field_type) { switch (field_type) {
case 'text': case 'text':
Expand All @@ -101,7 +104,8 @@ function getFieldValue(field, field_type) {
/** /**
* Returns values for all fields in fieldsets * Returns values for all fields in fieldsets
*/ */
function getAllValues() { function getAllValues()
{
var elements = $('fieldset input, fieldset select, fieldset textarea'); var elements = $('fieldset input, fieldset select, fieldset textarea');
var values = {}; var values = {};
var type, value; var type, value;
Expand All @@ -126,7 +130,8 @@ function getAllValues() {
* @param {String} type * @param {String} type
* @return boolean * @return boolean
*/ */
function checkFieldDefault(field, type) { function checkFieldDefault(field, type)
{
field = $(field); field = $(field);
var field_id = field.attr('id'); var field_id = field.attr('id');
if (typeof defaultValues[field_id] == 'undefined') { if (typeof defaultValues[field_id] == 'undefined') {
Expand Down Expand Up @@ -157,7 +162,8 @@ function checkFieldDefault(field, type) {
* Returns element's id prefix * Returns element's id prefix
* @param {Element} element * @param {Element} element
*/ */
function getIdPrefix(element) { function getIdPrefix(element)
{
return $(element).attr('id').replace(/[^-]+$/, ''); return $(element).attr('id').replace(/[^-]+$/, '');
} }


Expand Down Expand Up @@ -254,7 +260,8 @@ var validators = {
* @param {boolean} onKeyUp whether fire on key up * @param {boolean} onKeyUp whether fire on key up
* @param {Array} params validation function parameters * @param {Array} params validation function parameters
*/ */
function validateField(id, type, onKeyUp, params) { function validateField(id, type, onKeyUp, params)
{
if (typeof validators[type] == 'undefined') { if (typeof validators[type] == 'undefined') {
return; return;
} }
Expand All @@ -272,7 +279,8 @@ function validateField(id, type, onKeyUp, params) {
* @type Array * @type Array
* @return array of [function, paramseters to be passed to function] * @return array of [function, paramseters to be passed to function]
*/ */
function getFieldValidators(field_id, onKeyUpOnly) { function getFieldValidators(field_id, onKeyUpOnly)
{
// look for field bound validator // look for field bound validator
var name = field_id.match(/[^-]+$/)[0]; var name = field_id.match(/[^-]+$/)[0];
if (typeof validators._field[name] != 'undefined') { if (typeof validators._field[name] != 'undefined') {
Expand Down Expand Up @@ -302,7 +310,8 @@ function getFieldValidators(field_id, onKeyUpOnly) {
* *
* @param {Object} error_list list of errors in the form {field id: error array} * @param {Object} error_list list of errors in the form {field id: error array}
*/ */
function displayErrors(error_list) { function displayErrors(error_list)
{
for (var field_id in error_list) { for (var field_id in error_list) {
var errors = error_list[field_id]; var errors = error_list[field_id];
var field = $('#'+field_id); var field = $('#'+field_id);
Expand Down Expand Up @@ -354,7 +363,8 @@ function displayErrors(error_list) {
* @param {boolean} isKeyUp * @param {boolean} isKeyUp
* @param {Object} errors * @param {Object} errors
*/ */
function validate_fieldset(fieldset, isKeyUp, errors) { function validate_fieldset(fieldset, isKeyUp, errors)
{
fieldset = $(fieldset); fieldset = $(fieldset);
if (fieldset.length && typeof validators._fieldset[fieldset.attr('id')] != 'undefined') { if (fieldset.length && typeof validators._fieldset[fieldset.attr('id')] != 'undefined') {
var fieldset_errors = validators._fieldset[fieldset.attr('id')].apply(fieldset[0], [isKeyUp]); var fieldset_errors = validators._fieldset[fieldset.attr('id')].apply(fieldset[0], [isKeyUp]);
Expand All @@ -377,7 +387,8 @@ function validate_fieldset(fieldset, isKeyUp, errors) {
* @param {boolean} isKeyUp * @param {boolean} isKeyUp
* @param {Object} errors * @param {Object} errors
*/ */
function validate_field(field, isKeyUp, errors) { function validate_field(field, isKeyUp, errors)
{
field = $(field); field = $(field);
var field_id = field.attr('id'); var field_id = field.attr('id');
errors[field_id] = []; errors[field_id] = [];
Expand All @@ -403,7 +414,8 @@ function validate_field(field, isKeyUp, errors) {
* @param {Element} field * @param {Element} field
* @param {boolean} isKeyUp * @param {boolean} isKeyUp
*/ */
function validate_field_and_fieldset(field, isKeyUp) { function validate_field_and_fieldset(field, isKeyUp)
{
field = $(field); field = $(field);
var errors = {}; var errors = {};
validate_field(field, isKeyUp, errors); validate_field(field, isKeyUp, errors);
Expand All @@ -416,7 +428,8 @@ function validate_field_and_fieldset(field, isKeyUp) {
* *
* @param {Element} field * @param {Element} field
*/ */
function markField(field) { function markField(field)
{
field = $(field); field = $(field);
var type = getFieldType(field); var type = getFieldType(field);
var isDefault = checkFieldDefault(field, type); var isDefault = checkFieldDefault(field, type);
Expand All @@ -433,7 +446,8 @@ function markField(field) {
* @param {Element} field * @param {Element} field
* @param {boolean} display * @param {boolean} display
*/ */
function setRestoreDefaultBtn(field, display) { function setRestoreDefaultBtn(field, display)
{
var el = $(field).closest('td').find('.restore-default img'); var el = $(field).closest('td').find('.restore-default img');
el[display ? 'show' : 'hide'](); el[display ? 'show' : 'hide']();
} }
Expand Down Expand Up @@ -495,7 +509,8 @@ $(function() {
* *
* @param {String} tab_id * @param {String} tab_id
*/ */
function setTab(tab_id) { function setTab(tab_id)
{
$('.tabs a').removeClass('active').filter('[href=' + tab_id + ']').addClass('active'); $('.tabs a').removeClass('active').filter('[href=' + tab_id + ']').addClass('active');
$('.tabs_contents fieldset').hide().filter(tab_id).show(); $('.tabs_contents fieldset').hide().filter(tab_id).show();
location.hash = 'tab_' + tab_id.substr(1); location.hash = 'tab_' + tab_id.substr(1);
Expand Down Expand Up @@ -562,7 +577,8 @@ $(function() {
* *
* @param {String} field_id * @param {String} field_id
*/ */
function restoreField(field_id) { function restoreField(field_id)
{
var field = $('#'+field_id); var field = $('#'+field_id);
if (field.length == 0 || defaultValues[field_id] == undefined) { if (field.length == 0 || defaultValues[field_id] == undefined) {
return; return;
Expand Down
6 changes: 4 additions & 2 deletions js/db_search.js
Expand Up @@ -15,7 +15,8 @@
*/ */


/** Loads the database search results */ /** Loads the database search results */
function loadResult(result_path , table_name , link , ajaxEnable){ function loadResult(result_path , table_name , link , ajaxEnable)
{
$(document).ready(function() { $(document).ready(function() {
if(ajaxEnable) if(ajaxEnable)
{ {
Expand Down Expand Up @@ -43,7 +44,8 @@ function loadResult(result_path , table_name , link , ajaxEnable){
} }


/** Delete the selected search results */ /** Delete the selected search results */
function deleteResult(result_path , msg , ajaxEnable){ function deleteResult(result_path , msg , ajaxEnable)
{
$(document).ready(function() { $(document).ready(function() {
/** Hides the results shown by the browse criteria */ /** Hides the results shown by the browse criteria */
$("#table-info").hide(); $("#table-info").hide();
Expand Down
3 changes: 2 additions & 1 deletion js/db_structure.js
Expand Up @@ -24,7 +24,8 @@
* *
* @param jQuery object $this_anchor * @param jQuery object $this_anchor
*/ */
function PMA_adjustTotals($this_anchor) { function PMA_adjustTotals($this_anchor)
{
var $parent_tr = $this_anchor.closest('tr'); var $parent_tr = $this_anchor.closest('tr');
var $rows_td = $parent_tr.find('.tbl_rows'); var $rows_td = $parent_tr.find('.tbl_rows');
var $size_td = $parent_tr.find('.tbl_size'); var $size_td = $parent_tr.find('.tbl_size');
Expand Down
24 changes: 14 additions & 10 deletions js/export.js
Expand Up @@ -3,7 +3,7 @@
* Functions used in the export tab * Functions used in the export tab
* *
*/ */

/** /**
* Toggles the hiding and showing of each plugin's options * Toggles the hiding and showing of each plugin's options
* according to the currently selected plugin from the dropdown list * according to the currently selected plugin from the dropdown list
Expand All @@ -19,7 +19,7 @@
}); });


/** /**
* Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure * Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure
*/ */
$(document).ready(function() { $(document).ready(function() {
$("input[type='radio'][name$='sql_structure_or_data']").change(function() { $("input[type='radio'][name$='sql_structure_or_data']").change(function() {
Expand Down Expand Up @@ -50,7 +50,8 @@ $(document).ready(function() {
* options * options
*/ */


function toggle_structure_data_opts(pluginName) { function toggle_structure_data_opts(pluginName)
{
var radioFormName = pluginName + "_structure_or_data"; var radioFormName = pluginName + "_structure_or_data";
var dataDiv = "#" + pluginName + "_data"; var dataDiv = "#" + pluginName + "_data";
var structureDiv = "#" + pluginName + "_structure"; var structureDiv = "#" + pluginName + "_structure";
Expand Down Expand Up @@ -89,7 +90,8 @@ $(document).ready(function() {
/** /**
* Toggles the disabling of the "save to file" options * Toggles the disabling of the "save to file" options
*/ */
function toggle_save_to_file() { function toggle_save_to_file()
{
if($("#radio_dump_asfile:checked").length == 0) { if($("#radio_dump_asfile:checked").length == 0) {
$("#ul_save_asfile > li").fadeTo('fast', 0.4); $("#ul_save_asfile > li").fadeTo('fast', 0.4);
$("#ul_save_asfile > li > input").attr('disabled', 'disabled'); $("#ul_save_asfile > li > input").attr('disabled', 'disabled');
Expand All @@ -111,7 +113,8 @@ $(document).ready(function() {
/** /**
* For SQL plugin, toggles the disabling of the "display comments" options * For SQL plugin, toggles the disabling of the "display comments" options
*/ */
function toggle_sql_include_comments() { function toggle_sql_include_comments()
{
$("#checkbox_sql_include_comments").change(function() { $("#checkbox_sql_include_comments").change(function() {
if($("#checkbox_sql_include_comments:checked").length == 0) { if($("#checkbox_sql_include_comments:checked").length == 0) {
$("#ul_include_comments > li").fadeTo('fast', 0.4); $("#ul_include_comments > li").fadeTo('fast', 0.4);
Expand All @@ -130,8 +133,8 @@ function toggle_sql_include_comments() {
} }


/** /**
* For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options * For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options
*/ */
$(document).ready(function() { $(document).ready(function() {
$("#checkbox_sql_create_table_statements").change(function() { $("#checkbox_sql_create_table_statements").change(function() {
if($("#checkbox_sql_create_table_statements:checked").length == 0) { if($("#checkbox_sql_create_table_statements:checked").length == 0) {
Expand All @@ -144,7 +147,7 @@ $(document).ready(function() {
}); });
}); });


/** /**
* Disables the view output as text option if the output must be saved as a file * Disables the view output as text option if the output must be saved as a file
*/ */
$(document).ready(function() { $(document).ready(function() {
Expand All @@ -164,7 +167,8 @@ $(document).ready(function() {
/** /**
* Toggles display of options when quick and custom export are selected * Toggles display of options when quick and custom export are selected
*/ */
function toggle_quick_or_custom() { function toggle_quick_or_custom()
{
if($("$(this):checked").attr("value") == "custom") { if($("$(this):checked").attr("value") == "custom") {
$("#databases_and_tables").show(); $("#databases_and_tables").show();
$("#rows").show(); $("#rows").show();
Expand Down Expand Up @@ -222,4 +226,4 @@ $(document).ready(function() {
$("input[type='text'][name='limit_from']").removeAttr('disabled'); $("input[type='text'][name='limit_from']").removeAttr('disabled');
} }
}); });
}); });

0 comments on commit 1ec0b69

Please sign in to comment.