Production
This commit is contained in:
@@ -8,7 +8,7 @@ async function initDB() {
|
||||
if (features == null) {
|
||||
console.log("Loading DB");
|
||||
console.log(this.indexedDB);
|
||||
var request = this.indexedDB.open("flightgear", 2);
|
||||
var request = this.indexedDB.open("flightgear", 3);
|
||||
request.onerror = function (event) {
|
||||
reject(event);
|
||||
};
|
||||
@@ -26,7 +26,7 @@ async function initDB() {
|
||||
var objectStore = db.createObjectStore("airports", { keyPath: "properties.icao" });
|
||||
}
|
||||
if (event.oldVersion < 2) {
|
||||
// Version 1 is the first version of the database.
|
||||
// Version 2 is the first version of the database.
|
||||
var objectStore = event.target.transaction.objectStore("airports");
|
||||
var indexNames = objectStore.indexNames;
|
||||
var desiredKeyPathForMyIndex = "properties.icao";
|
||||
|
||||
@@ -64,6 +64,7 @@ async function scanGroundnetFiles(p, features) {
|
||||
}).catch(reason => {
|
||||
logger('info', "Crashed");
|
||||
logger('info', reason);
|
||||
this.postMessage('DONE');
|
||||
});
|
||||
|
||||
//walkDir(p, f => { readGroundnet(f, features) });
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Tobias Nickel
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
# tXml
|
||||
a very small and probably the fastest xml parser in pure javascript.
|
||||
|
||||
This lib only provides one single method. **tXml()**
|
||||
|
||||
1. this code is about 230 lines, can be easily extended.
|
||||
2. this code is 0.9kb minified + gzipped.
|
||||
3. this code is 5 - 10 times faster then sax/xml2js.
|
||||
4. this code can running in a worker.
|
||||
5. this code is parsing at average the same speed as native DOMParser + potential to be faster.
|
||||
6. this code is easy to read and good for study.
|
||||
7. this code creates a domObject with minimal footprint, that is easy to traverse.
|
||||
8. this code has proven in different projects, like RSS reader, openStreetmap, websites.
|
||||
9. this code can even parse handwritten XML that contains various errors.
|
||||
10. this code is working in client and server.
|
||||
11. this code is 100% covered by unit tests.
|
||||
|
||||
so, there are good reasons to give tXml.js a try.
|
||||
|
||||
## XML - features
|
||||
1. tags
|
||||
2. childTags
|
||||
3. text-nodes
|
||||
4. white-spaces
|
||||
5. attributes with single and double quotes
|
||||
6. attributes without value
|
||||
7. xmlComments (ignored)
|
||||
8. embedded CSS and Javascript
|
||||
9. HTML singleTag elements br, img, link, meta, hr
|
||||
10. doctype definitions
|
||||
11. xml namespaces
|
||||
12. sync API for a sync process
|
||||
13. getElementsById/-Class direct on the xmlString
|
||||
14. simplify, similar to PHP's [SimpleXML](http://php.net/manual/en/book.simplexml.php)
|
||||
15. filter, similar to underscore, as a alternative to CSS selectors
|
||||
16. monomorphism for fast processing and fewer if statements (a node always has tagName:'', attributes:{} and children:[])
|
||||
|
||||
17. streamSupport ! ! !
|
||||
|
||||
## Try Online
|
||||
you can to some test without installing online: [tnickel.de](http://tnickel.de/2017/04/02/txml-online/)
|
||||
|
||||
## Installation
|
||||
In browser you load it how ever you want. For example as tag: <script src="tXml.js"></script>.
|
||||
|
||||
In node and browseryfy, run **"npm install txml"** in your project.
|
||||
and then in your script you require it by "var tXml = require('txml');
|
||||
|
||||
## Methods
|
||||
|
||||
### **tXml** *(XML-string, options)*
|
||||
1. **XML string** is the XML to parse.
|
||||
2. **options** is optional
|
||||
**searchId** an ID of some object. that can be queried. Using this is incredible fast.
|
||||
**filter** a method, to filter for interesting nodes, use it like Array.filter.
|
||||
**simplify** to simplify the object, to an easier access
|
||||
|
||||
|
||||
EXAMPLE 1: tXml("<user is='great'><name>Tobias</name><familyName>Nickel</familyName><profession>Software Developer</profession><location>Shanghai / China</location></user>");
|
||||
```js
|
||||
// will return an object like:
|
||||
[{
|
||||
"tagName": "user",
|
||||
"attributes": {
|
||||
"is": "great"
|
||||
},
|
||||
"children": [{
|
||||
"tagName": "name",
|
||||
"children": [ "Tobias" ]
|
||||
}, {
|
||||
"tagName": "familyName",
|
||||
"children": [ "Nickel" ]
|
||||
}, {
|
||||
"tagName": "profession",
|
||||
"children": [ "Software Developer" ]
|
||||
}, {
|
||||
"tagName": "location",
|
||||
"children": [ "Shanghai / China" ]
|
||||
}
|
||||
]
|
||||
}]
|
||||
```
|
||||
EXAMLPLE 2: tXml("<user is='great'><name>Tobias</name><familyName>Nickel</familyName><profession>Software Developer</profession><location>Shanghai / China</location></user>",{simplify:1});
|
||||
|
||||
```js
|
||||
// will return an object like:
|
||||
{
|
||||
"user": {
|
||||
"name": "Tobias",
|
||||
"familyName": "Nickel",
|
||||
"profession": "Software Developer",
|
||||
"location": "Shanghai / China",
|
||||
"_attributes": {
|
||||
"is": "great"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
### **tXml.simpify** *(tXml_DOM_Object)*
|
||||
this method is used with the simplify parameter;
|
||||
1. **tXml_DOM_Object** the object to simplify.
|
||||
|
||||
### **tXml.filter** *(tXml_DOM_Object, f)*
|
||||
this method is used with the filter parameter, it is used like Array.filter.
|
||||
1. **tXml_DOM_Object** the object to filter.
|
||||
2. **f** a function that returns true if you want this elements in the result set.
|
||||
|
||||
### **tXml.getElementById** (xml,id)
|
||||
to find an element by ID. if you are only interested for the information on, a specific node, this is easy and fast, because not the entire xml need to get parsed to a tDOM Object. returns the element not simplified, you can do with tXml.simplify()
|
||||
1. **xml** the xml string to search in.
|
||||
2. **id** the id of the element to find
|
||||
|
||||
|
||||
### **tXml.getElementsByClassName** (xml,className)
|
||||
find the elements with the given class, without parsing the entire xml into a tDOM. so it is very fast and convenient. returns a list of elements.
|
||||
1. **xml** the xml string to search in.
|
||||
2. **className** the className of the element to find
|
||||
|
||||
|
||||
### **txml.parseStream** (stream, offset)
|
||||
1. stream is the stream or fileName,
|
||||
2. offset requires you to set short before the first item.
|
||||
usually files begin with simething like "<!DOCTYPE osm><osm>"
|
||||
so the offset need to be before the first item starts so that
|
||||
between that item and the offset is no "<" character.
|
||||
alternatively, pass astring, containing this preample.
|
||||
return stream, triggers even "xml" to get notified when a complete node has been parsed.
|
||||
is usefull for huge files, OSM-world, wikipedia-dump.
|
||||
|
||||
### **txml.transformStream** (offset)
|
||||
2. offset optional you to set short before the first item.
|
||||
usually files begin with simething like "<!DOCTYPE osm><osm>"
|
||||
so the offset need to be before the first item starts so that
|
||||
between that item and the offset is no "<" character.
|
||||
alternatively, pass astring, containing this preample.
|
||||
return transformStream.
|
||||
```js
|
||||
const xmlStream = fs.createReadStream('your.xml').pipe(txml.transformStream())
|
||||
for await(let element of xmlStream) {
|
||||
// your logic here ...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## Developer
|
||||
[Tobias Nickel](http://tnickel.de/) German software developer in Shanghai.
|
||||

|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
function tXml(a,c){function d(){for(var c=[];a[b];)if(60==a.charCodeAt(b)){if(47===a.charCodeAt(b+1)){b=a.indexOf(">",b);b+1&&(b+=1);break}else if(33===a.charCodeAt(b+1)){if(45==a.charCodeAt(b+2)){for(;-1!==b&&(62!==a.charCodeAt(b)||45!=a.charCodeAt(b-1)||45!=a.charCodeAt(b-2)||-1==b);)b=a.indexOf(">",b+1);-1===b&&(b=a.length)}else for(b+=2;62!==a.charCodeAt(b)&&a[b];)b++;b++;continue}var d=g();c.push(d)}else d=b,b=a.indexOf("<",b)-1,-2===b&&(b=a.length),d=a.slice(d,b+1),0<d.trim().length&&c.push(d),
|
||||
b++;return c}function k(){for(var c=b;-1===m.indexOf(a[b])&&a[b];)b++;return a.slice(c,b)}function g(){b++;for(var c=k(),g={},f=[];62!==a.charCodeAt(b)&&a[b];){var e=a.charCodeAt(b);if(64<e&&91>e||96<e&&123>e){var h=k();for(e=a.charCodeAt(b);e&&39!==e&&34!==e&&!(64<e&&91>e||96<e&&123>e)&&62!==e;)b++,e=a.charCodeAt(b);if(39===e||34===e){e=a[b];var l=++b;b=a.indexOf(e,l);e=a.slice(l,b);if(-1===b)return{tagName:c,attributes:g,children:f}}else e=null,b--;g[h]=e}b++}47!==a.charCodeAt(b-1)?"script"==c?
|
||||
(f=b+1,b=a.indexOf("\x3c/script>",b),f=[a.slice(f,b-1)],b+=9):"style"==c?(f=b+1,b=a.indexOf("</style>",b),f=[a.slice(f,b-1)],b+=8):-1==n.indexOf(c)&&(b++,f=d(h)):b++;return{tagName:c,attributes:g,children:f}}function f(){var b=(new RegExp("\\s"+c.attrName+"\\s*=['\"]"+c.attrValue+"['\"]")).exec(a);return b?b.index:-1}c=c||{};var b=c.pos||0,m="\n\t>/= ",n=c.noChildNodes||["img","br","input","meta","link"],h=null;if(void 0!==c.attrValue)for(c.attrName=c.attrName||"id",h=[];-1!==(b=f());)b=a.lastIndexOf("<",
|
||||
b),-1!==b&&h.push(g()),a=a.substr(b),b=0;else h=c.parseNode?g():d();c.filter&&(h=tXml.filter(h,c.filter));c.setPos&&(h.pos=b);return h}tXml.simplify=function(a){var c={};if(!a.length)return"";if(1===a.length&&"string"==typeof a[0])return a[0];a.forEach(function(a){if("object"===typeof a){c[a.tagName]||(c[a.tagName]=[]);var d=tXml.simplify(a.children||[]);c[a.tagName].push(d);a.attributes&&(d._attributes=a.attributes)}});for(var d in c)1==c[d].length&&(c[d]=c[d][0]);return c};
|
||||
tXml.filter=function(a,c){var d=[];a.forEach(function(a){"object"===typeof a&&c(a)&&d.push(a);a.children&&(a=tXml.filter(a.children,c),d=d.concat(a))});return d};
|
||||
tXml.stringify=function(a){function c(a){if(a)for(var g=0;g<a.length;g++)if("string"==typeof a[g])d+=a[g].trim();else{var f=void 0,b=a[g];d+="<"+b.tagName;for(f in b.attributes)d=null===b.attributes[f]?d+(" "+f):-1===b.attributes[f].indexOf('"')?d+(" "+f+'="'+b.attributes[f].trim()+'"'):d+(" "+f+"='"+b.attributes[f].trim()+"'");d+=">";c(b.children);d+="</"+b.tagName+">"}}var d="";c(a);return d};
|
||||
tXml.toContentString=function(a){if(Array.isArray(a)){var c="";a.forEach(function(a){c+=" "+tXml.toContentString(a);c=c.trim()});return c}return"object"===typeof a?tXml.toContentString(a.children):" "+a};tXml.getElementById=function(a,c,d){a=tXml(a,{attrValue:c});return d?tXml.simplify(a):a[0]};tXml.getElementsByClassName=function(a,c,d){a=tXml(a,{attrName:"class",attrValue:"[a-zA-Z0-9-s ]*"+c+"[a-zA-Z0-9-s ]*"});return d?tXml.simplify(a):a};
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable */
|
||||
const winURL = process.env.NODE_ENV === 'development'
|
||||
? `http://localhost:9080/src/renderer/utils/`
|
||||
: `file://D:/GIT/flightgear-airports/src/renderer/utils/`
|
||||
: `file://${process.resourcesPath}/workers/`
|
||||
|
||||
var scanner = importScripts(`${winURL}scan.js`);
|
||||
var apt = importScripts(`${winURL}apt.js`);
|
||||
@@ -9,7 +9,7 @@ var path = require('path');
|
||||
const fs = require('fs');
|
||||
const homedir = require('os').homedir();
|
||||
var airports = importScripts(`${winURL}airports.js`);
|
||||
importScripts('../txml/tXml.min.js');
|
||||
importScripts(`${winURL}txml/tXml.min.js`);
|
||||
|
||||
importScripts('logger.js');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user