diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-04-18 14:52:05 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-08-15 19:46:52 +0200 |
| commit | c9183be8b1c2938aa4b1f843bca323605da52c7e (patch) | |
| tree | a08dc435721e3ff1057aa8fec7f928081af6e4ba | |
| parent | 9b5c34025b97a76d54f50efec52297d856dedb2c (diff) | |
| download | wvs-vplan-c9183be8b1c2938aa4b1f843bca323605da52c7e.tar.gz wvs-vplan-c9183be8b1c2938aa4b1f843bca323605da52c7e.zip | |
Pläne in Tabs korrekt anzeigen, Popup über den geladenen Plänen anzeigen
| -rw-r--r-- | css/index.css | 5 | ||||
| -rw-r--r-- | index.html | 35 | ||||
| -rw-r--r-- | js/.index.js.swp | bin | 24576 -> 0 bytes | |||
| -rw-r--r-- | js/index.js | 46 |
4 files changed, 37 insertions, 49 deletions
diff --git a/css/index.css b/css/index.css index 22cfb46..919f63c 100644 --- a/css/index.css +++ b/css/index.css @@ -57,8 +57,3 @@ body { .pdfcanvas { height: 100%; } - -#loader { - width: 100%; - margin: 0 auto; -} @@ -28,15 +28,16 @@ </head> <body> <div class="app"> - <div data-role="page" class="page" id="mainpage" data-theme="a"> - <div data-role="header"> - <h1>WvS VPlan</h1> + <div data-role="tabs" id="vplantabs"> + <div data-role="navbar" id="vplannavbar"> + <ul> + <li><a href="#login">Login</a></li> + </ul> </div> - <div role="main" class="ui-content"> - <a id="lnklogin" href="#loginpopup" data-rel="popup" data-role="button" data-position-to="window" data-inline="true" style="display:none;"></a> + <div id="login" class="ui-content"> <div data-role="popup" id="loginpopup" data-theme="a"> - <form style="padding:10px 20px;" id="loginform" action="javascript:login()"> + <form style="padding:10px 20px;" id="loginform" action="javascript:login();"> <h3>Bitte einloggen</h3> <label for="username" class="ui-hidden-accessible">Benutzername</label> <input type="text" id="username" hint="Benutzername" autofocus required> @@ -45,15 +46,11 @@ <button type="submit">Einloggen</button> </form> - <div> - <img id="loader" src="css/images/ajax-loader.gif" style="display:none;"/> - </div> - <div class="ui-bar ui-bar-a ui-corner-all" style="display:none;" id="error_noconn"> <center>Etwas ist schiefgelaufen.</center> <center>Versuche es in Kürze noch einmal.</center> <div style="width:100%;margin 0 auto;"> - <button class="ui-btn" id="loadbtn" onclick="$('#loginpopup').close()">Pläne aus dem Speicher anzeigen</button> + <button class="ui-btn" id="loadbtn" onclick="$('#loginpopup').popup('close')">Pläne aus dem Speicher anzeigen</button> </div> </div> @@ -63,18 +60,10 @@ </div> </div> <!-- loginpopup --> - <div data-role="tabs" id="vplantabs"> - <div data-role="navbar"> - <ul> - <li><a href="#nothing">Nichts1</a></li> - </ul> - </div> - <div id="nothing"> - <p>Es sind noch keine Pläne verfügbar. Bitte logge dich ein!</p> - </div> - </div> <!-- vplantabs --> - </div> <!-- main ui-content --> - </div> <!-- mainpage --> + <p id="noplans" style="display:none">Es sind noch keine Pläne verfügbar.</p> + <center><a id="lnklogin" href="#loginpopup" data-rel="popup" data-role="button" data-position-to="window" data-inline="true">Bitte logge dich ein!</a></center> + </div> + </div> <!-- vplantabs --> </div> <!-- app --> <script type="text/javascript" src="js/jquery-2.1.0.min.js"></script> diff --git a/js/.index.js.swp b/js/.index.js.swp Binary files differdeleted file mode 100644 index b4c26c8..0000000 --- a/js/.index.js.swp +++ /dev/null diff --git a/js/index.js b/js/index.js index 47f1d39..cf02132 100644 --- a/js/index.js +++ b/js/index.js @@ -16,15 +16,14 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + // Login-Popup beim Start -$('#mainpage').on('pagebeforeshow', function(){ +$(document).bind('pageinit', function(){ setTimeout(function(){ load(); $('#lnklogin').click(); }, 500); -}); -$('#mainpage').on('pageshow', function(){ setTimeout(function(){ trylogin(); }, 2000); @@ -65,6 +64,7 @@ function render_pdf(url, divstr){ PDFJS.getDocument(url).then(function(pdf){ var viewer = document.getElementById(divstr); + console.log(viewer.text); var pageNumber = 1; renderPage(viewer, pdf, pageNumber++, function pageRenderingComplete(){ if(pageNumber > pdf.numPages){ @@ -77,8 +77,6 @@ function render_pdf(url, divstr){ /* wird bei Verbindungsfehlern oder anderen Fehlern aufgerufen */ function fail(text){ - $('#loginform').removeClass('ui-disabled'); - $('#loader').hide('slow'); $('#error_noconn').show('fast'); console.log('Fehler: ' + text.toString() + ' / ' + text.code); } @@ -87,16 +85,28 @@ function fail(text){ function addplanattr(fileEntry){ var sPath = fileEntry.toURL(); var name = fileEntry.name.replace('.pdf', ''); + name = name.replace(/[ ,]/g, ''); console.log('Dateiname: ' + name); - var vplantabs = $('#vplantabs').tabs(); - var ul = vplantabs.find('ul'); - $('<li><a href="#' + name + '">' + name + '</a></li>').appendTo(ul); - $('<div id="' + name + '"></div>').appendTo(vplantabs); + $('#vplannavbar').find('*').andSelf().each(function(){ + $(this).removeClass(function(i, cn){ + var matches = cn.match(/ui-[\w\-]+/g) || []; + return (matches.join(' ')); + }); + if($(this).attr('class') == ''){ + $(this).removeAttr('class'); + } + }); + + $('#vplannavbar').navbar('destroy'); + $('#vplannavbar ul').append('<li><a href="#' + name + '">' + name + '</a></li>'); + $('#vplannavbar').navbar(); + + $('#vplantabs').append('<div id="' + name + '" class="ui-content tablist-content">Bitte warten...</div>'); + $('#vplantabs').tabs('refresh'); render_pdf(sPath, name); - vplantabs.tabs('refresh'); // TODO geht nicht } /* lädt ein PDF anhand eines Links herunter, benötigt ID zur Sortierung */ @@ -111,8 +121,7 @@ function download_pdf(link){ dirEntry.getFile(filename, {create: false, exclusive: false}, function(fileEntry){ // Datei ist schon heruntergeladen - console.log('lade Datei nicht erneut herunter'); - addplanattr(fileEntry); + console.log('Datei schon heruntergeladen'); }, function(err){ // Datei existiert noch nicht @@ -164,8 +173,6 @@ function gotoverview(resulthtml){ if(resultarr == null){ $('#error_passwd').show('fast'); - $('#loginform').removeClass('ui-disabled'); - $('#loader').hide('slow'); return 0; } @@ -212,8 +219,6 @@ function loggedin(resulthtml){ function sendlogin(username, password){ var params = 'username=' + username + '&password=' + password; - $('#loginform').addClass('ui-disabled'); - $('#loader').show('fast'); $('#error_noconn').hide('fast'); $('#error_passwd').hide('fast'); @@ -265,8 +270,6 @@ function login(){ sendlogin(userdata[0], userdata[1]); return 1; }else{ - $('#loginform').removeClass('ui-disabled'); - $('#loader').hide('fast'); return 0; } } @@ -277,8 +280,7 @@ function login(){ function trylogin(){ var link = window.localStorage.getItem('overviewlink'); - $('#loginform').addClass('ui-disabled'); - $('#loader').show('fast'); + $('#loginpopup').popup('close'); if(typeof link !== 'undefined' && link != null){ console.log('Teste Login'); @@ -325,11 +327,13 @@ function load(){ console.log("Im Speicher: " + actual.length + " Pläne"); if(actual.length > 0){ + $('#noplans').hide('slow'); for(j = 0; j < actual.length; j++){ addplanattr(actual[j]); } }else{ - + $('#noplans').show('fast'); + $('#lnklogin').show('fast'); } }, fail); }, fail); |
