$m(document).ready(function () { var data={"flag":"true","storename" :"potaway.myshopify.com"}; var messagetiming=null; var messageaftersecond=null; $m.ajax({ data:JSON.stringify(data), url:"https://www.mlveda.com/ShopifyApps/GeoShippingBar/getcountrydetails", method:'post', success: function (data) { var countrymessage = JSON.parse(data); appendData(countrymessage); } }); function appendData(countrymessage){ if(countrymessage.hasOwnProperty("country") && countrymessage.hasOwnProperty("style")){ $m("body").prepend('
'); $m("head").append(""); $m("#countrymsg").css("background-color",countrymessage.style.background); $m("#countrymsg").css("color", countrymessage.style.color); window.textcolor = countrymessage.style.color; $m("#countrymsg").css("font-size",countrymessage.style.textsize+"px"); $m("#countrymsg").css("font-family",countrymessage.style.fontfamily); if(countrymessage.style.effecttype != undefined){ $m(".messagetext").css('visibility','hidden'); } messageaftersecond= parseInt(countrymessage.style.msgafterseconds); var messagedisplaytime =parseInt(countrymessage.style.msgdisplaytime); setTimeout(function(){ $m("#countrymsg").slideDown( function(){ if(countrymessage.style.effecttype != undefined){ $m(".messagetext").css('visibility','visible'); // if(countrymessage.style.effecttype == "normal"){ // $m(".messagetext").css('visibility','visible'); // } if(countrymessage.style.effecttype == "typing"){ typing(); } else if(countrymessage.style.effecttype == "sliding"){ sliding(); } } }) },messageaftersecond*1000); messagetiming = (messagedisplaytime+messageaftersecond)*1000; setTimeout(function() { $m("#countrymsg").slideUp('slow', function(){ $m("#countrymsg").remove(); }); },messagetiming); } } }); function typing() { var elements = $m('.messagetext'); var textarray = []; textarray.push($m('.messagetext').text()); var period = 4000; new TxtType(elements[0], textarray, period); } var TxtType = function (el, toRotate, period) { this.toRotate = toRotate; this.el = el; this.loopNum = 0; this.period = parseInt(period, 10) || 2000; this.txt = ''; this.tick(); this.isDeleting = true; }; TxtType.prototype.tick = function () { var i = this.loopNum % this.toRotate.length; var fullTxt = this.toRotate[i]; if (this.isDeleting) { this.txt = fullTxt.substring(0, this.txt.length - 1); } else { this.txt = fullTxt.substring(0, this.txt.length + 1); } this.el.innerHTML = '' + this.txt + ''; var that = this; var delta = 200 - Math.random() * 100; if (this.isDeleting) { delta /= 2; } if (!this.isDeleting && this.txt === fullTxt) { delta = this.period; this.isDeleting = true; } else if (this.isDeleting && this.txt === '') { this.isDeleting = false; this.loopNum++; delta = 500; } setTimeout(function () { if($m('.messagetext span').text().length == 1){ that.isDeleting = false; } that.tick(); }, delta); $m("").appendTo("head"); }; function sliding(){ var textpixel = $m(".messagetext span").width(); var windowpixel = $m(window).width(); $m('.messagetext').css('margin-right','-'+ (textpixel + windowpixel) +'px'); $m('.messagetext').animate({marginRight: '0px'}, 6000); } mlveda_Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", decode: function(input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = mlveda_Base64._utf8_decode(output); return output; }, _utf8_encode: function(string) { string = string.replace(/\r\n/g, "\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, _utf8_decode: function(utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while (i < utftext.length) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i + 1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } }