Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
Did some code cleaning, adding and removing ‘;’ and changing all
console.log to console.warn where they should be changed.
Ping #97
  • Loading branch information
spatialillusions committed Apr 12, 2017
1 parent 2319fa1 commit 6aad253
Show file tree
Hide file tree
Showing 45 changed files with 75 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/iconparts/2525b.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ module.exports = function (iconParts, properties, colors, STD2525, monoColor, al
defaultProperties.call(this,icn[key]);
iconParts[key] = icn[key];
}
}
};
6 changes: 3 additions & 3 deletions src/iconparts/tactical-points.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/letter-labels/tactical-points-2525.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,4 @@ module.exports = function tacticalPoints(sidc){
sidc['G-O-FA----'] = {};//TACGRP.OTH.FIX.ACU
sidc['G-O-FE----'] = {};//TACGRP.OTH.FIX.EM
sidc['G-O-FO----'] = {};//TACGRP.OTH.FIX.EOP
}
};
4 changes: 2 additions & 2 deletions src/letter-labels/tactical-points-app6.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function tacticalPoints(sidc){
sidc['G-C-MAAU--'] = {};//2.X.2.1.2.1.3 POP UP POINT (PUP)
sidc['G-C-MAAD--'] = {};//2.X.2.1.2.1.4 DOWNED AIRCREW PICK UP POINT
sidc['G-C-MDN---'] = {};//2.X.2.1.3.6 DUMMY MINEFIELD
sidc['G-C-MMPT--'] = { uniqueDesignation:{stroke:false,textanchor:"start",x:115,y:85,fontsize:45,fontweight:'bold'}};;//2.X.2.1.4.1.1 TARGET REFERENCE POINT (TRP)
sidc['G-C-MMPT--'] = { uniqueDesignation:{stroke:false,textanchor:"start",x:115,y:85,fontsize:45,fontweight:'bold'}};//2.X.2.1.4.1.1 TARGET REFERENCE POINT (TRP)
sidc['G-C-MMPO--'] = {};//2.X.2.1.4.1.4 OBSERVATION POST/OUTPOST
sidc['G-C-MMPOC-'] = {};//2.X.2.1.4.1.4.1 COMBAT OUTPOST
sidc['G-C-MMPOR-'] = {};//2.X.2.1.4.1.4.2 OBSERVATION POST OCCUPIED BY DISMOUNTED SCOUTS OR RECONNAISSANCE
Expand Down Expand Up @@ -433,4 +433,4 @@ module.exports = function tacticalPoints(sidc){
sidc['G-O-IK----'] = {};//2.X.3.4.5 KNOWN INSURGENT VEHICLE
sidc['G-O-ID----'] = {};//2.X.3.4.6 DRUG VEHICLE
sidc['G-O-IF----'] = {};//2.X.3.4.7 INTERNAL SECURITY FORCE
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-2525b-ch2.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ module.exports = function air(sId,bbox,icn,_STD2525){
// Tactical points
sId['G-O-SBWD--'] = icn['TP.WRECK, DANGEROUS'];//TACGRP.OTH.SSUBSR.BTMRTN.WRKD
bbox['G-O-SBXD--'] = {x1:35,x2:165,y1:70,y2:130};
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-air.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ module.exports = function air(sId,bbox,icn,_STD2525){
sId['S-A-CF----'] = [icn['AR.I.FF.CIVILIAN FIXED WING']];
sId['S-A-CH----'] = [icn['AR.I.FF.CIVILIAN ROTARY WING']];
sId['S-A-CL----'] = [icn['AR.I.FF.CIVILIAN BALLOON']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-emergencymanagementsymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@ module.exports = function emergencymanagementsymbols(sId,bbox,icn,_STD2525){
sId["E-F-MG----"] = [icn['GR.IN.IC.STORAGE TOWER']];
sId["E-F-MH----"] = [icn['GR.IN.IC.SURFACE WATER INTAKE']];
sId["E-F-MI----"] = [icn['GR.IN.IC.WASTEWATER TREATMENT FACILITY']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-equipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ module.exports = function equipment(sId,bbox,icn,_STD2525){
if (!equipmentBottom.hasOwnProperty(key)) continue;
bbox['S-G-'+key] = {x1:50,x2:150,y1:50,y2:equipmentBottom[key]};
}
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-ground.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,4 @@ module.exports = function ground(sId,bbox,icn,_STD2525){
//1.X.3.1.6 BROKEN SIDC
sId['S-G-UH2---'] = [icn['GR.IC.FF.SUPPLY'],icn['GR.IC.FF.HEADQUARTERS OR HEADQUARTERS ELEMENT']];
sId['S-G-UHGL--'] = sId['S-G-GL----'] = [icn['GR.IC.LIAISON']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-installations.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ module.exports = function installations(sId,bbox,icn,_STD2525){
sId['S-G-IX----'] = [icn['GR.IC.FF.MEDICAL']];
sId['S-G-IXH---'] = [icn['GR.IC.FF.MEDICAL TREATMENT FACILITY']];
sId['S-G-IRR---'] = sId['S-G-IRSR--'] = [icn['GR.IN.IC.SEA SURFACE INSTALLATION, OIL RIG/PLATFORM']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-sea.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ module.exports = function sea(sId,bbox,icn,_STD2525){
sId['S-S-ZM----'] = [icn['SE.IC.SEA MINELIKE']];
sId['S-S-ZN----'] = [icn['SE.IC.NAVIGATIONAL']];
sId['S-S-ZI----'] = [icn['SE.IC.ICEBERG']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-signalsIntelligence.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ module.exports = function signalsIntelligence(sId,bbox,icn,_STD2525){
sId['I-U-SRS---'] = [icn['SI.IC.RADAR'],icn['SI.M1.SIERRA'],icn['SI.M2.SIERRA']];
sId['I-U-SRT---'] = [icn['SI.IC.RADAR'],icn['SI.M1.TANGO'],icn['SI.M2.ALPHA']];
sId['I-U-SRU---'] = [icn['SI.IC.RADAR'],icn['SI.M1.UNIFORM'],icn['SI.M2.NOVEMBER']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-sof.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ module.exports = function sof(sId,bbox,icn,_STD2525){
sId['S-F-GPA---'] = sId['S-F-GSPA--'] = [icn['GR.EQ.PSYCHOLOGICAL OPERATIONS EQUIPMENT'], ms._translate(0,-30,ms._scale(0.7,icn['AR.I.MILITARY FIXED WING']))];
sId['S-F-GC----'] = sId['S-F-GCA---'] = [icn['GR.IC.CIVIL AFFAIRS']];
sId['S-F-GB----'] = sId['S-F-B-----'] = [icn['AR.I.SPECIAL OPERATIONS FORCES'],icn['GR.M2.SUPPORT']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-space.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ module.exports = function space(sId,bbox,icn,_STD2525){
sId['S-P-V-----'] = [icn['SP.I.FF.CREWED SPACE VEHICLE']];
sId['S-P-T-----'] = [icn['SP.I.FF.SPACE STATION']];
sId['S-P-L-----'] = [icn['SP.I.SPACE LAUNCH VEHICLE']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-stabilityoperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ module.exports = function stabilityoperations(sId,bbox,icn,_STD2525){
sId['O-G-F-----'] = [icn['ST.IC.GROUP'],icn['ST.M1.GANG']];
sId['O-R-------'] = [icn['ST.IC.INDIVIDUAL'],icn['ST.M1.RAPE']];
sId['O-R-A-----'] = [icn['ST.IC.INDIVIDUAL'],icn['ST.M1.RAPE'],icn['ST.IC.ATTEMPTED CRIMINAL ACTIVITY']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-subsurface.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ module.exports = function subsurface(sId,bbox,icn,_STD2525){
sId['S-U-NBW---'] = [icn['SU.IC.WRECK']];
sId['S-U-NM----'] = [icn['SU.IC.MARINE LIFE']];
sId['S-U-NA----'] = [icn['SU.IC.SEA ANOMALY']];
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-tactical-points-2525.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,4 @@ module.exports = function tacticalPoints(sidc,bbox,icn,std2525){
sidc['G-O-FA----'] = icn['TP.FIX ACOUSTIC'];//TACGRP.OTH.FIX.ACU
sidc['G-O-FE----'] = icn['TP.FIX ELECTRO-MAGNETIC'];//TACGRP.OTH.FIX.EM
sidc['G-O-FO----'] = icn['TP.FIX ELECTRO-OPTICAL'];//TACGRP.OTH.FIX.EOP
}
};
2 changes: 1 addition & 1 deletion src/letter-sidc/icons-tactical-points-app6.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,4 @@ module.exports = function tacticalPoints(sidc,bbox,icn,std2525){
sidc['G-O-IK----'] = icn['ST.IC.KNOWN INSURGENT VEHICLE'];//2.X.3.4.5
sidc['G-O-ID----'] = [icn['ST.IC.KNOWN INSURGENT VEHICLE'],icn['ST.M1.DRUG']];//2.X.3.4.6
sidc['G-O-IF----'] = icn['ST.IC.INTERNAL SECURITY FORCE'];//2.X.3.4.7
}
};
29 changes: 15 additions & 14 deletions src/ms.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ ms.getHqStafLength = function() {
ms.getSymbolParts = function() {
return this._symbolParts.slice(0);
};
ms.getVersion = function() {return this.version};
ms.getVersion = function() {return this.version;};
ms.outline = function(geom, outline, stroke, color){
var clone;
if(Array.isArray(geom)){
var clone = [];
clone = [];
for(var i in geom){
clone.push(ms.outline(geom[i],outline,stroke,color));
}
}else{
var clone = {};
clone = {};
for (var key in geom){
if(['fill','fillopacity'].indexOf(key) == -1){
clone[key] = geom[key];
Expand Down Expand Up @@ -178,63 +179,63 @@ ms.setStandard = require('./ms/setstandard.js');

// For backward compability
ms.addMarkerParts = function(part) {
console.log('addMarkerParts() is deprecated and should not be used, use addSymbolPart() instead.');
console.warn('addMarkerParts() is deprecated and should not be used, use addSymbolPart() instead.');
ms.addSymbolPart(part);
};
ms.bboxMax = function(box1, box2){
console.log('bboxMax() is deprecated and should not be used, use BBox.merge() instead.');
console.warn('bboxMax() is deprecated and should not be used, use BBox.merge() instead.');
return box1.merge(box2);
};
ms.buildingBlock = function(pre, post, bbox) {
console.log('buildingBlock() is deprecated and should not be used.');
console.warn('buildingBlock() is deprecated and should not be used.');
if ( pre.length == 1 && Array.isArray(pre[0]) ) pre = pre[0];
if ( post.length == 1 && Array.isArray(post[0]) ) post = post[0];
return {pre: pre, post: post, bbox: bbox};
};
ms.addLetterLabelOverrides = function(parts){
console.log('addLetterLabelOverrides() is deprecated and should not be used, use addLabelOverrides() instead.');
console.warn('addLetterLabelOverrides() is deprecated and should not be used, use addLabelOverrides() instead.');
if (typeof parts === 'function') {
if (!this._labelOverrides.hasOwnProperty('letter')) this._labelOverrides['letter'] = [];
this._labelOverrides['letter'] = this._labelOverrides['letter'].concat(parts);
}
};
ms.addLetterSIDCicons = function(parts){
console.log('addLetterSIDCicons() is deprecated and should not be used, use addSIDCicons() instead.');
console.warn('addLetterSIDCicons() is deprecated and should not be used, use addSIDCicons() instead.');
if (typeof parts === 'function') {
this._letterSIDCicons = this._letterSIDCicons.concat(parts);
}
};
ms.addNumberLabelOverrides = function(parts){
console.log('addNumberLabelOverrides() is deprecated and should not be used, use addLabelOverrides() instead.');
console.warn('addNumberLabelOverrides() is deprecated and should not be used, use addLabelOverrides() instead.');
if (typeof parts === 'function') {
if (!this._labelOverrides.hasOwnProperty('number')) this._labelOverrides['number'] = [];
this._labelOverrides['number'] = this._labelOverrides['number'].concat(parts);
}
};
ms.addNumberSIDCicons = function(parts){
console.log('addNumberSIDCicons() is deprecated and should not be used, use addSIDCicons() instead.');
console.warn('addNumberSIDCicons() is deprecated and should not be used, use addSIDCicons() instead.');
if (typeof parts === 'function') {
this._numberSIDCicons = this._numberSIDCicons.concat(parts);
}
};

ms.bbox = function(box){
console.log('bbox() is deprecated and should not be used, use BBox() instead.');
console.warn('bbox() is deprecated and should not be used, use BBox() instead.');
return ms.BBox(box);
}

ms.colorMode = function(civilian, friend, hostile, neutral, unknown) {
console.log('colorMode() is deprecated and should not be used, use ColorMode() instead.');
console.warn('colorMode() is deprecated and should not be used, use ColorMode() instead.');
return ms.ColorMode(civilian, friend, hostile, neutral, unknown);
};

ms.getMarkerParts = function() {
console.log('getMarkerParts() is deprecated and should not be used, use getSymbolParts() instead.');
console.warn('getMarkerParts() is deprecated and should not be used, use getSymbolParts() instead.');
return ms.getSymbolParts();
};

ms.setMarkerParts = function(parts) {
console.log('setMarkerParts() is deprecated and should not be used, use setSymbolParts() instead.');
console.warn('setMarkerParts() is deprecated and should not be used, use setSymbolParts() instead.');
ms.setSymbolParts(parts);
return ms;
};
Expand Down
8 changes: 4 additions & 4 deletions src/ms.symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function symbol(option1,options){
this.fillOpacity = 1; // Possibility to change the fill opacity
this.frame = true; // Should the icon be framed
this.strokeWidth = 4; // The stroke width of he icon frame.
this.outlineColor = 'rgb(239, 239, 239)' // Color of the outline
this.outlineColor = 'rgb(239, 239, 239)';// Color of the outline
this.outlineWidth = 0; // Width of the outline.
this.icon = true; // Should we display the icon?
this.monoColor = false; // Should the icon be monocromatic and if so what color
Expand Down Expand Up @@ -65,7 +65,7 @@ function symbol(option1,options){

// Initiate symbol.
this.setOptions.call(this, options);
};
}

// This is here so that we have it initiated in this.symbol from the beginning
symbol.prototype.asCanvas = require('./symbol/ascanvas.js');
Expand All @@ -82,11 +82,11 @@ symbol.prototype.toDataURL = function() { return ("data:image/svg+xml;base64," +

// For backward compability
symbol.prototype.asImage = function(){
console.log('asImage() is deprecated and should not be used, use toDataURL() instead.');
console.warn('asImage() is deprecated and should not be used, use toDataURL() instead.');
return this.toDataURL.call(this);
};
symbol.prototype.getMarker = function(){
console.log('getMarker() is deprecated and should not be used, in most cases its not needed and you can use setOptions() instead.');
console.warn('getMarker() is deprecated and should not be used, in most cases its not needed and you can use setOptions() instead.');
return this.setOptions.call(this);
};

Expand Down
2 changes: 1 addition & 1 deletion src/ms/bbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function(box){
return {
height: this.y2-this.y1,
width: this.x2-this.x1
}
};
},
merge: function(box) {
this.x1 = ( box.x1 <= this.x1 ) ? box.x1 : this.x1;
Expand Down
2 changes: 1 addition & 1 deletion src/ms/iconparts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/number-sidc/icons-activites.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ module.exports = function activites(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_STD2525)
sIdm1['17'] = [icn['ST.M1.INCIDENT']];
sIdm1['18'] = [icn['ST.M1.THEFT']];
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-air.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ module.exports = function air(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_STD2525){
sIdm2['10'] = [icn['AIR.M2.LONG RANGE']];
sIdm2['11'] = [icn['AIR.M2.DOWNLINKED']];
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-airmissile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ module.exports = function airmissile(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_STD2525
sIdm2['15'] = [icn['AIR.MISSILE.M2.LONG RANGE']];
sIdm2['16'] = [icn['SPACE.MISSILE.M2.SPACE']];
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-cyberspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ module.exports = function cyberspace(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_STD2525
sId['160800'] = [icn['CY.IC.SERVICE OUTAGE']];
sId['160900'] = [icn['CY.IC.DEVICE OUTAGE']];
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-landcivilian.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ module.exports = function landcivilian(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_STD25

sIdm2['01'] = [icn['ST.M2.LEADER OR LEADERSHIP']];
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-landequipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,4 @@ module.exports = function landequipment(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_STD2
bbox[key] = {y2:equipmentBottom[key]};
}
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-landinstallation.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ module.exports = function landinstallation(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_S
sIdm2['07'] = [icn['GR.IN.M2.NUCLEAR MATERIAL STORAGE']];
sIdm2['08'] = [icn['GR.IN.M2.WEAPONS GRADE PRODUCTION']];
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-landunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,4 @@ module.exports = function landunit(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_STD2525){
sIdm2['56'] = [icn['GR.M2.UTILITY']];
sIdm2['57'] = [icn['GR.M2.COMBAT SEARCH AND RESCUE']];
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-minewarfare.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ module.exports = function minewarfare(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_STD252
sId['200000'] = [icn['SU.IC.ENVIRONMENTAL REPORT LOCATION']];
sId['210000'] = [icn['SU.IC.DIVE REPORT LOCATION']];
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-sea.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ module.exports = function sea(sId,sIdm1,sIdm2,bbox,symbolSet,icn,_STD2525){
sIdm2['14'] = [icn['SE.M2.REMOTELY PILOTED']];
sIdm2['15'] = [icn['SE.M2.EXPENDABLE']];
}
}
};
2 changes: 1 addition & 1 deletion src/number-sidc/icons-seabedinstallations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ module.exports = function seabedinstallations(sId,sIdm1,sIdm2,bbox,symbolSet,icn
sId['110000'] = [icn['SU.IC.SEABED INSTALLATION, MAN-MADE, MILITARY']];
sId['120000'] = [icn['SU.IC.SEABED INSTALLATION, MAN-MADE, NON-MILITARY']];
}
}
};
Loading

0 comments on commit 6aad253

Please sign in to comment.