//-------------------------------- //iCode php framework v3.6.0 //last modified 2014-04-22 //-------------------------------- /*invoke({ * cls:"sample.index", //*require * method:"getContent", //*require * ui:"#divContent", * ui_fadeIn:true, * data:{ * param1:value1, * param2:value2 * }, * progress_msg:"Loading…", * finish:function(result){ * $("div#divMsg").text(result.msg); * } * }); */ var invoke_count = 0; function invoke(instance) { if (instance.progress_msg != null) { progressWithMsg(instance.progress_msg); } var outerHTML = null; if (instance.ui != null) { outerHTML = evalHtml(instance.ui); } var callback = instance.finish; var req = { service:instance.cls, method:instance.method, ui:outerHTML, data:instance.data }; if (instance.async == null) { instance.async = true; } if (instance.display_error == null) { instance.display_error = true; } //counter for invoke invoke_count++; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", async:instance.async, url: getServiceUrl(), data: JSON.stringify(req), dataType: "json", error: function(xhr, ajaxOptions, thrownError) { if (xhr.responseText != "" && instance.display_error) { alert("[" + instance.cls + "." + instance.method + "] \r\nrequest error with message : \r\n------------------------------\r\n" + xhr.responseText); } }, success: function(res) { if (instance.debug) { alert(JSON.stringify(res)); return; } if (res.result != null) { if (res.result.debug != null) { debug(res.result.debug); } } if (res.eval_js != null) { eval(res.eval_js); } if (res.ui != null && instance.ui != null) { if (instance.ui_fadeIn) { $(instance.ui)[0].outerHTML = $(res.ui).hide()[0].outerHTML; //(for ie only) if (navigator.appName == "Microsoft Internet Explorer") { $(instance.ui)[0].outerHTML = $(instance.ui)[0].outerHTML.replace(/(\r|\n)+/ig, ""); } $(instance.ui).fadeIn('slow'); } else { $(instance.ui)[0].outerHTML = res.ui; } } if (callback != null) { callback(res.result); } }, complete: function() { //deduce invoke counter invoke_count--; if (instance.progress_msg != null) { setTimeout(unprogress, 500); } } }); } function evalHtml(html) { //replace value into html $(html).find("input").each(function (){ //value $(this).attr('value',$(this).val()); //checkbox if ($(this).attr('type') == "checkbox") { if (this.checked) { $(this).attr("checked","checked"); $(this)[0].setAttribute("checked", "checked"); } else { $(this).removeAttr("checked"); } } }); $(html).find("textarea").each(function (){ $(this).html($(this).val().replace(/(\r\n|\n|\r)/g, "
")); }); $(html).find("select").each(function (){ val = $(this).val(); $(this).find("option").each(function(){ if ($(this).val() == val) { $(this).attr("selected","selected"); $(this)[0].setAttribute("selected", "selected"); } else { $(this).removeAttr("selected"); } }); }); var outerHTML = $(html)[0].outerHTML; //(for ie only) if (navigator.appName == "Microsoft Internet Explorer") { //option selected outerHTML = outerHTML.replace(/