Remove some of the duplicate files for code cleanup.
Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
This commit is contained in:
parent
b5824ef13e
commit
fd4e5f0c54
@ -1,14 +0,0 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Conditionally included if framing is not allowed
|
||||
*/
|
||||
if (self === top) {
|
||||
var style_element = document.getElementById('cfs-style');
|
||||
// check if style_element has already been removed
|
||||
// to avoid frequently reported js error
|
||||
if (typeof(style_element) !== 'undefined' && style_element !== null) {
|
||||
style_element.parentNode.removeChild(style_element);
|
||||
}
|
||||
} else {
|
||||
top.location = self.location;
|
||||
}
|
||||
@ -1,393 +0,0 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/* This script handles PMA Drag Drop Import, loaded only when configuration is enabled.*/
|
||||
|
||||
/**
|
||||
* Class to handle PMA Drag and Drop Import
|
||||
* feature
|
||||
*/
|
||||
PMA_DROP_IMPORT = {
|
||||
/**
|
||||
* @var int, count of total uploads in this view
|
||||
*/
|
||||
uploadCount: 0,
|
||||
/**
|
||||
* @var int, count of live uploads
|
||||
*/
|
||||
liveUploadCount: 0,
|
||||
/**
|
||||
* @var string array, allowed extensions
|
||||
*/
|
||||
allowedExtensions: ['sql', 'xml', 'ldi', 'mediawiki', 'shp'],
|
||||
/**
|
||||
* @var string array, allowed extensions for compressed files
|
||||
*/
|
||||
allowedCompressedExtensions: ['gz', 'bz2', 'zip'],
|
||||
/**
|
||||
* @var obj array to store message returned by import_status.php
|
||||
*/
|
||||
importStatus: [],
|
||||
/**
|
||||
* Checks if any dropped file has valid extension or not
|
||||
*
|
||||
* @param file filename
|
||||
*
|
||||
* @return string, extension for valid extension, '' otherwise
|
||||
*/
|
||||
_getExtension: function (file) {
|
||||
var arr = file.split('.');
|
||||
ext = arr[arr.length - 1];
|
||||
|
||||
// check if compressed
|
||||
if (jQuery.inArray(ext.toLowerCase(),
|
||||
PMA_DROP_IMPORT.allowedCompressedExtensions) !== -1) {
|
||||
ext = arr[arr.length - 2];
|
||||
}
|
||||
|
||||
// Now check for extension
|
||||
if (jQuery.inArray(ext.toLowerCase(),
|
||||
PMA_DROP_IMPORT.allowedExtensions) !== -1) {
|
||||
return ext;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
/**
|
||||
* Shows upload progress for different sql uploads
|
||||
*
|
||||
* @param: hash (string), hash for specific file upload
|
||||
* @param: percent (float), file upload percentage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_setProgress: function (hash, percent) {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.children('progress').val(percent);
|
||||
},
|
||||
/**
|
||||
* Function to upload the file asynchronously
|
||||
*
|
||||
* @param formData FormData object for a specific file
|
||||
* @param hash hash of the current file upload
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_sendFileToServer: function (formData, hash) {
|
||||
var uploadURL = './import.php'; // Upload URL
|
||||
var extraData = {};
|
||||
var jqXHR = $.ajax({
|
||||
xhr: function () {
|
||||
var xhrobj = $.ajaxSettings.xhr();
|
||||
if (xhrobj.upload) {
|
||||
xhrobj.upload.addEventListener('progress', function (event) {
|
||||
var percent = 0;
|
||||
var position = event.loaded || event.position;
|
||||
var total = event.total;
|
||||
if (event.lengthComputable) {
|
||||
percent = Math.ceil(position / total * 100);
|
||||
}
|
||||
// Set progress
|
||||
PMA_DROP_IMPORT._setProgress(hash, percent);
|
||||
}, false);
|
||||
}
|
||||
return xhrobj;
|
||||
},
|
||||
url: uploadURL,
|
||||
type: 'POST',
|
||||
contentType:false,
|
||||
processData: false,
|
||||
cache: false,
|
||||
data: formData,
|
||||
success: function (data) {
|
||||
PMA_DROP_IMPORT._importFinished(hash, false, data.success);
|
||||
if (!data.success) {
|
||||
PMA_DROP_IMPORT.importStatus[PMA_DROP_IMPORT.importStatus.length] = {
|
||||
hash: hash,
|
||||
message: data.error
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// -- provide link to cancel the upload
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize').html('<span hash="' +
|
||||
hash + '" class="pma_drop_file_status" task="cancel">' +
|
||||
PMA_messages.dropImportMessageCancel + '</span>');
|
||||
|
||||
// -- add event listener to this link to abort upload operation
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.on('click', function () {
|
||||
if ($(this).attr('task') === 'cancel') {
|
||||
jqXHR.abort();
|
||||
$(this).html('<span>' + PMA_messages.dropImportMessageAborted + '</span>');
|
||||
PMA_DROP_IMPORT._importFinished(hash, true, false);
|
||||
} else if ($(this).children('span').html() ===
|
||||
PMA_messages.dropImportMessageFailed) {
|
||||
// -- view information
|
||||
var $this = $(this);
|
||||
$.each(PMA_DROP_IMPORT.importStatus,
|
||||
function (key, value) {
|
||||
if (value.hash === hash) {
|
||||
$('.pma_drop_result:visible').remove();
|
||||
var filename = $this.parent('span').attr('data-filename');
|
||||
$('body').append('<div class="pma_drop_result"><h2>' +
|
||||
PMA_messages.dropImportImportResultHeader + ' - ' +
|
||||
filename + '<span class="close">x</span></h2>' + value.message + '</div>');
|
||||
$('.pma_drop_result').draggable(); // to make this dialog draggable
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Triggered when an object is dragged into the PMA UI
|
||||
*
|
||||
* @param event obj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_dragenter : function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (!PMA_DROP_IMPORT._hasFiles(event)) {
|
||||
return;
|
||||
}
|
||||
if (PMA_commonParams.get('db') === '') {
|
||||
$('.pma_drop_handler').html(PMA_messages.dropImportSelectDB);
|
||||
} else {
|
||||
$('.pma_drop_handler').html(PMA_messages.dropImportDropFiles);
|
||||
}
|
||||
$('.pma_drop_handler').fadeIn();
|
||||
},
|
||||
/**
|
||||
* Check if dragged element contains Files
|
||||
*
|
||||
* @param event the event object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
_hasFiles: function (event) {
|
||||
return !(typeof event.originalEvent.dataTransfer.types === 'undefined' ||
|
||||
$.inArray('Files', event.originalEvent.dataTransfer.types) < 0 ||
|
||||
$.inArray(
|
||||
'application/x-moz-nativeimage',
|
||||
event.originalEvent.dataTransfer.types
|
||||
) >= 0);
|
||||
},
|
||||
/**
|
||||
* Triggered when dragged file is being dragged over PMA UI
|
||||
*
|
||||
* @param event obj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_dragover: function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (!PMA_DROP_IMPORT._hasFiles(event)) {
|
||||
return;
|
||||
}
|
||||
$('.pma_drop_handler').fadeIn();
|
||||
},
|
||||
/**
|
||||
* Triggered when dragged objects are left
|
||||
*
|
||||
* @param event obj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_dragleave: function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
var $pma_drop_handler = $('.pma_drop_handler');
|
||||
$pma_drop_handler.clearQueue().stop();
|
||||
$pma_drop_handler.fadeOut();
|
||||
$pma_drop_handler.html(PMA_messages.dropImportDropFiles);
|
||||
},
|
||||
/**
|
||||
* Called when upload has finished
|
||||
*
|
||||
* @param string, unique hash for a certain upload
|
||||
* @param bool, true if upload was aborted
|
||||
* @param bool, status of sql upload, as sent by server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_importFinished: function (hash, aborted, status) {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.children('progress').hide();
|
||||
var icon = 'icon ic_s_success';
|
||||
// -- provide link to view upload status
|
||||
if (!aborted) {
|
||||
if (status) {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.html('<span>' + PMA_messages.dropImportMessageSuccess + '</a>');
|
||||
} else {
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.html('<span class="underline">' + PMA_messages.dropImportMessageFailed +
|
||||
'</a>');
|
||||
icon = 'icon ic_s_error';
|
||||
}
|
||||
} else {
|
||||
icon = 'icon ic_s_notice';
|
||||
}
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash +
|
||||
'"] span.filesize span.pma_drop_file_status')
|
||||
.attr('task', 'info');
|
||||
|
||||
// Set icon
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.prepend('<img src="./themes/dot.gif" title="finished" class="' +
|
||||
icon + '"> ');
|
||||
|
||||
// Decrease liveUploadCount by one
|
||||
$('.pma_import_count').html(--PMA_DROP_IMPORT.liveUploadCount);
|
||||
if (!PMA_DROP_IMPORT.liveUploadCount) {
|
||||
$('.pma_sql_import_status h2 .close').fadeIn();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Triggered when dragged objects are dropped to UI
|
||||
* From this function, the AJAX Upload operation is initiated
|
||||
*
|
||||
* @param event object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
_drop: function (event) {
|
||||
// We don't want to prevent users from using
|
||||
// browser's default drag-drop feature on some page(s)
|
||||
if ($('.noDragDrop').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dbname = PMA_commonParams.get('db');
|
||||
var server = PMA_commonParams.get('server');
|
||||
|
||||
// if no database is selected -- no
|
||||
if (dbname !== '') {
|
||||
var files = event.originalEvent.dataTransfer.files;
|
||||
if (!files || files.length === 0) {
|
||||
// No files actually transferred
|
||||
$('.pma_drop_handler').fadeOut();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
$('.pma_sql_import_status').slideDown();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var ext = (PMA_DROP_IMPORT._getExtension(files[i].name));
|
||||
var hash = AJAX.hash(++PMA_DROP_IMPORT.uploadCount);
|
||||
|
||||
var $pma_sql_import_status_div = $('.pma_sql_import_status div');
|
||||
$pma_sql_import_status_div.append('<li data-hash="' + hash + '">' +
|
||||
((ext !== '') ? '' : '<img src="./themes/dot.gif" title="invalid format" class="icon ic_s_notice"> ') +
|
||||
escapeHtml(files[i].name) + '<span class="filesize" data-filename="' +
|
||||
escapeHtml(files[i].name) + '">' + (files[i].size / 1024).toFixed(2) +
|
||||
' kb</span></li>');
|
||||
|
||||
// scroll the UI to bottom
|
||||
$pma_sql_import_status_div.scrollTop(
|
||||
$pma_sql_import_status_div.scrollTop() + 50
|
||||
); // 50 hardcoded for now
|
||||
|
||||
if (ext !== '') {
|
||||
// Increment liveUploadCount by one
|
||||
$('.pma_import_count').html(++PMA_DROP_IMPORT.liveUploadCount);
|
||||
$('.pma_sql_import_status h2 .close').fadeOut();
|
||||
|
||||
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
|
||||
.append('<br><progress max="100" value="2"></progress>');
|
||||
|
||||
// uploading
|
||||
var fd = new FormData();
|
||||
fd.append('import_file', files[i]);
|
||||
fd.append('noplugin', Math.random().toString(36).substring(2, 12));
|
||||
fd.append('db', dbname);
|
||||
fd.append('server', server);
|
||||
fd.append('token', PMA_commonParams.get('token'));
|
||||
fd.append('import_type', 'database');
|
||||
// todo: method to find the value below
|
||||
fd.append('MAX_FILE_SIZE', '4194304');
|
||||
// todo: method to find the value below
|
||||
fd.append('charset_of_file','utf-8');
|
||||
// todo: method to find the value below
|
||||
fd.append('allow_interrupt', 'yes');
|
||||
fd.append('skip_queries', '0');
|
||||
fd.append('format',ext);
|
||||
fd.append('sql_compatibility','NONE');
|
||||
fd.append('sql_no_auto_value_on_zero','something');
|
||||
fd.append('ajax_request','true');
|
||||
fd.append('hash', hash);
|
||||
|
||||
// init uploading
|
||||
PMA_DROP_IMPORT._sendFileToServer(fd, hash);
|
||||
} else if (!PMA_DROP_IMPORT.liveUploadCount) {
|
||||
$('.pma_sql_import_status h2 .close').fadeIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
$('.pma_drop_handler').fadeOut();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when some user drags, dragover, leave
|
||||
* a file to the PMA UI
|
||||
* @param object Event data
|
||||
* @return void
|
||||
*/
|
||||
$(document).on('dragenter', PMA_DROP_IMPORT._dragenter);
|
||||
$(document).on('dragover', PMA_DROP_IMPORT._dragover);
|
||||
$(document).on('dragleave', '.pma_drop_handler', PMA_DROP_IMPORT._dragleave);
|
||||
|
||||
// when file is dropped to PMA UI
|
||||
$(document).on('drop', 'body', PMA_DROP_IMPORT._drop);
|
||||
|
||||
// minimizing-maximising the sql ajax upload status
|
||||
$(document).on('click', '.pma_sql_import_status h2 .minimize', function () {
|
||||
if ($(this).attr('toggle') === 'off') {
|
||||
$('.pma_sql_import_status div').css('height','270px');
|
||||
$(this).attr('toggle','on');
|
||||
$(this).html('-'); // to minimize
|
||||
} else {
|
||||
$('.pma_sql_import_status div').css('height','0px');
|
||||
$(this).attr('toggle','off');
|
||||
$(this).html('+'); // to maximise
|
||||
}
|
||||
});
|
||||
|
||||
// closing sql ajax upload status
|
||||
$(document).on('click', '.pma_sql_import_status h2 .close', function () {
|
||||
$('.pma_sql_import_status').fadeOut(function () {
|
||||
$('.pma_sql_import_status div').html('');
|
||||
PMA_DROP_IMPORT.importStatus = []; // clear the message array
|
||||
});
|
||||
});
|
||||
|
||||
// Closing the import result box
|
||||
$(document).on('click', '.pma_drop_result h2 .close', function () {
|
||||
$(this).parent('h2').parent('div').remove();
|
||||
});
|
||||
140
js/keyhandler.js
140
js/keyhandler.js
@ -1,140 +0,0 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
// global var that holds: 0- if ctrl key is not pressed 1- if ctrl key is pressed
|
||||
var ctrlKeyHistory = 0;
|
||||
|
||||
/**
|
||||
* Allows moving around inputs/select by Ctrl+arrows
|
||||
*
|
||||
* @param object event data
|
||||
*/
|
||||
function onKeyDownArrowsHandler (e) {
|
||||
e = e || window.event;
|
||||
|
||||
var o = (e.srcElement || e.target);
|
||||
if (!o) {
|
||||
return;
|
||||
}
|
||||
if (o.tagName !== 'TEXTAREA' && o.tagName !== 'INPUT' && o.tagName !== 'SELECT') {
|
||||
return;
|
||||
}
|
||||
if ((e.which !== 17) && (e.which !== 37) && (e.which !== 38) && (e.which !== 39) && (e.which !== 40)) {
|
||||
return;
|
||||
}
|
||||
if (!o.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.type === 'keyup') {
|
||||
if (e.which === 17) {
|
||||
ctrlKeyHistory = 0;
|
||||
}
|
||||
return;
|
||||
} else if (e.type === 'keydown') {
|
||||
if (e.which === 17) {
|
||||
ctrlKeyHistory = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctrlKeyHistory !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
var pos = o.id.split('_');
|
||||
if (pos[0] !== 'field' || typeof pos[2] === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
var x = pos[2];
|
||||
var y = pos[1];
|
||||
|
||||
switch (e.keyCode) {
|
||||
case 38:
|
||||
// up
|
||||
y--;
|
||||
break;
|
||||
case 40:
|
||||
// down
|
||||
y++;
|
||||
break;
|
||||
case 37:
|
||||
// left
|
||||
x--;
|
||||
break;
|
||||
case 39:
|
||||
// right
|
||||
x++;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox/') > -1;
|
||||
|
||||
var id = 'field_' + y + '_' + x;
|
||||
|
||||
var nO = document.getElementById(id);
|
||||
if (! nO) {
|
||||
id = 'field_' + y + '_' + x + '_0';
|
||||
nO = document.getElementById(id);
|
||||
}
|
||||
|
||||
// skip non existent fields
|
||||
if (! nO) {
|
||||
return;
|
||||
}
|
||||
|
||||
// for firefox select tag
|
||||
var lvalue = o.selectedIndex;
|
||||
var nOvalue = nO.selectedIndex;
|
||||
|
||||
nO.focus();
|
||||
|
||||
if (is_firefox) {
|
||||
var ffcheck = 0;
|
||||
var ffversion;
|
||||
for (ffversion = 3 ; ffversion < 25 ; ffversion++) {
|
||||
var is_firefox_v_24 = navigator.userAgent.toLowerCase().indexOf('firefox/' + ffversion) > -1;
|
||||
if (is_firefox_v_24) {
|
||||
ffcheck = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ffcheck === 1) {
|
||||
if (e.which === 38 || e.which === 37) {
|
||||
nOvalue++;
|
||||
} else if (e.which === 40 || e.which === 39) {
|
||||
nOvalue--;
|
||||
}
|
||||
nO.selectedIndex = nOvalue;
|
||||
} else {
|
||||
if (e.which === 38 || e.which === 37) {
|
||||
lvalue++;
|
||||
} else if (e.which === 40 || e.which === 39) {
|
||||
lvalue--;
|
||||
}
|
||||
o.selectedIndex = lvalue;
|
||||
}
|
||||
}
|
||||
|
||||
if (nO.tagName !== 'SELECT') {
|
||||
nO.select();
|
||||
}
|
||||
e.returnValue = false;
|
||||
}
|
||||
|
||||
AJAX.registerTeardown('keyhandler.js', function () {
|
||||
$(document).off('keydown keyup', '#table_columns');
|
||||
$(document).off('keydown keyup', 'table.insertRowTable');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('keyhandler.js', function () {
|
||||
$(document).on('keydown keyup', '#table_columns', function (event) {
|
||||
onKeyDownArrowsHandler(event.originalEvent);
|
||||
});
|
||||
$(document).on('keydown keyup', 'table.insertRowTable', function (event) {
|
||||
onKeyDownArrowsHandler(event.originalEvent);
|
||||
});
|
||||
});
|
||||
@ -1,84 +0,0 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* @fileoverview Implements the shiftkey + click remove column
|
||||
* from order by clause funcationality
|
||||
* @name columndelete
|
||||
*
|
||||
* @requires jQuery
|
||||
*/
|
||||
|
||||
function captureURL (url) {
|
||||
var URL = {};
|
||||
url = '' + url;
|
||||
// Exclude the url part till HTTP
|
||||
url = url.substr(url.search('sql.php'), url.length);
|
||||
// The url part between ORDER BY and &session_max_rows needs to be replaced.
|
||||
URL.head = url.substr(0, url.indexOf('ORDER+BY') + 9);
|
||||
URL.tail = url.substr(url.indexOf('&session_max_rows'), url.length);
|
||||
return URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for navigating to the generated URL
|
||||
*
|
||||
* @param object target HTMLAnchor element
|
||||
* @param object parent HTMLDom Object
|
||||
*/
|
||||
|
||||
function removeColumnFromMultiSort (target, parent) {
|
||||
var URL = captureURL(target);
|
||||
var begin = target.indexOf('ORDER+BY') + 8;
|
||||
var end = target.indexOf(PMA_commonParams.get('arg_separator') + 'session_max_rows');
|
||||
// get the names of the columns involved
|
||||
var between_part = target.substr(begin, end - begin);
|
||||
var columns = between_part.split('%2C+');
|
||||
// If the given column is not part of the order clause exit from this function
|
||||
var index = parent.find('small').length ? parent.find('small').text() : '';
|
||||
if (index === '') {
|
||||
return '';
|
||||
}
|
||||
// Remove the current clicked column
|
||||
columns.splice(index - 1, 1);
|
||||
// If all the columns have been removed dont submit a query with nothing
|
||||
// After order by clause.
|
||||
if (columns.length === 0) {
|
||||
var head = URL.head;
|
||||
head = head.slice(0,head.indexOf('ORDER+BY'));
|
||||
URL.head = head;
|
||||
// removing the last sort order should have priority over what
|
||||
// is remembered via the RememberSorting directive
|
||||
URL.tail += PMA_commonParams.get('arg_separator') + 'discard_remembered_sort=1';
|
||||
}
|
||||
URL.head = URL.head.substring(URL.head.indexOf('?') + 1);
|
||||
var middle_part = columns.join('%2C+');
|
||||
params = URL.head + middle_part + URL.tail;
|
||||
return params;
|
||||
}
|
||||
|
||||
AJAX.registerOnload('keyhandler.js', function () {
|
||||
$('th.draggable.column_heading.pointer.marker a').on('click', function (event) {
|
||||
var url = $(this).parent().find('input').val();
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
if (event.ctrlKey || event.altKey) {
|
||||
event.preventDefault();
|
||||
var params = removeColumnFromMultiSort(url, $(this).parent());
|
||||
if (params) {
|
||||
AJAX.source = $(this);
|
||||
PMA_ajaxShowMessage();
|
||||
params += argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true';
|
||||
$.post('sql.php', params, AJAX.responseHandler);
|
||||
}
|
||||
} else if (event.shiftKey) {
|
||||
event.preventDefault();
|
||||
AJAX.source = $(this);
|
||||
PMA_ajaxShowMessage();
|
||||
var params = url.substring(url.indexOf('?') + 1);
|
||||
params += argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true';
|
||||
$.post('sql.php', params, AJAX.responseHandler);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
AJAX.registerTeardown('keyhandler.js', function () {
|
||||
$(document).off('click', 'th.draggable.column_heading.pointer.marker a');
|
||||
});
|
||||
@ -1,729 +0,0 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* @fileoverview events handling from normalization page
|
||||
* @name normalization
|
||||
*
|
||||
* @requires jQuery
|
||||
*/
|
||||
|
||||
/**
|
||||
* AJAX scripts for normalization.php
|
||||
*
|
||||
*/
|
||||
|
||||
var normalizeto = '1nf';
|
||||
var primary_key;
|
||||
var data_parsed = null;
|
||||
function appendHtmlColumnsList () {
|
||||
$.get(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'getColumns': true
|
||||
},
|
||||
function (data) {
|
||||
if (data.success === true) {
|
||||
$('select[name=makeAtomic]').html(data.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
function goTo3NFStep1 (newTables) {
|
||||
if (Object.keys(newTables).length === 1) {
|
||||
newTables = [PMA_commonParams.get('table')];
|
||||
}
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'tables': newTables,
|
||||
'step': '3.1'
|
||||
}, function (data) {
|
||||
$('#page_content').find('h3').html(PMA_messages.str3NFNormalization);
|
||||
$('#mainContent').find('legend').html(data.legendText);
|
||||
$('#mainContent').find('h4').html(data.headText);
|
||||
$('#mainContent').find('p').html(data.subText);
|
||||
$('#mainContent').find('#extra').html(data.extra);
|
||||
$('#extra').find('form').each(function () {
|
||||
var form_id = $(this).attr('id');
|
||||
var colname = $(this).data('colname');
|
||||
$('#' + form_id + ' input[value=\'' + colname + '\']').next().remove();
|
||||
$('#' + form_id + ' input[value=\'' + colname + '\']').remove();
|
||||
});
|
||||
$('#mainContent').find('#newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
|
||||
if (data.subText !== '') {
|
||||
$('<input/>')
|
||||
.attr({ type: 'button', value: PMA_messages.strDone })
|
||||
.on('click', function () {
|
||||
processDependencies('', true);
|
||||
})
|
||||
.appendTo('.tblFooters');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
function goTo2NFStep1 () {
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'step': '2.1'
|
||||
}, function (data) {
|
||||
$('#page_content h3').html(PMA_messages.str2NFNormalization);
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
$('#mainContent h4').html(data.headText);
|
||||
$('#mainContent p').html(data.subText);
|
||||
$('#mainContent #extra').html(data.extra);
|
||||
$('#mainContent #newCols').html('');
|
||||
if (data.subText !== '') {
|
||||
var doneButton = $('<input />')
|
||||
.attr({ type: 'submit', value: PMA_messages.strDone, })
|
||||
.on('click', function () {
|
||||
processDependencies(data.primary_key);
|
||||
})
|
||||
.appendTo('.tblFooters');
|
||||
} else {
|
||||
if (normalizeto === '3nf') {
|
||||
$('#mainContent #newCols').html(PMA_messages.strToNextStep);
|
||||
setTimeout(function () {
|
||||
goTo3NFStep1([PMA_commonParams.get('table')]);
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function goToFinish1NF () {
|
||||
if (normalizeto !== '1nf') {
|
||||
goTo2NFStep1();
|
||||
return true;
|
||||
}
|
||||
$('#mainContent legend').html(PMA_messages.strEndStep);
|
||||
$('#mainContent h4').html(
|
||||
'<h3>' + PMA_sprintf(PMA_messages.strFinishMsg, escapeHtml(PMA_commonParams.get('table'))) + '</h3>'
|
||||
);
|
||||
$('#mainContent p').html('');
|
||||
$('#mainContent #extra').html('');
|
||||
$('#mainContent #newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
}
|
||||
|
||||
function goToStep4 () {
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'step4': true
|
||||
}, function (data) {
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
$('#mainContent h4').html(data.headText);
|
||||
$('#mainContent p').html(data.subText);
|
||||
$('#mainContent #extra').html(data.extra);
|
||||
$('#mainContent #newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
for (var pk in primary_key) {
|
||||
$('#extra input[value=\'' + escapeJsString(primary_key[pk]) + '\']').attr('disabled','disabled');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function goToStep3 () {
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'step3': true
|
||||
}, function (data) {
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
$('#mainContent h4').html(data.headText);
|
||||
$('#mainContent p').html(data.subText);
|
||||
$('#mainContent #extra').html(data.extra);
|
||||
$('#mainContent #newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
primary_key = JSON.parse(data.primary_key);
|
||||
for (var pk in primary_key) {
|
||||
$('#extra input[value=\'' + escapeJsString(primary_key[pk]) + '\']').attr('disabled','disabled');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function goToStep2 (extra) {
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'step2': true
|
||||
}, function (data) {
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
$('#mainContent h4').html(data.headText);
|
||||
$('#mainContent p').html(data.subText);
|
||||
$('#mainContent #extra,#mainContent #newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
if (data.hasPrimaryKey === '1') {
|
||||
if (extra === 'goToStep3') {
|
||||
$('#mainContent h4').html(PMA_messages.strPrimaryKeyAdded);
|
||||
$('#mainContent p').html(PMA_messages.strToNextStep);
|
||||
}
|
||||
if (extra === 'goToFinish1NF') {
|
||||
goToFinish1NF();
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
goToStep3();
|
||||
}, 3000);
|
||||
}
|
||||
} else {
|
||||
// form to select columns to make primary
|
||||
$('#mainContent #extra').html(data.extra);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function goTo2NFFinish (pd) {
|
||||
var tables = {};
|
||||
for (var dependson in pd) {
|
||||
tables[dependson] = $('#extra input[name="' + dependson + '"]').val();
|
||||
}
|
||||
datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'pd': JSON.stringify(pd),
|
||||
'newTablesName':JSON.stringify(tables),
|
||||
'createNewTables2NF':1 };
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'normalization.php',
|
||||
data: datastring,
|
||||
async:false,
|
||||
success: function (data) {
|
||||
if (data.success === true) {
|
||||
if (data.queryError === false) {
|
||||
if (normalizeto === '3nf') {
|
||||
$('#pma_navigation_reload').trigger('click');
|
||||
goTo3NFStep1(tables);
|
||||
return true;
|
||||
}
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
$('#mainContent h4').html(data.headText);
|
||||
$('#mainContent p').html('');
|
||||
$('#mainContent #extra').html('');
|
||||
$('.tblFooters').html('');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.extra, false);
|
||||
}
|
||||
$('#pma_navigation_reload').trigger('click');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function goTo3NFFinish (newTables) {
|
||||
for (var table in newTables) {
|
||||
for (var newtbl in newTables[table]) {
|
||||
var updatedname = $('#extra input[name="' + newtbl + '"]').val();
|
||||
newTables[table][updatedname] = newTables[table][newtbl];
|
||||
if (updatedname !== newtbl) {
|
||||
delete newTables[table][newtbl];
|
||||
}
|
||||
}
|
||||
}
|
||||
datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'newTables':JSON.stringify(newTables),
|
||||
'createNewTables3NF':1 };
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'normalization.php',
|
||||
data: datastring,
|
||||
async:false,
|
||||
success: function (data) {
|
||||
if (data.success === true) {
|
||||
if (data.queryError === false) {
|
||||
$('#mainContent legend').html(data.legendText);
|
||||
$('#mainContent h4').html(data.headText);
|
||||
$('#mainContent p').html('');
|
||||
$('#mainContent #extra').html('');
|
||||
$('.tblFooters').html('');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.extra, false);
|
||||
}
|
||||
$('#pma_navigation_reload').trigger('click');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var backup = '';
|
||||
function goTo2NFStep2 (pd, primary_key) {
|
||||
$('#newCols').html('');
|
||||
$('#mainContent legend').html(PMA_messages.strStep + ' 2.2 ' + PMA_messages.strConfirmPd);
|
||||
$('#mainContent h4').html(PMA_messages.strSelectedPd);
|
||||
$('#mainContent p').html(PMA_messages.strPdHintNote);
|
||||
var extra = '<div class="dependencies_box">';
|
||||
var pdFound = false;
|
||||
for (var dependson in pd) {
|
||||
if (dependson !== primary_key) {
|
||||
pdFound = true;
|
||||
extra += '<p class="displayblock desc">' + escapeHtml(dependson) + ' -> ' + escapeHtml(pd[dependson].toString()) + '</p>';
|
||||
}
|
||||
}
|
||||
if (!pdFound) {
|
||||
extra += '<p class="displayblock desc">' + PMA_messages.strNoPdSelected + '</p>';
|
||||
extra += '</div>';
|
||||
} else {
|
||||
extra += '</div>';
|
||||
datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'pd': JSON.stringify(pd),
|
||||
'getNewTables2NF':1 };
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'normalization.php',
|
||||
data: datastring,
|
||||
async:false,
|
||||
success: function (data) {
|
||||
if (data.success === true) {
|
||||
extra += data.message;
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#mainContent #extra').html(extra);
|
||||
$('.tblFooters').html('<input type="button" value="' + PMA_messages.strBack + '" id="backEditPd"/><input type="button" id="goTo2NFFinish" value="' + PMA_messages.strGo + '"/>');
|
||||
$('#goTo2NFFinish').on('click', function () {
|
||||
goTo2NFFinish(pd);
|
||||
});
|
||||
}
|
||||
|
||||
function goTo3NFStep2 (pd, tablesTds) {
|
||||
$('#newCols').html('');
|
||||
$('#mainContent legend').html(PMA_messages.strStep + ' 3.2 ' + PMA_messages.strConfirmTd);
|
||||
$('#mainContent h4').html(PMA_messages.strSelectedTd);
|
||||
$('#mainContent p').html(PMA_messages.strPdHintNote);
|
||||
var extra = '<div class="dependencies_box">';
|
||||
var pdFound = false;
|
||||
for (var table in tablesTds) {
|
||||
for (var i in tablesTds[table]) {
|
||||
dependson = tablesTds[table][i];
|
||||
if (dependson !== '' && dependson !== table) {
|
||||
pdFound = true;
|
||||
extra += '<p class="displayblock desc">' + escapeHtml(dependson) + ' -> ' + escapeHtml(pd[dependson].toString()) + '</p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!pdFound) {
|
||||
extra += '<p class="displayblock desc">' + PMA_messages.strNoTdSelected + '</p>';
|
||||
extra += '</div>';
|
||||
} else {
|
||||
extra += '</div>';
|
||||
datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'tables': JSON.stringify(tablesTds),
|
||||
'pd': JSON.stringify(pd),
|
||||
'getNewTables3NF':1 };
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'normalization.php',
|
||||
data: datastring,
|
||||
async:false,
|
||||
success: function (data) {
|
||||
data_parsed = data;
|
||||
if (data.success === true) {
|
||||
extra += data_parsed.html;
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#mainContent #extra').html(extra);
|
||||
$('.tblFooters').html('<input type="button" value="' + PMA_messages.strBack + '" id="backEditPd"/><input type="button" id="goTo3NFFinish" value="' + PMA_messages.strGo + '"/>');
|
||||
$('#goTo3NFFinish').on('click', function () {
|
||||
if (!pdFound) {
|
||||
goTo3NFFinish([]);
|
||||
} else {
|
||||
goTo3NFFinish(data_parsed.newTables);
|
||||
}
|
||||
});
|
||||
}
|
||||
function processDependencies (primary_key, isTransitive) {
|
||||
var pd = {};
|
||||
var tablesTds = {};
|
||||
var dependsOn;
|
||||
pd[primary_key] = [];
|
||||
$('#extra form').each(function () {
|
||||
var tblname;
|
||||
if (isTransitive === true) {
|
||||
tblname = $(this).data('tablename');
|
||||
primary_key = tblname;
|
||||
if (!(tblname in tablesTds)) {
|
||||
tablesTds[tblname] = [];
|
||||
}
|
||||
tablesTds[tblname].push(primary_key);
|
||||
}
|
||||
var form_id = $(this).attr('id');
|
||||
$('#' + form_id + ' input[type=checkbox]:not(:checked)').prop('checked', false);
|
||||
dependsOn = '';
|
||||
$('#' + form_id + ' input[type=checkbox]:checked').each(function () {
|
||||
dependsOn += $(this).val() + ', ';
|
||||
$(this).attr('checked','checked');
|
||||
});
|
||||
if (dependsOn === '') {
|
||||
dependsOn = primary_key;
|
||||
} else {
|
||||
dependsOn = dependsOn.slice(0, -2);
|
||||
}
|
||||
if (! (dependsOn in pd)) {
|
||||
pd[dependsOn] = [];
|
||||
}
|
||||
pd[dependsOn].push($(this).data('colname'));
|
||||
if (isTransitive === true) {
|
||||
if (!(tblname in tablesTds)) {
|
||||
tablesTds[tblname] = [];
|
||||
}
|
||||
if ($.inArray(dependsOn, tablesTds[tblname]) === -1) {
|
||||
tablesTds[tblname].push(dependsOn);
|
||||
}
|
||||
}
|
||||
});
|
||||
backup = $('#mainContent').html();
|
||||
if (isTransitive === true) {
|
||||
goTo3NFStep2(pd, tablesTds);
|
||||
} else {
|
||||
goTo2NFStep2(pd, primary_key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function moveRepeatingGroup (repeatingCols) {
|
||||
var newTable = $('input[name=repeatGroupTable]').val();
|
||||
var newColumn = $('input[name=repeatGroupColumn]').val();
|
||||
if (!newTable) {
|
||||
$('input[name=repeatGroupTable]').focus();
|
||||
return false;
|
||||
}
|
||||
if (!newColumn) {
|
||||
$('input[name=repeatGroupColumn]').focus();
|
||||
return false;
|
||||
}
|
||||
datastring = {
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'repeatingColumns': repeatingCols,
|
||||
'newTable':newTable,
|
||||
'newColumn':newColumn,
|
||||
'primary_columns':primary_key.toString()
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'normalization.php',
|
||||
data: datastring,
|
||||
async:false,
|
||||
success: function (data) {
|
||||
if (data.success === true) {
|
||||
if (data.queryError === false) {
|
||||
goToStep3();
|
||||
}
|
||||
PMA_ajaxShowMessage(data.message, false);
|
||||
$('#pma_navigation_reload').trigger('click');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
AJAX.registerTeardown('normalization.js', function () {
|
||||
$('#extra').off('click', '#selectNonAtomicCol');
|
||||
$('#splitGo').off('click');
|
||||
$('.tblFooters').off('click', '#saveSplit');
|
||||
$('#extra').off('click', '#addNewPrimary');
|
||||
$('.tblFooters').off('click', '#saveNewPrimary');
|
||||
$('#extra').off('click', '#removeRedundant');
|
||||
$('#mainContent p').off('click', '#createPrimaryKey');
|
||||
$('#mainContent').off('click', '#backEditPd');
|
||||
$('#mainContent').off('click', '#showPossiblePd');
|
||||
$('#mainContent').off('click', '.pickPd');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('normalization.js', function () {
|
||||
var selectedCol;
|
||||
normalizeto = $('#mainContent').data('normalizeto');
|
||||
$('#extra').on('click', '#selectNonAtomicCol', function () {
|
||||
if ($(this).val() === 'no_such_col') {
|
||||
goToStep2();
|
||||
} else {
|
||||
selectedCol = $(this).val();
|
||||
}
|
||||
});
|
||||
|
||||
$('#splitGo').on('click', function () {
|
||||
if (!selectedCol || selectedCol === '') {
|
||||
return false;
|
||||
}
|
||||
var numField = $('#numField').val();
|
||||
$.get(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'splitColumn': true,
|
||||
'numFields': numField
|
||||
},
|
||||
function (data) {
|
||||
if (data.success === true) {
|
||||
$('#newCols').html(data.message);
|
||||
$('.default_value').hide();
|
||||
$('.enum_notice').hide();
|
||||
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', id: 'saveSplit', value: PMA_messages.strSave })
|
||||
.appendTo('.tblFooters');
|
||||
|
||||
var cancelSplitButton = $('<input />')
|
||||
.attr({ type: 'submit', id: 'cancelSplit', value: PMA_messages.strCancel })
|
||||
.on('click', function () {
|
||||
$('#newCols').html('');
|
||||
$(this).parent().html('');
|
||||
})
|
||||
.appendTo('.tblFooters');
|
||||
}
|
||||
}
|
||||
);
|
||||
return false;
|
||||
});
|
||||
$('.tblFooters').on('click','#saveSplit', function () {
|
||||
central_column_list = [];
|
||||
if ($('#newCols #field_0_1').val() === '') {
|
||||
$('#newCols #field_0_1').focus();
|
||||
return false;
|
||||
}
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
datastring = $('#newCols :input').serialize();
|
||||
datastring += argsep + 'ajax_request=1' + argsep + 'do_save_data=1' + argsep + 'field_where=last';
|
||||
$.post('tbl_addfield.php', datastring, function (data) {
|
||||
if (data.success) {
|
||||
$.post(
|
||||
'sql.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'dropped_column': selectedCol,
|
||||
'purge' : 1,
|
||||
'sql_query': 'ALTER TABLE `' + PMA_commonParams.get('table') + '` DROP `' + selectedCol + '`;',
|
||||
'is_js_confirmed': 1
|
||||
},
|
||||
function (data) {
|
||||
if (data.success === true) {
|
||||
appendHtmlColumnsList();
|
||||
$('#newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
selectedCol = '';
|
||||
}
|
||||
);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#extra').on('click', '#addNewPrimary', function () {
|
||||
$.get(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'addNewPrimary': true
|
||||
},
|
||||
function (data) {
|
||||
if (data.success === true) {
|
||||
$('#newCols').html(data.message);
|
||||
$('.default_value').hide();
|
||||
$('.enum_notice').hide();
|
||||
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', id: 'saveNewPrimary', value: PMA_messages.strSave })
|
||||
.appendTo('.tblFooters');
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', id: 'cancelSplit', value: PMA_messages.strCancel })
|
||||
.on('click', function () {
|
||||
$('#newCols').html('');
|
||||
$(this).parent().html('');
|
||||
})
|
||||
.appendTo('.tblFooters');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
);
|
||||
return false;
|
||||
});
|
||||
$('.tblFooters').on('click', '#saveNewPrimary', function () {
|
||||
var datastring = $('#newCols :input').serialize();
|
||||
var argsep = PMA_commonParams.get('arg_separator');
|
||||
datastring += argsep + 'field_key[0]=primary_0' + argsep + 'ajax_request=1' + argsep + 'do_save_data=1' + argsep + 'field_where=last';
|
||||
$.post('tbl_addfield.php', datastring, function (data) {
|
||||
if (data.success === true) {
|
||||
$('#mainContent h4').html(PMA_messages.strPrimaryKeyAdded);
|
||||
$('#mainContent p').html(PMA_messages.strToNextStep);
|
||||
$('#mainContent #extra').html('');
|
||||
$('#mainContent #newCols').html('');
|
||||
$('.tblFooters').html('');
|
||||
setTimeout(function () {
|
||||
goToStep3();
|
||||
}, 2000);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#extra').on('click', '#removeRedundant', function () {
|
||||
var dropQuery = 'ALTER TABLE `' + PMA_commonParams.get('table') + '` ';
|
||||
$('#extra input[type=checkbox]:checked').each(function () {
|
||||
dropQuery += 'DROP `' + $(this).val() + '`, ';
|
||||
});
|
||||
dropQuery = dropQuery.slice(0, -2);
|
||||
$.post(
|
||||
'sql.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'sql_query': dropQuery,
|
||||
'is_js_confirmed': 1
|
||||
},
|
||||
function (data) {
|
||||
if (data.success === true) {
|
||||
goToStep2('goToFinish1NF');
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
$('#extra').on('click', '#moveRepeatingGroup', function () {
|
||||
var repeatingCols = '';
|
||||
$('#extra input[type=checkbox]:checked').each(function () {
|
||||
repeatingCols += $(this).val() + ', ';
|
||||
});
|
||||
|
||||
if (repeatingCols !== '') {
|
||||
var newColName = $('#extra input[type=checkbox]:checked:first').val();
|
||||
repeatingCols = repeatingCols.slice(0, -2);
|
||||
var confirmStr = PMA_sprintf(PMA_messages.strMoveRepeatingGroup, escapeHtml(repeatingCols), escapeHtml(PMA_commonParams.get('table')));
|
||||
confirmStr += '<input type="text" name="repeatGroupTable" placeholder="' + PMA_messages.strNewTablePlaceholder + '"/>' +
|
||||
'( ' + escapeHtml(primary_key.toString()) + ', <input type="text" name="repeatGroupColumn" placeholder="' + PMA_messages.strNewColumnPlaceholder + '" value="' + escapeHtml(newColName) + '">)' +
|
||||
'</ol>';
|
||||
$('#newCols').html(confirmStr);
|
||||
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', value: PMA_messages.strCancel })
|
||||
.on('click', function () {
|
||||
$('#newCols').html('');
|
||||
$('#extra input[type=checkbox]').prop('checked', false);
|
||||
})
|
||||
.appendTo('.tblFooters');
|
||||
$('<input />')
|
||||
.attr({ type: 'submit', value: PMA_messages.strGo })
|
||||
.on('click', function () {
|
||||
moveRepeatingGroup(repeatingCols);
|
||||
})
|
||||
.appendTo('.tblFooters');
|
||||
}
|
||||
});
|
||||
$('#mainContent p').on('click', '#createPrimaryKey', function (event) {
|
||||
event.preventDefault();
|
||||
var url = { create_index: 1,
|
||||
server: PMA_commonParams.get('server'),
|
||||
db: PMA_commonParams.get('db'),
|
||||
table: PMA_commonParams.get('table'),
|
||||
added_fields: 1,
|
||||
add_fields:1,
|
||||
index: { Key_name:'PRIMARY' },
|
||||
ajax_request: true
|
||||
};
|
||||
var title = PMA_messages.strAddPrimaryKey;
|
||||
indexEditorDialog(url, title, function () {
|
||||
// on success
|
||||
$('.sqlqueryresults').remove();
|
||||
$('.result_query').remove();
|
||||
$('.tblFooters').html('');
|
||||
goToStep2('goToStep3');
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$('#mainContent').on('click', '#backEditPd', function () {
|
||||
$('#mainContent').html(backup);
|
||||
});
|
||||
$('#mainContent').on('click', '#showPossiblePd', function () {
|
||||
if ($(this).hasClass('hideList')) {
|
||||
$(this).html('+ ' + PMA_messages.strShowPossiblePd);
|
||||
$(this).removeClass('hideList');
|
||||
$('#newCols').slideToggle('slow');
|
||||
return false;
|
||||
}
|
||||
if ($('#newCols').html() !== '') {
|
||||
$('#showPossiblePd').html('- ' + PMA_messages.strHidePd);
|
||||
$('#showPossiblePd').addClass('hideList');
|
||||
$('#newCols').slideToggle('slow');
|
||||
return false;
|
||||
}
|
||||
$('#newCols').insertAfter('#mainContent h4');
|
||||
$('#newCols').html('<div class="center">' + PMA_messages.strLoading + '<br/>' + PMA_messages.strWaitForPd + '</div>');
|
||||
$.post(
|
||||
'normalization.php',
|
||||
{
|
||||
'ajax_request': true,
|
||||
'db': PMA_commonParams.get('db'),
|
||||
'table': PMA_commonParams.get('table'),
|
||||
'findPdl': true
|
||||
}, function (data) {
|
||||
$('#showPossiblePd').html('- ' + PMA_messages.strHidePd);
|
||||
$('#showPossiblePd').addClass('hideList');
|
||||
$('#newCols').html(data.message);
|
||||
});
|
||||
});
|
||||
$('#mainContent').on('click', '.pickPd', function () {
|
||||
var strColsLeft = $(this).next('.determinants').html();
|
||||
var colsLeft = strColsLeft.split(',');
|
||||
var strColsRight = $(this).next().next().html();
|
||||
var colsRight = strColsRight.split(',');
|
||||
for (var i in colsRight) {
|
||||
$('form[data-colname="' + colsRight[i].trim() + '"] input[type="checkbox"]').prop('checked', false);
|
||||
for (var j in colsLeft) {
|
||||
$('form[data-colname="' + colsRight[i].trim() + '"] input[value="' + colsLeft[j].trim() + '"]').prop('checked', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -1,59 +0,0 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* @fileoverview function used for page-related settings
|
||||
* @name Page-related settings
|
||||
*
|
||||
* @requires jQuery
|
||||
* @requires jQueryUI
|
||||
* @required js/functions.js
|
||||
*/
|
||||
|
||||
function showSettings (selector) {
|
||||
var buttons = {};
|
||||
buttons[PMA_messages.strApply] = function () {
|
||||
$('.config-form').submit();
|
||||
};
|
||||
|
||||
buttons[PMA_messages.strCancel] = function () {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
|
||||
// Keeping a clone to restore in case the user cancels the operation
|
||||
var $clone = $(selector + ' .page_settings').clone(true);
|
||||
$(selector)
|
||||
.dialog({
|
||||
title: PMA_messages.strPageSettings,
|
||||
width: 700,
|
||||
minHeight: 250,
|
||||
modal: true,
|
||||
open: function () {
|
||||
$(this).dialog('option', 'maxHeight', $(window).height() - $(this).offset().top);
|
||||
},
|
||||
close: function () {
|
||||
$(selector + ' .page_settings').replaceWith($clone);
|
||||
},
|
||||
buttons: buttons
|
||||
});
|
||||
}
|
||||
|
||||
function showPageSettings () {
|
||||
showSettings('#page_settings_modal');
|
||||
}
|
||||
|
||||
function showNaviSettings () {
|
||||
showSettings('#pma_navigation_settings');
|
||||
}
|
||||
|
||||
AJAX.registerTeardown('page_settings.js', function () {
|
||||
$('#page_settings_icon').css('display', 'none');
|
||||
$('#page_settings_icon').off('click');
|
||||
$('#pma_navigation_settings_icon').off('click');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('page_settings.js', function () {
|
||||
if ($('#page_settings_modal').length) {
|
||||
$('#page_settings_icon').css('display', 'inline');
|
||||
$('#page_settings_icon').on('click', showPageSettings);
|
||||
}
|
||||
$('#pma_navigation_settings_icon').on('click', showNaviSettings);
|
||||
});
|
||||
@ -1,92 +0,0 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* for server_replication.php
|
||||
*
|
||||
*/
|
||||
|
||||
var random_server_id = Math.floor(Math.random() * 10000000);
|
||||
var conf_prefix = 'server-id=' + random_server_id + '\nlog_bin=mysql-bin\nlog_error=mysql-bin.err\n';
|
||||
|
||||
function update_config () {
|
||||
var conf_ignore = 'binlog_ignore_db=';
|
||||
var conf_do = 'binlog_do_db=';
|
||||
var database_list = '';
|
||||
|
||||
if ($('#db_select option:selected').size() === 0) {
|
||||
$('#rep').text(conf_prefix);
|
||||
} else if ($('#db_type option:selected').val() === 'all') {
|
||||
$('#db_select option:selected').each(function () {
|
||||
database_list += conf_ignore + $(this).val() + '\n';
|
||||
});
|
||||
$('#rep').text(conf_prefix + database_list);
|
||||
} else {
|
||||
$('#db_select option:selected').each(function () {
|
||||
database_list += conf_do + $(this).val() + '\n';
|
||||
});
|
||||
$('#rep').text(conf_prefix + database_list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('replication.js', function () {
|
||||
$('#db_type').off('change');
|
||||
$('#db_select').off('change');
|
||||
$('#master_status_href').off('click');
|
||||
$('#master_slaves_href').off('click');
|
||||
$('#slave_status_href').off('click');
|
||||
$('#slave_control_href').off('click');
|
||||
$('#slave_errormanagement_href').off('click');
|
||||
$('#slave_synchronization_href').off('click');
|
||||
$('#db_reset_href').off('click');
|
||||
$('#db_select_href').off('click');
|
||||
$('#reset_slave').off('click');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('replication.js', function () {
|
||||
$('#rep').text(conf_prefix);
|
||||
$('#db_type').on('change', update_config);
|
||||
$('#db_select').on('change', update_config);
|
||||
|
||||
$('#master_status_href').on('click', function () {
|
||||
$('#replication_master_section').toggle();
|
||||
});
|
||||
$('#master_slaves_href').on('click', function () {
|
||||
$('#replication_slaves_section').toggle();
|
||||
});
|
||||
$('#slave_status_href').on('click', function () {
|
||||
$('#replication_slave_section').toggle();
|
||||
});
|
||||
$('#slave_control_href').on('click', function () {
|
||||
$('#slave_control_gui').toggle();
|
||||
});
|
||||
$('#slave_errormanagement_href').on('click', function () {
|
||||
$('#slave_errormanagement_gui').toggle();
|
||||
});
|
||||
$('#slave_synchronization_href').on('click', function () {
|
||||
$('#slave_synchronization_gui').toggle();
|
||||
});
|
||||
$('#db_reset_href').on('click', function () {
|
||||
$('#db_select option:selected').prop('selected', false);
|
||||
$('#db_select').trigger('change');
|
||||
});
|
||||
$('#db_select_href').on('click', function () {
|
||||
$('#db_select option').prop('selected', true);
|
||||
$('#db_select').trigger('change');
|
||||
});
|
||||
$('#reset_slave').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $anchor = $(this);
|
||||
var question = PMA_messages.strResetSlaveWarning;
|
||||
$anchor.PMA_confirm(question, $anchor.attr('href'), function (url) {
|
||||
PMA_ajaxShowMessage();
|
||||
AJAX.source = $anchor;
|
||||
var params = {
|
||||
'ajax_page_request': true,
|
||||
'ajax_request': true,
|
||||
};
|
||||
$.post(url, params, AJAX.responseHandler);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user