1 function editVariable(link) {
2 var varName = $(link).parent().parent().find('th:first').first().text().replace(/ /g,'_');
3 var mySaveLink = $(saveLink);
4 var myCancelLink = $(cancelLink);
5 var $cell = $(link).parent();
7 $cell.addClass('edit');
9 $cell.find('a.editLink').remove();
11 mySaveLink.click(function() {
12 $.get('server_variables.php?' + url_query,
13 { ajax_request: true, type: 'setval', varName: varName, varValue: $cell.find('input').attr('value') },
15 if(data.success) $cell.html(data.variable);
17 PMA_ajaxShowMessage(data.error);
18 $cell.html($cell.find('span.oldContent').html());
20 $cell.removeClass('edit');
27 myCancelLink.click(function() {
28 $cell.html($cell.find('span.oldContent').html());
29 $cell.removeClass('edit');
34 $.get('server_variables.php?' + url_query,
35 { ajax_request: true, type: 'getval', varName: varName },
37 // hide original content
38 $cell.html('<span class="oldContent" style="display:none;">' + $cell.html() + '</span>');
39 // put edit field and save/cancel link
40 $cell.prepend('<table class="serverVariableEditTable" border="0"><tr><td></td><td style="width:100%;"><input type="text" value="' + data + '"/></td></tr</table>');
41 $cell.find('table td:first').append(mySaveLink);
42 $cell.find('table td:first').append(myCancelLink);
52 var testString = 'abcdefghijklmnopqrstuvwxyz0123456789,ABCEFGHIJKLMOPQRSTUVWXYZ';
57 editLink = '<a href="#" class="editLink" onclick="return editVariable(this);"><img class="icon ic_b_edit" src="themes/dot.gif" alt=""> '+PMA_messages['strEdit']+'</a>';
58 saveLink = '<a href="#" class="saveLink"><img class="icon ic_b_save" src="themes/dot.gif" alt=""> '+PMA_messages['strSave']+'</a> ';
59 cancelLink = '<a href="#" class="cancelLink"><img class="icon ic_b_close" src="themes/dot.gif" alt=""> '+PMA_messages['strCancel']+'</a> ';
66 /* Variable editing */
68 $('table.data tbody tr td:nth-child(2)').hover(
70 // Only add edit element if it is the global value, not session value and not when the element is being edited
71 if($(this).parent().children('th').length > 0 && ! $(this).hasClass('edit'))
72 $(this).prepend(editLink);
75 $(this).find('a.editLink').remove();
80 /*** This code snippet takes care that the table stays readable. It cuts off long strings the table overlaps the window size ***/
81 $('table.data').after($tmpDiv=$('<span>'+testString+'</span>'));
82 charWidth = $tmpDiv.width() / testString.length;
85 $(window).resize(limitTableWidth);
88 function limitTableWidth() {
94 $('table.data').after($tmpTable=$('<table id="testTable" style="width:100%;"><tr><td>'+testString+'</td></tr></table>'));
95 maxTableWidth = $('#testTable').width();
97 charDiff = ($('table.data').width()-maxTableWidth) / charWidth;
99 if($('body').innerWidth() < $('table.data').width()+10 || $('body').innerWidth() > $('table.data').width()+20) {
102 $('table.data tbody tr td:nth-child(2)').each(function() {
103 maxChars=Math.max($(this).text().length,maxChars);
106 // Do not resize smaller if there's only 50 chars displayed already
107 if(charDiff > 0 && maxChars < 50) return;
109 $('table.data tbody tr td:nth-child(2)').each(function() {
110 if((charDiff>0 && $(this).text().length > maxChars-charDiff) || (charDiff<0 && $(this).find('abbr.cutoff').length>0)) {
111 if($(this).find('abbr.cutoff').length > 0)
112 fulltext = $(this).find('abbr.cutoff').attr('title');
114 fulltext = $(this).text();
115 // Do not cut off elements with html in it and hope they are not too long
116 if(fulltext.length != $(this).html().length) return 0;
119 if(fulltext.length < maxChars-charDiff)
120 $(this).html(fulltext);
121 else $(this).html('<abbr class="cutoff" title="'+fulltext+'">'+fulltext.substr(0,maxChars-charDiff-3)+'...</abbr>');
127 // Filter options are invisible for disabled js users
128 $('fieldset#tableFilter').css('display','');
130 $('#filterText').keyup(function(e) {
131 if($(this).val().length==0) textFilter=null;
132 else textFilter = new RegExp("(^| )"+$(this).val().replace(/_/g,' '),'i');
136 function filterVariables() {
141 $('table.filteredData tbody tr').each(function() {
142 firstCell = $(this).children(':first');
144 if(mark_next || textFilter==null || textFilter.exec(firstCell.text())) {
145 // If current row is 'marked', also display next row
146 if($(this).hasClass('marked') && !mark_next)
148 else mark_next=false;
151 $(this).css('display','');
153 $(this).addClass('odd');
154 $(this).removeClass('even');
156 $(this).addClass('even');
157 $(this).removeClass('odd');
160 $(this).css('display','none');