S
SteveYoungTbird
I have a working javascript script with some global variables which I
want to use alongside other scripts. The script includes the following:
var side_bar_html = "";
var gmarkers = [];
var icount = 0;
function createMarker(point,name,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "mouseover", function() {
marker.openInfoWindow(html);
});
GEvent.addListener(marker, "click", function() {
drawMap(point);
});
READ.gmarkers[READ.icount] = marker;
READ.side_bar_html += '<a href="javascript:myclick(' + READ.icount
+ ')">' + name + '</a><br>';
READ.icount++;
return marker;
};
function myclick(icount) {
GEvent.trigger(gmarkers[icount], "mouseover");
};
I therefore have put the global variables into a namespace like this:
var READ = {};
READ.side_bar_html = "";
READ.gmarkers = [];
READ.icount = 0;
function createMarker(point,name,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "mouseover", function() {
marker.openInfoWindow(html);
});
GEvent.addListener(marker, "click", function() {
drawMap(point);
});
READ.gmarkers[READ.icount] = marker;
READ.side_bar_html += '<a href="javascript:myclick(' + READ.icount
+ ')">' + name + '</a><br>';
READ.icount++;
return marker;
};
function myclick(READ.icount) {
GEvent.trigger(READ.gmarkers[READ.icount], "mouseover");
};
But if I try to use the script with the namespace I get a Firebug error
"missing ) after formal parameters. function myclick(READ.icount) {\n"
It's getting late and I can't seem to work this out. Can anyone help?
want to use alongside other scripts. The script includes the following:
var side_bar_html = "";
var gmarkers = [];
var icount = 0;
function createMarker(point,name,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "mouseover", function() {
marker.openInfoWindow(html);
});
GEvent.addListener(marker, "click", function() {
drawMap(point);
});
READ.gmarkers[READ.icount] = marker;
READ.side_bar_html += '<a href="javascript:myclick(' + READ.icount
+ ')">' + name + '</a><br>';
READ.icount++;
return marker;
};
function myclick(icount) {
GEvent.trigger(gmarkers[icount], "mouseover");
};
I therefore have put the global variables into a namespace like this:
var READ = {};
READ.side_bar_html = "";
READ.gmarkers = [];
READ.icount = 0;
function createMarker(point,name,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "mouseover", function() {
marker.openInfoWindow(html);
});
GEvent.addListener(marker, "click", function() {
drawMap(point);
});
READ.gmarkers[READ.icount] = marker;
READ.side_bar_html += '<a href="javascript:myclick(' + READ.icount
+ ')">' + name + '</a><br>';
READ.icount++;
return marker;
};
function myclick(READ.icount) {
GEvent.trigger(READ.gmarkers[READ.icount], "mouseover");
};
But if I try to use the script with the namespace I get a Firebug error
"missing ) after formal parameters. function myclick(READ.icount) {\n"
It's getting late and I can't seem to work this out. Can anyone help?