Shipment Times v0.2.5
Shipment times shows a calculated time in which it will take to transport the selected goods to the destination.
The calculation includes the time in which it will take to load the goods, plus the travel time and then a total time.

Download
Click the following links to download the script file:
Shipment Times v0.2.5: shipment_times.user.js
Total unique downloads: 21,752
Changes
- v0.2.5: Small bug fix
- v0.2.3: Updates of loading times for Ikariam 0.3
- v0.2.2: Fixed problems with having spaces in townnames
- v0.2.1: Fixed a small bug in when using the textfields to transport the resources
- v0.2.0: Script now is compatible with Ikariam v0.2.7
Comments and issues should be posted on the Forum Thread
Subject: Re: Shipment Times
your correct
i didnt explain myself very well. hopefully this will clear it up for you 
what i think your problem is:
the function "getCityName()" returns a different value to what is used on line 196 in certain circumstances.
document.getElementById('citySelect')[document.getElementById('citySelect').selectedIndex].innerHTML == "[00:00] TownName";
getCityName() == "TownName";
both these values need to be the same for the script to work. (i think)
if you were to replace (line ~196)
document.getElementById('citySelect')[document.getElementById('citySelect').selectedIndex].innerHTMLwith
getCityName();and change getCityName() to
function getCityName() {return document.getElementById('citySelect')[document.getElementById('citySelect').selectedIndex].value;
}
it should work
by, BagBag at 2009-04-15 13:18:32
Subject: Re: Shipment Times
BagBag, I don't explained very well
The function works well, but you use it only to get the GM value.
In my case city var is set with coords and is get without coords --> the port level readed is 0. (I check this with two alerts)
But if you use the function to set and to get, the script works perfect.
by, NubeRoja at 2009-04-15 12:47:48
Subject: Re: Shipment Times
ive had a look the function, and the part that would be using it.
it does look like certain configurations of the dropdown box (there are 3 i think) could make it fail to read the citys name.
if the function were to check the value instead of the innerHTML of the select options it (should) be the cityId no matter what configuration the drop down is in
by, BagBag at 2009-04-15 09:35:12
Subject: Re: Shipment Times
Hi, your script is very usefull but i always have the same problem with it,
The city name stored in GM is different than the readed,
If you have a function to get the city name, why don't you use always this function?
// Check if the city page is loaded, and if so, update the portsize
if (document.getElementById('city') != null)
{
var city = getCityName();
this code works fine for me in the spanish ikariam server ikariam.es
and finally a small suggestion, can you implement this script in the takeoffer page and colonize page?
by, NubeRoja at 2009-04-15 03:52:23
Subject: Re: Shipment Times
I'd have to agree with BagBag, the time and processing required to perform a HTTP request for all or even one town far out weights the cost of storing a few port levels.
Plus the process being slower.
Along with finally the new fact that performing HTTP requests on Ikariam servers is deemed illegal.
That all said, is a neat idea and an interesting approach to ensuring correct data.
by, immortalnights at 2009-04-12 20:31:50
Subject: Re: Shipment Times
what you propose would guarantee that the port level used in the calculation is up-to date, but it uses an extra http request, which should sparingly.
each value for port level (for every city) is updated automatically every time you visit the city in question, the maximum value this stored value can be off by is 1 level as you have to visit the city to upgrade the port. (although if you use direct linking/an add-on this may not be the case).
I'm not sure that the memory saved by not caching the port levels out-weighs the cost of an extra http request.
My knowledge of http requests is slim to non-existent, but I believe your using synchronous requests which if a time-out occurs can block the rest of the JavaScript execution (again I suck at these so could be way off the mark)
by, BagBag at 2009-04-09 20:55:23
Subject: Re: Shipment Times
Here is a simple bit of code that get the port level of from the transport page without having to go to the city page first. This makes the script more useful because you don't not have to rely on going to each city first and it doesn't rely on using the GM_setValue which eats up memory.
function getPortLvl() {
var cityId = document.getElementById('citySelect')[document.getElementById('citySelect').selectedIndex].value;
var gameServer = top.location.host;
var portLevel = 0;
try {
var req = new XMLHttpRequest();
req.open('GET', 'http://' + gameServer + '/index.php' + '?view=city&id='+ cityId, false);
req.send(null);
if(req.status == 200) {
var hiddenDiv = document.createElement("div");
hiddenDiv.setAttribute("style", "display: hidden;");
document.body.appendChild(hiddenDiv);
hiddenDiv.innerHTML = req.responseText;
var positions = document.getElementById('locations');
for (var i = 0; i < positions.childNodes.length; i++) {
if (positions.childNodes[i].className == "port") {
var aPortLevel = (positions.childNodes[i].childNodes[3].title.split(" "));
portLevel = parseInt(aPortLevel.last());
break;
}
}
document.body.removeChild(hiddenDiv);
}
} catch(er) {
alert(er);
}
return portLevel;
}
by, corners at 2009-04-09 16:45:29
Subject: Re: Shipment Times
is there a problem with it? (i dont use it so i dont know).
if there is, please could you post some more details about the problems/errors you are receiving?
edit: installed it and can see the problem :p it calculates the loading speed wrong (off by about 200 hours in my case)
ill have a look at fixing it.
by, BagBag at 2009-03-14 07:28:56
Subject: Re: Shipment Times
Will there be an update soon for this feature?
by, Crispy at 2009-03-14 07:24:02
Subject: Re: Shipment Times
In version 2.5,I had to change this line (towards the end):
var city = document.getElementById('citySelect')[document.getElementById('citySelect').selectedIndex].innerHTML;
To read like the following lines (borrowed from the top of the script), in order for it to work:
var city_raw = document.getElementById('citySelect')[document.getElementById('citySelect').selectedIndex].innerHTML;
// Is the player showing cords?
if (city_raw.indexOf(":") != -1)
{
// Showing cords
var cordsEnd = city_raw.indexOf("]") + 2;
city=city_raw.substring(cordsEnd, city_raw.length);
}
else
{
// Not showing cords
city=city_raw;
}
Thought the developer might like to know.
by, Crinisuilla at 2009-03-09 15:11:36