diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-04-13 12:04:21 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-08-15 19:46:52 +0200 |
| commit | cdc5aec0f72fa965b3f53327fda5176a2417b670 (patch) | |
| tree | 90dd9eef1625855029af85e9ed2ca8b84d20c7d9 /js/index.js | |
| parent | 904783a7dd10ce24d3deedce41730dc999833077 (diff) | |
| download | wvs-vplan-cdc5aec0f72fa965b3f53327fda5176a2417b670.tar.gz wvs-vplan-cdc5aec0f72fa965b3f53327fda5176a2417b670.zip | |
benutze Array für aktuelle Pläne in load()
Diffstat (limited to 'js/index.js')
| -rw-r--r-- | js/index.js | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/js/index.js b/js/index.js index a9b1a65..01fd866 100644 --- a/js/index.js +++ b/js/index.js @@ -325,43 +325,25 @@ function trylogin(){ } } -/* checkt, ob die Pläne in entries aktuell sind und gibt die Anzahl zurück */ -function countactual(entries){ +/* gibt aktuelle Pläne aus entries zurück */ +function getactual(entries){ var fname_re = new RegExp('([^-]{4})-([^-]{2})-([^-]{2})(.*?)\.pdf'); // \d funktioniert nicht - var actual = 0; var today = new Date(); + var actual = []; - for(j = 0; j < entries.length; j++){ - var name = entries[j].name; - console.log(name); - var results = name.match(fname_re); + entries.forEach(function(entry){ + console.log(entry.name); + var results = entry.name.match(fname_re); var fdate = new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3])); - + if(fdate >= today){ - actual++; + actual.push(entry); } - console.log(actual); - } + }); return actual; } -/* fügt die Attribute aktueller Pläne aus entries zu den Pages hinzu */ -function addactual(entries){ - var fname_re = new RegExp('([^-]{4})-([^-]{2})-([^-]{2})(.*?)\.pdf'); // \d funktioniert nicht - var actual = 0; - var today = new Date(); - - for(j = 0; j < entries.length; j++){ - var results = entries[j].name.match(fname_re); - var fdate = new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3])); - - if(fdate >= today){ - addplanattr(entries[j], actual++); - } - } -} - /* lädt Vertretungspläne aus dem Speicher [1) SD-Karte oder 2) dem internen Speicher] */ function load(){ window.requestFileSystem( @@ -373,13 +355,16 @@ function load(){ dirReader.readEntries( function(entries){ - var actual = countactual(entries); + var actual = getactual(entries); + + console.log("Im Speicher: " + actual.length + " Pläne"); - console.log("Im Speicher: " + actual + " Pläne"); + if(actual.length > 0){ + prepare_html(actual.length); - if(actual > 0){ - prepare_html(actual); - addactual(entries); + for(j = 0; j < actual.length; j++){ + addplanattr(actual[j], j); + } }else{ } |
