Translated using Weblate (Armenian)
[phpmyadmin.git] / js / normalization.js
blob8e008389da54fbe3dac2c69fec3847e4ffb3a328
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * @fileoverview   events handling from normalization page
4  * @name            normalization
5  *
6  * @requires    jQuery
7  */
9 /**
10  * AJAX scripts for normalization.php
11  *
12  */
14 var normalizeto = '1nf';
15 var primary_key;
16 var data_parsed = null;
17 function appendHtmlColumnsList()
19     $.get(
20         "normalization.php",
21         {
22             "token": PMA_commonParams.get('token'),
23             "ajax_request": true,
24             "db": PMA_commonParams.get('db'),
25             "table": PMA_commonParams.get('table'),
26             "getColumns": true
27         },
28         function(data) {
29             if (data.success === true) {
30                 $('select[name=makeAtomic]').html(data.message);
31             }
32         }
33     );
35 function goTo3NFStep1(newTables)
37     if (Object.keys(newTables).length === 1) {
38         newTables = [PMA_commonParams.get('table')];
39     }
40     $.post(
41         "normalization.php",
42         {
43             "token": PMA_commonParams.get('token'),
44             "ajax_request": true,
45             "db": PMA_commonParams.get('db'),
46             "tables": newTables,
47             "step": '3.1'
48         }, function(data) {
49             $("#page_content h3").html(PMA_messages.str3NFNormalization);
50             $("#mainContent legend").html(data.legendText);
51             $("#mainContent h4").html(data.headText);
52             $("#mainContent p").html(data.subText);
53             $("#mainContent #extra").html(data.extra);
54             $("#extra form").each(function() {
55                 var form_id = $(this).attr('id');
56                 var colname = $(this).data('colname');
57                 $("#" + form_id + " input[value='" + colname + "']").next().remove();
58                 $("#" + form_id + " input[value='" + colname + "']").remove();
59             });
60             $("#mainContent #newCols").html('');
61             $('.tblFooters').html('');
62             if (data.subText !== "") {
63                 $('.tblFooters').html('<input type="button" onClick="processDependencies(\'\', true);" value="' + PMA_messages.strDone + '"/>');
64             }
65         }
66     );
68 function goTo2NFStep1() {
69     $.post(
70         "normalization.php",
71         {
72             "token": PMA_commonParams.get('token'),
73             "ajax_request": true,
74             "db": PMA_commonParams.get('db'),
75             "table": PMA_commonParams.get('table'),
76             "step": '2.1'
77         }, function(data) {
78             $("#page_content h3").html(PMA_messages.str2NFNormalization);
79             $("#mainContent legend").html(data.legendText);
80             $("#mainContent h4").html(data.headText);
81             $("#mainContent p").html(data.subText);
82             $("#mainContent #extra").html(data.extra);
83             $("#mainContent #newCols").html('');
84             if (data.subText !== '') {
85                 $('.tblFooters').html('<input type="submit" value="' + PMA_messages.strDone + '" onclick="processDependencies(\'' + data.primary_key + '\');">');
86             } else {
87                 if (normalizeto === '3nf') {
88                     $("#mainContent #newCols").html(PMA_messages.strToNextStep);
89                     setTimeout(function() {
90                         goTo3NFStep1([PMA_commonParams.get('table')]);
91                     }, 3000);
92                 }
93             }
94         });
97 function goToFinish1NF()
99     if (normalizeto !== '1nf') {
100         goTo2NFStep1();
101         return true;
102     }
103     $("#mainContent legend").html(PMA_messages.strEndStep);
104     $("#mainContent h4").html(
105         "<h3>" + PMA_sprintf(PMA_messages.strFinishMsg, PMA_commonParams.get('table')) + "</h3>"
106     );
107     $("#mainContent p").html('');
108     $("#mainContent #extra").html('');
109     $("#mainContent #newCols").html('');
110     $('.tblFooters').html('');
113 function goToStep4()
115     $.post(
116         "normalization.php",
117         {
118             "token": PMA_commonParams.get('token'),
119             "ajax_request": true,
120             "db": PMA_commonParams.get('db'),
121             "table": PMA_commonParams.get('table'),
122             "step4": true
123         }, function(data) {
124             $("#mainContent legend").html(data.legendText);
125             $("#mainContent h4").html(data.headText);
126             $("#mainContent p").html(data.subText);
127             $("#mainContent #extra").html(data.extra);
128             $("#mainContent #newCols").html('');
129             $('.tblFooters').html('');
130             for(var pk in primary_key) {
131                 $("#extra input[value='" + primary_key[pk] + "']").attr("disabled","disabled");
132             }
133         }
134     );
137 function goToStep3()
139     $.post(
140         "normalization.php",
141         {
142             "token": PMA_commonParams.get('token'),
143             "ajax_request": true,
144             "db": PMA_commonParams.get('db'),
145             "table": PMA_commonParams.get('table'),
146             "step3": true
147         }, function(data) {
148             $("#mainContent legend").html(data.legendText);
149             $("#mainContent h4").html(data.headText);
150             $("#mainContent p").html(data.subText);
151             $("#mainContent #extra").html(data.extra);
152             $("#mainContent #newCols").html('');
153             $('.tblFooters').html('');
154             primary_key = $.parseJSON(data.primary_key);
155             for(var pk in primary_key) {
156                 $("#extra input[value='" + primary_key[pk] + "']").attr("disabled","disabled");
157             }
158         }
159     );
162 function goToStep2(extra)
164     $.post(
165         "normalization.php",
166         {
167             "token": PMA_commonParams.get('token'),
168             "ajax_request": true,
169             "db": PMA_commonParams.get('db'),
170             "table": PMA_commonParams.get('table'),
171             "step2": true
172         }, function(data) {
173             $("#mainContent legend").html(data.legendText);
174             $("#mainContent h4").html(data.headText);
175             $("#mainContent p").html(data.subText);
176             $("#mainContent #extra,#mainContent #newCols").html('');
177             $('.tblFooters').html('');
178             if (data.hasPrimaryKey === "1") {
179                 if(extra === 'goToStep3') {
180                     $("#mainContent h4").html(PMA_messages.strPrimaryKeyAdded);
181                     $("#mainContent p").html(PMA_messages.strToNextStep);
182                 }
183                 if(extra === 'goToFinish1NF') {
184                     goToFinish1NF();
185                 } else {
186                     setTimeout(function() {
187                         goToStep3();
188                     }, 3000);
189                 }
190             } else {
191                 //form to select columns to make primary
192                 $("#mainContent #extra").html(data.extra);
193             }
194         }
195     );
198 function goTo2NFFinish(pd)
200     var tables = {};
201     for (var dependson in pd) {
202         tables[dependson] = $('#extra input[name="' + dependson + '"]').val();
203     }
204     datastring = {"token": PMA_commonParams.get('token'),
205             "ajax_request": true,
206             "db": PMA_commonParams.get('db'),
207             "table": PMA_commonParams.get('table'),
208             "pd": JSON.stringify(pd),
209             "newTablesName":JSON.stringify(tables),
210             "createNewTables2NF":1};
211     $.ajax({
212             type: "GET",
213             url: "normalization.php",
214             data: datastring,
215             async:false,
216             success: function(data) {
217                 if (data.success === true) {
218                     if(data.queryError === false) {
219                         if (normalizeto === '3nf') {
220                             $("#pma_navigation_reload").click();
221                             goTo3NFStep1(tables);
222                             return true;
223                         }
224                         $("#mainContent legend").html(data.legendText);
225                         $("#mainContent h4").html(data.headText);
226                         $("#mainContent p").html('');
227                         $("#mainContent #extra").html('');
228                         $('.tblFooters').html('');
229                     } else {
230                         PMA_ajaxShowMessage(data.extra, false);
231                     }
232                     $("#pma_navigation_reload").click();
233                 } else {
234                     PMA_ajaxShowMessage(data.error, false);
235                 }
236             }
237         });
240 function goTo3NFFinish(newTables)
242     for (var table in newTables) {
243         for (var newtbl in newTables[table]) {
244             var updatedname = $('#extra input[name="' + newtbl + '"]').val();
245             newTables[table][updatedname] = newTables[table][newtbl];
246             if (updatedname !== newtbl) {
247                 delete newTables[table][newtbl];
248             }
249         }
250     }
251     datastring = {"token": PMA_commonParams.get('token'),
252             "ajax_request": true,
253             "db": PMA_commonParams.get('db'),
254             "newTables":JSON.stringify(newTables),
255             "createNewTables3NF":1};
256     $.ajax({
257             type: "GET",
258             url: "normalization.php",
259             data: datastring,
260             async:false,
261             success: function(data) {
262                 if (data.success === true) {
263                     if(data.queryError === false) {
264                         $("#mainContent legend").html(data.legendText);
265                         $("#mainContent h4").html(data.headText);
266                         $("#mainContent p").html('');
267                         $("#mainContent #extra").html('');
268                         $('.tblFooters').html('');
269                     } else {
270                         PMA_ajaxShowMessage(data.extra, false);
271                     }
272                     $("#pma_navigation_reload").click();
273                 } else {
274                     PMA_ajaxShowMessage(data.error, false);
275                 }
276             }
277         });
279 var backup = '';
280 function goTo2NFStep2(pd, primary_key)
282     $("#newCols").html('');
283     $("#mainContent legend").html(PMA_messages.strStep + ' 2.2 ' + PMA_messages.strConfirmPd);
284     $("#mainContent h4").html(PMA_messages.strSelectedPd);
285     $("#mainContent p").html(PMA_messages.strPdHintNote);
286     var extra = '<div class="dependencies_box">';
287     var pdFound = false;
288     for (var dependson in pd) {
289         if (dependson !== primary_key) {
290             pdFound = true;
291             extra += '<p class="displayblock desc">' + escapeHtml(dependson) + " -> " + escapeHtml(pd[dependson].toString()) + '</p>';
292         }
293     }
294     if(!pdFound) {
295         extra += '<p class="displayblock desc">' + PMA_messages.strNoPdSelected + '</p>';
296         extra += '</div>';
297     } else {
298         extra += '</div>';
299         datastring = {"token": PMA_commonParams.get('token'),
300             "ajax_request": true,
301             "db": PMA_commonParams.get('db'),
302             "table": PMA_commonParams.get('table'),
303             "pd": JSON.stringify(pd),
304             "getNewTables2NF":1};
305         $.ajax({
306             type: "GET",
307             url: "normalization.php",
308             data: datastring,
309             async:false,
310             success: function(data) {
311                 if (data.success === true) {
312                     extra += data.message;
313                 } else {
314                     PMA_ajaxShowMessage(data.error, false);
315                 }
316             }
317         });
318     }
319     $("#mainContent #extra").html(extra);
320     $('.tblFooters').html('<input type="button" value="' + PMA_messages.strBack + '" id="backEditPd"/><input type="button" id="goTo2NFFinish" value="' + PMA_messages.strGo + '"/>');
321     $("#goTo2NFFinish").click(function(){
322         goTo2NFFinish(pd);
323     });
326 function goTo3NFStep2(pd, tablesTds)
328     $("#newCols").html('');
329     $("#mainContent legend").html(PMA_messages.strStep + ' 3.2 ' + PMA_messages.strConfirmTd);
330     $("#mainContent h4").html(PMA_messages.strSelectedTd);
331     $("#mainContent p").html(PMA_messages.strPdHintNote);
332     var extra = '<div class="dependencies_box">';
333     var pdFound = false;
334     for (var table in tablesTds) {
335         for (var i in tablesTds[table]) {
336             dependson = tablesTds[table][i];
337             if (dependson !== '' && dependson !== table) {
338                 pdFound = true;
339                 extra += '<p class="displayblock desc">' + escapeHtml(dependson) + " -> " + escapeHtml(pd[dependson].toString()) + '</p>';
340             }
341         }
342     }
343     if(!pdFound) {
344         extra += '<p class="displayblock desc">' + PMA_messages.strNoTdSelected + '</p>';
345         extra += '</div>';
346     } else {
347         extra += '</div>';
348         datastring = {"token": PMA_commonParams.get('token'),
349             "ajax_request": true,
350             "db": PMA_commonParams.get('db'),
351             "tables": JSON.stringify(tablesTds),
352             "pd": JSON.stringify(pd),
353             "getNewTables3NF":1};
354         $.ajax({
355             type: "GET",
356             url: "normalization.php",
357             data: datastring,
358             async:false,
359             success: function(data) {
360                 data_parsed = $.parseJSON(data.message);
361                 if (data.success === true) {
362                     extra += data_parsed.html;
363                 } else {
364                     PMA_ajaxShowMessage(data.error, false);
365                 }
366             }
367         });
368     }
369     $("#mainContent #extra").html(extra);
370     $('.tblFooters').html('<input type="button" value="' + PMA_messages.strBack + '" id="backEditPd"/><input type="button" id="goTo3NFFinish" value="' + PMA_messages.strGo + '"/>');
371     $("#goTo3NFFinish").click(function(){
372         if (!pdFound) {
373             goTo3NFFinish([]);
374         } else {
375             goTo3NFFinish(data_parsed.newTables);
376         }
377     });
379 function processDependencies(primary_key, isTransitive)
381     var pd = {};
382     var tablesTds = {};
383     var dependsOn;
384     pd[primary_key] = [];
385     $("#extra form").each(function() {
386         var tblname;
387         if (isTransitive === true) {
388             tblname = $(this).data('tablename');
389             primary_key = tblname;
390             if (!(tblname in tablesTds)) {
391                 tablesTds[tblname] = [];
392             }
393             tablesTds[tblname].push(primary_key);
394         }
395         var form_id = $(this).attr('id');
396         $('#' + form_id + ' input[type=checkbox]:not(:checked)').removeAttr('checked');
397         dependsOn = '';
398         $('#' + form_id + ' input[type=checkbox]:checked').each(function(){
399             dependsOn += $(this).val() + ', ';
400             $(this).attr("checked","checked");
401         });
402         if (dependsOn === '') {
403             dependsOn = primary_key;
404         } else {
405             dependsOn = dependsOn.slice(0, -2);
406         }
407         if (! (dependsOn in pd)) {
408             pd[dependsOn] = [];
409         }
410         pd[dependsOn].push($(this).data('colname'));
411         if (isTransitive === true) {
412             if (!(tblname in tablesTds)) {
413                 tablesTds[tblname] = [];
414             }
415             if ($.inArray(dependsOn, tablesTds[tblname]) === -1) {
416                 tablesTds[tblname].push(dependsOn);
417             }
418         }
419     });
420     backup = $("#mainContent").html();
421     if (isTransitive === true) {
422         goTo3NFStep2(pd, tablesTds);
423     } else {
424         goTo2NFStep2(pd, primary_key);
425     }
426     return false;
429 function moveRepeatingGroup(repeatingCols) {
430     var newTable = $("input[name=repeatGroupTable]").val();
431     var newColumn = $("input[name=repeatGroupColumn]").val();
432     if (!newTable) {
433         $("input[name=repeatGroupTable]").focus();
434         return false;
435     }
436     if (!newColumn) {
437         $("input[name=repeatGroupColumn]").focus();
438         return false;
439     }
440     datastring = {"token": PMA_commonParams.get('token'),
441         "ajax_request": true,
442         "db": PMA_commonParams.get('db'),
443         "table": PMA_commonParams.get('table'),
444         "repeatingColumns": repeatingCols,
445         "newTable":newTable,
446         "newColumn":newColumn,
447         "primary_columns":primary_key.toString()
448     };
449     $.ajax({
450         type: "POST",
451         url: "normalization.php",
452         data: datastring,
453         async:false,
454         success: function(data) {
455             if (data.success === true) {
456                 if(data.queryError === false) {
457                     goToStep3();
458                 }
459                 PMA_ajaxShowMessage(data.message, false);
460                 $("#pma_navigation_reload").click();
461             } else {
462                 PMA_ajaxShowMessage(data.error, false);
463             }
464         }
465     });
467 AJAX.registerTeardown('normalization.js', function () {
468     $("#extra").off("click", "#selectNonAtomicCol");
469     $("#splitGo").unbind('click');
470     $('.tblFooters').off("click", "#saveSplit");
471     $("#extra").off("click", "#addNewPrimary");
472     $(".tblFooters").off("click", "#saveNewPrimary");
473     $("#extra").off("click", "#removeRedundant");
474     $("#mainContent p").off("click", "#createPrimaryKey");
475     $("#mainContent").off("click", "#backEditPd");
476     $("#mainContent").off("click", "#showPossiblePd");
477     $("#mainContent").off("click", ".pickPd");
480 AJAX.registerOnload('normalization.js', function() {
481     var selectedCol;
482     normalizeto = $("#mainContent").data('normalizeto');
483     $("#extra").on("click", "#selectNonAtomicCol", function() {
484         if ($(this).val() === 'no_such_col') {
485             goToStep2();
486         } else {
487             selectedCol = $(this).val();
488         }
489     });
491     $("#splitGo").click(function() {
492         if(!selectedCol || selectedCol === '') {
493             return false;
494         }
495         var numField = $("#numField").val();
496         $.get(
497             "normalization.php",
498             {
499                 "token": PMA_commonParams.get('token'),
500                 "ajax_request": true,
501                 "db": PMA_commonParams.get('db'),
502                 "table": PMA_commonParams.get('table'),
503                 "splitColumn": true,
504                 "numFields": numField
505             },
506         function(data) {
507                 if (data.success === true) {
508                     $('#newCols').html(data.message);
509                     $('.default_value').hide();
510                     $('.enum_notice').hide();
511                     $('.tblFooters').html("<input type='submit' id='saveSplit' value='" + PMA_messages.strSave + "'/>" +
512                         "<input type='submit' id='cancelSplit' value='" + PMA_messages.strCancel + "' " +
513                         "onclick=\"$('#newCols').html('');$(this).parent().html('')\"/>");
514                 }
515             }
516         );
517         return false;
518     });
519     $('.tblFooters').on("click","#saveSplit", function() {
520         central_column_list = [];
521         if ($("#newCols #field_0_1").val() === '') {
522             $("#newCols #field_0_1").focus();
523             return false;
524         }
525         datastring = $('#newCols :input').serialize();
526         datastring += "&ajax_request=1&do_save_data=1&field_where=last";
527         $.post("tbl_addfield.php", datastring, function(data) {
528             if (data.success) {
529                 $.get(
530                     "sql.php",
531                     {
532                         "token": PMA_commonParams.get('token'),
533                         "ajax_request": true,
534                         "db": PMA_commonParams.get('db'),
535                         "table": PMA_commonParams.get('table'),
536                         "dropped_column": selectedCol,
537                         "sql_query": 'ALTER TABLE `' + PMA_commonParams.get('table') + '` DROP `' + selectedCol + '`;',
538                         "is_js_confirmed": 1
539                     },
540                 function(data) {
541                         if (data.success === true) {
542                             appendHtmlColumnsList();
543                             $('#newCols').html('');
544                             $('.tblFooters').html('');
545                         } else {
546                             PMA_ajaxShowMessage(data.error, false);
547                         }
548                         selectedCol = '';
549                     }
550                 );
551             } else {
552                 PMA_ajaxShowMessage(data.error, false);
553             }
554         });
555     });
557     $("#extra").on("click", "#addNewPrimary", function() {
558         $.get(
559             "normalization.php",
560             {
561                 "token": PMA_commonParams.get('token'),
562                 "ajax_request": true,
563                 "db": PMA_commonParams.get('db'),
564                 "table": PMA_commonParams.get('table'),
565                 "addNewPrimary": true
566             },
567         function(data) {
568                 if (data.success === true) {
569                     $('#newCols').html(data.message);
570                     $('.default_value').hide();
571                     $('.enum_notice').hide();
572                     $('.tblFooters').html("<input type='submit' id='saveNewPrimary' value='" + PMA_messages.strSave + "'/>" +
573                         "<input type='submit' id='cancelSplit' value='" + PMA_messages.strCancel + "' " +
574                         "onclick=\"$('#newCols').html('');$(this).parent().html('')\"/>");
575                 } else {
576                     PMA_ajaxShowMessage(data.error, false);
577                 }
578             }
579         );
580         return false;
581     });
582     $(".tblFooters").on("click", "#saveNewPrimary", function() {
583         var datastring = $('#newCols :input').serialize();
584         datastring += "&field_key[0]=primary_0&ajax_request=1&do_save_data=1&field_where=last";
585         $.post("tbl_addfield.php", datastring, function(data) {
586             if (data.success === true) {
587                 $("#mainContent h4").html(PMA_messages.strPrimaryKeyAdded);
588                 $("#mainContent p").html(PMA_messages.strToNextStep);
589                 $("#mainContent #extra").html('');
590                 $("#mainContent #newCols").html('');
591                 $('.tblFooters').html('');
592                 setTimeout(function() {
593                     goToStep3();
594                 }, 2000);
595             } else {
596                 PMA_ajaxShowMessage(data.error, false);
597             }
598         });
599     });
600     $("#extra").on("click", "#removeRedundant", function() {
601         var dropQuery = 'ALTER TABLE `' + PMA_commonParams.get('table') + '` ';
602         $("#extra input[type=checkbox]:checked").each(function() {
603             dropQuery += 'DROP `' + $(this).val() + '`, ';
604         });
605         dropQuery = dropQuery.slice(0, -2);
606         $.get(
607             "sql.php",
608             {
609                 "token": PMA_commonParams.get('token'),
610                 "ajax_request": true,
611                 "db": PMA_commonParams.get('db'),
612                 "table": PMA_commonParams.get('table'),
613                 "sql_query": dropQuery,
614                 "is_js_confirmed": 1
615             },
616         function(data) {
617                 if (data.success === true) {
618                     goToStep2('goToFinish1NF');
619                 } else {
620                     PMA_ajaxShowMessage(data.error, false);
621                 }
622             }
623         );
624     });
625     $("#extra").on("click", "#moveRepeatingGroup", function() {
626         var repeatingCols = '';
627         $("#extra input[type=checkbox]:checked").each(function() {
628             repeatingCols += $(this).val() + ', ';
629         });
631         if (repeatingCols !== '') {
632             var newColName = $("#extra input[type=checkbox]:checked:first").val();
633             repeatingCols = repeatingCols.slice(0, -2);
634             var confirmStr = PMA_sprintf(PMA_messages.strMoveRepeatingGroup, escapeHtml(repeatingCols), escapeHtml(PMA_commonParams.get('table')));
635             confirmStr += '<input type="text" name="repeatGroupTable" placeholder="' + PMA_messages.strNewTablePlaceholder + '"/>' +
636                 '( ' + escapeHtml(primary_key.toString()) + ', <input type="text" name="repeatGroupColumn" placeholder="' + PMA_messages.strNewColumnPlaceholder + '" value="' + escapeHtml(newColName) + '">)' +
637                 '</ol>';
638             $("#newCols").html(confirmStr);
639             $('.tblFooters').html('<input type="submit" value="' + PMA_messages.strCancel + '" onclick="$(\'#newCols\').html(\'\');$(\'#extra input[type=checkbox]\').removeAttr(\'checked\')"/>' +
640                 '<input type="submit" value="' + PMA_messages.strGo + '" onclick="moveRepeatingGroup(\'' + repeatingCols + '\')"/>');
641         }
642     });
643     $("#mainContent p").on("click", "#createPrimaryKey", function(event) {
644         event.preventDefault();
645         var url = { create_index: 1,
646             server:  PMA_commonParams.get('server'),
647             db: PMA_commonParams.get('db'),
648             table: PMA_commonParams.get('table'),
649             token: PMA_commonParams.get('token'),
650             added_fields: 1,
651             add_fields:1,
652             index: {Key_name:'PRIMARY'},
653             ajax_request: true
654         };
655         var title = PMA_messages.strAddPrimaryKey;
656         indexEditorDialog(url, title, function(){
657             //on success
658             $(".sqlqueryresults").remove();
659             $('.result_query').remove();
660             $('.tblFooters').html('');
661             goToStep2('goToStep3');
662         });
663         return false;
664     });
665     $("#mainContent").on("click", "#backEditPd", function(){
666         $("#mainContent").html(backup);
667     });
668     $("#mainContent").on("click", "#showPossiblePd", function(){
669         if($(this).hasClass('hideList')) {
670             $(this).html('+ ' + PMA_messages.strShowPossiblePd);
671             $(this).removeClass('hideList');
672             $("#newCols").slideToggle("slow");
673             return false;
674         }
675         if($("#newCols").html() !== '') {
676             $("#showPossiblePd").html('- ' + PMA_messages.strHidePd);
677             $("#showPossiblePd").addClass('hideList');
678             $("#newCols").slideToggle("slow");
679             return false;
680         }
681         $("#newCols").insertAfter("#mainContent h4");
682         $("#newCols").html('<div class="center">' + PMA_messages.strLoading + '<br/>' + PMA_messages.strWaitForPd + '</div>');
683         $.post(
684         "normalization.php",
685         {
686             "token": PMA_commonParams.get('token'),
687             "ajax_request": true,
688             "db": PMA_commonParams.get('db'),
689             "table": PMA_commonParams.get('table'),
690             "findPdl": true
691         }, function(data) {
692             $("#showPossiblePd").html('- ' + PMA_messages.strHidePd);
693             $("#showPossiblePd").addClass('hideList');
694             $("#newCols").html(data.message);
695         });
696     });
697     $("#mainContent").on("click", ".pickPd", function(){
698         var strColsLeft = $(this).next('.determinants').html();
699         var colsLeft = strColsLeft.split(',');
700         var strColsRight = $(this).next().next().html();
701         var colsRight = strColsRight.split(',');
702         for (var i in colsRight) {
703             $('form[data-colname="' + colsRight[i].trim() + '"] input[type="checkbox"]').prop('checked', false);
704             for (var j in colsLeft) {
705                 $('form[data-colname="' + colsRight[i].trim() + '"] input[value="' + colsLeft[j].trim() + '"]').prop('checked', true);
706             }
707         }
708     });