From 0ab840c3f81b29d6911f1042bc1a0dbcc0c44878 Mon Sep 17 00:00:00 2001 From: schneefux Date: Thu, 1 May 2014 16:47:25 +0200 Subject: zeige Verbindungsfehler --- BUILDING | 1 + config.xml | 10 +--------- index.html | 6 +++++- js/index.js | 20 +++++++++++++++++--- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/BUILDING b/BUILDING index 028db1f..5d0d168 100644 --- a/BUILDING +++ b/BUILDING @@ -7,3 +7,4 @@ cordova plugin add org.apache.cordova.device cordova plugin add org.apache.cordova.file cordova plugin add org.apache.cordova.file-transfer cordova build +cordova plugin add org.apache.cordova.network-information diff --git a/config.xml b/config.xml index 48f272d..71e847a 100644 --- a/config.xml +++ b/config.xml @@ -21,15 +21,6 @@ --> - - - - - - - - - diff --git a/index.html b/index.html index cfad5d5..3e1180c 100644 --- a/index.html +++ b/index.html @@ -84,10 +84,14 @@ - + + + diff --git a/js/index.js b/js/index.js index 049c0cf..5749631 100644 --- a/js/index.js +++ b/js/index.js @@ -50,6 +50,16 @@ document.addEventListener('resume', function(){ track('event/resume'); }); +document.addEventListener('offline', function offline(){ + $('#loginsubmit').prop('disabled', true); + $('#error_noconn').show('fast'); +}, false); + +document.addEventListener('online', function online(){ + $('#loginsubmit').prop('disabled', false); + $('#error_noconn').hide('fast'); +}, false); + var _paq = _paq || []; $('#mainpage').on('pagebeforeshow', function(){ /* Sprache setzen */ @@ -380,9 +390,9 @@ function renderPdf(url, divstr){ /* wird bei Verbindungsfehlern oder anderen Fehlern aufgerufen */ function fail(text){ $('#lnklogin').click(); - $('#error_noconn').show('fast'); + $('#error_general').show('fast'); console.log('Fehler: ' + text.toString() + ' / ' + text.code); - track('error/connectiondown'); + track('error/general_' + text.toString() + '_' + text.code); } /* entfernt das Logintab */ @@ -577,7 +587,7 @@ function loggedIn(resultHtml){ function sendLogin(username, password){ var params = 'username=' + username + '&password=' + password; - $('#error_noconn').hide('fast'); + $('#error_general').hide('fast'); $('#error_passwd').hide('fast'); var request = $.ajax({ @@ -624,6 +634,10 @@ function getUserData(){ /* loggt ein oder zeigt Loginform */ function login(){ + if(navigator.connection.type === Connection.NONE){ + return; + } + $.mobile.loading('show', {theme: 'a'}); userdata = getUserData(); -- cgit v1.3.1