Coding AJAX-compatible GM scripts
Moderator: Tech Team
Forum rules
Please read the Community Guidelines before posting.
Please read the Community Guidelines before posting.
OK - I've just uploaded the latest version...
VERSION : 2.13
(2.12 was crap)
FIXED :
Fixed Coloured Drop downs for Doodle earth (and other maps with brackets in)
Fixed Link labels to point to this thread...
TODO :
Clock Format doesn't work <- does anyone care about this one?
Clock Parsing not always correct (Noticed with 08 and 09 times - anymore?)
WISHLIST :
Objectives <- Added once first map with this in Quenched (AoR?)
Territory counter for FOW games.
Anything else that needs to be added?
C.
VERSION : 2.13
(2.12 was crap)
FIXED :
Fixed Coloured Drop downs for Doodle earth (and other maps with brackets in)
Fixed Link labels to point to this thread...
TODO :
Clock Format doesn't work <- does anyone care about this one?
Clock Parsing not always correct (Noticed with 08 and 09 times - anymore?)
WISHLIST :
Objectives <- Added once first map with this in Quenched (AoR?)
Territory counter for FOW games.
Anything else that needs to be added?
C.

Highest score : 2297
- Aerial Attack
- Posts: 1132
- Joined: Mon Jun 04, 2007 7:59 pm
- Location: Generation One: The Clan
xmaveric wrote:Could you please disable clock processing until the 08 & 09 times are fixed? Or add that as an option to the menu?
Due to the fact that 08 -> 09 are less than the majority of the time - this is fairly minor - so for that very reason I won't for the majority script...
Adding an option that is superfluous for the future is to much work...
However you could do this...
Right click on Monkey...
Select "Conquer Club - BOB"
Click Edit
Search on clock.innerHTML
Then put two forward slashes at the beginning of the line...
i.e.
Code: Select all
// clock.innerHTML = hours1+'hrs '+minutes1+'min '+seconds1+'sec';
instead of...
Code: Select all
clock.innerHTML = hours1+'hrs '+minutes1+'min '+seconds1+'sec';
This will disable the updates to the clock...
C.

Highest score : 2297
- Optimus Prime
- Posts: 9665
- Joined: Mon Mar 12, 2007 9:33 pm
- Gender: Male
- Ishiro
- Posts: 324
- Joined: Mon Jul 17, 2006 5:53 pm
- Gender: Male
- Location: Under the Rainbow
- Contact:
The problem with the clock counting down is that lack already makes updates to the clock section. Any changes made to it are overwritten by lack. You end up with two processes battling for control, and depending on how they are written will determine which, if either, wins.
I never tested to make sure this worked, but...
The first section is the functions needed to advance the clock.
The second section is to initialize the clock.
What this does is hide lack's clock and insert a new one. The new one is updated from lack's and then the countdown is started. Its supposed to check its own count against lack's count every cycle, and if lack's count is different, update to use his count.
As I said, not sure if this works, but its worth a shot yeti_c. If not, perhaps you can fix whatever is broken.
I never tested to make sure this worked, but...
The first section is the functions needed to advance the clock.
Code: Select all
function ClockTimer()
{
var TimeStr = unsafeWindow.gameClock.innerHTML;
var stepClock = document.getElementById("newclock").innerHTML;
var TargetTime = TimeStr.split(/hrs\n|min\n|sec/);
var TargetTime2 = stepClock.split(/hrs\n|min\n|sec/);
var CurrHour = parseInt(TargetTime[0]);
var CurrMinute = parseInt(TargetTime[1]);
var CurrSecond = parseInt(TargetTime[2]);
var stepCurrHour = parseInt(TargetTime2[0]);
var stepCurrMinute = parseInt(TargetTime2[1]);
var stepCurrSecond = parseInt(TargetTime2[2]);
if (!(CurrHour < stepCurrHour) && !(CurrMinute < stepCurrMinute))
{
CurrHour = stepCurrHour;
CurrMinute = stepCurrMinute;
CurrSecond = stepCurrSecond;
}
--CurrSecond;
if(CurrSecond < 0 ){
--CurrMinute;
if( CurrMinute < 0 ){
--CurrHour;
if( CurrHour < 0 ){
CurrHour = 0;
}
CurrMinute = 59;
}
CurrSecond = 59;
}
document.getElementById("newclock").innerHTML = zslash(CurrHour, 2) + 'hrs\n' + zslash(String(CurrMinute), 2) + 'min\n' + zslash(CurrSecond, 2) + 'sec ';
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var day = ' @ ';
var ampm = ' ';
minutes = (minutes + CurrMinute);
if (minutes >= 60) {
hours = hours + 1;
minutes = minutes - 60;
}
hours = (hours + CurrHour);
//alert ('h:' + hours);
if (hours >= 24)
{
day = " tomorrow @ ";
hours = hours - 24
}
if (myOptions['24hourClockFormat']=="am/pm") {
ampm = " am";
if (hours >= 12)
{
ampm = " pm";
hours = hours - 12;
}
if (hours == 0) hours = 12;
}
else
{
if (hours < 10)
{
hours = "0" + hours;
}
}
if (minutes < 10)
minutes = "0" + minutes;
var clock
if (myOptions['24hourClockFormat']!="Off") {
clock = "<br />" + day + "<b>" + hours + ":" + minutes + ampm + " " + "</b>"
}
else
{
clock = ""
}
document.getElementById("newclock").innerHTML += ' ' + clock;
}
function zslash(svalue, iwidth)
{
var szero = String(svalue);
var ch = szero.substr(0,1);
while (ch == ' ')
{
szero = szero.substr(1, szero.length);
ch = szero.substr(0,1);
}
ch = szero.substr(szero.length - 1, szero.length);
while (ch == ' ')
{
szero = szero.substr(0, szero.length - 1);
ch = szero.substr(szero.length - 1, szero.length);
}
var i=0;
for (i=0; i < (iwidth - szero.length); i++)
{
szero = '0' + szero;
}
return szero;
}
The second section is to initialize the clock.
Code: Select all
var clockInterval;
/*---- Start Clock ----*/
var TimeStr = unsafeWindow.gameClock.innerHTML;
unsafeWindow.gameClock.style.display = "none !important";
var newClock = document.createElement('span');
newClock.id="newclock";
unsafeWindow.gameClock.parentNode.insertBefore(newClock, unsafeWindow.gameClock);
newClock.innerHTML = TimeStr;
if (clockInterval != "")
{
window.clearInterval(clockInterval);
clockInterval = "";
}
clockInterval = window.setInterval(ClockTimer, 1000);
What this does is hide lack's clock and insert a new one. The new one is updated from lack's and then the countdown is started. Its supposed to check its own count against lack's count every cycle, and if lack's count is different, update to use his count.
As I said, not sure if this works, but its worth a shot yeti_c. If not, perhaps you can fix whatever is broken.
I'll take a look at slipping that stuff in...
I stripped the original back down to simpler stuff to make it just update the countdown... and then when AJAX updates it get the new starting numbers and start counting down again...
Like Ishiro says - it's all a matter of getting the timing right without breaking each others code...
C.
PS no more updates this week - will have another look next week.
I stripped the original back down to simpler stuff to make it just update the countdown... and then when AJAX updates it get the new starting numbers and start counting down again...
Like Ishiro says - it's all a matter of getting the timing right without breaking each others code...
C.
PS no more updates this week - will have another look next week.

Highest score : 2297
yeti_c wrote:Frop wrote:I like how the Map Inspect option was modified, but you're still stuck to manually refreshing the page if you want the 'Map Inspect' text map to (dis)appear.
Apart from that, keep up the great work!
Actually - the latest version does the on off for map inspect on the fly - check the correct topic for better updates...
C.
Yeah, with 'modified' I was talking about the on-the-fly stuff. What I meant was that you still have to manually refresh the page if you want the 'Map Inspect' text map to (dis)appear.

- Aerial Attack
- Posts: 1132
- Joined: Mon Jun 04, 2007 7:59 pm
- Location: Generation One: The Clan
Frop wrote:yeti_c wrote:Frop wrote:I like how the Map Inspect option was modified, but you're still stuck to manually refreshing the page if you want the 'Map Inspect' text map to (dis)appear.
Apart from that, keep up the great work! :)
Actually - the latest version does the on off for map inspect on the fly - check the correct topic for better updates...
C.
Yeah, with 'modified' I was talking about the on-the-fly stuff. What I meant was that you still have to manually refresh the page if you want the 'Map Inspect' text map to (dis)appear. :)
Frop,
Please post the Game #, so we (members of the forum and yeti_c) can see the map and situation. In all of my games, the map inspect refreshes appropriately when I stop HOVERING over a territory - now, I haven't actually CLICKED on a territory.
Frop wrote:yeti_c wrote:Frop wrote:I like how the Map Inspect option was modified, but you're still stuck to manually refreshing the page if you want the 'Map Inspect' text map to (dis)appear.
Apart from that, keep up the great work!
Actually - the latest version does the on off for map inspect on the fly - check the correct topic for better updates...
C.
Yeah, with 'modified' I was talking about the on-the-fly stuff. What I meant was that you still have to manually refresh the page if you want the 'Map Inspect' text map to (dis)appear.
What version of the code are you running?
C.

Highest score : 2297
yeti_c wrote:Frop wrote:yeti_c wrote:Frop wrote:I like how the Map Inspect option was modified, but you're still stuck to manually refreshing the page if you want the 'Map Inspect' text map to (dis)appear.
Apart from that, keep up the great work!
Actually - the latest version does the on off for map inspect on the fly - check the correct topic for better updates...
C.
Yeah, with 'modified' I was talking about the on-the-fly stuff. What I meant was that you still have to manually refresh the page if you want the 'Map Inspect' text map to (dis)appear.
What version of the code are you running?
C.
Firefox 2.0.0.9, Greasemonkey 0.7.20070607.0, script version 2.13. To avoid issues I always uninstall the previous version of the script including all associated preferences.
I took a number of screenshots, hopefully I can illustrate the situation. Prerequisite is to browse a game with Map Inspect turned off.
1) Off
Now when I turn Map Inspect on, you can see that it works when I hover over a country - yet there is no text map.
2) On, no refresh
However, when I manually refresh the page the text map shows up (site option 'refresh map' does not have the same effect).
3) On, refreshed
When I turn Map Inspect off again the text map remains on the screen and doesn't disappear until I manually refresh the page.
4) Off, no refresh
- Aerial Attack
- Posts: 1132
- Joined: Mon Jun 04, 2007 7:59 pm
- Location: Generation One: The Clan
My armies all seem to line up perfectly. I am using the Large Maps setting (in CC's My Settings).
I am using the latest version of BOB (released Thurs Nov 8).
My guess is that you are either using an older version - possible
OR
You have Small Maps in your My Settings (under Personal Menu in the left navigation area) - more likely.
I guess yeti will have to do an update that checks for map size setting.
I am using the latest version of BOB (released Thurs Nov 8).
My guess is that you are either using an older version - possible
OR
You have Small Maps in your My Settings (under Personal Menu in the left navigation area) - more likely.
I guess yeti will have to do an update that checks for map size setting.
Aerial Attack wrote:My armies all seem to line up perfectly. I am using the Large Maps setting (in CC's My Settings).
I am using the latest version of BOB (released Thurs Nov.
My guess is that you are either using an older version - possible
OR
You have Small Maps in your My Settings (under Personal Menu in the left navigation area) - more likely.
I guess yeti will have to do an update that checks for map size setting.
Don't know about casper, but I have the same problem with map size set to Large.
casper wrote:yep i use large maps. any idea yeti? what is that feature for in the first place?
Widowmakers pointed out the pixels were off by one... but they weren't for me... and no-one else had complained... so my assumption - and I believe it's still true is that "most" people it works with the offsets at 0...
However there are a few with this problem - thus I intorduced the ability to move the numbers around a bit to line them up... the overlaid numbers are there to replace the existing numbers that get faded out when you change the map fade options...
C.

Highest score : 2297
Frop wrote:yeti_c wrote:Frop wrote:yeti_c wrote:Frop wrote:I like how the Map Inspect option was modified, but you're still stuck to manually refreshing the page if you want the 'Map Inspect' text map to (dis)appear.
Apart from that, keep up the great work!
Actually - the latest version does the on off for map inspect on the fly - check the correct topic for better updates...
C.
Yeah, with 'modified' I was talking about the on-the-fly stuff. What I meant was that you still have to manually refresh the page if you want the 'Map Inspect' text map to (dis)appear.
What version of the code are you running?
C.
Firefox 2.0.0.9, Greasemonkey 0.7.20070607.0, script version 2.13. To avoid issues I always uninstall the previous version of the script including all associated preferences.
I took a number of screenshots, hopefully I can illustrate the situation. Prerequisite is to browse a game with Map Inspect turned off.
1) Off
Now when I turn Map Inspect on, you can see that it works when I hover over a country - yet there is no text map.
2) On, no refresh
However, when I manually refresh the page the text map shows up (site option 'refresh map' does not have the same effect).
3) On, refreshed
When I turn Map Inspect off again the text map remains on the screen and doesn't disappear until I manually refresh the page.
4) Off, no refresh
Great bug report - I'm pretty sure I know what's going on - I'll fix it on Monday...
C.

Highest score : 2297
- Marshall Law
- Posts: 50
- Joined: Mon Aug 13, 2007 9:45 am
yeti_c wrote:casper wrote:the overlaid numbers are there to replace the existing numbers that get faded out when you change the map fade options...
C.
It seems to go back and forth for me. Sometimes it's right on and other times it's not. I haven't looked into the code (I am a bit rusty) but i dont understand why it has to be this way. In the older versions of BOB was there an double overlay approach like this one? Are the original numbers locked into the map image? Thanks, yeti.
Marshall Law wrote:yeti_c wrote:the overlaid numbers are there to replace the existing numbers that get faded out when you change the map fade options...
C.
It seems to go back and forth for me. Sometimes it's right on and other times it's not. I haven't looked into the code (I am a bit rusty) but i dont understand why it has to be this way. In the older versions of BOB was there an double overlay approach like this one? Are the original numbers locked into the map image? Thanks, yeti.
The old non ajax way of coding the site was completely changed for the AJAX way... and the only way for me to be able to fade the map - fades the numbers... and then the only way to get non faded numbers is to overlay another map that's not inside the div that's faded...
It's interesting that it changes for you... I assumed it would either be correct or out!!
I've not found any rhyme or reason as to why it's out - except that Widowmakers reported it - and he's got a long user name - and that might knock out some layout!!
C.
Last edited by yeti_c on Sat Nov 10, 2007 6:31 am, edited 1 time in total.

Highest score : 2297
OK - I've just uploaded the latest version...
VERSION : 2.14
FIXED :
Map Inspect Div now dynamic when turning it on and off.
TODO :
Clock Format doesn't work <- does anyone care about this one?
Clock Parsing not always correct (Noticed with 08 and 09 times - anymore?)
WISHLIST :
Objectives <- Added once first map with this in Quenched (AoR?)
Territory counter for FOW games.
Anything else that needs to be added?
C.
VERSION : 2.14
FIXED :
Map Inspect Div now dynamic when turning it on and off.
TODO :
Clock Format doesn't work <- does anyone care about this one?
Clock Parsing not always correct (Noticed with 08 and 09 times - anymore?)
WISHLIST :
Objectives <- Added once first map with this in Quenched (AoR?)
Territory counter for FOW games.
Anything else that needs to be added?
C.

Highest score : 2297
- Lobster Crush
- Posts: 93
- Joined: Sun Mar 18, 2007 12:18 am
- Location: Winneapolis, Minnetoba
good job on this yeti...but bob's been wacky for me since about version 2.09 or so.
see image below...the army counts are duplicated again below the map, and map inspect doesn't work at all.
also, there's no menu for bob on the left.
i've tried clearing my cache, etc., but with no luck so far.
the only thing i haven't done is opened up the script to manually tweak the settings, to see if it's one setting in particular that's causing the bug.
if i discover something, i'll post it here.
see image below...the army counts are duplicated again below the map, and map inspect doesn't work at all.
also, there's no menu for bob on the left.
i've tried clearing my cache, etc., but with no luck so far.
the only thing i haven't done is opened up the script to manually tweak the settings, to see if it's one setting in particular that's causing the bug.
if i discover something, i'll post it here.
Lobster Crush wrote:good job on this yeti...but bob's been wacky for me since about version 2.09 or so.
see image below...the army counts are duplicated again below the map, and map inspect doesn't work at all.
also, there's no menu for bob on the left.
i've tried clearing my cache, etc., but with no luck so far.
the only thing i haven't done is opened up the script to manually tweak the settings, to see if it's one setting in particular that's causing the bug.
if i discover something, i'll post it here.
Hi Lobster,
Can you do the following...
a) Install latest.
b) goto "Tools" -> "Error Console"
c) Press the "Clear" button.
d) Press the "Errors" tab
e) Load a game that this occurs in
f) Copy what appears in the Error Console screen and post it in here.
Cheers,
C.

Highest score : 2297

