Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   Разбор событий в скрипте. (https://javascript.ru/forum/events/25290-razbor-sobytijj-v-skripte.html)

arbitr 31.01.2012 23:21

Разбор событий в скрипте.
 
Всем вечер добрый, заголовок не информативный но не знал как правильно коротко описать.
итак есть скрипт
// ==UserScript==
// @name ***
// @namespace ***
// @description ***
// @author 
// @include [url]http://ru7.grepolis.com/game/*[/url]
// @exclude file://*
// ==/UserScript==
var nelem=document.createElement("div");
nelem.style.position="absolute";
nelem.style.left="500px";
nelem.style.top="0px";
nelem.style.width="340px";
nelem.style.height="40px";
nelem.style.zIndex="2000";
nelem.style.backgroundColor="white";
nelem.id="***";nelem.innerHTML="<input type='button' onclick='/*var chunk=WMap.toChunk(486,501);for(m in chunk.rel)alert(m+\":\"+chunk.rel[m]);return;*/if(this.value==\"Off\"){date = new Date();canUpdate=true;this.value=\"On\";autoInter=setInterval(function(){if(canUpdate){"
 
+"$.ajax({type: \"POST\",url: \"http://ru7.grepolis.com/game/farm_town_info?action=claim_load&town_id=1174&h=\"+encodeURIComponent(Game.csrfToken),data: \"json=%7B%22target_id%22%3A%22625%22%2C%22claim_type%22%3A%22normal%22%2C%22time%22%3A300%2C%22town_id%22%3A%221174%22%2C%22nlreq_id%22%3A\"+Layout.getLastRequestedNotificationId()+\"%7D\",success: function(msg){}});"
+"$.ajax({type: \"POST\",url: \"http://ru7.grepolis.com/game/farm_town_info?action=claim_load&town_id=1174&h=\"+encodeURIComponent(Game.csrfToken),data: \"json=%7B%22target_id%22%3A%22626%22%2C%22claim_type%22%3A%22normal%22%2C%22time%22%3A300%2C%22town_id%22%3A%221174%22%2C%22nlreq_id%22%3A\"+Layout.getLastRequestedNotificationId()+\"%7D\",success: function(msg){}});"
+"$.ajax({type: \"POST\",url: \"http://ru7.grepolis.com/game/farm_town_info?action=claim_load&town_id=1174&h=\"+encodeURIComponent(Game.csrfToken),data: \"json=%7B%22target_id%22%3A%22627%22%2C%22claim_type%22%3A%22normal%22%2C%22time%22%3A300%2C%22town_id%22%3A%221174%22%2C%22nlreq_id%22%3A\"+Layout.getLastRequestedNotificationId()+\"%7D\",success: function(msg){}});"
+"$.ajax({type: \"POST\",url: \"http://ru7.grepolis.com/game/farm_town_info?action=claim_load&town_id=1174&h=\"+encodeURIComponent(Game.csrfToken),data: \"json=%7B%22target_id%22%3A%22628%22%2C%22claim_type%22%3A%22normal%22%2C%22time%22%3A300%2C%22town_id%22%3A%221174%22%2C%22nlreq_id%22%3A\"+Layout.getLastRequestedNotificationId()+\"%7D\",success: function(msg){}});"
+"$.ajax({type: \"POST\",url: \"http://ru7.grepolis.com/game/farm_town_info?action=claim_load&town_id=1174&h=\"+encodeURIComponent(Game.csrfToken),data: \"json=%7B%22target_id%22%3A%22629%22%2C%22claim_type%22%3A%22normal%22%2C%22time%22%3A300%2C%22town_id%22%3A%221174%22%2C%22nlreq_id%22%3A\"+Layout.getLastRequestedNotificationId()+\"%7D\",success: function(msg){}});"
+"$.ajax({type: \"POST\",url: \"http://ru7.grepolis.com/game/farm_town_info?action=claim_load&town_id=1174&h=\"+encodeURIComponent(Game.csrfToken),data: \"json=%7B%22target_id%22%3A%22630%22%2C%22claim_type%22%3A%22normal%22%2C%22time%22%3A300%2C%22town_id%22%3A%221174%22%2C%22nlreq_id%22%3A\"+Layout.getLastRequestedNotificationId()+\"%7D\",success: function(msg){}});"
+"$.ajax({type: \"POST\",url: \"http://ru7.grepolis.com/game/farm_town_info?action=claim_load&town_id=1174&h=\"+encodeURIComponent(Game.csrfToken),data: \"json=%7B%22target_id%22%3A%22631%22%2C%22claim_type%22%3A%22normal%22%2C%22time%22%3A300%2C%22town_id%22%3A%221174%22%2C%22nlreq_id%22%3A\"+Layout.getLastRequestedNotificationId()+\"%7D\",success: function(msg){}});"
+"$.ajax({type: \"POST\",url: \"http://ru7.grepolis.com/game/farm_town_info?action=claim_load&town_id=1174&h=\"+encodeURIComponent(Game.csrfToken),data: \"json=%7B%22target_id%22%3A%22632%22%2C%22claim_type%22%3A%22normal%22%2C%22time%22%3A300%2C%22town_id%22%3A%221174%22%2C%22nlreq_id%22%3A\"+Layout.getLastRequestedNotificationId()+\"%7D\",success: function(msg){}});"
 
+"canUpdate=false;date = new Date();}asec=Math.floor(((new Date)-date)/1000);if(asec>330){canUpdate=true;};document.getElementById(\"IdTmelem\").innerHTML=330-asec;},5000);}else {this.value=\"Off\";clearInterval(autoInter);}' value='Off'/>";
document.body.appendChild(nelem);
var tmelem=document.createElement("div");
tmelem.innerHTML="0";
tmelem.id="IdTmelem";
var inCounter=0;
var canUpdate=0;
nelem.appendChild(tmelem);

на данный момент насколько я понимаю я пеерстал получать отклик и у меня не идет счетчик времени.
можете мне помочь решить вопрос?

arbitr 01.02.2012 13:43

если не там создал тему или что либо непонятно в вопросе, то плиз...


Часовой пояс GMT +3, время: 22:05.