ShadowGovermentLibBeta

Shadow Goverment Lib Beta

بۇ قوليازمىنى بىۋاسىتە قاچىلاشقا بولمايدۇ. بۇ باشقا قوليازمىلارنىڭ ئىشلىتىشى ئۈچۈن تەمىنلەنگەن ئامبار بولۇپ، ئىشلىتىش ئۈچۈن مېتا كۆرسەتمىسىگە قىستۇرىدىغان كود: // @require https://update.greatest.deepsurf.us/scripts/12383/73947/ShadowGovermentLibBeta.js

  1. if($("section.top-bar-section > ul.foundation-right").length==1){
  2. /*---Initialization parameters---*/
  3. var localUrl = new String( window.location );
  4. var URLBattle = "battle.html?id=";
  5. var URLSettings = "editCitizen.html?Settings";
  6. var URLShadowGovernment = "editCitizen.html?ShadowGovernment";
  7. var URLMotivation = "newCitizenStatistics.html";
  8. var style;
  9. /*---Initialization parameters---*/
  10.  
  11. /*---Initialization menu---*/
  12. $('<a class="button foundation-style" title="Shadow Government Settings" href="editCitizen.html?Settings"><i class="icon-star"></i>SG Settings</a><br>').insertBefore($(".foundation-right.hidden-overflow > div:first > a:last"));
  13. $('<a class="button foundation-style" title="Shadow Government Main" href="editCitizen.html?ShadowGovernment"><i class="icon-star"></i>SG Main</a><br>').insertBefore($(".foundation-right.hidden-overflow > div:first > a:last"));
  14. /*---Initialization menu---*/
  15.  
  16. function SGChecked(flag){
  17. if(flag){
  18. return "checked";
  19. } else {
  20. return "";
  21. }
  22. }
  23.  
  24. /*---On Settings Page---*/
  25. if (localUrl.indexOf( URLSettings, 0 ) >= 0){
  26. var wrapperSettings = $("#userMenu + script + div");
  27. wrapperSettings.attr("id","WrapperMainConfig");
  28. wrapperSettings.empty();
  29. $('<center><h1>Shadow Government Settings</h1></center><p style="clear: both"></p><br>').appendTo(wrapperSettings);
  30. $('<div id="SettingsSpectator" class="testDivblue" style="width:100%;"><h3 id="SettingsSpectatorTittle">Settings Spectator</h3></div>').appendTo(wrapperSettings);
  31. $('<div id="SettingsMotivator" class="testDivblue" style="width:100%;"><h3 id="SettingsMotivatorTittle">Settings Motivator</h3></div>').appendTo(wrapperSettings);
  32. $('<div id="SettingsDemoralizator" class="testDivblue" style="width:100%;"><h3 id="SettingsDemoralizatorTittle">Settings Demoralizator</h3></div>').appendTo(wrapperSettings);
  33. $('<b title="default value: 7000, ultra speed value: 1750">SGTimerSpectator: </b><input id="SGTimerSpectatorText" name="SGTimerSpectatorText" type="text" value="'+$.jStorage.get('SGTimerSpectator', 7000)+'" autocomplete="off"><input id="SGTimerSpectatorSubmit" value="Change" type="button"><br>').appendTo("#SettingsSpectator");
  34. $('<b title="default value: 1">SGFakeUserID: </b><input id="SGFakeUserIDText" name="SGFakeUserIDText" type="text" value="'+$.jStorage.get('SGFakeUserID', 1)+'" autocomplete="off"><input id="SGFakeUserIDSubmit" value="Change" type="button"><br>').appendTo("#SettingsSpectator");
  35. $('<b title="default value: 1">SGFakeCitizenshipID: </b><input id="SGFakeCitizenshipIDText" name="SGFakeCitizenshipIDText" type="text" value="'+$.jStorage.get('SGFakeCitizenshipID', 1)+'" autocomplete="off"><input id="SGFakeCitizenshipIDSubmit" value="Change" type="button"><br>').appendTo("#SettingsSpectator");
  36. $('<b title="default value: true">SGSpectatorMode: </b><input class="SGSpectatorModeRadio" type="radio" name="SGSpectatorMode" value="true" '+SGChecked($.jStorage.get('SGSpectatorMode', true))+'> True <input class="SGSpectatorModeRadio" type="radio" name="SGSpectatorMode" value="false" '+SGChecked(!$.jStorage.get('SGSpectatorMode', true))+'>False<br>').appendTo("#SettingsSpectator");
  37. $('<b title="default value: true">SGMotivationMode: </b><input class="SGMotivationModeRadio" type="radio" name="SGMotivationMode" value="true" '+SGChecked($.jStorage.get('SGMotivationMode', true))+'> True <input class="SGMotivationModeRadio" type="radio" name="SGMotivationMode" value="false" '+SGChecked(!$.jStorage.get('SGMotivationMode', true))+'>False<br>').appendTo("#SettingsMotivator");
  38. $('<b title="default value: 10000">SGDemoralizatorTimerSpectator: </b><input id="SGDemoralizatorTimerSpectatorText" name="SGDemoralizatorTimerSpectatorText" type="text" value="'+$.jStorage.get('SGDemoralizatorTimerSpectator', 10000)+'" autocomplete="off"><input id="SGDemoralizatorTimerSpectatorSubmit" value="Change" type="button"><br>').appendTo("#SettingsDemoralizator");
  39. $('<b title="default value: 10">SGDemoralizatorFakeUserIDCount: </b><input id="SGDemoralizatorFakeUserIDCountText" name="SGDemoralizatorFakeUserIDCountText" type="text" value="'+$.jStorage.get('SGDemoralizatorFakeUserIDCount', 10)+'" autocomplete="off"><input id="SGDemoralizatorFakeUserIDCountSubmit" value="Change" type="button"><br>').appendTo("#SettingsDemoralizator");
  40. $('<b title="default value: 2">SGDemoralizatorFakeCitizenshipID: </b><input id="SGDemoralizatorFakeCitizenshipIDText" name="SGDemoralizatorFakeCitizenshipIDText" type="text" value="'+$.jStorage.get('SGDemoralizatorFakeCitizenshipID', 2)+'" autocomplete="off"><input id="SGDemoralizatorFakeCitizenshipIDSubmit" value="Change" type="button"><br>').appendTo("#SettingsDemoralizator");
  41. $('<b title="default value: false">SGDemoralizatorMode: </b><input class="SGDemoralizatorModeRadio" type="radio" name="SGDemoralizatorMode" value="true" '+SGChecked($.jStorage.get('SGDemoralizatorMode', false))+'> True <input class="SGDemoralizatorModeRadio" type="radio" name="SGDemoralizatorMode" value="false" '+SGChecked(!$.jStorage.get('SGDemoralizatorMode', false))+'>False<br>').appendTo("#SettingsDemoralizator");
  42. $('#SGTimerSpectatorSubmit').click(function(){
  43. $.jStorage.set('SGTimerSpectator', $('#SGTimerSpectatorText').val());
  44. });
  45. $('#SGFakeUserIDSubmit').click(function(){
  46. $.jStorage.set('SGFakeUserID', $('#SGFakeUserIDText').val());
  47. });
  48. $('#SGFakeCitizenshipIDSubmit').click(function(){
  49. $.jStorage.set('SGFakeCitizenshipID', $('#SGFakeCitizenshipIDText').val());
  50. });
  51. $('.SGSpectatorModeRadio').click(function(){
  52. if ($(this).val()==="true"){
  53. $.jStorage.set('SGSpectatorMode', true);
  54. } else {
  55. $.jStorage.set('SGSpectatorMode', false);
  56. }
  57. });
  58. $('.SGMotivationModeRadio').click(function(){
  59. if ($(this).val()==="true"){
  60. $.jStorage.set('SGMotivationMode', true);
  61. } else {
  62. $.jStorage.set('SGMotivationMode', false);
  63. }
  64. });
  65. $('#SGDemoralizatorTimerSpectatorSubmit').click(function(){
  66. $.jStorage.set('SGDemoralizatorTimerSpectator', $('#SGDemoralizatorTimerSpectatorText').val());
  67. });
  68. $('#SGDemoralizatorFakeUserIDCountSubmit').click(function(){
  69. $.jStorage.set('SGDemoralizatorFakeUserIDCount', $('#SGDemoralizatorFakeUserIDCountText').val());
  70. });
  71. $('#SGDemoralizatorFakeCitizenshipIDSubmit').click(function(){
  72. $.jStorage.set('SGDemoralizatorFakeCitizenshipID', $('#SGDemoralizatorFakeCitizenshipIDText').val());
  73. });
  74. $('.SGDemoralizatorModeRadio').click(function(){
  75. if ($(this).val()==="true"){
  76. $.jStorage.set('SGDemoralizatorMode', true);
  77. } else {
  78. $.jStorage.set('SGDemoralizatorMode', false);
  79. }
  80. });
  81. $('<p style="clear: both"></p><br>').appendTo(wrapperSettings);
  82. }
  83. /*---On Settings Page---*/
  84. /*---On Shadow Government Page---*/
  85. if (localUrl.indexOf( URLShadowGovernment, 0 ) >= 0){
  86. var wrapperSG = $("#userMenu + script + div");
  87. wrapperSG.attr("id","WrapperMainConfig");
  88. wrapperSG.empty();
  89. $('<center><h1>Shadow Government Blank</h1></center><p style="clear: both"></p><br>').appendTo(wrapperSG);
  90. }
  91. /*---On Shadow Government Page---*/
  92. /*---On Battle Page---*/
  93. if (localUrl.indexOf( URLBattle, 0 ) >= 0){
  94. /*---Отключаем стилями картинки в окне сообщения боя---*/
  95. var stringCSS = '.fightsprite.critical1,.fightsprite.critical0,.fightsprite.critical2,.fightsprite.critical3,.fightsprite.normal1,.fightsprite.normal0,.fightsprite.normal2,.fightsprite.normal3,.fightsprite.miss,.fightsprite.toofast {\n display:none;\n}\n\n';
  96. stringCSS += '.fightsprite.critical1 + br,.fightsprite.critical0 + br,.fightsprite.critical2 + br,.fightsprite.critical3 + br,.fightsprite.normal1 + br,.fightsprite.normal0 + br,.fightsprite.normal2 + br,.fightsprite.normal3 + br,.fightsprite.miss + br,.fightsprite.toofast + br {\n display:none;\n}\n\n';
  97. stringCSS += '#fightResponse{\n margin:0 auto .6em!important;\n padding:9px 0px 2px;\n font-size:14px;\n font-family:\'Open Sans\',Arial,sans-serif!important;\n background:#eee;\n border-radius:3px;\n -moz-border-radius:3px;\n -o-border-radius:3px;\n -webkit-border-radius:3px;\n border:1px solid #777;\n background-position:25px 0!important;\n box-shadow:0 0 3px rgba(0,187,255,0.5),0 0 12px rgba(142,153,168,0.2) inset;\n -o-box-shadow:0 0 3px rgba(0,187,255,0.5),0 0 12px rgba(142,153,168,0.2) inset;\n -webkit-box-shadow:0 0 3px rgba(0,187,255,0.5),0 0 12px rgba(142,153,168,0.2) inset;\n -moz-box-shadow:0 0 3px rgba(0,187,255,0.5),0 0 12px rgba(142,153,168,0.2) inset;\n word-wrap:break-word;\n}\n\n';
  98. stringCSS += '#fightStatus{\n border-radius:3px;\n -moz-border-radius:3px;\n -o-border-radius:3px;\n -webkit-border-radius:3px;\n border:1px solid #777;\n background-position:25px 0!important;\n box-shadow:0 0 3px rgba(0,187,255,0.5),0 0 12px rgba(142,153,168,0.2) inset;\n -o-box-shadow:0 0 3px rgba(0,187,255,0.5),0 0 12px rgba(142,153,168,0.2) inset;\n -webkit-box-shadow:0 0 3px rgba(0,187,255,0.5),0 0 12px rgba(142,153,168,0.2) inset;\n -moz-box-shadow:0 0 3px rgba(0,187,255,0.5),0 0 12px rgba(142,153,168,0.2) inset;\n word-wrap:break-word;\n}\n\n';
  99. style = document.createElement( "style" );
  100. style.type = "text/css";
  101. style.textContent = stringCSS;
  102. document.body.appendChild( style );
  103. style = undefined;
  104. /*---Отключаем стилями картинки в окне сообщения боя---*/
  105.  
  106. /*---Отключаем модальные окна на странице боя---*/
  107. window.picoModal=function() {
  108. return true;
  109. }
  110. /*---Отключаем модальные окна на странице боя---*/
  111. /*---Минимизируем заголовок боя---*/
  112. $("#battleHeaderImage").remove();
  113. $("#mainFight").css({"margin-top": "0px", "margin-bottom": ".4em","background-color": "white","border-radius": "3px",});
  114. $("#mainFight .fightFont").removeClass("fightFont").addClass("fightFontSG");
  115. $("#mainFight .fightFontSG").css({"text-shadow": "0 0 2px black",});
  116. /*---Минимизируем заголовок боя---*/
  117.  
  118. /*---Минимизируем списки топ3/топ10 по урону на странице боя---*/
  119. $("#battleStats").show();
  120. if($("#totalattackers").length==0 ) {
  121. $("#battleStats").append('<div class="foundation-style small-10 columns SpectatorsBattleStatsElements"><div class="foundation-style small-5 columns"><b>Total defenders online:</b><i id="totaldefenders" style="display: inline;">0</i> <a style="font-size: 11px;" href="" id="defendersLink">Show details</a> <a style="font-size: 11px; display: none;" href="" id="defendersLinkHide">Hide details</a> <br><div align="center" id="defendersMenu" style="font-size: 11px; text-align: center; padding: 1em; margin: auto; display: block;">No one <br> </div></div><div class="foundation-style small-5 columns"><b>Total attackers online:</b><i id="totalattackers" style="display: inline;">0</i> <a style="font-size: 11px;" href="" id="attackersLink">Show details</a> <a style="font-size: 11px; display: none;" href="" id="attackersLinkHide">Hide details</a> <br><div align="center" id="attackersMenu" style="font-size: 11px; text-align: center; padding: 1em; margin: auto; display: block;">No one <br> </div></div>');
  122. $("#battleStats").append('<div class="foundation-style small-10 columns SpectatorsBattleStatsElements"><b>Total spectators online:</b><i id="totalspectators" style="display: inline;">0</i> <a style="font-size: 11px;" href="" id="spectatorsLink">Show details</a> <a style="font-size: 11px; display: none;" href="" id="spectatorsLinkHide">Hide details</a> <br><div align="center" id="spectatorsMenu" style="font-size: 11px; text-align: center; padding: 1em; margin: auto; display: block;">No one <br> </div> </div>');
  123. }
  124. $('#spectatorsLink').click(function () { $('#spectatorsLink').fadeOut('fast', function () { $('#spectatorsLinkHide').fadeIn('fast'); $('#spectatorsMenu').fadeIn('fast'); }); return false; });
  125. $('#spectatorsLinkHide').click(function () { $('#spectatorsLinkHide').fadeOut('fast', function () { $('#spectatorsLink').fadeIn('fast'); $('#spectatorsMenu').fadeOut('fast'); }); return false; });
  126.  
  127. $('#attackersLink').click(function () { $('#attackersLink').fadeOut('fast', function () { $('#attackersLinkHide').fadeIn('fast'); $('#attackersMenu').fadeIn('fast'); }); return false; });
  128. $('#attackersLinkHide').click(function () { $('#attackersLinkHide').fadeOut('fast', function () { $('#attackersLink').fadeIn('fast'); $('#attackersMenu').fadeOut('fast'); }); return false; });
  129.  
  130. $('#defendersLink').click(function () { $('#defendersLink').fadeOut('fast', function () { $('#defendersLinkHide').fadeIn('fast'); $('#defendersMenu').fadeIn('fast'); }); return false; });
  131. $('#defendersLinkHide').click(function () { $('#defendersLinkHide').fadeOut('fast', function () { $('#defendersLink').fadeIn('fast'); $('#defendersMenu').fadeOut('fast'); }); return false; });
  132. $("#battleSelectable:first + #battleSelectable div.small-10:first").remove();
  133. $('<div id="wrapperBattleStatsButtons" class="foundation-style small-10 columns" style="margin-bottom:.4em;"></div>').insertBefore($("#battleSelectable:first + #battleSelectable div.small-4:first"));
  134. $('<div id="showTop3BattleStats" style="padding-bottom:.4em;padding-top:.4em;margin:.4em .4em 0 .4em;" class="foundation-style button"> Show Top 3 </div>').appendTo($("#wrapperBattleStatsButtons"));
  135. $('<div id="showTop10BattleStats" style="padding-bottom:.4em;padding-top:.4em;margin:.4em .4em 0 .4em;" class="foundation-style button"> Show Top 10 </div>').appendTo($("#wrapperBattleStatsButtons"));
  136. $('<div id="showRecentActionsBattleStats" style="padding-bottom:.4em;padding-top:.4em;margin:.4em .4em 0 .4em;" class="foundation-style button"> Recent Actions </div>').appendTo($("#wrapperBattleStatsButtons"));
  137. $('<div id="showSpectatorsBattleStats" style="padding-bottom:.4em;padding-top:.4em;margin:.4em .4em 0 .4em;" class="foundation-style button"> Spectators </div>').appendTo($("#wrapperBattleStatsButtons"));
  138.  
  139. $("#wrapperBattleStatsButtons + div.small-4, #wrapperBattleStatsButtons + div.small-4 + div.small-2, #wrapperBattleStatsButtons + div.small-4 + div.small-2 + div.small-4").addClass("Top3BattleStatsElements");
  140. $("#battleStats > div.small-10:first").addClass("Top10BattleStatsElements");
  141. $(".Top10BattleStatsElements + div.small-10").addClass("RecentActionsBattleStatsElements");
  142. //$(".RecentActionsBattleStatsElements + div.small-10, .RecentActionsBattleStatsElements + div.small-10 + div.small-10").addClass("SpectatorsBattleStatsElements");
  143.  
  144. $(".Top3BattleStatsElements").css('display', $.jStorage.get('SGTop3BattleStatsElements', "none"));
  145. $("#showTop3BattleStats").click(function () {
  146. $(".Top3BattleStatsElements").toggle("fast", function () {
  147. $.jStorage.set('SGTop3BattleStatsElements', $(".Top3BattleStatsElements").css('display'));
  148. });
  149. });
  150. $(".Top10BattleStatsElements").css('display', $.jStorage.get('SGTop10BattleStatsElements', "none"));
  151. $("#showTop10BattleStats").click(function () {
  152. $(".Top10BattleStatsElements").toggle("fast", function () {
  153. $.jStorage.set('SGTop10BattleStatsElements', $(".Top10BattleStatsElements").css('display'));
  154. });
  155. });
  156. $(".RecentActionsBattleStatsElements").css('display', $.jStorage.get('SGRecentActionsBattleStatsElements', "none"));
  157. $("#showRecentActionsBattleStats").click(function () {
  158. $(".RecentActionsBattleStatsElements").toggle("fast", function () {
  159. $.jStorage.set('SGRecentActionsBattleStatsElements', $(".RecentActionsBattleStatsElements").css('display'));
  160. });
  161. });
  162. $(".SpectatorsBattleStatsElements").css('display', $.jStorage.get('SGSpectatorsBattleStatsElements', "none"));
  163. $("#showSpectatorsBattleStats").click(function () {
  164. $(".SpectatorsBattleStatsElements").toggle("fast", function () {
  165. $.jStorage.set('SGSpectatorsBattleStatsElements', $(".SpectatorsBattleStatsElements").css('display'));
  166. });
  167. });
  168. /*---Минимизируем списки топ3/топ10 по урону на странице боя---*/
  169.  
  170. /*---Формируем блок сообщений боя---*/
  171. $('#fightStatus').show().css({'width':'initial',}).removeClass("testDivblue").addClass("fightContainer");
  172. $('#fightResponse').hide().addClass("foundation-style small-10 columns");
  173. //$('#fightResponse > div').addClass("testDivblue");
  174. $('<div id="wrapperStatusActionButtons" class="foundation-style small-10 columns" style="margin-bottom:.4em;"></div>').insertBefore($("#fightResponse"));
  175. $('<div id="SGShowStatusAction" style="padding-bottom:.4em;padding-top:.4em;margin:.4em .4em 0 .4em;" class="foundation-style button"> Show Status Action </div>').appendTo($("#wrapperStatusActionButtons"));
  176. $("#fightResponse").css('display', $.jStorage.get('SGShowStatusActionButton', "none"));
  177. $("#SGShowStatusAction").click(function () {
  178. $("#fightResponse").toggle("fast", function () {
  179. $.jStorage.set('SGShowStatusActionButton', $("#fightResponse").css('display'));
  180. });
  181. });
  182. /*---Формируем блок сообщений боя---*/
  183. /*---Спектатор---*/
  184. //var SGSpectatorMode = $.jStorage.get('SGSpectatorMode', 1);
  185. if($.jStorage.get('SGSpectatorMode', true)){
  186. var SGTimerSpectator = $.jStorage.get('SGTimerSpectator', 7000); // Кд отправки запросов данных 1 секунда = 1000 миллисекунд.
  187.  
  188. function sendUpdateRequestSpectator() {
  189. if (!hasFocus)
  190. return;
  191. var FakeUserID = $.jStorage.get('SGFakeUserID', 1); // Айди фейкового пользователя.
  192. var FakeCitizenshipID = $.jStorage.get('SGFakeCitizenshipID', 1); // Айди гражданства фейкового пользователя.
  193. var dataString = 'id=' + $("#battleRoundId").val() + "&at="+FakeUserID+"&ci="+FakeCitizenshipID+"&premium=1";
  194. $.ajax({
  195. type: "GET",
  196. url: "battleScore.html",
  197. data: dataString,
  198. dataType: "json",
  199. success: function(msg) {
  200. updateStatus(msg.attackerScore, msg.defenderScore, msg.remainingTimeInSeconds, msg.percentAttackers);
  201. updateBattleHeros(msg.topAttackers, msg.topDefenders);
  202. updateTop10(msg.top10Attackers, msg.top10Defenders);
  203. updateBattleMonitor(msg);
  204. //updatePlace(msg.yourPlace);
  205. //updateTotalDamage(msg.totalPlayerDamage);
  206. for (var i = 0; i < msg.recentAttackers.length; i++) {
  207. if (msg.recentAttackers[i].id == latestAttackerId) {
  208. msg.recentAttackers = msg.recentAttackers.slice(0, i);
  209. break;
  210. }
  211. }
  212. for (var i = 0; i < msg.recentDefenders.length; i++) {
  213. if (msg.recentDefenders[i].id == latestDefenderId) {
  214. msg.recentDefenders = msg.recentDefenders.slice(0, i);
  215. break;
  216. }
  217. }
  218. if (msg.recentAttackers.length != 0) {
  219. latestAttackerId = msg.recentAttackers[0].id;
  220. attackerHits = msg.recentAttackers;
  221. }
  222. if (msg.recentDefenders.length != 0) {
  223. latestDefenderId = msg.recentDefenders[0].id;
  224. defenderHits = msg.recentDefenders;
  225. }
  226. }
  227. });
  228. }
  229. var intervalID = window.setInterval(sendUpdateRequestSpectator, SGTimerSpectator);
  230. continueThread = false;
  231. }
  232. /*---Спектатор---*/
  233. /*---Фейк Спектатор Деморализатор---*/
  234. if($.jStorage.get('SGDemoralizatorMode', false)){
  235. var SGDemoralizatorFakeUserIDCount = $.jStorage.get('SGDemoralizatorFakeUserIDCount', 10);
  236. var SGDemoralizatorFakeCitizenshipID = $.jStorage.get('SGDemoralizatorFakeCitizenshipID', 2);
  237. var SGDemoralizatorTimerSpectator = $.jStorage.get('SGDemoralizatorTimerSpectator', 10000);
  238.  
  239. function sendUpdateRequestSpectatorFake(UserID,CitizenshipID) {
  240. var dataString = 'id=' + $("#battleRoundId").val() + "&at="+UserID+"&ci="+CitizenshipID+"&premium=1";
  241. $.ajax({
  242. type: "GET",
  243. url: "battleScore.html",
  244. data: dataString,
  245. dataType: "json"
  246. });
  247. }
  248.  
  249. function FakeSpectators(){
  250. n = 0;
  251. while (n < SGDemoralizatorFakeUserIDCount) {
  252. setTimeout(sendUpdateRequestSpectatorFake, (n+1)*(SGDemoralizatorTimerSpectator/SGDemoralizatorFakeUserIDCount), (n+1), SGDemoralizatorFakeCitizenshipID);
  253. n++;
  254. }
  255. }
  256.  
  257. window.setInterval(FakeSpectators, SGDemoralizatorTimerSpectator);
  258. }
  259. /*---Фейк Спектатор Деморализатор---*/
  260. }
  261. /*---On Battle Page---*/
  262.  
  263. /*---On Motivation Page---*/
  264. if (localUrl.indexOf( URLMotivation, 0 ) >= 0){
  265. //var SGMotivationMode = $.jStorage.get('SGMotivationMode', 1);
  266. if($.jStorage.get('SGMotivationMode', true)){
  267. var CurrentDay = /\d+/gim.exec($("#userMenu div div.panel.callout b:eq(2)").html());
  268. var CurrentDay = parseInt(CurrentDay[0]);
  269. var tmpMotivateCountToday = {day: CurrentDay,count: 0};
  270. var MotivateCountToday = JSON.parse($.jStorage.get('SGMotivateCountToday', JSON.stringify(tmpMotivateCountToday)));
  271. //console.log(MotivateCountToday);
  272. if (MotivateCountToday.day != tmpMotivateCountToday.day){
  273. MotivateCountToday = tmpMotivateCountToday;
  274. $.jStorage.set('SGMotivateCountToday', JSON.stringify(MotivateCountToday));
  275. }
  276.  
  277. $(".dataTable ul.button.foundation-center.foundation-style-group li a.foundation-style.button.small.help i.icon-cupcake").parent().parent().toggle();
  278. $("<span>Today motivate count: <b id=\"countMotivationToday\">0</b><span>").insertAfter("#newCitizenStatsForm");
  279. $("#countMotivationToday").html(MotivateCountToday.count);
  280.  
  281. $( "table.dataTable tr" ).each(function( index, element ) {
  282. if ($(this).children("td").children("i.icon-uniF478").length>0){
  283. var MotivateUserID = $(this).children("td:first").children(".profileLink").attr("href").replace("profile.html?id=","");
  284. if ($(this).children("td:eq(4)").children("i.icon-uniF478").length==1){
  285. $(this).children("td:eq(4)").empty();
  286. $(this).children("td:eq(4)").append('<i id="motivate-weapons-'+MotivateUserID+'" style="cursor: pointer; color: #000; font-size: 1.25em; text-shadow: 0 0 0" class="motivate-element motivate-weapons icon-tank" value="'+MotivateUserID+'"></i>');
  287. }
  288. if ($(this).children("td:eq(5)").children("i.icon-uniF478").length==1){
  289. $(this).children("td:eq(5)").empty();
  290. $(this).children("td:eq(5)").append('<i id="motivate-breads-'+MotivateUserID+'" style="cursor: pointer; color: #000; font-size: 1.25em; text-shadow: 0 0 0" class="motivate-element motivate-breads icon-bread" value="'+MotivateUserID+'"></i>');
  291. }
  292. if ($(this).children("td:eq(6)").children("i.icon-uniF478").length==1){
  293. $(this).children("td:eq(6)").empty();
  294. $(this).children("td:eq(6)").append('<i id="motivate-gifts-'+MotivateUserID+'" style="cursor: pointer; color: #000; font-size: 1.25em; text-shadow: 0 0 0" class="motivate-element motivate-gifts icon-gift" value="'+MotivateUserID+'"></i>');
  295. }
  296. }
  297. return true;
  298. });
  299.  
  300. function motivateResponse (jqXHR, timeout, message) {
  301. var dataString = /type=(\d)&id=(\d+)/gim.exec($(this)[0].data);
  302. var idType = parseInt(dataString[1]);
  303. var idUser = parseInt(dataString[2]);
  304. var arrType = ["none","weapons","breads","gifts"]
  305. var messageResponse = "";
  306. if (messageResponse = /&citizenMessage=(\S+)/gim.exec(jqXHR.getResponseHeader("TM-finalURLdhdg"))){
  307. if (messageResponse[1]=="SUCCESFULLY_MOTIVATED"){
  308. var parentTDw = $("#motivate-"+arrType[idType]+"-"+idUser).parent();
  309. parentTDw.empty();
  310. parentTDw.append('<i title="Мотивация прошла успешно" style="color: #0c0; font-size: 1.25em; text-shadow: 0 0 0" class="icon-uniF479"></i>');
  311. MotivateCountToday.count = MotivateCountToday.count+1;
  312. $.jStorage.set('SGMotivateCountToday', JSON.stringify(MotivateCountToday));
  313. $("#countMotivationToday").html(MotivateCountToday.count);
  314. } else {
  315. $("#motivate-"+arrType[idType]+"-"+idUser).attr("title","Ошибка: "+messageResponse[1]);
  316. }
  317. } else if(/Вы отправили слишком много мотиваций сегодня/gim.exec(jqXHR.responseText)){
  318. var parentTDw = $("#motivate-"+arrType[idType]+"-"+idUser).parent();
  319. parentTDw.empty();
  320. parentTDw.append('<i title="Вы отправили слишком много мотиваций сегодня" style="color: #c00; font-size: 1.25em; text-shadow: 0 0 0" class="icon-uniF478"></i>');
  321. MotivateCountToday.count = 5;
  322. $.jStorage.set('SGMotivateCountToday', JSON.stringify(MotivateCountToday));
  323. $("#countMotivationToday").html(MotivateCountToday.count);
  324. } else if(/Вы уже отправляли комплект этому гражданину сегодня/gim.exec(jqXHR.responseText)){
  325. var parentTDw = $("#motivate-"+arrType[idType]+"-"+idUser).parent();
  326. parentTDw.empty();
  327. parentTDw.append('<i title="Вы уже отправляли комплект этому гражданину сегодня" style="color: #c00; font-size: 1.25em; text-shadow: 0 0 0" class="icon-uniF478"></i>');
  328. } else if(/Этот гражданин получил слишком много мотиваций сегодня/gim.exec(jqXHR.responseText)){
  329. var parentTDw = $("#motivate-"+arrType[idType]+"-"+idUser).parent();
  330. parentTDw.empty();
  331. parentTDw.append('<i title="Этот гражданин получил слишком много мотиваций сегодня" style="color: #c00; font-size: 1.25em; text-shadow: 0 0 0" class="icon-uniF478"></i>');
  332. } else if(/Этот гражданин получил все виды мотивационных комплектов сегодня/gim.exec(jqXHR.responseText)){
  333. var parentTDw = $("#motivate-"+arrType[idType]+"-"+idUser).parent();
  334. parentTDw.empty();
  335. parentTDw.append('<i title="Этот гражданин получил все виды мотивационных комплектов сегодня" style="color: #c00; font-size: 1.25em; text-shadow: 0 0 0" class="icon-uniF478"></i>');
  336. } else if(/У вас не достаточно предметов/gim.exec(jqXHR.responseText)){
  337. var parentTDw = $("#motivate-"+arrType[idType]+"-"+idUser).parent();
  338. parentTDw.empty();
  339. parentTDw.append('<i title="У вас не достаточно предметов" style="color: #c00; font-size: 1.25em; text-shadow: 0 0 0" class="icon-uniF478"></i>');
  340. }
  341. }
  342.  
  343. $(".motivate-element").click(function(){
  344. var typeMotivate = 0;
  345. if ($(this).hasClass("motivate-weapons")){
  346. typeMotivate = 1;
  347. } else if ($(this).hasClass("motivate-breads")){
  348. typeMotivate = 2;
  349. } else if ($(this).hasClass("motivate-gifts")){
  350. typeMotivate = 3;
  351. }
  352. var parentTD = $(this).parent();
  353. var userID = $(this).attr("value");
  354. var dataString = "type="+typeMotivate+"&id="+userID;
  355. $.ajax({
  356. type: "POST",
  357. url: "motivateCitizen.html?id="+userID,
  358. data: dataString,
  359. dataType: "json",
  360. error: motivateResponse
  361. });
  362. });
  363.  
  364. $(".motivate-element").hover(function() {
  365. $(this).css("color", "#999");
  366. }, function() {
  367. $(this).css("color", "#000");
  368. });
  369. }
  370. }
  371. /*---On Motivation Page---*/
  372. }