-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpersist.js
29 lines (27 loc) · 888 Bytes
/
persist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var PersistModul = PersistModul || (function () {
return {
rgStations: [
{ sName: "Geratshf", nFrequence: 123500 }
],
readSingleFile: function (e) {
var file = e.target.files[0];
if (!file) return;
var reader = new FileReader();
reader.onload = function (e) {
/* var sContents = e.target.result;
displayContents(sContents);
console.log(e.target.result); */
var rgStations = e.target.result.split("\n");
PersistModul.rgStations = rgStations.map(function (currentValue, index, arr) {
var rgValues = currentValue.split(";");
return {
sName: rgValues[0],
nFrequence: Math.round(parseFloat(rgValues[1]) * 1000) // ein parseFloat(128.950) * 1000 fuehrt seltsamerweise zu 128949.9999
};
});
console.log("read:", rgStations.length, " stations (rgStations.length)");
};
reader.readAsText(file);
}
};
})();