//----------------------- // CLX CUSTOM Communicator Class // by Andy Haeberli // www.crealogix.com // vs. 0.1 2005-05-10 // ---------------------- // //--------------------------- // CLX_custom_communicator Constructor //--------------------------- CLX_custom_communicator = function (objRef, communicationDebugMode) { // objRef ist eine Referenz zum CLX_Translator bzw. zum aufrufenden Object this.refTranslator = objRef; this.communicationDebugMode = communicationDebugMode; this.version = "v2005-05-10-001_clx"; }; //--------------------------- // CLX_custom_communicator getVersion //--------------------------- CLX_custom_communicator.prototype.getVersion = function() { return ("CLX CUSTOM Communicator Class Version: "+this.version); }; //--------------------------- // CLX_custom_communicator init //--------------------------- CLX_custom_communicator.prototype.init = function() { // Help: Schnittstelle if (this.communicationDebugMode == true) { commtrace("Schnittstelle CUSTOM gefunden"); } // URL aus FlashVars this.url = unescape(_root.custom_communicationURL); commtrace("Diese URL wurde empfangen: "+this.url) // this.parseURL(); this.userData = new Object(); this.userData.error = "noValue"; this.userData.user_id = "noValue"; this.userData.username = "noValue"; this.userData.lesson_location = "noValue"; this.userData.lesson_status = "noValue"; this.userData.lesson_score = "noValue"; this.userData.lesson_time = "noValue"; this.userData.lesson_data = "noValue"; if (this.custom_catcher_uri == 0) { // Help: Parameter aus URL if (this.communicationDebugMode == true) { commtrace("Keine oder nicht alle URL-Parameter geparst"); } this.refTranslator.initCallback(1); } else { // Help: Parameter aus URL if (this.communicationDebugMode == true) { commtrace("URL-Parameter geparst"); } this.refTranslator.initCallback(0); } }; //--------------------------- // CLX_custom_communicator parseURL //--------------------------- CLX_custom_communicator.prototype.parseURL = function() { var tURL_array = this.url.split("?"); var tParam_array = tURL_array[1].split("&"); for (var i = 0; i < tParam_array.length; i++ ) { var tProp_array = tParam_array[i].split('='); if (tProp_array[0].toLowerCase() == 'wbt_id' ) { this.wbt_id = tProp_array[1]; } if (tProp_array[0].toLowerCase() == 'custom_url' ) { this.custom_catcher_uri = tProp_array[1]; } } if (this.communicationDebugMode == true) { commtrace("CUSTOM Catcher URI: "+this.custom_catcher_uri); commtrace("WBT ID: "+this.wbt_id); } }; //--------------------------- // CLX_custom_communicator getUserData //--------------------------- CLX_custom_communicator.prototype.getUserData = function() { this.communication_lv = new LoadVars(); this.communication_lv.refObj = this; this.communication_lv.command = "Get"; this.communication_lv.wbt_id = this.wbt_id; this.communication_lv.onLoad = this.dataLoaded; this.communication_lv.sendAndLoad(this.custom_catcher_uri, this.communication_lv, "Post"); // Help: Get-String-Ausgabe (Aufbau und Inhalt) if (this.communicationDebugMode == true) { commtrace("Folgender GetParam an das LMS gesendet:") commtrace (unescape(this.communication_lv.toString())); } }; //--------------------------- // CLX_custom_communicator setUserData //--------------------------- CLX_custom_communicator.prototype.setUserData = function() { this.communication_lv = new LoadVars(); this.communication_lv.refObj = this; this.communication_lv.command = "Set"; this.communication_lv.wbt_id = this.wbt_id; this.communication_lv.lesson_location = this.userData.lesson_location; this.communication_lv.lesson_status = this.userData.lesson_status; this.communication_lv.lesson_score = this.userData.lesson_score; this.communication_lv.lesson_time = this.userData.lesson_time; this.communication_lv.lesson_data = this.userData.lesson_data; this.communication_lv.onLoad = this.dataLoaded; this.communication_lv.sendAndLoad(this.custom_catcher_uri, this.communication_lv, "Post"); // Help: Set-String-Ausgabe (Aufbau und Inhalt) if (this.communicationDebugMode == true) { commtrace("Folgender SetParam an das LMS gesendet:") commtrace (unescape(this.communication_lv.toString())); } }; //--------------------------- // CLX_custom_communicator exitUserData //--------------------------- CLX_custom_communicator.prototype.connectionExit = function() { this.refTranslator.connectionExitCallback(0); }; //--------------------------- // CLX_custom_communicator dataLoaded //--------------------------- CLX_custom_communicator.prototype.dataLoaded = function(ok) { if(ok) { // error this.refObj.userData.error = this.error; if (this.command == "Get") { // user_id this.refObj.userData.user_id = unescape(this.user_id); // user_name this.refObj.userData.username = unescape(this.username); // lesson_location this.refObj.userData.lesson_location = unescape(this.lesson_location).replace(" ", ""); // lesson_status this.refObj.userData.lesson_status = unescape(this.lesson_status).replace(" ", ""); // lesson_score this.refObj.userData.lesson_score = unescape(this.lesson_score).replace(" ", ""); // lesson_time this.refObj.userData.lesson_time = unescape(this.lesson_time).replace(" ", ""); // lesson_data this.refObj.userData.lesson_data = unescape(this.lesson_data).replace(" ", ""); // // Help: Empfangene Werte if (this.refObj.communicationDebugMode == true) { commtrace("Folgende Werte vom LMS empfangen:") commtrace ("error: "+unescape(this.error)); commtrace ("user_id: "+unescape(this.user_id)); commtrace ("username: "+unescape(this.username)); commtrace ("lesson_location: "+unescape(this.lesson_location)); commtrace ("lesson_status: "+unescape(this.lesson_status)); commtrace ("lesson_score: "+unescape(this.lesson_score)); commtrace ("lesson_time: "+unescape(this.lesson_time)); commtrace ("lesson_data: "+unescape(this.lesson_data)); } this.refObj.refTranslator.getUserDataCallback(this.refObj.userData.error); } else if (this.command == "Set") { // Help: Empfangene Werte if (this.refObj.communicationDebugMode == true) { commtrace("Folgende Werte vom LMS empfangen:") commtrace ("error: "+unescape(this.error)); } this.refObj.refTranslator.setUserDataCallback(this.refObj.userData.error); } } else { // Help: Fehler-Ausgabe if (this.refObj.communicationDebugMode == true) { commtrace("Ladevorgang fehlerhaft"); } if (this.command == "Get") { this.refObj.refTranslator.getUserDataCallback(1); } else if (this.command == "Set") { this.refObj.refTranslator.setUserDataCallback(1); } } }; // //--------------------------- // CLX_custom_communicator getWBT_ID //--------------------------- CLX_custom_communicator.prototype.getWBT_ID = function() { return this.wbt_id }; // //--------------------------- // CLX_custom_communicator getError //--------------------------- CLX_custom_communicator.prototype.getError = function() { return this.userData.error; }; //--------------------------- // CLX_custom_communicator getStudent_id //--------------------------- CLX_custom_communicator.prototype.getStudent_id = function() { return this.userData.user_id; }; //--------------------------- // CLX_custom_communicator getStudent_name //--------------------------- CLX_custom_communicator.prototype.getStudent_name = function() { return this.userData.username; }; //--------------------------- // CLX_custom_communicator setLesson_location //--------------------------- CLX_custom_communicator.prototype.setLesson_location = function(whichValue) { this.userData.lesson_location = whichValue; }; //--------------------------- // CLX_custom_communicator getLesson_location //--------------------------- CLX_custom_communicator.prototype.getLesson_location = function() { return this.userData.lesson_location; }; //--------------------------- // CLX_custom_communicator setLesson_status //--------------------------- CLX_custom_communicator.prototype.setLesson_status = function(whichValue) { this.userData.lesson_status = whichValue; }; //--------------------------- // CLX_custom_communicator getLesson_status //--------------------------- CLX_custom_communicator.prototype.getLesson_status = function() { return this.userData.lesson_status; }; //--------------------------- // CLX_custom_communicator setScore //--------------------------- CLX_custom_communicator.prototype.setScore = function(whichValue) { this.userData.lesson_score = whichValue; }; //--------------------------- // CLX_custom_communicator getScore //--------------------------- CLX_custom_communicator.prototype.getScore = function() { return this.userData.lesson_score; }; //--------------------------- // CLX_custom_communicator setTime //--------------------------- CLX_custom_communicator.prototype.setTime = function(whichValue) { this.userData.lesson_time = whichValue; }; //--------------------------- // CLX_custom_communicator getTime //--------------------------- CLX_custom_communicator.prototype.getTime = function() { return this.userData.lesson_time; }; //--------------------------- // CLX_custom_communicator setLesson_data //--------------------------- CLX_custom_communicator.prototype.setLesson_data = function(whichValue) { this.userData.lesson_data = whichValue; }; //--------------------------- // CLX_custom_communicator getLesson_data //--------------------------- CLX_custom_communicator.prototype.getLesson_data = function() { return this.userData.lesson_data; };