/* vim: set expandtab sw=4 ts=4 sts=4: */ /** * @fileoverview function used in this file builds history tab and generates query. * * @requires jQuery * @requires moves.js * @version $Id$ */ var history_array = []; // Global array to store history objects var select_field = []; // Global array to store informaation for columns which are used in select clause var g_index; var vqb_editor = null; /** * To display details of objects(where,rename,Having,aggregate,groupby,orderby,having) * * @param index index of history_array where change is to be made * **/ function detail (index) { var type = history_array[index].get_type(); var str; if (type === 'Where') { str = 'Where ' + history_array[index].get_column_name() + history_array[index].get_obj().getrelation_operator() + history_array[index].get_obj().getquery(); } if (type === 'Rename') { str = 'Rename ' + history_array[index].get_column_name() + ' To ' + history_array[index].get_obj().getrename_to(); } if (type === 'Aggregate') { str = 'Select ' + history_array[index].get_obj().get_operator() + '( ' + history_array[index].get_column_name() + ' )'; } if (type === 'GroupBy') { str = 'GroupBy ' + history_array[index].get_column_name(); } if (type === 'OrderBy') { str = 'OrderBy ' + history_array[index].get_column_name() + ' ' + history_array[index].get_obj().get_order(); } if (type === 'Having') { str = 'Having '; if (history_array[index].get_obj().get_operator() !== 'None') { str += history_array[index].get_obj().get_operator() + '( ' + history_array[index].get_column_name() + ' )'; str += history_array[index].get_obj().getrelation_operator() + history_array[index].get_obj().getquery(); } else { str = 'Having ' + history_array[index].get_column_name() + history_array[index].get_obj().getrelation_operator() + history_array[index].get_obj().getquery(); } } return str; } /** * Sorts history_array[] first,using table name as the key and then generates the HTML code for history tab, * clubbing all objects of same tables together * This function is called whenever changes are made in history_array[] * * * @param {int} init starting index of unsorted array * @param {int} finit last index of unsorted array * **/ function display (init, finit) { var str; var i; var j; var k; var sto; var temp; // this part sorts the history array based on table name,this is needed for clubbing all object of same name together. for (i = init; i < finit; i++) { sto = history_array[i]; temp = history_array[i].get_tab();// + '.' + history_array[i].get_obj_no(); for Self JOINS for (j = 0; j < i; j++) { if (temp > (history_array[j].get_tab())) {// + '.' + history_array[j].get_obj_no())) { //for Self JOINS for (k = i; k > j; k--) { history_array[k] = history_array[k - 1]; } history_array[j] = sto; break; } } } // this part generates HTML code for history tab.adds delete,edit,and/or and detail features with objects. str = ''; // string to store Html code for history tab for (i = 0; i < history_array.length; i++) { temp = history_array[i].get_tab(); // + '.' + history_array[i].get_obj_no(); for Self JOIN str += '
'; if (history_array[i].get_and_or()) { str += ' | '; } else { str += ''; } str += '' + PMA_getImage('b_sbrowse', PMA_messages.strColumnName) + ' | ' + '' + $('').text(history_array[i].get_column_name()).html() + ' | '; if (history_array[i].get_type() === 'GroupBy' || history_array[i].get_type() === 'OrderBy') { var detailDesc = $('').text(detail(i)).html(); str += ' | ' + PMA_getImage('s_info', detail(i)) + ' | ' + '' + history_array[i].get_type() + ' | ' + '' + PMA_getImage('b_drop', PMA_messages.strDelete) + ' | '; } else { var detailDesc = $('').text(detail(i)).html(); str += '' + PMA_getImage('s_info', detail(i)) + ' | ' + '' + history_array[i].get_type() + ' | ' + '' + PMA_getImage('b_edit', PMA_messages.strEdit) + ' | ' + '' + PMA_getImage('b_drop', PMA_messages.strDelete) + ' | '; } str += '