Skip to content
Snippets Groups Projects
Commit 8796d14f authored by Brandon Bergren's avatar Brandon Bergren
Browse files

Rewrite pieces of icon.js more defensively to prevent prototype bugs and type errors and so forth.

parent 8dc5028f
No related branches found
No related tags found
No related merge requests found
...@@ -41,11 +41,12 @@ Drupal.gmap.getIcon = function(setname, sequence) { ...@@ -41,11 +41,12 @@ Drupal.gmap.getIcon = function(setname, sequence) {
} }
this.gicons[setname] = []; this.gicons[setname] = [];
var q = Drupal.gmap.icons[setname]; var q = Drupal.gmap.icons[setname];
var p, t;
for (var i=0; i<q.sequence.length; i++) { for (var i=0; i<q.sequence.length; i++) {
var t = new GIcon(); t = new GIcon();
var p = Drupal.gmap.iconpath + q.path; p = Drupal.gmap.iconpath + q.path;
t.image = p + q.sequence[i].f; t.image = p + q.sequence[i].f;
if (q.shadow.f != '') { if (q.shadow.f !== '') {
t.shadow = p + q.shadow.f; t.shadow = p + q.shadow.f;
t.shadowSize = new GSize(q.shadow.w, q.shadow.h); t.shadowSize = new GSize(q.shadow.w, q.shadow.h);
} }
...@@ -53,14 +54,13 @@ Drupal.gmap.getIcon = function(setname, sequence) { ...@@ -53,14 +54,13 @@ Drupal.gmap.getIcon = function(setname, sequence) {
t.iconAnchor = new GPoint(q.anchorX, q.anchorY); t.iconAnchor = new GPoint(q.anchorX, q.anchorY);
t.infoWindowAnchor = new GPoint(q.infoX, q.infoY); t.infoWindowAnchor = new GPoint(q.infoX, q.infoY);
for (var j=0; j<othimg.length; j++) { for (var j=0; j<othimg.length; j++) {
if ((typeof(q[othimg[j]])=='string') && (q[othimg[j]] != '')) { if (q[othimg[j]] !== '') {
t[othimg[j]] = p + q[othimg[j]]; t[othimg[j]] = p + q[othimg[j]];
} }
} }
// @@@ imageMap? // @@@ imageMap?
this.gicons[setname][i] = t; this.gicons[setname][i] = t;
} }
delete q;
delete Drupal.gmap.icons[setname]; delete Drupal.gmap.icons[setname];
} }
// TODO: Random, other cycle methods. // TODO: Random, other cycle methods.
...@@ -75,23 +75,21 @@ Drupal.gmap.getIcon = function(setname, sequence) { ...@@ -75,23 +75,21 @@ Drupal.gmap.getIcon = function(setname, sequence) {
Drupal.gmap.iconSetup = function() { Drupal.gmap.iconSetup = function() {
Drupal.gmap.icons = {}; Drupal.gmap.icons = {};
var m = Drupal.gmap.icondata; var m = Drupal.gmap.icondata;
for (var path in m) { var filef, filew, fileh, files;
for (var path in m) {if (m.hasOwnProperty(path)) {
// Reconstitute files array // Reconstitute files array
var filef = m[path].f; filef = m[path].f;
var filew = Drupal.gmap.expandArray(m[path].w,filef.length); filew = Drupal.gmap.expandArray(m[path].w,filef.length);
var fileh = Drupal.gmap.expandArray(m[path].h,filef.length); fileh = Drupal.gmap.expandArray(m[path].h,filef.length);
var files = []; files = [];
for (var i = 0; i < filef.length; i++) { for (var i = 0; i < filef.length; i++) {
files[i] = {f : filef[i], w : filew[i], h : fileh[i]}; files[i] = {f : filef[i], w : filew[i], h : fileh[i]};
} }
delete filef;
delete filew;
delete fileh;
for (var ini in m[path].i) { for (var ini in m[path].i) {if (m[path].i.hasOwnProperty(ini)) {
$.extend(Drupal.gmap.icons,Drupal.gmap.expandIconDef(m[path].i[ini],path,files)); $.extend(Drupal.gmap.icons,Drupal.gmap.expandIconDef(m[path].i[ini],path,files));
} }}
} }}
}; };
/** /**
...@@ -134,7 +132,7 @@ Drupal.gmap.expandIconDef = function(c,path,files) { ...@@ -134,7 +132,7 @@ Drupal.gmap.expandIconDef = function(c,path,files) {
} }
for (i = 0; i < c[0][0].length; i++) { for (i = 0; i < c[0][0].length; i++) {
for (j = 0; j < decomp.length; j++) { for (j = 0; j < decomp.length; j++) {
if (i == 0) { if (i === 0) {
defaults[decomp[j]] = c[0][j][i]; defaults[decomp[j]] = c[0][j][i];
} }
else { else {
...@@ -147,7 +145,7 @@ Drupal.gmap.expandIconDef = function(c,path,files) { ...@@ -147,7 +145,7 @@ Drupal.gmap.expandIconDef = function(c,path,files) {
} }
for (i = 0; i < sets.length; i++) { for (i = 0; i < sets.length; i++) {
for (j = 0; j < decomp.length; j++) { for (j = 0; j < decomp.length; j++) {
if (sets[i][decomp[j]] == fallback[j]) { if (sets[i][decomp[j]] === fallback[j]) {
sets[i][decomp[j]] = defaults[decomp[j]]; sets[i][decomp[j]] = defaults[decomp[j]];
} }
} }
...@@ -163,7 +161,7 @@ Drupal.gmap.expandIconDef = function(c,path,files) { ...@@ -163,7 +161,7 @@ Drupal.gmap.expandIconDef = function(c,path,files) {
icons[key].sequence[j] = files[icons[key].sequence[j]]; icons[key].sequence[j] = files[icons[key].sequence[j]];
} }
for (j = 0; j < imagerep.length; j++) { for (j = 0; j < imagerep.length; j++) {
if (typeof(icons[key][imagerep[j]])=='number') { if (typeof(icons[key][imagerep[j]])==='number') {
icons[key][imagerep[j]] = files[icons[key][imagerep[j]]]; icons[key][imagerep[j]] = files[icons[key][imagerep[j]]];
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment