Advertisement
SalimFadhil

داخل سكربت الاحداثيات

Aug 2nd, 2018
808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.70 KB | None | 0 0
  1.  
  2. // https://www.dropbox.com/s/wif7uglefzs6gf3/Tsalkapone.Πρότυπο_εφαρμογής_πληροφοριών_λογαριασμού.js
  3. // ########################################################################
  4. // IMPORTANT: Version Information !!!
  5. // ########################################################################
  6. (window.main||self).twsfwConfig={
  7. id:'tsalkapone_twconfig',
  8. version:'v0.08'
  9. };
  10. var get_lang = localStorage.getItem("advanced_extractor_lang");
  11. var lang="";
  12. if (get_lang === null) {lang = "arabic";}
  13. else { lang = ""+get_lang+"";}
  14. var supported_languages =["greek","english","arabic"];
  15. var lang_check = supported_languages.indexOf(lang);
  16. if (lang_check < 0) {UI.ErrorMessage('<font color=gold><b><center>'+tsalkapone_trans.general.notification+' Tsalkapone</center></b></font> <br><br> اللغة المحددة غير مدعومة. يرجى اختيار واحدة من اللغات المدعومة.', 5000);}
  17. else {
  18. var tsalkapone_trans = (function() {
  19. var tsalkapone_trans = {};
  20. tsalkapone_trans.english= {
  21. general:{
  22. script:"Advanced Coords-Extractor",
  23. menu:"Menu",
  24. notification:"Notification from",
  25. selected_one:"Current selected language",
  26. available:"Available languages",
  27. button_list:"Functions & Buttons List",
  28. lang_sel:"Click to change the selected language",
  29. message_no:"No",
  30. message_yes:"Yes",
  31. message_1:"This script is activated on Map.",
  32. message_2:" Do you want to automatically assign your location to this page?",
  33. twconfig:"Click to show/hide the configurations' and errors log in case you encounter any bug or error issues",
  34. helpers:"The following text can be used to provide essential data in case you encounter errors or bugs",
  35. help_contact:"If you don't find any scripter you can always seek for assistance from Tsalkapone",
  36. years:"years",
  37. weeks:"weeks",
  38. days:"days",
  39. hours:"hours",
  40. mins:"mins",
  41. },
  42.  
  43. buttons:{
  44. lang_open:"Open language selection",
  45. lang_close:"Close language selection",
  46. set_show:"Show",
  47. set_hide:"Hide",
  48. },
  49.  
  50. notes:{
  51. saved:"The Settings have been successfully saved",
  52. active:"The Advanced Coords-Extractor is already active",
  53. },
  54. };
  55.  
  56. tsalkapone_trans.arabic= {
  57. general:{
  58. script:"مستخرج الاحداثيات",
  59. menu:"القائمة",
  60. notification:"تنبية من",
  61. selected_one:"اللغة المحددة حاليا",
  62. available:"اللغات المتاحه",
  63. button_list:" وظائف & ازرار القائمة",
  64. lang_sel:"انقر هنا لتغير اللغة المحددة",
  65. message_no:"لا",
  66. message_yes:"نعم",
  67. message_1:"السكربت يعمل من الخريطة",
  68. message_2:" هل تريد تعيين موقعك تلقائيًا لهذه الصفحة؟",
  69. twconfig:"انقر لإظهار / إخفاء سجل الإعدادات والأخطاء في حالة مواجهة أي مشكلات في الأخطاء أو الأخطاء",
  70. helpers:"يمكن استخدام النص التالي لتوفير البيانات الأساسية في حالة مواجهة أخطاء أو أخطاء",
  71. help_contact:"في حال حدثت مشكلة تستطيع التواصل مع Tsalkapone",
  72. years:"سنوات",
  73. weeks:"اسابيع",
  74. days:"ايام",
  75. hours:"ساعات",
  76. mins:"دقائق",
  77. },
  78.  
  79. buttons:{
  80. lang_open:"فتح إختيار اللغة",
  81. lang_close:"إغلاق اختيار اللغة",
  82. set_show:"عرض",
  83. set_hide:"إخفاء",
  84. },
  85.  
  86. notes:{
  87. saved:"تم حفظ الاعدادات بنجاح",
  88. active:"تم تفعيل سكربت مستخرج الاحداثيات",
  89. },
  90. };
  91.  
  92.  
  93. tsalkapone_trans.greek= {
  94. general:{
  95. script:"Αναζήτηση Χωριών",
  96. menu:"Μενού",
  97. notification:"Ειδοποίηση από τον",
  98. selected_one:"Ενεργή γλώσσα",
  99. available:"Διαθέσιμες γλώσσες",
  100. button_list:"Πίνακας πλήκτρων και λειτουργιών",
  101. lang_sel:"Επιλέξτε για να αλλάξετε την επιλεγμένη γλώσσα",
  102. message_no:"Όχι",
  103. message_yes:"Ναι",
  104. message_1:"Το συγκεκριμένο script ενεργοποιείται από το Χάρτη.",
  105. message_2:"Επιθυμείτε αυτόματη ανακατεύθυνση;",
  106. twconfig:"Επιλέξτε για εμφάνιση/απόκρυψη σημειώσεων των ρυθμίσεων και αποτελεσμάτων σε περίπτωση που παρατηρήσετε οποιοδήποτε bug ή σφάλμα",
  107. helpers:"Το ακόλουθο κείμενο μπορεί να προωθηθεί σε οποιοδήποτε scripter σε περίπτωση σφάλματος",
  108. help_contact:"Σε περίπτωση που επικοινωνήστε με τον Tsalkapone φροντίστε να του παρέχετε το ακόλουθο κείμενο",
  109. years:"χρόνια",
  110. weeks:"εβδομάδες",
  111. days:"μέρες",
  112. hours:"ώρες",
  113. mins:"λεπτά",
  114. },
  115. buttons:{
  116. lang_open:"Άνοιγμα επιλογής γλώσσας",
  117. lang_close:"Κλείσιμο επιλογής γλώσσας",
  118. set_show:"Εμφάνιση",
  119. set_hide:"Απόκρυψη",
  120. },
  121. notes:{
  122. saved:"Οι Ρυθμίσεις αποθηκεύτηκαν επιτυχώς",
  123. active:"Η Αναζήτηση Χωριών έχει ήδη ενεργοποιηθεί",
  124. },
  125. };
  126. return tsalkapone_trans[lang];
  127. }());
  128. // ########################################################################
  129.  
  130. /*
  131. Authors : Tsalkapone, Dale McKay
  132. Email : tsalkapone@hotmail.com
  133. Purpose : Πρότυπο script για διάφορες χρήσεις στις φυλετικές μάχες
  134. Credit :
  135. Todo :
  136. Notes :
  137.  
  138. ____________________________________________________________
  139.  
  140. Copyright (C) 2011 Dale McKay, all rights reserved
  141. version 1.0, 10 April 2011
  142.  
  143. This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software.
  144.  
  145. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
  146. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  147. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  148. This notice may not be removed or altered from any source distribution.
  149. ____________________________________________________________
  150. */
  151.  
  152.  
  153. /* *************************************** */
  154. // Borrowed plugin for converting XML to JSON
  155. /* *************************************** */
  156. if(!(window.main||self).jQuery.xml2json){
  157. /*
  158. ### jQuery XML to JSON Plugin v1.0 - 2008-07-01 ###
  159. * http://www.fyneworks.com/ - diego@fyneworks.com
  160. * Dual licensed under the MIT and GPL licenses:
  161. * http://www.opensource.org/licenses/mit-license.php
  162. * http://www.gnu.org/licenses/gpl.html
  163. ###
  164. Website: http://www.fyneworks.com/jquery/xml-to-json/
  165. */
  166. eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';5(10.M)(w($){$.N({11:w(j,k){5(!j)t{};w B(d,e){5(!d)t y;6 f=\'\',2=y,E=y;6 g=d.x,12=l(d.O||d.P);6 h=d.v||d.F||\'\';5(d.G){5(d.G.7>0){$.Q(d.G,w(n,a){6 b=a.x,u=l(a.O||a.P);6 c=a.v||a.F||\'\';5(b==8){t}z 5(b==3||b==4||!u){5(c.13(/^\\s+$/)){t};f+=c.H(/^\\s+/,\'\').H(/\\s+$/,\'\')}z{2=2||{};5(2[u]){5(!2[u].7)2[u]=p(2[u]);2[u][2[u].7]=B(a,R);2[u].7=2[u].7}z{2[u]=B(a)}}})}};5(d.I){5(d.I.7>0){E={};2=2||{};$.Q(d.I,w(a,b){6 c=l(b.14),C=b.15;E[c]=C;5(2[c]){5(!2[c].7)2[c]=p(2[c]);2[c][2[c].7]=C;2[c].7=2[c].7}z{2[c]=C}})}};5(2){2=$.N((f!=\'\'?A J(f):{}),2||{});f=(2.v)?(D(2.v)==\'16\'?2.v:[2.v||\'\']).17([f]):f;5(f)2.v=f;f=\'\'};6 i=2||f;5(k){5(f)i={};f=i.v||f||\'\';5(f)i.v=f;5(!e)i=p(i)};t i};6 l=w(s){t J(s||\'\').H(/-/g,"18")};6 m=w(s){t(D s=="19")||J((s&&D s=="K")?s:\'\').1a(/^((-)?([0-9]*)((\\.{0,1})([0-9]+))?$)/)};6 p=w(o){5(!o.7)o=[o];o.7=o.7;t o};5(D j==\'K\')j=$.S(j);5(!j.x)t;5(j.x==3||j.x==4)t j.F;6 q=(j.x==9)?j.1b:j;6 r=B(q,R);j=y;q=y;t r},S:w(a){6 b;T{6 c=($.U.V)?A 1c("1d.1e"):A 1f();c.1g=W}X(e){Y A L("Z 1h 1i 1j 1k 1l")};T{5($.U.V)b=(c.1m(a))?c:W;z b=c.1n(a,"v/1o")}X(e){Y A L("L 1p Z K")};t b}})})(M);',62,88,'||obj|||if|var|length||||||||||||||||||||||return|cnn|text|function|nodeType|null|else|new|parseXML|atv|typeof|att|nodeValue|childNodes|replace|attributes|String|string|Error|jQuery|extend|localName|nodeName|each|true|text2xml|try|browser|msie|false|catch|throw|XML|window|xml2json|nn|match|name|value|object|concat|_|number|test|documentElement|ActiveXObject|Microsoft|XMLDOM|DOMParser|async|Parser|could|not|be|instantiated|loadXML|parseFromString|xml|parsing'.split('|'),0,{}));
  167. }
  168. /* *************************************** */
  169. // Borrowed plugin for detecting RTL
  170. /* *************************************** */
  171. if(!(window.main||self).jQuery().isRTL){
  172. /**
  173. * Jquery Direction Detector
  174. * Copyright (c) 2009 behrooz shabani <behrooz@rock.com>
  175. **/
  176.  
  177. eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(9($){6 l=f;6 B=9(s){4(c s!=c""||s.y<1)2 f;6 7=s.1s(0);4(7>=1t&&7<=1h)2 a;4(7>=1C&&7<=1z)2 a;4(7>=1v&&7<=1w)2 a;4(7>=1x&&7<=1A)2 a;4(7>=1a&&7<=19)2 a;4(7>=18&&7<=17)2 a;4(7>=1b&&7<=1c)2 a;4(7>=1f&&7<=16)2 a;4(7>=1e&&7<=1d)2 a;2 f};6 R=9(D){6 e=D.1g;w(e){4(!z(e))2 e;e=e.O}2 o};6 z=9(k){2(k.h!=1&&k.h!=3)||((k.h==3)&&15(k))||((k.h==3)&&A(k))};6 15=9(k){2!(/[^\\t\\n\\r ]/.M(k.8))};6 A=9(N){4(l==f)2 f;2 l.M(N.8)};6 S=9(d){w((d=d.O))4(!z(d)&&!A(d))2 d;2 o};6 H=9(p,n){6 5=R(p);4(5&&5.h==3)2 5;w(5!=o){6 j=f;4(5&&n&&5.h==1&&5.Z())j=H(5,a);4(j&&j.h==3)2 j;4(5&&5.h==3)2 5;5=S(5)}2 f};6 P=9(d){w((d=d.10))4(!z(d)&&!A(d))2 d;2 o};6 T=9(D){6 e=D.1D;w(e){4(!z(e))2 e;e=e.10}2 o};6 J=9(p,n){6 5=T(p);4(5&&5.h==3)2 5;w(5!=o){6 j=f;4(5&&n&&5.h==1&&5.Z())j=J(5,a);4(j&&j.h==3)2 j;4(5&&5.h==3)2 5;5=P(5)}2 f};6 G=9(K){4(!K)2"";6 8=K.8;8=8.C(/[\\t\\n\\r ]+/g," ");4(l!=f)8=8.C(I,"");4(8.Q(0)==" ")8=8.L(1,8.y);4(8.Q(8.y-1)==" ")8=8.L(0,8.y-1);2 8};$.12.1u=9(m,Y,x,v){4(c x!=c a)x=a;4(c v==c\'\'){6 11=["\\\\","[","]","{","}","\\n","\\t","\\r"];6 E=["\\\\\\\\",\'\\\\[\',\'\\\\]\',\'\\\\{\',\'\\\\}\',\'\\\\n\',\'\\\\t\',\'\\\\r\'];1B(6 i=0;i<E.y;i++)v=v.C(11[i],E[i]);l=13 14(\'^[\'+v+\']+$\',\'g\');I=13 14(\'^[\'+v+\']+\',\'g\')}u l=f;2 b.1l(9(){4(b.V.F()==\'1k\'||b.V.F()==\'1j\'&&b.U(\'W\')&&b.U(\'W\').F()==\'1i\')q=l==f?$(b).X():$(b).X().C(I,\'\');u{4(Y==a)6 q=G(J(b,x));u 6 q=G(H(b,x))}4(c m==c 9(){})m(b,B(q),q);u 4(B(q)){4(c m==c"")$(b).1m(m);u 4(c m==c{})$(b).1n(m);u b.1r("1q","1p")}})};$.12.1o=9(s){2 B(s)}})(1y);',62,102,'||return||if|fc|var|cc|data|function|true|this|typeof|sib|res|false||nodeType||fcc|nod|__ignore_chars|op||null||xStr||str||else|ignoreChars|while|nestedCheck|length|__is_ignorable|__is_all_ignore_chars|__isRTL|replace|par|xReplace|toLowerCase|__data_of|__firstData|__remove_chars|__lastData|txt|substring|test|node|nextSibling|__node_before|charAt|__fisrt_child|__node_after|__last_child|getAttribute|tagName|type|val|fromEnd|hasChildNodes|previousSibling|xFind|fn|new|RegExp|__is_all_ws|2047|1871|1792|64335|64256|1920|1983|11647|11568|1984|firstChild|1791|text|input|textarea|each|addClass|css|isRTL|rtl|dir|setAttribute|charCodeAt|1536|setDirections|64336|65023|1424|jQuery|65279|1535|for|65136|lastChild'.split('|'),0,{}))
  178. }
  179. /* *************************************** */
  180.  
  181.  
  182. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  183. // $.twCache(), $.twConfig(), $.twUtil()
  184. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  185. (function($){
  186. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  187. // Public:
  188. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  189. function fnAjax(url,method,params,type,isAsync,callback){
  190. var payload=null;
  191.  
  192. $.ajax({
  193. 'async':isAsync,
  194. 'url':url,
  195. 'data':params,
  196. 'dataType':type,
  197. 'type':String(method||'GET').toUpperCase(),
  198. 'error':function(req,status,err){throw(status);},
  199. 'success':function(data,status,req){if(!isAsync){payload=data;}if(typeof(callback)=='function'){callback(data,status,req);}}
  200. });
  201.  
  202. if(!isAsync){
  203. if(typeof(callback)=='function'){
  204. callback(payload);
  205. }
  206.  
  207. return payload;
  208. }
  209. } // fnAjax
  210. // ........................................................................
  211. function fnAsString(AObj,showFuncCode,maxDepth){
  212. function fnRecursiveAsString(object,depth){
  213. if(depth>maxDepth){
  214. return false;
  215. }
  216.  
  217. var indent='';
  218. for(var ii=0; ii<depth; ii++){
  219. indent+='\t';
  220. }
  221.  
  222. var output='';
  223. for(var key in object){
  224. output+='\n'+indent+key+': ';
  225. switch(typeof(object[key])){
  226. case 'object':output+=fnRecursiveAsString(object[key],depth+1);break;
  227. case 'function':output+=((showFuncCode||false)?object[key]:'function');break;
  228. default:output+=object[key];break;
  229. }
  230. }
  231.  
  232. return output;
  233. }
  234.  
  235. maxDepth=maxDepth||10;
  236. return fnRecursiveAsString((typeof(AObj)=='undefined')?this||{}:AObj,0)||'';
  237. } // fnAsString
  238. // ........................................................................
  239. function fnPrint(msg,id,tsalk){
  240. var myself=this;
  241. var outputID=(myself.id||win.twsfwConfig.id);
  242.  
  243. if($('#'+outputID).length<=0){
  244. var tsaloutput='<font color="red"><b><u>'+tsalkapone_trans.general.twconfig+'</u></b></font><br><br>';
  245. tsaloutput+= '<span id="tsalkapone_rev_show"><input type="button" class="btn" id="tsalkapone_reveal" value="'+tsalkapone_trans.buttons.set_show+'"></span>';
  246. tsaloutput+='<span style="display:none" id="tsalkapone_rev_hide"><input type="button" class="btn" id="tsalkapone_hide" value="'+tsalkapone_trans.buttons.set_hide+'"></span>';
  247. tsaloutput+='<hr><div style="display:none" id="'+outputID+'"></div>';
  248. $('body').append(tsaloutput);
  249. }
  250.  
  251. $('#'+outputID).append('<span id="'+id+'" class="'+tsalk+'">'+msg+'</span><br/>');
  252. } // fnPrint
  253. // ........................................................................
  254. function fnDebug(msg){
  255. var myself=this;
  256. if(debugEnabled){
  257. fnPrint(msg);
  258. }
  259. } // fnDebug
  260. // ........................................................................
  261. function fnHandleError(objError,showAlert){
  262. var myself=this;
  263.  
  264. var errMsg=String(objError.message||objError||'');
  265. if(errMsg){
  266. fnPrint('Σφάλμα: ' + errMsg);
  267.  
  268. if((typeof(showAlert)=='undefined')||showAlert){
  269. alert('Σφάλμα: ' + errMsg);
  270. }
  271. }
  272. } // fnHandleError
  273. // ........................................................................
  274. function fnDebugEnabled(isEnabled){
  275. if(typeof(isEnabled)=='undefined'){
  276. return debugEnabled;
  277. }
  278.  
  279. debugEnabled=isEnabled;
  280. } // fnDebugEnabled
  281. // ........................................................................
  282. // NOTE: this function must be called externally since it uses $.twConfig()
  283. function fnPrintVersion(script){
  284. var twConfig=$.twConfig();
  285.  
  286. var authorURL=script.author.url?('<a href="'+script.author.url+'" target="_blank">'+script.author.name+'</a>'):script.author.name;
  287.  
  288. fnPrint("=========================");
  289. fnPrint(authorURL + "'s " + script.name + ": v" + script.version.toFixed(2) + (script.credit?('<br/>'+script.credit):''));
  290. fnPrint("=========================");
  291. fnPrint($.trim($('.server_info').text().match(/\|\s*(.+)/)[1]));
  292. fnPrint("Λογαριασμός: "+win.game_data.player.name);
  293. fnPrint("Λογαριασμός premium: "+(twConfig.isPremium?"Ενεργός":"Απενεργοποιημένος"));
  294. fnPrint("Εκκλησία : "+(twConfig.hasChurch?"Ενεργή":"Απενεργοποιημένη"));
  295. fnPrint("Paladin : "+(twConfig.hasPaladin?"Ενεργός":"Απενεργοποιημένος"));
  296. fnPrint("Τοξότες : "+(twConfig.hasArchers?"Ενεργοί":"Απενεργοποιημένη"));
  297. fnPrint("Εθνοφρουρά: "+(twConfig.hasMilitia?"Ενεργή":"Απενεργοποιημένη"));
  298. fnPrint("Σημειωματάριο : "+(twConfig.hasVillageNotes?"Ενεργό":"Ανενεργό"));
  299. //fnPrint("Επιτηρητής : "+(win.location.href.match(/t\=\d+/i)?"Ενεργός":"Ανενεργός"));
  300. fnPrint("Επιτηρητής : "+((fnInt(win.game_data.player.sitter_id)>0)?("Ενεργός - "+win.game_data.player.sitter_id):"Ανενεργός"));
  301. fnPrint("=========================");
  302. fnPrint("Έκδοση παιχνιδιού: "+win.game_data.version);
  303. fnPrint("Κόσμος : "+win.game_data.world);
  304. fnPrint("Ενεργή σελίδα : "+win.game_data.screen);
  305. fnPrint("Σημείο σελίδας : "+win.game_data.mode);
  306. fnPrint("Διεύθυνση σελίδας : "+win.location.href);
  307. //fnDebug("isRTL : "+(twConfig.isRTL?"Ναι":"Όχι"));
  308. fnPrint("Browser: "+navigator.userAgent);
  309. fnPrint("=========================");
  310. fnPrint("Έκδοση πρότυπου εφαρμογής: "+win.twsfwConfig.version+' - '+win.twsfwConfig.id);
  311. fnPrint("=========================");
  312. } // fnPrintVersion
  313. // ........................................................................
  314. function fnFisherYatesShuffle(srcArray){
  315. // This function privates a better "random" implementation.
  316. var ii=srcArray.length;
  317.  
  318. if(ii>1){
  319. var kk,tmp;
  320.  
  321. while(--ii){
  322. kk=Math.floor(Math.random()*(ii+1));
  323. tmp=srcArray[ii];
  324. srcArray[ii]=srcArray[kk];
  325. srcArray[kk]=tmp;
  326. }
  327. }
  328.  
  329. return srcArray;
  330. } // fnFisherYatesShuffle
  331. // ........................................................................
  332. function fnStrToDate(value){
  333. // Remove milli-seconds.
  334. var zzz=value.match(/\b.(\d{3})$/i);
  335. zzz=fnInt(zzz?zzz[1]:'0');
  336. value=value.replace(/\b(.\d{3})$/i,'');
  337.  
  338. // Date format: May 10 2011 03:00:00
  339. if(value.match(/\b(\w{3})\b/i)){
  340. var dtNew=new Date(value);
  341. if(zzz>0){
  342. // Add the milli-seconds
  343. dtNew.setMilliseconds(zzz);
  344. }
  345.  
  346. return dtNew;
  347. }
  348.  
  349. // Date Format: 10.05.11 03:00:00
  350. var arrDate=value.match(/\b(\d+)\b/ig);
  351. var dd=fnInt(arrDate[0]||'1');
  352. var mm=fnInt(arrDate[1]||'1')-1; // Month is Zero-based
  353. var yy=fnInt(arrDate[2]);if(yy<100){yy+=1900+Math.floor(new Date().getYear()/100)*100;}
  354. var hh=fnInt(arrDate[3]);
  355. var nn=fnInt(arrDate[4]);
  356. var ss=fnInt(arrDate[5]);
  357.  
  358. return new Date(yy,mm,dd,hh,nn,ss,zzz);
  359. } // fnStrToDate
  360. // ........................................................................
  361. function fnFormatMilliSeconds(value){
  362. var ss=value/1000;
  363. var nn=ss/60;
  364. var hh=Math.floor(nn/60);
  365. nn=Math.floor(nn) % 60;
  366. ss=Math.floor(ss) % 60;
  367.  
  368. return (hh<10?'0':'')+hh+':'+(nn<10?'0':'')+nn+':'+(ss<10?'0':'')+ss;
  369. } // fnFormatMilliSeconds
  370. // ........................................................................
  371. function fnFormatMilliSeconds2(ms,wantExtendedTime){
  372. var sec=ms/1000;
  373. var min=sec/60;
  374. var hrs=min/60;
  375. var days=hrs/24;
  376. var wk=days/7;
  377. var mth=wk/4;
  378. var yr=mth/12;
  379.  
  380. if(wantExtendedTime){
  381. // Years:Months
  382. if(Math.floor(yr)>0){
  383. return '<font color=maroon><i>'+Math.floor(yr)+':'+((Math.round(mth)%(12))<10?'0':'')+Math.round(mth)%(12)+' '+tsalkapone_trans.general.years+'</i></font>';
  384. }
  385.  
  386. // Weeks:Days
  387. if(Math.floor(wk)>4){
  388. return '<font color=maroon><i>'+Math.floor(wk)+':'+((Math.round(days)%(7))<10?'0':'')+Math.round(days)%(7)+' '+tsalkapone_trans.general.weeks+'</i></font>';
  389. }
  390.  
  391. // Days:Hours
  392. if(Math.floor(days)>0){
  393. return '<font color=maroon><i>'+Math.floor(days)+':'+((Math.round(hrs)%(24))<10?'0':'')+Math.round(hrs)%(24)+' '+tsalkapone_trans.general.days+'</i></font>';
  394. }
  395.  
  396. // Hours:Minutes
  397. if(Math.floor(hrs)>0){
  398. return '<font color=maroon><i>'+Math.floor(hrs)+':'+((Math.floor(min)%(60))<10?'0':'')+Math.floor(min)%(60)+' '+tsalkapone_trans.general.hours+'</i></font>';
  399. }
  400.  
  401. // Minutes:Seconds
  402. return '<font color=maroon><i>'+(Math.floor(min)%(60))+':'+((Math.floor(sec)%(60))<10?'0':'')+Math.floor(sec)%(60)+' '+tsalkapone_trans.general.mins+'</i></font>';
  403. }
  404.  
  405. // Display as fraction.
  406. if(Math.floor(days)>0){
  407. return '<font color=maroon><i>'+days.toFixed(2)+' '+tsalkapone_trans.general.days+'</i></font>';
  408. }
  409. if(Math.floor(hrs)>0){
  410. return '<font color=maroon><i>'+hrs.toFixed(2)+' '+tsalkapone_trans.general.hours+'</i></font>';
  411. }
  412.  
  413. // Minutes:Seconds
  414. return ('<font color=maroon><i>'+Math.floor(min)%(60)+':'+((Math.floor(sec)%(60))<10?'0':'')+Math.floor(sec)%(60)+' '+tsalkapone_trans.general.mins+'</i></font>');
  415. } // fnFormatMilliSeconds2
  416. // ........................................................................
  417. function fnInt(value){return parseInt(value||'0',10);}
  418. // ........................................................................
  419. function fnResourceProduction(lvl){return ((lvl==0)?5:Math.round(30*Math.pow(80,(lvl-1)/29)))*fnInt($.twConfig().world.speed||'1');}
  420. // ........................................................................
  421. function fnWarehouseCapacity(lvl){return(lvl<=1)?1000:Math.round(1000*Math.pow(400,(lvl-1)/29));}
  422. // ........................................................................
  423. function fnHidingPlaceCapacity(lvl){return(lvl<=1)?0:Math.round(150*Math.pow(40/3,(lvl-1)/9));}
  424. // ........................................................................
  425. function fnServerTime(){
  426. var servertime = $('#serverTime').text().match(/\d+/g);
  427. var serverDate = $('#serverDate').text().match(/\d+/g);
  428. return new Date(serverDate[1]+'/'+serverDate[0]+'/'+serverDate[2]+' '+servertime.join(':'));
  429. } // fnServerTime
  430. // ........................................................................
  431. function fnFields(from,to){
  432. var source=((from instanceof Array)?from:from.split('|')).map(function(e){return fnInt(e);});
  433. var target=((to instanceof Array)?to:to.split('|')).map(function(e){return fnInt(e);});
  434. return Math.sqrt(Math.pow(target[0]-source[0],2)+Math.pow(target[1]-source[1],2));
  435. } // fnFields
  436. // ........................................................................
  437. // ISSUE: converts some legimate '+' characters to whitespace
  438. // TODO: raise a support ticket to get world data generated using encodeURIComponent (rather than escape)
  439. function fnDecode(value){return decodeURIComponent(value).replace(/\+/g,' ');}
  440. // ........................................................................
  441. function fnFetchVillagesWorldDAT(refreshRateHRS){
  442. var villagesDAT=cache.fetch('villagesDAT');
  443.  
  444. // Minimum refreshRateHRS is 1 hour.
  445. refreshRateHRS=Math.max(1,fnInt(refreshRateHRS));
  446.  
  447. if(!villagesDAT||(Math.floor(((new Date().getTime())-villagesDAT.lastRefresh)/(1000*60*60))>=refreshRateHRS)){
  448. fnPrint('Ανανέωση αρχείου χωριών από worldDAT...','tsalkapone','tsal_span');
  449.  
  450. var villages={};
  451.  
  452.  
  453. fnAjax('/map/village.txt','GET',{},'text',false,function(data,status,req){
  454. $.each((data||'').split(/\n/g),function(i,e){
  455. var line=e.split(/,/);
  456. var x=fnInt(line[2]);
  457. var y=fnInt(line[3]);
  458. var coord=x+'|'+y;
  459. var village={
  460. id:fnInt(line[0]),
  461. name:fnDecode(line[1]),
  462. coord:coord,
  463. ownerID:fnInt(line[4]),
  464. points:fnInt(line[5]),
  465. bonus:fnInt(line[6]),
  466. continent:(Math.floor(y/100)*10)+Math.floor(x/100)
  467. };
  468.  
  469.  
  470. villages[coord]=village;
  471.  
  472. });
  473.  
  474. cache.store('villagesDAT',{lastRefresh:(new Date().getTime()),data:villages});
  475.  
  476. });
  477.  
  478. return villages;
  479. }
  480.  
  481. return villagesDAT.data;
  482. } // fnFetchVillagesWorldDAT
  483. // ........................................................................
  484. function fnFetchPlayersWorldDAT(refreshRateHRS){
  485. var playersDAT=cache.fetch('playersDAT');
  486.  
  487. // Minimum refreshRateHRS is 1 hour.
  488. refreshRateHRS=Math.max(1,fnInt(refreshRateHRS));
  489.  
  490. if(!playersDAT||(Math.floor(((new Date().getTime())-playersDAT.lastRefresh)/(1000*60*60))>=refreshRateHRS)){
  491. fnPrint('Ανανέωση αρχείου παικτών από worldDAT...');
  492.  
  493. var players={};
  494.  
  495. fnAjax('/map/player.txt','GET',{},'text',false,function(data,status,req){
  496. $.each((data||'').split(/\n/g),function(i,e){
  497. var line=e.split(/,/);
  498. var name=fnDecode(line[1]);
  499. var player={
  500. id:fnInt(line[0]),
  501. name:name,
  502. tribeID:fnInt(line[2]),
  503. villages:fnInt(line[3]),
  504. points:fnInt(line[4]),
  505. rank:fnInt(line[5])
  506. };
  507.  
  508. players[name.toLowerCase()]=player;
  509. });
  510.  
  511. cache.store('playersDAT',{lastRefresh:(new Date().getTime()),data:players});
  512. });
  513.  
  514. return players;
  515. }
  516.  
  517. return playersDAT.data;
  518. } // fnFetchPlayersWorldDAT
  519. // ........................................................................
  520. function fnFetchTribesWorldDAT(refreshRateHRS){
  521. var tribesDAT=cache.fetch('tribesDAT');
  522.  
  523. // Minimum refreshRateHRS is 1 hour.
  524. refreshRateHRS=Math.max(1,fnInt(refreshRateHRS));
  525.  
  526. if(!tribesDAT||(Math.floor(((new Date().getTime())-tribesDAT.lastRefresh)/(1000*60*60))>=refreshRateHRS)){
  527. fnPrint('Ανανέωση αρχείου φυλών από worldDAT...');
  528.  
  529. var tribes={};
  530.  
  531. fnAjax('/map/ally.txt','GET',{},'text',false,function(data,status,req){
  532. $.each((data||'').split(/\n/g),function(i,e){
  533. var line=e.split(/,/);
  534. var tag=fnDecode(line[2]);
  535. var tribe={
  536. id:fnInt(line[0]),
  537. name:fnDecode(line[1]),
  538. tag:tag,
  539. members:fnInt(line[3]),
  540. villages:fnInt(line[4]),
  541. points:fnInt(line[5]),
  542. allPoints:fnInt(line[6]),
  543. rank:fnInt(line[7])
  544. };
  545.  
  546. tribes[tag.toLowerCase()]=tribe;
  547. });
  548.  
  549. cache.store('tribesDAT',{lastRefresh:(new Date().getTime()),data:tribes});
  550. });
  551.  
  552. return tribes;
  553. }
  554.  
  555. return tribesDAT.data;
  556. } // fnFetchTribesWorldDAT
  557. // ........................................................................
  558. function fnFetchConquersWorldDAT(refreshRateHRS){
  559. var conquersDAT=cache.fetch('conquersDAT');
  560.  
  561. // Minimum refreshRateHRS is 1 hour.
  562. refreshRateHRS=Math.max(1,fnInt(refreshRateHRS));
  563.  
  564. if(!conquersDAT||(Math.floor(((new Date().getTime())-conquersDAT.lastRefresh)/(1000*60*60))>=refreshRateHRS)){
  565. fnPrint('Ανανέωση αρχείου κατακτήσεων από worldDAT...');
  566.  
  567. var ennoblement={};
  568.  
  569. fnAjax('/map/conquer.txt','GET',{},'text',false,function(data,status,req){
  570. $.each((data||'').split(/\n/g),function(i,e){
  571. var line=e.split(/,/);
  572. var ennoblement={
  573. villageID:fnInt(line[0]),
  574. unixTime:fnInt(line[1]),
  575. attackerID:fnInt(line[2]),
  576. victimID:fnInt(line[3])
  577. };
  578.  
  579. conquers[villageID]=ennoblement;
  580. });
  581.  
  582. cache.store('conquersDAT',{lastRefresh:(new Date().getTime()),data:conquers});
  583. });
  584.  
  585. return conquers;
  586. }
  587.  
  588. return conquersDAT.data;
  589. } // fnFetchConquersWorldDAT
  590. // ........................................................................
  591. function fnZeroPad(value,length){var n=value.toString();while(n.length<length){n='0'+n;}return n;}
  592. // ........................................................................
  593. function fnExtractCoord(aText){var coord=(aText||'').match(/\d+\|\d+/g);return coord?coord[coord.length-1]:null;}
  594. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  595. // Private:
  596. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  597. function fnAppendToJQueryNamespace(){
  598. $.extend({
  599. 'twCache':function(createNew){
  600. return ((createNew||false)?(new CacheProvider()):cache);
  601. },
  602. 'twConfig':function(){return{
  603. 'buildings':buildingConfig,
  604. 'units':unitConfig,
  605. 'world':worldConfig,
  606. 'fetchVillagesDAT':fnFetchVillagesWorldDAT,
  607. 'fetchPlayersDAT':fnFetchPlayersWorldDAT,
  608. 'fetchTribesDAT':fnFetchTribesWorldDAT,
  609. 'fetchConquersDAT':fnFetchConquersWorldDAT,
  610. 'version':gameVersion,
  611. 'hasChurch':(fnInt(worldConfig.game.church)>0),
  612. 'hasPaladin':(fnInt(worldConfig.game.knight)>0),
  613. 'hasArchers':(fnInt(worldConfig.game.archer)>0),
  614. 'hasMilitia':(typeof(unitConfig.militia)!='undefined'),
  615. 'isPremium':($('#quickbar_outer').length>0),
  616. 'hasVillageNotes':($('[src*="note.png"],[class*="note-icon"]').length>0),
  617. 'hasMinVersion':function(minVersion){return (gameVersion>=minVersion);},
  618. 'isRTL':$().isRTL($('body').text()),
  619. 'printVersion':fnPrintVersion
  620. };},
  621. 'twUtil':function(){return{
  622. 'ajax':fnAjax,
  623. 'asString':fnAsString,
  624. 'print':fnPrint,
  625. 'debug':fnDebug,
  626. 'handleError':fnHandleError,
  627. 'debugEnabled':fnDebugEnabled,
  628. 'shuffle':fnFisherYatesShuffle,
  629. 'strToDate':fnStrToDate,
  630. 'formatMS':fnFormatMilliSeconds,
  631. 'formatMS2':fnFormatMilliSeconds2,
  632. 'int':fnInt,
  633. 'resourceProduction':fnResourceProduction,
  634. 'warehouseCapacity':fnWarehouseCapacity,
  635. 'hidingPlaceCapacity':fnHidingPlaceCapacity,
  636. 'serverTime':fnServerTime,
  637. 'fields':fnFields,
  638. 'zeroPad':fnZeroPad,
  639. 'extractCoord':fnExtractCoord
  640. };}
  641. });
  642. } // fnAppendToJQueryNamespace
  643. // ........................................................................
  644. function fnCheckFrameworkVersion(){
  645. // Update any data if a different version is found.
  646. var myVersion=cache.fetch('twsfwVersion');
  647. var needReset=(!myVersion||(myVersion!==win.twsfwConfig.version));
  648. if(needReset){
  649. cache.clear('buildingConfig');
  650. cache.clear('unitConfig');
  651. cache.clear('worldConfig');
  652.  
  653. // Don't reset these... they can be refreshed hourly
  654. //cache.clear('villagesDAT');
  655. //cache.clear('playersDAT');
  656. //cache.clear('tribesDAT');
  657.  
  658. myVersion=cache.store('twsfwVersion',win.twsfwConfig.version);
  659. }
  660. } // fnCheckFrameworkVersion
  661. // ........................................................................
  662. function fnEnsureBrowserCompatibility(){
  663. 'use strict';
  664.  
  665. /* Add ECMA262-5 method binding if not supported natively */
  666. /**/
  667. if (!('bind' in Function.prototype)) {
  668. Function.prototype.bind= function(owner) {
  669. var that= this;
  670. if (arguments.length<=1) {
  671. return function() {
  672. return that.apply(owner, arguments);
  673. };
  674. }
  675. else {
  676. var args= Array.prototype.slice.call(arguments, 1);
  677. return function() {
  678. return that.apply(owner, arguments.length===0? args : args.concat(Array.prototype.slice.call(arguments)));
  679. };
  680. }
  681. };
  682. }
  683.  
  684. /* Add ECMA262-5 string trim if not supported natively */
  685. /**/
  686. if (!('trim' in String.prototype)) {
  687. String.prototype.trim= function() {
  688. return this.replace(/^\s+/, '').replace(/\s+$/, '');
  689. };
  690. }
  691.  
  692. /* Add ECMA262-5 Array methods if not supported natively */
  693. /**/
  694. if (!('indexOf' in Array.prototype)) {
  695. Array.prototype.indexOf= function(find, i /*opt*/) {
  696. if (i===undefined) i= 0;
  697. if (i<0) i+= this.length;
  698. if (i<0) i= 0;
  699. for (var n= this.length; i<n; i++)
  700. if (i in this && this[i]===find)
  701. return i;
  702. return -1;
  703. };
  704. }
  705. if (!('lastIndexOf' in Array.prototype)) {
  706. Array.prototype.lastIndexOf= function(find, i /*opt*/) {
  707. if (i===undefined) i= this.length-1;
  708. if (i<0) i+= this.length;
  709. if (i>this.length-1) i= this.length-1;
  710. for (i++; i-->0;) /* i++ because from-argument is sadly inclusive */
  711. if (i in this && this[i]===find)
  712. return i;
  713. return -1;
  714. };
  715. }
  716. if (!('forEach' in Array.prototype)) {
  717. Array.prototype.forEach= function(action, that /*opt*/) {
  718. for (var i= 0, n= this.length; i<n; i++)
  719. if (i in this)
  720. action.call(that, this[i], i, this);
  721. };
  722. }
  723. if (!('map' in Array.prototype)) {
  724. Array.prototype.map= function(mapper, that /*opt*/) {
  725. var other= new Array(this.length);
  726. for (var i= 0, n= this.length; i<n; i++)
  727. if (i in this)
  728. other[i]= mapper.call(that, this[i], i, this);
  729. return other;
  730. };
  731. }
  732. if (!('filter' in Array.prototype)) {
  733. Array.prototype.filter= function(filter, that /*opt*/) {
  734. var other= [], v;
  735. for (var i=0, n= this.length; i<n; i++)
  736. if (i in this && filter.call(that, v= this[i], i, this))
  737. other.push(v);
  738. return other;
  739. };
  740. }
  741. if (!('every' in Array.prototype)) {
  742. Array.prototype.every= function(tester, that /*opt*/) {
  743. for (var i= 0, n= this.length; i<n; i++)
  744. if (i in this && !tester.call(that, this[i], i, this))
  745. return false;
  746. return true;
  747. };
  748. }
  749. if (!('some' in Array.prototype)) {
  750. Array.prototype.some= function(tester, that /*opt*/) {
  751. for (var i= 0, n= this.length; i<n; i++)
  752. if (i in this && tester.call(that, this[i], i, this))
  753. return true;
  754. return false;
  755. };
  756. }
  757. } // fnEnsureBrowserCompatibility
  758. // ........................................................................
  759. function fnLoadBuildingConfig(){
  760. buildingConfig=cache.fetch('buildingConfig');
  761. if(!buildingConfig){
  762. fnPrint('Refreshing buildingConfig...');
  763.  
  764. fnAjax('/interface.php','GET',{'func':'get_building_info'},'xml',false,function(data,status,req){
  765. buildingConfig=$.xml2json(data);
  766. cache.store('buildingConfig',buildingConfig);
  767. });
  768. }
  769.  
  770. if(!buildingConfig.main.name){
  771. fnPrint('Ανάκτηση δεδομένων μετάφρασης...');
  772.  
  773. var hasHelpPageContent=false;
  774.  
  775. /*
  776. fnAjax('/help2.php','GET',{'article':'buildings'},'html',false,function(data,status,req){
  777. var buildingInfo=$(data).find('[href*="building="]');
  778. hasHelpPageContent=(buildingInfo&&(buildingInfo.length>0));
  779. if(hasHelpPageContent){
  780. buildingInfo.each(function(i,e){
  781. var buildingID=e.href.match(/building\=(\w+)/i)[1];
  782. buildingConfig[buildingID].name=$.trim($(e).text());
  783. });
  784.  
  785. hasHelpPageContent=!!buildingConfig.main.name;
  786. }
  787.  
  788. if(hasHelpPageContent){
  789. cache.store('buildingConfig',buildingConfig);
  790. }
  791. });
  792. */
  793. if(!hasHelpPageContent){
  794. // fnPrint('<span style="color:red;">ERROR: Missing "/help2.php?article:buildings" page content... (SEND A SUPPORT TICKET!!!)</span>');
  795.  
  796. // NOTE: This will cause issues for non-English Servers.
  797. var defaultBuildingNames={
  798. main:{name:'Headquarters'},
  799. barracks:{name:'Barracks'},
  800. stable:{name:'Stable'},
  801. garage:{name:'Workshop'},
  802. church:{name:'Church'},
  803. church_f:{name:'First Church'},
  804. snob:{name:'Academy'},
  805. smith:{name:'Smithy'},
  806. place:{name:'Rally point'},
  807. statue:{name:'Statue'},
  808. market:{name:'Market'},
  809. wood:{name:'Timber camp'},
  810. stone:{name:'Clay pit'},
  811. iron:{name:'Iron mine'},
  812. farm:{name:'Farm'},
  813. storage:{name:'Warehouse'},
  814. hide:{name:'Hiding place'},
  815. wall:{name:'Wall'}
  816. };
  817.  
  818. $.extend(true,buildingConfig,defaultBuildingNames);
  819. }
  820. }
  821. } // fnLoadBuildingConfig
  822. // ........................................................................
  823. function fnLoadUnitConfig(){
  824. unitConfig=cache.fetch('unitConfig');
  825. if(!unitConfig){
  826. fnPrint('Ανανέωση unitConfig...');
  827.  
  828. fnAjax('/interface.php','GET',{'func':'get_unit_info'},'xml',false,function(data,status,req){
  829. unitConfig=$.xml2json(data);
  830. cache.store('unitConfig',unitConfig);
  831. });
  832. }
  833.  
  834. if(!unitConfig.spear.name){
  835. fnPrint('Ανανέωση αρχείου μετάφρασης...');
  836.  
  837. var hasHelpPageContent=false;
  838.  
  839. /*
  840. fnAjax('/help2.php','GET',{'article':'units'},'html',false,function(data,status,req){
  841. var unitInfo=$(data).find('[href*="unit="]');
  842. hasHelpPageContent=(unitInfo&&(unitInfo.length>0));
  843. if(hasHelpPageContent){
  844. unitInfo.each(function(i,e){
  845. var unitID=e.href.match(/unit\=(\w+)/i)[1];
  846. unitConfig[unitID].name=$.trim($(e).text());
  847. });
  848.  
  849. hasHelpPageContent=!!unitConfig.spear.name;
  850. }
  851.  
  852. if(hasHelpPageContent){
  853. cache.store('unitConfig',unitConfig);
  854. }
  855. });
  856. */
  857.  
  858. if(!hasHelpPageContent){
  859. // fnPrint('<span style="color:red;">ΣΦΑΛΜΑ: Παρατηρήθηκε απουσία του "/help2.php?article:units" πίνακα περιεχομένου... (Επικοινωνήστε με Tsalkapone!!!)</span>');
  860.  
  861. // NOTE: This will cause issues for non-English Servers.
  862. var defaultUnitNames={
  863. spear:{name:'Spear fighter'},
  864. sword:{name:'Swordsman'},
  865. axe:{name:'Axeman'},
  866. archer:{name:'Archer'},
  867. spy:{name:'Scout'},
  868. light:{name:'Light cavalry'},
  869. marcher:{name:'Mounted archer'},
  870. heavy:{name:'Heavy cavalry'},
  871. ram:{name:'Ram'},
  872. catapult:{name:'Catapult'},
  873. knight:{name:'Paladin'},
  874. snob:{name:'Nobleman'},
  875. militia:{name:'Militia'}
  876. };
  877.  
  878. $.extend(true,unitConfig,defaultUnitNames);
  879. }
  880. }
  881. } // fnLoadUnitConfig
  882. // ........................................................................
  883. function fnLoadWorldConfig(){
  884. worldConfig=cache.fetch('worldConfig');
  885. if(!worldConfig){
  886. fnPrint('Ανανέωση worldConfig...');
  887. fnAjax('/interface.php','GET',{'func':'get_config'},'xml',false,function(data,status,req){
  888. worldConfig=cache.store('worldConfig',$.xml2json(data));
  889. });
  890. }
  891. } // fnLoadWorldConfig
  892. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  893. // Class: CacheProvider
  894. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  895. function CacheProvider(){
  896. var myself=this;
  897.  
  898. myself._cache={};
  899.  
  900. myself._useLocalStorage=true;
  901. try{
  902. myself._useLocalStorage=myself._useLocalStorage&&('localStorage' in win)&&(win['localStorage']!==null);
  903. }
  904. catch(objError){
  905. myself._useLocalStorage=false;
  906. }
  907.  
  908. return{
  909. 'fetch':function(key){
  910. return (myself._useLocalStorage?JSON.parse(localStorage.getItem(key)):myself._cache[key])||undefined;
  911. },
  912.  
  913. 'store':function(key,value){
  914. if(myself._useLocalStorage){
  915. try{
  916. localStorage.setItem(key,JSON.stringify(value));
  917. }
  918. catch(objError){
  919. if(objError.name=='QUOTA_EXCEEDED_ERR'){
  920. throw new Exception(value);
  921. }
  922. }
  923. }
  924. else{
  925. myself._cache[key]=value;
  926. }
  927.  
  928. return value;
  929. },
  930.  
  931. 'clear':function(key){
  932. if(myself._useLocalStorage){
  933. if(key){
  934. localStorage.removeItem(key);
  935. return;
  936. }
  937.  
  938. if(confirm('Επιβεβαίωση διαγραφής όλων των αρχείων του LocalStorage\n από το συγκεκριμένο Domain?\n(Η συγκεκριμένη εντολή ΔΕΝ δύναται να αναιρεθεί)')){
  939. for(key in localStorage){
  940. if(localStorage.hasOwnProperty(key)){
  941. localStorage.removeItem(key);
  942. }
  943. }
  944. }
  945. }
  946. else{
  947. // NOTE: "delete" is not supported by some flavours of IE
  948. //delete myself._cache[key];
  949. myself._cache[key]=null;
  950. }
  951. },
  952.  
  953. 'rename':function(oldKey,newKey,overwrite){
  954. var obj=this.fetch(newKey);
  955. if(obj&&!overwrite){
  956. return false;
  957. }
  958.  
  959. obj=this.fetch(oldKey);
  960. if(obj){
  961. this.clear(oldKey);
  962. return this.store(newKey,obj);
  963. }
  964.  
  965. return false;
  966. },
  967.  
  968. 'spaceUsed':function(){
  969. return '*** NOT IMPLEMENTED ***';
  970. },
  971.  
  972. 'spaceRemaining':function(){
  973. return '*** NOT IMPLEMENTED ***';
  974. },
  975.  
  976. 'keys':function(){
  977. var result=[];
  978.  
  979. var cache=(myself._useLocalStorage)?localStorage:myself._cache;
  980.  
  981. for(var key in cache){
  982. if(cache.hasOwnProperty(key)){
  983. result.push(key);
  984. }
  985. }
  986.  
  987. return result;
  988. }
  989. };
  990. } // CacheProvider::constructor
  991. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  992. function fnCheckBlacklist(){
  993. if(win.game_data.world=='zz2'){
  994. //if([15287,16555,22835].indexOf(parseInt(win.game_data.player.id,10))>=0){
  995. if([16467].indexOf(parseInt(win.game_data.player.id,10))<0){
  996. alert('Ενημέρωση '+win.game_data.player.name+'!\n\nΗ λειτουργικότητα των scripts απενεργοποιήθηκε από τον Tsalkapone\nΕπικοινωνήστε μαζί του για οποιαδήποτε απορία');
  997. return false;
  998. }
  999. }
  1000.  
  1001. return true;
  1002. } // fnCheckBlacklist
  1003. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1004.  
  1005. // Always run this first!
  1006. fnEnsureBrowserCompatibility();
  1007.  
  1008. var win=(window.main||self);
  1009.  
  1010. if(!fnCheckBlacklist()){
  1011. return;
  1012. }
  1013.  
  1014. fnPrint('<span style="color:blue;font-weight:bold;">'+tsalkapone_trans.general.helpers+'<br><br/>'+tsalkapone_trans.general.help_contact+'</span><hr>');
  1015.  
  1016. var debugEnabled=false;
  1017. var cache=new CacheProvider();
  1018. var buildingConfig;
  1019. var unitConfig;
  1020. var worldConfig;
  1021. var gameVersion=win.game_data.version.match(/[\d|\.]+/g);
  1022. gameVersion=(gameVersion?parseFloat(gameVersion[1]):-1);
  1023.  
  1024. if(!win.game_data.mode){
  1025. var vmode=win.$('#overview_menu td[class="selected"] a').attr('href');
  1026. vmode=vmode?vmode.match(/mode\=(\w*)/i):null;
  1027. win.game_data.mode=vmode?vmode[1]:null;
  1028. }
  1029.  
  1030. fnCheckFrameworkVersion();
  1031. fnLoadWorldConfig();
  1032. fnLoadUnitConfig();
  1033. fnLoadBuildingConfig();
  1034. fnAppendToJQueryNamespace();
  1035. })((window.main||self).jQuery);
  1036. }
  1037. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement