diff options
Diffstat (limited to 'js')
| -rw-r--r-- | js/index.js | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/js/index.js b/js/index.js index fd94eac..3c67280 100644 --- a/js/index.js +++ b/js/index.js @@ -173,7 +173,34 @@ function get_plan(link, id){ request.fail(fail); } -function get_overview(link){ +function prepare_html(number){ + // Pages für Vertretungsplände erstellen und pageshow-Events festlegen + + for(j = 0; j < number; j++){ + new_html = page_html.replace(/{ID}/g, j); + + $('#loginpage').after(new_html); + + if(j + 1 < number){ + $('#page-vplan-' + j).on('swipeleft', function(event){ + $.mobile.changePage('#page-vplan-' + (parseInt($('.ui-page-active').attr('id').match(/\d+/)[0]) + 1)); + }); + } + + if(j - 1 >= 0){ + $('#page-vplan-' + j).on('swiperight', function(event){ + $.mobile.changePage('#page-vplan-' + (parseInt($('.ui-page-active').attr('id').match(/\d+/)[0]) - 1)); + }); + } + + $('#page-vplan-' + j).on('pageshow', function(event){ + render_pdf($('.ui-page-active').attr('id').replace(/page-vplan/, '#pdf')); + }); + } + +} + +function get_overview(link, callback){ var request = $.ajax({ url: link }); @@ -229,9 +256,7 @@ function get_overview(link){ console.log('Übersichts-Request erfolgreich'); }); - request.fail(function(){ - return false; - }); + request.fail(callback); } function sendlogin(username, password){ @@ -257,7 +282,7 @@ function sendlogin(username, password){ window.localStorage.setItem('overviewlink', link); console.log('Eingeloggt'); - get_overview(link, false); + get_overview(link, fail); }); request.fail(fail); |
