Skip to content

Commit

Permalink
fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
phish108 committed Feb 2, 2015
1 parent 75f78da commit 5360757
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 13 deletions.
27 changes: 19 additions & 8 deletions www/js/models/lmsModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,20 @@
* This method checks whether there is a dynamic version of the rsd.json
* (we expect a php script for Ilias and Moodle)
*/
function rsdCheckAgain() {
console.log("check for dynamic rsd file");
$.ajax({
"url": serverURL + ".php",
"dataType": "json",
"success": validateRSD,
"error": rsdFail
});
function rsdCheckAgain(xhr) {
if (xhr.status > 0) {
console.log("check for dynamic rsd file ");
$.ajax({
"url": serverURL + ".php",
"dataType": "json",
"success": validateRSD,
"error": rsdFail
});
}
else {
// in this case we could not reach the target host
rsdFail();
}
}

serverURL.trim(); // remove whitespaces
Expand All @@ -391,6 +397,11 @@

// first check whether the URL is already registeed
if (!this.findServerByURL(serverURL)) {
// check for a trailing slash
if (serverURL.search(/\/$/) === -1) {
// add a slash
serverURL = serverURL + "/";
}
// add the rsd.json to the URL
serverURL = serverURL + "rsd";

Expand Down
54 changes: 49 additions & 5 deletions www/js/views/lmsView.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*jslint white: true, vars: true, sloppy: true, devel: true, plusplus: true, browser: true */
/*jslint white: true, vars: true, sloppy: true, devel: true, plusplus: true, todo: true, browser: true */

/** THIS COMMENT MUST NOT BE REMOVED
Licensed to the Apache Software Foundation (ASF) under one
Expand Down Expand Up @@ -104,19 +104,62 @@ function LMSView() {
});

function closeAddAndRefresh() {
// a new LMS has been successfully added
// a new LMS has been successfully added
// clear the form an show the placeholder
$("#addlmsplaceholder").toggleClass("hidden");
$("#addlmsinputbox").toggleClass("hidden");
$("#addlmsinput")[0].value = "";
this.refresh(); // display the new LMS
$("#addlmsinput")[0].blur();

if ($("#addlmsbutton").hasClass("hidden")) {
$("#addlmsbutton").removeClass("hidden");
$("#addlmswait").addClass("hidden");
}
self.refresh(); // display the new LMS
// hide waiting cycle
}

$(document).bind("LMS_AVAILABLE", closeAddAndRefresh);
$(document).bind("LMS_UNAVAILABLE", closeAddAndRefresh);


$("#addlmsform").bind("submit", function (ev) {
ev.preventDefault(); // prevent reloading before we can have bugs
console.log("form submit");
var lmsurl = $("#addlmsinput")[0].value;
var turl = lmsurl;
turl.replace(/^https?:\/\//i, "");

if (self.app.models.connection.isOnline() &&
lmsurl &&
lmsurl.length &&
turl &&
turl.length > 5) {

console.log("add a new LMS!");
self.app.models.lms.getServerRSD(lmsurl);
// display waiting circle
$("#addlmsbutton").addClass("hidden");
$("#addlmswait").removeClass("hidden");
}
else {
// simply close the form
console.log("LMSView.closeAddForm");
self.closeAddForm();
}
});

function cbCloseForm() {
self.closeAddForm();
}


}

LMSView.prototype.closeAddForm = function () {

};

/**
* opens the view,
* it sets the current view is the active
Expand Down Expand Up @@ -179,6 +222,7 @@ LMSView.prototype.tap = function (event) {
$("#addlmsplaceholder").toggleClass("hidden");
$("#addlmsinputbox").toggleClass("hidden");
$("#addlmsinput")[0].value = "";
$("#addlmsinput")[0].blur();
$("#addlmsbutton").removeClass("hidden");
}
else {
Expand All @@ -204,8 +248,9 @@ LMSView.prototype.tap = function (event) {
$("#addlmsplaceholder").toggleClass("hidden");
$("#addlmsinputbox").toggleClass("hidden");
$("#addlmsinput")[0].value = "";
$("#addlmsinput")[0].blur();
$("#addlmsbutton").removeClass("hidden");
$("#addlmswait").addClass("hidden")
$("#addlmswait").addClass("hidden");
}
}
}
Expand Down Expand Up @@ -472,7 +517,6 @@ LMSView.prototype.showLMSRegistrationMessage = function (message, servername) {
//self.hideRotation(servername);
self.deselectItemVisuals(servername);
self.deactivateLMS(servername);
console.log("previouslms is " + previouslms);
// activate the previsous LMS before changing the visuals
var previouslms = this.app.models.lms.getPreviousServer();
self.app.models.lms.setActiveServer(previouslms);
Expand Down

0 comments on commit 5360757

Please sign in to comment.