ShadowGovermentLibBeta

Shadow Goverment Lib Beta

目前為 2015-09-12 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/12383/73931/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. style = document.createElement( "style" );
  98. style.type = "text/css";
  99. style.textContent = stringCSS;
  100. document.body.appendChild( style );
  101. style = undefined;
  102. /*---Отключаем стилями картинки в окне сообщения боя---*/
  103.  
  104. /*---Отключаем модальные окна на странице боя---*/
  105. window.picoModal=function() {
  106. return true;
  107. }
  108. /*---Отключаем модальные окна на странице боя---*/
  109. /*---Минимизируем заголовок боя---*/
  110. $("#battleHeaderImage").remove();
  111. $("#mainFight").css({"margin-top": "0px", "margin-bottom": ".4em",});
  112. $("#mainFight .fightFont").removeClass("fightFont").addClass("fightFontSG");
  113. $("#mainFight .fightFontSG").css({"text-shadow": "0 0 2px black",});
  114. /*---Минимизируем заголовок боя---*/
  115.  
  116. /*---Минимизируем списки топ3/топ10 по урону на странице боя---*/
  117. $("#battleStats").show();
  118. $("#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; display: none;" href="" id="defendersLink">Show details</a> <a style="font-size: 11px;" 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; display: none;" href="" id="attackersLink">Show details</a> <a style="font-size: 11px; display: inline;" 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>');
  119. $("#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; display: none;" href="" id="spectatorsLink">Show details</a> <a style="font-size: 11px;" 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>');
  120. $('#spectatorsLink').click(function () { $('#spectatorsLink').fadeOut('fast', function () { $('#spectatorsLinkHide').fadeIn('fast'); $('#spectatorsMenu').fadeIn('fast'); }); return false; });
  121. $('#spectatorsLinkHide').click(function () { $('#spectatorsLinkHide').fadeOut('fast', function () { $('#spectatorsLink').fadeIn('fast'); $('#spectatorsMenu').fadeOut('fast'); }); return false; });
  122.  
  123. $('#attackersLink').click(function () { $('#attackersLink').fadeOut('fast', function () { $('#attackersLinkHide').fadeIn('fast'); $('#attackersMenu').fadeIn('fast'); }); return false; });
  124. $('#attackersLinkHide').click(function () { $('#attackersLinkHide').fadeOut('fast', function () { $('#attackersLink').fadeIn('fast'); $('#attackersMenu').fadeOut('fast'); }); return false; });
  125.  
  126. $('#defendersLink').click(function () { $('#defendersLink').fadeOut('fast', function () { $('#defendersLinkHide').fadeIn('fast'); $('#defendersMenu').fadeIn('fast'); }); return false; });
  127. $('#defendersLinkHide').click(function () { $('#defendersLinkHide').fadeOut('fast', function () { $('#defendersLink').fadeIn('fast'); $('#defendersMenu').fadeOut('fast'); }); return false; });
  128. $("#battleSelectable:first + #battleSelectable div.small-10:first").remove();
  129. $('<div id="wrapperBattleStatsButtons" class="foundation-style small-10 columns" style="margin-bottom:.4em;"></div>').insertBefore($("#battleSelectable:first + #battleSelectable div.small-4:first"));
  130. $('<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"));
  131. $('<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"));
  132. $('<div id="showRecentActionsBattleStats" style="padding-bottom:.4em;padding-top:.4em;margin:.4em .4em 0 .4em;" class="foundation-style button"> Recent Actions </div>').appendTo($("#wrapperBattleStatsButtons"));
  133. $('<div id="showSpectatorsBattleStats" style="padding-bottom:.4em;padding-top:.4em;margin:.4em .4em 0 .4em;" class="foundation-style button"> Spectators </div>').appendTo($("#wrapperBattleStatsButtons"));
  134.  
  135. $("#wrapperBattleStatsButtons + div.small-4, #wrapperBattleStatsButtons + div.small-4 + div.small-2, #wrapperBattleStatsButtons + div.small-4 + div.small-2 + div.small-4").addClass("Top3BattleStatsElements");
  136. $("#battleStats > div.small-10:first").addClass("Top10BattleStatsElements");
  137. $(".Top10BattleStatsElements + div.small-10").addClass("RecentActionsBattleStatsElements");
  138. //$(".RecentActionsBattleStatsElements + div.small-10, .RecentActionsBattleStatsElements + div.small-10 + div.small-10").addClass("SpectatorsBattleStatsElements");
  139.  
  140. $(".Top3BattleStatsElements").css('display', $.jStorage.get('SGTop3BattleStatsElements', "none"));
  141. $("#showTop3BattleStats").click(function () {
  142. $(".Top3BattleStatsElements").toggle("fast", function () {
  143. $.jStorage.set('SGTop3BattleStatsElements', $(".Top3BattleStatsElements").css('display'));
  144. });
  145. });
  146. $(".Top10BattleStatsElements").css('display', $.jStorage.get('SGTop10BattleStatsElements', "none"));
  147. $("#showTop10BattleStats").click(function () {
  148. $(".Top10BattleStatsElements").toggle("fast", function () {
  149. $.jStorage.set('SGTop10BattleStatsElements', $(".Top10BattleStatsElements").css('display'));
  150. });
  151. });
  152. $(".RecentActionsBattleStatsElements").css('display', $.jStorage.get('SGRecentActionsBattleStatsElements', "none"));
  153. $("#showRecentActionsBattleStats").click(function () {
  154. $(".RecentActionsBattleStatsElements").toggle("fast", function () {
  155. $.jStorage.set('SGRecentActionsBattleStatsElements', $(".RecentActionsBattleStatsElements").css('display'));
  156. });
  157. });
  158. $(".SpectatorsBattleStatsElements").css('display', $.jStorage.get('SGSpectatorsBattleStatsElements', "none"));
  159. $("#showSpectatorsBattleStats").click(function () {
  160. $(".SpectatorsBattleStatsElements").toggle("fast", function () {
  161. $.jStorage.set('SGSpectatorsBattleStatsElements', $(".SpectatorsBattleStatsElements").css('display'));
  162. });
  163. });
  164. /*---Минимизируем списки топ3/топ10 по урону на странице боя---*/
  165.  
  166. /*---Формируем блок сообщений боя---*/
  167. $('#fightStatus').show().css({'width':'initial',}).removeClass("testDivblue").addClass("fightContainer");
  168. $('#fightResponse').hide().addClass("foundation-style small-10 columns");
  169. $('#fightResponse > div').addClass("testDivblue");
  170. $('<div id="wrapperStatusActionButtons" class="foundation-style small-10 columns" style="margin-bottom:.4em;"></div>').insertBefore($("#fightResponse"));
  171. $('<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"));
  172. $("#fightResponse").css('display', $.jStorage.get('SGShowStatusActionButton', "none"));
  173. $("#SGShowStatusAction").click(function () {
  174. $("#fightResponse").toggle("fast", function () {
  175. $.jStorage.set('SGShowStatusActionButton', $("#fightResponse").css('display'));
  176. });
  177. });
  178. /*---Формируем блок сообщений боя---*/
  179. /*---Спектатор---*/
  180. //var SGSpectatorMode = $.jStorage.get('SGSpectatorMode', 1);
  181. if($.jStorage.get('SGSpectatorMode', true)){
  182. var SGTimerSpectator = $.jStorage.get('SGTimerSpectator', 7000); // Кд отправки запросов данных 1 секунда = 1000 миллисекунд.
  183.  
  184. function sendUpdateRequestSpectator() {
  185. if (!hasFocus)
  186. return;
  187. var FakeUserID = $.jStorage.get('SGFakeUserID', 1); // Айди фейкового пользователя.
  188. var FakeCitizenshipID = $.jStorage.get('SGFakeCitizenshipID', 1); // Айди гражданства фейкового пользователя.
  189. var dataString = 'id=' + $("#battleRoundId").val() + "&at="+FakeUserID+"&ci="+FakeCitizenshipID+"&premium=1";
  190. $.ajax({
  191. type: "GET",
  192. url: "battleScore.html",
  193. data: dataString,
  194. dataType: "json",
  195. success: function(msg) {
  196. updateStatus(msg.attackerScore, msg.defenderScore, msg.remainingTimeInSeconds, msg.percentAttackers);
  197. updateBattleHeros(msg.topAttackers, msg.topDefenders);
  198. updateTop10(msg.top10Attackers, msg.top10Defenders);
  199. updateBattleMonitor(msg);
  200. //updatePlace(msg.yourPlace);
  201. //updateTotalDamage(msg.totalPlayerDamage);
  202. for (var i = 0; i < msg.recentAttackers.length; i++) {
  203. if (msg.recentAttackers[i].id == latestAttackerId) {
  204. msg.recentAttackers = msg.recentAttackers.slice(0, i);
  205. break;
  206. }
  207. }
  208. for (var i = 0; i < msg.recentDefenders.length; i++) {
  209. if (msg.recentDefenders[i].id == latestDefenderId) {
  210. msg.recentDefenders = msg.recentDefenders.slice(0, i);
  211. break;
  212. }
  213. }
  214. if (msg.recentAttackers.length != 0) {
  215. latestAttackerId = msg.recentAttackers[0].id;
  216. attackerHits = msg.recentAttackers;
  217. }
  218. if (msg.recentDefenders.length != 0) {
  219. latestDefenderId = msg.recentDefenders[0].id;
  220. defenderHits = msg.recentDefenders;
  221. }
  222. }
  223. });
  224. }
  225. var intervalID = window.setInterval(sendUpdateRequestSpectator, SGTimerSpectator);
  226. continueThread = false;
  227. }
  228. /*---Спектатор---*/
  229. /*---Фейк Спектатор Деморализатор---*/
  230. if($.jStorage.get('SGDemoralizatorMode', false)){
  231. var SGDemoralizatorFakeUserIDCount = $.jStorage.get('SGDemoralizatorFakeUserIDCount', 10);
  232. var SGDemoralizatorFakeCitizenshipID = $.jStorage.get('SGDemoralizatorFakeCitizenshipID', 2);
  233. var SGDemoralizatorTimerSpectator = $.jStorage.get('SGDemoralizatorTimerSpectator', 10000);
  234.  
  235. function sendUpdateRequestSpectatorFake(UserID,CitizenshipID) {
  236. var dataString = 'id=' + $("#battleRoundId").val() + "&at="+UserID+"&ci="+CitizenshipID+"&premium=1";
  237. $.ajax({
  238. type: "GET",
  239. url: "battleScore.html",
  240. data: dataString,
  241. dataType: "json"
  242. });
  243. }
  244.  
  245. function FakeSpectators(){
  246. n = 0;
  247. while (n < SGDemoralizatorFakeUserIDCount) {
  248. setTimeout(sendUpdateRequestSpectatorFake, (n+1)*(SGDemoralizatorTimerSpectator/SGDemoralizatorFakeUserIDCount), (n+1), SGDemoralizatorFakeCitizenshipID);
  249. n++;
  250. }
  251. }
  252.  
  253. window.setInterval(FakeSpectators, SGDemoralizatorTimerSpectator);
  254. }
  255. /*---Фейк Спектатор Деморализатор---*/
  256. }
  257. /*---On Battle Page---*/
  258.  
  259. /*---On Motivation Page---*/
  260. if (localUrl.indexOf( URLMotivation, 0 ) >= 0){
  261. //var SGMotivationMode = $.jStorage.get('SGMotivationMode', 1);
  262. if($.jStorage.get('SGMotivationMode', true)){
  263. var CurrentDay = /\d+/gim.exec($("#userMenu div div.panel.callout b:eq(2)").html());
  264. var CurrentDay = parseInt(CurrentDay[0]);
  265. var tmpMotivateCountToday = {day: CurrentDay,count: 0};
  266. var MotivateCountToday = JSON.parse($.jStorage.get('SGMotivateCountToday', JSON.stringify(tmpMotivateCountToday)));
  267. //console.log(MotivateCountToday);
  268. if (MotivateCountToday.day != tmpMotivateCountToday.day){
  269. MotivateCountToday = tmpMotivateCountToday;
  270. $.jStorage.set('SGMotivateCountToday', JSON.stringify(MotivateCountToday));
  271. }
  272.  
  273. $(".dataTable ul.button.foundation-center.foundation-style-group li a.foundation-style.button.small.help i.icon-cupcake").parent().parent().toggle();
  274. $("<span>Today motivate count: <b id=\"countMotivationToday\">0</b><span>").insertAfter("#newCitizenStatsForm");
  275. $("#countMotivationToday").html(MotivateCountToday.count);
  276.  
  277. $( "table.dataTable tr" ).each(function( index, element ) {
  278. if ($(this).children("td").children("i.icon-uniF478").length>0){
  279. var MotivateUserID = $(this).children("td:first").children(".profileLink").attr("href").replace("profile.html?id=","");
  280. if ($(this).children("td:eq(4)").children("i.icon-uniF478").length==1){
  281. $(this).children("td:eq(4)").empty();
  282. $(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>');
  283. }
  284. if ($(this).children("td:eq(5)").children("i.icon-uniF478").length==1){
  285. $(this).children("td:eq(5)").empty();
  286. $(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>');
  287. }
  288. if ($(this).children("td:eq(6)").children("i.icon-uniF478").length==1){
  289. $(this).children("td:eq(6)").empty();
  290. $(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>');
  291. }
  292. }
  293. return true;
  294. });
  295.  
  296. function motivateResponse (jqXHR, timeout, message) {
  297. var dataString = /type=(\d)&id=(\d+)/gim.exec($(this)[0].data);
  298. var idType = parseInt(dataString[1]);
  299. var idUser = parseInt(dataString[2]);
  300. var arrType = ["none","weapons","breads","gifts"]
  301. var messageResponse = "";
  302. if (messageResponse = /&citizenMessage=(\S+)/gim.exec(jqXHR.getResponseHeader("TM-finalURLdhdg"))){
  303. if (messageResponse[1]=="SUCCESFULLY_MOTIVATED"){
  304. var parentTDw = $("#motivate-"+arrType[idType]+"-"+idUser).parent();
  305. parentTDw.empty();
  306. parentTDw.append('<i title="Мотивация прошла успешно" style="color: #0c0; font-size: 1.25em; text-shadow: 0 0 0" class="icon-uniF479"></i>');
  307. MotivateCountToday.count = MotivateCountToday.count+1;
  308. $.jStorage.set('SGMotivateCountToday', JSON.stringify(MotivateCountToday));
  309. $("#countMotivationToday").html(MotivateCountToday.count);
  310. } else {
  311. $("#motivate-"+arrType[idType]+"-"+idUser).attr("title","Ошибка: "+messageResponse[1]);
  312. }
  313. } else if(/Вы отправили слишком много мотиваций сегодня/gim.exec(jqXHR.responseText)){
  314. var parentTDw = $("#motivate-"+arrType[idType]+"-"+idUser).parent();
  315. parentTDw.empty();
  316. parentTDw.append('<i title="Вы отправили слишком много мотиваций сегодня" style="color: #c00; font-size: 1.25em; text-shadow: 0 0 0" class="icon-uniF478"></i>');
  317. MotivateCountToday.count = 5;
  318. $.jStorage.set('SGMotivateCountToday', JSON.stringify(MotivateCountToday));
  319. $("#countMotivationToday").html(MotivateCountToday.count);
  320. } else if(/Вы уже отправляли комплект этому гражданину сегодня/gim.exec(jqXHR.responseText)){
  321. var parentTDw = $("#motivate-"+arrType[idType]+"-"+idUser).parent();
  322. parentTDw.empty();
  323. parentTDw.append('<i title="Вы уже отправляли комплект этому гражданину сегодня" style="color: #c00; font-size: 1.25em; text-shadow: 0 0 0" class="icon-uniF478"></i>');
  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. }
  337. }
  338.  
  339. $(".motivate-element").click(function(){
  340. var typeMotivate = 0;
  341. if ($(this).hasClass("motivate-weapons")){
  342. typeMotivate = 1;
  343. } else if ($(this).hasClass("motivate-breads")){
  344. typeMotivate = 2;
  345. } else if ($(this).hasClass("motivate-gifts")){
  346. typeMotivate = 3;
  347. }
  348. var parentTD = $(this).parent();
  349. var userID = $(this).attr("value");
  350. var dataString = "type="+typeMotivate+"&id="+userID;
  351. $.ajax({
  352. type: "POST",
  353. url: "motivateCitizen.html?id="+userID,
  354. data: dataString,
  355. dataType: "json",
  356. error: motivateResponse
  357. });
  358. });
  359.  
  360. $(".motivate-element").hover(function() {
  361. $(this).css("color", "#999");
  362. }, function() {
  363. $(this).css("color", "#000");
  364. });
  365. }
  366. }
  367. /*---On Motivation Page---*/
  368. }