8 changed files with 8817 additions and 26 deletions
			
			
		@ -1,7 +1,7 @@ | 
				
			|||||||
@echo off | 
					@echo off | 
				
			||||||
 | 
					
 | 
				
			||||||
pushd src | 
					pushd src | 
				
			||||||
node embed.js | 
					node ../tools/embed.js | 
				
			||||||
node ../node_modules/typescript/lib/tsc.js | 
					node ../node_modules/typescript/lib/tsc.js | 
				
			||||||
node purify.js | 
					node ../tools/purify.js | 
				
			||||||
popd | 
					popd | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@ | 
				
			|||||||
#!/bin/bash | 
					#!/bin/bash | 
				
			||||||
 | 
					
 | 
				
			||||||
cd src | 
					cd src | 
				
			||||||
node embed.js | 
					node ../tools/embed.js | 
				
			||||||
../node_modules/typescript/bin/tsc | 
					../node_modules/typescript/bin/tsc | 
				
			||||||
node purify.js | 
					node ../tools/purify.js | 
				
			||||||
 | 
				
			|||||||
									
										
											File diff suppressed because it is too large
											Load Diff
										
									
								
							
						| 
		 Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 128 KiB  | 
									
										
											File diff suppressed because one or more lines are too long
										
									
								
							
						@ -1,22 +0,0 @@ | 
				
			|||||||
let fs = require('fs') | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function embedSvg(src, dst) { | 
					 | 
				
			||||||
	fs.readFile(src, 'utf8', function(err, data) { | 
					 | 
				
			||||||
		if(err) throw err; | 
					 | 
				
			||||||
		data = data.replace(/<\?xml[^\?]*\?>[\r\n]*/g, ''); | 
					 | 
				
			||||||
		data = data.replace(/<svg[^>]*>[\r\n]*/g, ''); | 
					 | 
				
			||||||
		data = data.replace(/<\/svg>[\r\n]*/g, ''); | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		data = data.replace(/>\s*<desc[^>]*>/g, ' '); | 
					 | 
				
			||||||
		data = data.replace(/<\/desc>/g, '>'); | 
					 | 
				
			||||||
		data = data.replace(/"/g, '"'); | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		data = "(<any>window)['"+src+"'] = `" + data + "`;"; | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		fs.writeFile(dst, data, function(err) { | 
					 | 
				
			||||||
			if(err) throw err; | 
					 | 
				
			||||||
		}); | 
					 | 
				
			||||||
	}); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
embedSvg('climate-zones-map.svg', 'climate-zones-map.svg.ts'); | 
					 | 
				
			||||||
@ -0,0 +1,51 @@ | 
				
			|||||||
 | 
					let fs = require('fs') | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function embedSvg(src, dst) { | 
				
			||||||
 | 
						fs.readFile(src, 'utf8', function(err, data) { | 
				
			||||||
 | 
							if(err) throw err; | 
				
			||||||
 | 
							data = data.replace(/<\?xml[^\?]*\?>[\r\n]*/g, ''); | 
				
			||||||
 | 
							data = data.replace(/<svg[^>]*>[\r\n]*/g, ''); | 
				
			||||||
 | 
							data = data.replace(/<\/svg>[\r\n]*/g, ''); | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							data = data.replace(/>\s*<desc[^>]*>/g, ' '); | 
				
			||||||
 | 
							data = data.replace(/<\/desc>/g, '>'); | 
				
			||||||
 | 
							data = data.replace(/"/g, '"'); | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							data = "(<any>window)['"+src.replace(/^.*[\\\/]/, '')+"'] = `" + data + "`;"; | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							fs.writeFile(dst, data, function(err) { | 
				
			||||||
 | 
								if(err) throw err; | 
				
			||||||
 | 
							}); | 
				
			||||||
 | 
						}); | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function embedCsv(src, dst) { | 
				
			||||||
 | 
						fs.readFile(src, 'utf8', function(err, csvData) { | 
				
			||||||
 | 
							if(err) throw err; | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							let csvLines = csvData.split('\n').map(str => str.split(';')); | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							let jsData = {}; | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							let zones = csvLines[0]; | 
				
			||||||
 | 
							for(let zoneIdx = 0; zoneIdx < zones.length; ++zoneIdx) { | 
				
			||||||
 | 
								let zoneName = zones[zoneIdx]; | 
				
			||||||
 | 
								let zoneData = []; | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								for(let lineIdx = 1; lineIdx < csvLines.length; ++lineIdx) { | 
				
			||||||
 | 
									zoneData[lineIdx-1] = Math.round(Number(csvLines[lineIdx][zoneIdx])); | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								jsData[zoneName] = zoneData; | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							let content = "(<any>window)['"+src.replace(/^.*[\\\/]/, '')+"'] = " + JSON.stringify(jsData) + ";"; | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							fs.writeFile(dst, content, function(err) { | 
				
			||||||
 | 
								if(err) throw err; | 
				
			||||||
 | 
							}); | 
				
			||||||
 | 
						}); | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					embedSvg('../data/climate-zones-map.svg', 'climate-zones-map.svg.ts'); | 
				
			||||||
 | 
					embedCsv('../data/climate-zones-data.csv', 'climate-zones-data.ts'); | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue