forked from katiaOutayeb/Application-avec-HAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.miranda.min.js
1 lines (1 loc) · 1.89 KB
/
jquery.miranda.min.js
1
$.fn.mirandajs=function(data,options){function mirandaParse(JSON,jsonNode){var HTML_SAIDA="",JSON_NODE=JSON;if(""!=jsonNode&&(JSON_NODE=eval("JSON."+jsonNode)),$.isArray(JSON_NODE))for(var k in JSON_NODE)HTML_SAIDA+=mirandaReplace(JSON_NODE[k]);else HTML_SAIDA+=mirandaReplace(JSON_NODE);HTML_OBJ.html(HTML_SAIDA),0==settings.delay?eval("HTML_OBJ."+settings.effect+"()"):eval("HTML_OBJ."+settings.effect+'("'+settings.delay+'")'),JSON_NODE_INDEX+1<JSON_NODE_TOTAL&&(JSON_NODE_INDEX++,HTML_OBJ=$("#"+settings.containers[JSON_NODE_INDEX]),HTML_BASE=HTML_OBJ.html(),setTimeout(function(){mirandaParse(JSON,settings.jsonNode[JSON_NODE_INDEX])},settings.nodeDelay))}function mirandaReplace(e){var t=HTML_BASE;return keys=$.map(e,function(e,n){t=t.split("[["+n+"]]").join(e)}),t}function mirandaIsURL(e){return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(e)}var settings=$.extend({jsonNode:[""],containers:[this.attr("id")],effect:"show",delay:5e3,ajaxMethod:"GET",postData:{},noCache:!1},options);if($.isArray(settings.jsonNode))if(settings.jsonNode.length==settings.containers.length){var HTML_OBJ=$("#"+settings.containers[0]),HTML_BASE=HTML_OBJ.html(),JSON_NODE_INDEX=0,JSON_NODE_TOTAL=settings.jsonNode.length;if("string"==typeof data){if(settings.noCache){var concatUrl="?";-1!=data.indexOf(concatUrl)&&(concatUrl="&"),data+=concatUrl+"nocache="+$.now()}"GET"==settings.ajaxMethod.toUpperCase()?$.get(data,function(e){mirandaParse(e,settings.jsonNode[JSON_NODE_INDEX])}):$.post(data,settings.postData,function(e){mirandaParse(data=e,settings.jsonNode[JSON_NODE_INDEX])},"json")}else mirandaParse(data,settings.jsonNode[JSON_NODE_INDEX])}else alert("ERRO: The length of jsonNode and containers must be equal.");else alert('ERRO: jsonNode needs to be a array. Ex: ["'+settings.jsonNode+'"]')};