summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/index.js83
1 files changed, 44 insertions, 39 deletions
diff --git a/js/index.js b/js/index.js
index 8649175..140c585 100644
--- a/js/index.js
+++ b/js/index.js
@@ -16,6 +16,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Login-Popup beim Start
+$('#loginpage').on('pagebeforeshow', function loginform(){
+ setTimeout(function(){
+ $('#lnklogin').click();
+ }, 500);
+});
+
+// einen Slider zu einem Ladebalken umstylen
+$(document).on('pageinit', function(){
+ $('#loader').parent().find('input').hide();
+ $('#loader').parent().find('.ui-slider-track').css('margin', '0 15px 0 15px');
+ $('#loader').parent().find('.ui-slider-handle').hide();
+});
+
var page_html = '\n\
<div data-role="page" class="page" id="page-vplan-{ID}" data-prefetch>\n\
<div data-role="header">\n\
@@ -71,7 +85,9 @@ function render_pdf(viewerstr){
}
function fail(text){
- alert("Etwas ist schiefgelaufen: " + text.toString());
+ $('#error_noconn').show("fast");
+ $('#loader').hide("slow");
+ console.log("Fehler: " + text.toString());
}
function download_pdf(link, id){
@@ -96,6 +112,7 @@ function download_pdf(link, id){
$('#pdf-' + id).attr('data-plan-url', theFile.toURL());
if(location.href.indexOf("page-") == -1){
+ $('#loader').hide("fast");
$.mobile.changePage("#page-vplan-" + id);
}
},
@@ -124,9 +141,7 @@ function get_plan(link, id){
download_pdf(pdflink, id);
});
- request.fail(function(jqXHR, textStatus){
- alert("Etwas ist schiefgelaufen: " + textStatus);
- });
+ request.fail(fail);
}
function get_overview(link){
@@ -141,14 +156,14 @@ function get_overview(link){
// Pages für Vertretungsplände erstellen und pageshow-Events festlegen
- var resultl = result.match(plans_re).length;
+ var resultarr = result.match(plans_re);
- if(resultl == 0){
- //$.mobile.changePage("#loginpopup", {rel: "dialog", position-to: 'window', inline: 'true'});
- $("#loginform").removeClass('ui-disabled');
- return;
+ if(resultarr == null){
+ //TODO
}
+ var resultl = resultarr.length;
+
for(j = 0; j < resultl; j++){
new_html = page_html.replace(/{ID}/g, j);
@@ -185,43 +200,33 @@ function get_overview(link){
console.log('Übersichts-Request erfolgreich');
});
- request.fail(function(jqXHR, textStatus){
- alert("Etwas ist schiefgelaufen: " + textStatus);
- });
+ request.fail(fail);
}
-$(document).on("pageinit", function login(){
- $('#lnklogin').click();
- $('#loginpopup').on("popupafterclose", function(event){
- $.mobile.loading("show", {
- text: "Lade...",
- textVisible: true,
- theme: "b",
- });
-
- var username = encodeURIComponent($("#username").val());
- var password = encodeURIComponent($("#password").val());
- var params = "username=" + username + "&password=" + password;
+function login(){
+ var username = encodeURIComponent($("#username").val());
+ var password = encodeURIComponent($("#password").val());
+ var params = "username=" + username + "&password=" + password;
- var request = $.ajax({
- type: "POST",
- url: "https://***REMOVED***/moodle/login/index.php",
- data: {username: username, password: password}
- });
- request.done(function(result){
- var vertretungs_re = new RegExp("title=\"Vertretungsplan\" href=\"(http://***REMOVED***\\.de/moodle/course/view\\.php\\?id=\\d+)");
- var link = vertretungs_re.exec(result)[1];
+ var request = $.ajax({
+ type: "POST",
+ url: "https://***REMOVED***/moodle/login/index.php",
+ data: {username: username, password: password}
+ });
+
+ $('#loader').show("fast");
- console.log('Login-Request erfolgreich: ' + link);
+ request.done(function(result){
+ var vertretungs_re = new RegExp("title=\"Vertretungsplan\" href=\"(http://***REMOVED***\\.de/moodle/course/view\\.php\\?id=\\d+)");
+ var link = vertretungs_re.exec(result)[1];
- get_overview(link);
- });
+ console.log('Login-Request erfolgreich: ' + link);
- request.fail(function(jqXHR, textStatus){
- alert("Etwas ist schiefgelaufen: " + textStatus);
- });
+ get_overview(link);
});
-});
+
+ request.fail(fail);
+}
var app = {
// Application Constructor