1 AJAX.registerTeardown("config.js",function(){$("input[id], select[id], textarea[id]").unbind("change").unbind("keyup");$("input[type=button][name=submit_reset]").unbind("click");$("div.tabs_contents").undelegate();$("#import_local_storage, #export_local_storage").unbind("click");$("form.prefs-form").unbind("change").unbind("submit");$("div.click-hide-message").die("click");$("#prefs_autoload").find("a").unbind("click")});AJAX.registerOnload("config.js",function(){$("#topmenu2").find("li.active a").attr("rel","samepage");$("#topmenu2").find("li:not(.active) a").attr("rel","newpage")});var defaultValues={};function getFieldType(b){b=$(b);var a=b.prop("tagName");if(a=="INPUT"){return b.attr("type")}else{if(a=="SELECT"){return"select"}else{if(a=="TEXTAREA"){return"text"}}}return""}function setFieldValue(f,e,d){f=$(f);switch(e){case"text":f.attr("value",(d!=undefined?d:f.attr("defaultValue")));break;case"checkbox":f.attr("checked",(d!=undefined?d:f.attr("defaultChecked")));break;case"select":var a=f.prop("options");var c,b=a.length;if(d==undefined){for(c=0;c<b;c++){a[c].selected=a[c].defaultSelected}}else{for(c=0;c<b;c++){a[c].selected=(d.indexOf(a[c].value)!=-1)}}break}markField(f)}function getFieldValue(f,e){f=$(f);switch(e){case"text":return f.prop("value");case"checkbox":return f.prop("checked");case"select":var b=f.prop("options");var d,c=b.length,a=[];for(d=0;d<c;d++){if(b[d].selected){a.push(b[d].value)}}return a}return null}function getAllValues(){var e=$("fieldset input, fieldset select, fieldset textarea");var a={};var c,d;for(var b=0;b<e.length;b++){c=getFieldType(e[b]);d=getFieldValue(e[b],c);if(typeof d!="undefined"){if(c=="select"){d=d[0]}a[e[b].name]=d}}return a}function checkFieldDefault(f,d){f=$(f);var c=f.attr("id");if(typeof defaultValues[c]=="undefined"){return true}var e=true;var b=getFieldValue(f,d);if(d!="select"){e=b==defaultValues[c]}else{if(b.length!=defaultValues[c].length){e=false}else{for(var a=0;a<b.length;a++){if(b[a]!=defaultValues[c][a]){e=false;break}}}}return e}function getIdPrefix(a){return $(a).attr("id").replace(/[^-]+$/,"")}var validate={};var validators={_regexp_numeric:/^[0-9]+$/,_regexp_pcre_extract:/(.)(.*)\1(.*)?/,validate_positive_number:function(b){if(b&&this.value==""){return true}var a=this.value!="0"&&validators._regexp_numeric.test(this.value);return a?true:PMA_messages.error_nan_p},validate_non_negative_number:function(b){if(b&&this.value==""){return true}var a=validators._regexp_numeric.test(this.value);return a?true:PMA_messages.error_nan_nneg},validate_port_number:function(b){if(this.value==""){return true}var a=validators._regexp_numeric.test(this.value)&&this.value!="0";return a&&this.value<=65535?true:PMA_messages.error_incorrect_port},validate_by_regex:function(a,c){if(a&&this.value==""){return true}var d=c.match(validators._regexp_pcre_extract);var b=this.value.match(new RegExp(d[2],d[3]))!=null;return b?true:PMA_messages.error_invalid_value},validate_upper_bound:function(a,c){var b=parseInt(this.value);if(isNaN(b)){return true}return b<=c?true:$.sprintf(PMA_messages.error_value_lte,c)},_field:{},_fieldset:{}};function validateField(d,b,a,c){if(typeof validators[b]=="undefined"){return}if(typeof validate[d]=="undefined"){validate[d]=[]}validate[d].push([b,c,a])}function getFieldValidators(e,b){var a=e.match(/[^-]+$/)[0];if(typeof validators._field[a]!="undefined"){return[[validators._field[a],null]]}var f=[];if(typeof validate[e]!="undefined"){for(var d=0,c=validate[e].length;d<c;d++){if(b&&!validate[e][d][2]){continue}f.push([validators[validate[e][d][0]],validate[e][d][1]])}}return f}function displayErrors(j){for(var k in j){var h=j[k];var g=$("#"+k);var e=g.attr("tagName")=="FIELDSET";var d=e?g.find("dl.errors"):g.siblings(".inline_errors");h=$.grep(h,function(i){return i!=""});if(!e){var f=(g.attr("type")=="checkbox")?g.parent():g;f[h.length?"addClass":"removeClass"]("field-error")}if(h.length){if(d.length==0){if(e){d=$('<dl class="errors" />');g.find("table").before(d)}else{d=$('<dl class="inline_errors" />');g.closest("td").append(d)}}var c="";for(var b=0,a=h.length;b<a;b++){c+="<dd>"+h[b]+"</dd>"}d.html(c)}else{if(d!==null){d.remove()}}}}function validate_fieldset(a,b,e){a=$(a);if(a.length&&typeof validators._fieldset[a.attr("id")]!="undefined"){var c=validators._fieldset[a.attr("id")].apply(a[0],[b]);for(var d in c){if(typeof e[d]=="undefined"){e[d]=[]}if(typeof c[d]=="string"){c[d]=[c[d]]}$.merge(e[d],c[d])}}}function validate_field(g,b,h){g=$(g);var e=g.attr("id");h[e]=[];var f=getFieldValidators(e,b);for(var d=0;d<f.length;d++){var c=f[d][1]!=null?f[d][1].slice(0):[];c.unshift(b);var a=f[d][0].apply(g[0],c);if(a!==true){if(typeof a=="string"){a=[a]}$.merge(h[e],a)}}}function validate_field_and_fieldset(b,a){b=$(b);var c={};validate_field(b,a,c);validate_fieldset(b.closest("fieldset"),a,c);displayErrors(c)}function markField(d){d=$(d);var b=getFieldType(d);var c=checkFieldDefault(d,b);var a=(b=="checkbox")?d.parent():d;setRestoreDefaultBtn(d,!c);a[c?"removeClass":"addClass"]("custom")}function setRestoreDefaultBtn(c,b){var a=$(c).closest("td").find(".restore-default img");a[b?"show":"hide"]()}AJAX.registerOnload("config.js",function(){var c=$("input[id], select[id], textarea[id]");$("input[id], select[id], textarea[id]").each(function(){markField(this);var f=$(this);f.bind("change",function(){validate_field_and_fieldset(this,false);markField(this)});var e=f.attr("tagName");if(e=="INPUT"&&f.attr("type")=="text"){f.keyup(function(){validate_field_and_fieldset(f,true);markField(f)})}if(e=="TEXTAREA"){f.attr("spellcheck",false)}});var b=$("#check_page_refresh");if(b.length==0||b.val()=="1"){var d={};for(var a=0;a<c.length;a++){validate_field(c[a],false,d)}$("fieldset").each(function(){validate_fieldset(this,false,d)});displayErrors(d)}else{if(b){b.val("1")}}});function setTab(a){$("ul.tabs li").removeClass("active").find("a[href=#"+a+"]").parent().addClass("active");$("div.tabs_contents fieldset").hide().filter("#"+a).show();location.hash="tab_"+a;$("form.config-form input[name=tab_hash]").val(location.hash)}AJAX.registerOnload("config.js",function(){var b=$("ul.tabs");if(!b.length){return}b.find("a").click(function(d){d.preventDefault();setTab($(this).attr("href").substr(1))}).filter(":first").parent().addClass("active");$("div.tabs_contents fieldset").hide().filter(":first").show();var a;var c=function(){if(location.hash!=a){a=location.hash;if(location.hash.match(/^#tab_.+/)&&$("#"+location.hash.substr(5)).length){setTab(location.hash.substr(5))}}};c();setInterval(c,200)});AJAX.registerOnload("config.js",function(){$("input[type=button][name=submit_reset]").click(function(){var a=$(this).closest("fieldset").find("input, select, textarea");for(var c=0,b=a.length;c<b;c++){setFieldValue(a[c],getFieldType(a[c]))}})});function restoreField(a){var b=$("#"+a);if(b.length==0||defaultValues[a]==undefined){return}setFieldValue(b,getFieldType(b),defaultValues[a])}AJAX.registerOnload("config.js",function(){$("div.tabs_contents").delegate(".restore-default, .set-value","mouseenter",function(){$(this).css("opacity",1)}).delegate(".restore-default, .set-value","mouseleave",function(){$(this).css("opacity",0.25)}).delegate(".restore-default, .set-value","click",function(d){d.preventDefault();var a=$(this).attr("href");var c;if($(this).hasClass("restore-default")){c=a;restoreField(c.substr(1))}else{c=a.match(/^[^=]+/)[0];var b=a.match(/=(.+)$/)[1];setFieldValue($(c),"text",b)}$(c).trigger("change")}).find(".restore-default, .set-value").css({display:"inline-block",opacity:0.25})});AJAX.registerOnload("config.js",function(){offerPrefsAutoimport();var c=$("#import_local_storage, #export_local_storage");if(!c.length){return}c.prop("disabled",false).add("#export_text_file, #import_text_file").click(function(){var d=$(this).attr("id");var e=d.match(/local_storage$/)?d.replace(/local_storage$/,"text_file"):d.replace(/text_file$/,"local_storage");$("#opts_"+e).addClass("disabled").find("input").prop("disabled",true);$("#opts_"+d).removeClass("disabled").find("input").prop("disabled",false)});var b=window.localStorage||false;var a=b?(window.localStorage.config||false):false;$("div.localStorage-"+(b?"un":"")+"supported").hide();$("div.localStorage-"+(a?"empty":"exists")).hide();if(a){updatePrefsDate()}$("form.prefs-form").change(function(){var e=$(this);var d=false;if(!b){d=e.find("input[type=radio][value$=local_storage]").prop("checked")}else{if(!a&&e.attr("name")=="prefs_import"&&$("#import_local_storage")[0].checked){d=true}}e.find("input[type=submit]").prop("disabled",d)}).submit(function(f){var d=$(this);if(d.attr("name")=="prefs_export"&&$("#export_local_storage")[0].checked){f.preventDefault();savePrefsToLocalStorage(d)}else{if(d.attr("name")=="prefs_import"&&$("#import_local_storage")[0].checked){d.find("input[name=json]").val(window.localStorage.config)}}});$("div.click-hide-message").live("click",function(){$(this).hide().parent(".group").css("height","").next("form").show()})});function savePrefsToLocalStorage(a){a=$(a);var b=a.find("input[type=submit]");b.prop("disabled",true);$.ajax({url:"prefs_manage.php",cache:false,type:"POST",data:{ajax_request:true,token:a.find("input[name=token]").val(),submit_get_json:true},success:function(c){window.localStorage.config=c.prefs;window.localStorage.config_mtime=c.mtime;window.localStorage.config_mtime_local=(new Date()).toUTCString();updatePrefsDate();$("div.localStorage-empty").hide();$("div.localStorage-exists").show();var d=a.parent(".group");d.css("height",d.height()+"px");a.hide("fast");a.prev(".click-hide-message").show("fast")},complete:function(){b.prop("disabled",false)}})}function updatePrefsDate(){var b=new Date(window.localStorage.config_mtime_local);var a=PMA_messages.strSavedOn.replace("@DATE@",formatDate(b));$("#opts_import_local_storage div.localStorage-exists").html(a)}function formatDate(a){return a.getFullYear()+"-"+(a.getMonth()<10?"0"+a.getMonth():a.getMonth())+"-"+(a.getDate()<10?"0"+a.getDate():a.getDate())+" "+(a.getHours()<10?"0"+a.getHours():a.getHours())+":"+(a.getMinutes()<10?"0"+a.getMinutes():a.getMinutes())}function offerPrefsAutoimport(){var b=(window.localStorage||false)&&(window.localStorage.config||false);var a=$("#prefs_autoload");if(!a.length||!b){return}a.find("a").click(function(d){d.preventDefault();var c=$(this);if(c.attr("href")=="#no"){a.remove();$.post("index.php",{token:a.find("input[name=token]").val(),prefs_autoload:"hide"});return}a.find("input[name=json]").val(window.localStorage.config);a.find("form").submit()});a.show()};