﻿$.fn.serializeJson = function(){var s = [];$(this).each(function(){if(this.type == "checkbox")s.push("\"" + this.name + "\" : " + this.checked);else if(this.type == "radio" && !this.checked)return;else if(this.type == "select-multiple")$('option:selected', this).each(function(){s.push("\"" + this.name + "\" : \"" + $.trim(this.value.replace(/\"/g,"\\\"")) + "\"");});else s.push("\"" + this.name + "\" : \"" + $.trim(this.value.replace(/\\/g,"\\\\").replace(/\"/g,"\\\"")) + "\"");});return "{ " + s.join(", ") + " }";};$.fn.deserializeJson = function(json){var s = [];$(this).each(function(){if(this.type == "checkbox")this.checked = json[this.name];else if(this.type == "radio")this.checked = (json[this.name] == this.value);else if(this.type == "select-one" && $(this).attr("editable")){var isExit = false;obj = this;$("option", this).each(function(){if($.trim(this.value) == $.trim(json[obj.name]))isExit = true});if(!isExit){$(this).prepend("<option value=\"" + $.trim(json[this.name]) + "\" selected>" + $.trim(json[this.name]) + "</option>");document.onkeydown = function(){var k = event.keyCode;if((event.ctrlKey == true && k == 82) || (k == 116) || (event.ctrlKey == true && k == 116)){event.keyCode = 0;event.returnValue = false;event.cancelBubble = true;}};document.oncontextmenu = function(){return false};}this.value = $.trim(json[this.name]);}else if(this.type == "select-multiple")$("option", this).each(function(){if($.trim(json[this.name]) == $.trim(this.value)){this.selected = true}});else this.value = $.trim(json[this.name].toString());});};$.text = function(rs){return ($.browser.msie ? rs.text : rs.documentElement.textContent);};