var zoomfactor = 1; var zoomzoom = 0; //********************************************************************************** // Constants //********************************************************************************** var AJAX_TIMEOUT = "5000";//config['ajaxTimeout']; // timeout for AJAX-Requests in milliseconds //alert (config['ajaxTimeout']); var MAX_ERRORS = "15"; // give up after amount of errors var DEBUG = "1"; // log to console if(DEBUG == 1) { DEBUG = true; } else { DEBUG =false; } var MAILTYPE_FILE = 0; // Mail Type code var MAILTYPE_LINK = 1; // ditto var MAILTYPE_CLIPBOARD = 2; // ditto //********************************************************************************** // Globals //********************************************************************************** var hasUsercustomization = false; // is true if UserCustomization is set var gridWidth = null; // if new ImageGrid it is set with the width var gridToTop = null; var gridHeight = null; var gridToLeft = null; //var stopApplication = false; var fileDialog = null; var linkDialog = null; var clipboardDialog = null; var ieHasNotMousedOverYet = true; /**************************************************************************************** bugfix-try for IE: first layer popups w/o mouse curser focus have dialog content at the wrong place (about top: 5px instead of top: 40px) *****************************************************************************************/ /*var ieHasNotMousedOverYet = true; function checkIEMouseFocus() { if($.browser.msie) { $('html').; } }*/ //********************************************************************************** // Global functions //********************************************************************************** var init = function() { createDialog(fDController, "fileDialog", "417px", "418px"); createDialog(cDController, "clipboardDialog","417px","208px"); createDialog(lDController, "linkDialog","417px","208px"); createDialog(eDController, "endDialog", "417px","352px"); createDialog(clDController, "closeDialog","417px","208px"); createDialog(mDController, "messageDialog","417px","208px"); //STS: Opera Bugfix // cProcessor.getNextContent(); setTimeout(function () { cProcessor.getNextContent(); },1000); jQuery(window).unload( function () { cProcessor.unload() } ); } function startConference() { var x = 0; var y = 0; var w = screen.width; var h = screen.height; var myForm = document.getElementById('startForm'); /*for (var i = 0; i < 2; i++) { if (myForm.auswahl[i].checked) { var mode = myForm.auswahl[i].value; } } if (mode == 'pop') { var imgWin = window.open( popupUrl, 'imgWin', "dependant=yes, location=no, menubar=no, status=0, toolbar=0, left=x, top=y, width="+ w +", height="+ h +", resizable=yes, scrollbars=yes, innerWidth="+ w +", innerheight="+ h); myForm.target = 'imgWin'; document.getElementById('isPopup').value = 1; }*/ myForm.submit(); } /** * Function : dump() * Arguments: The data - array,hash(associative array),object * The level - OPTIONAL * Returns : The textual representation of the array. * This function was inspired by the print_r function of PHP. * This will accept some data as the argument and return a * text that will be a more readable version of the * array/hash/object that is given. */ var dump = function(arr,level) { var dumpedText = ""; if(!level) level = 0; //The padding given at the beginning of the line. var levelPadding = ""; for(var j=0;j \"" + value + "\"\n"; } } } else { //Stings/Chars/Numbers etc. dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; } log(dumpedText); return dumpedText; } var log = function(msg) { if (DEBUG) { if ( window.console && typeof(window.console) != undefined && window.console.log && typeof(window.console.log) != undefined ) { window.console.log(msg); } else { //nth for now */ } } } var createDialog = function(controller, id, width, height) { var dialog = jQuery('#' + id).dialog({ modal: false, resizable: false, autoOpen: false, width: width, height: height }); controller.dialog = dialog; } function checkEnter(event){ /*var characterCode if(e && e.which){ e = e characterCode = e.which } else{ e = event characterCode = e.keyCode } if(characterCode == 13){ document.getElementById('credentials').submit(); return false; } } return true */ if(event.keyCode=='13') { document.getElementById('credentials').submit(); } } //********************************************************************************** // Dialog-Controller //********************************************************************************** var LinkDialogController = function() { this.dialog = null; this.closeDialog = function() { this.dialog.dialog('close'); } this.removeDialog = function() { this.dialog.dialog('destroy'); } this.openDialog = function() { this.dialog.dialog('open'); this.dialog.dialog('moveToTop'); } this.setLink = function(link) { var o = document.getElementById('dialogClass'); if (document.createEvent) { var evt = document.createEvent("Events"); evt.initEvent('mouseover', true, true); o.dispatchEvent(evt); } else if (document.createEventObject) { var evt = document.createEventObject(); o.fireEvent('on' + 'mouseover', evt); } o = null; jQuery('#linkDialog-link').html(link); jQuery('#linkDialog-openButton').attr('href', link); } this.openLink = function() { // only thing to do at the moment: close the dialog. this.closeDialog(); } } var ClipboardDialogController = function() { this.dialog = null; this.closeDialog = function() { this.dialog.dialog('close'); } this.removeDialog = function() { this.dialog.dialog('destroy'); } this.openDialog = function() { this.dialog.dialog('open'); this.dialog.dialog('moveToTop'); } this.selectContent = function() { var area = jQuery("#clipboardDialog-textArea"); area.focus(); area.select(); } this.setContent = function(content) { jQuery('#clipboardDialog-textArea').attr('value', content); this.selectContent(); } } var FileDialogController = function() { this.selectedRow = null; this.fields = new Array(); this.dialog = null; this.closeDialog = function() { this.dialog.dialog('close'); } this.removeDialog = function() { this.dialog.dialog('destroy'); } this.openDialog = function() { this.dialog.dialog('open'); this.dialog.dialog('moveToTop'); } this.addField = function(params) { var screenName = null; var name = params.nameOrContent; var length = params.contentLength; // Extract substring if name is too long if (name.length > 30) { screenName = name.substring(0, 27) + '...'; } else { screenName = name; } // BK & BM siehe ProjektDB ID 202 screenName = screenName.replace (//g, ">"); // end BK & BM //log(length); // Calculate length in Readable form if (length > 1024 * 1024 * 1024) { length = (length / 1024 / 1024 / 1024).toFixed(2); length = length + 'GB'; } else if (length > 1024 * 1024) { length = (length / 1024 / 1024).toFixed(2); length = length + 'MB'; } else { length = (length / 1024).toFixed(1); length = length + 'KB'; } // Add to table this.fields.push(new Array(params.fileId, name, params.mailType, screenName, length)); this.fillTable(); // fill new } this.saveData = function() { params = this.fields[this.getFieldIndex(this.selectedRow)]; //log(this.selectedRow); switch(params[2]) // params[2] = mailType { case MAILTYPE_FILE: //alert(httpRoot + 'conference/file/id/' + params[0]); document.location.href = getFileUrl + '/id/' + params[0]; // params[0] = fileId break; case MAILTYPE_LINK: lDController.setLink(params[1]); // params[1] = nameOrContent lDController.openDialog(); break; case MAILTYPE_CLIPBOARD: cDController.setContent(params[1]); // params[1] = nameOrContent cDController.openDialog(); break; default: // nothing } } this.deleteData = function(mailId) { var sendRemoteRemoveRequest = false ; if (mailId == null) { // delete has not come from remote, but from user interaction sendRemoteRemoveRequest = true; mailId = this.selectedRow; } // Delete from view jQuery('#' + mailId).remove(); // Delete from fields var foundIndex = this.getFieldIndex(mailId); if (foundIndex != null) { this.fields.splice(foundIndex, 1); } if (sendRemoteRemoveRequest) { cProcessor.remoteDeleteFile(mailId); } } this.fillTable = function() { //TODO: Klappt das bei mehr trs vor dem gewuenschten?Klappt alles so wie es soll. Struktur? line = jQuery("tr").get(2); if(line) { for (var z = 0; z < this.fields.length; z++) { jQuery('#' + this.fields[z][0]).remove(); } } for (var z = 0; z < this.fields.length; z++) { // Create row and add basic attributes var tr = jQuery('').appendTo('#dlTable'); tr.attr('id', this.fields[z][0]); tr.addClass('rows'); // Add event callbacks per row tr.click(this.getClick(tr)); tr.mouseover(this.getMouseOver(tr)); tr.mouseout(this.getMouseOut(tr)); // Choose image according to type var imageSrc = null; switch (this.fields[z][2]) { case MAILTYPE_FILE: imageSrc = '../images/file.png'; break; case MAILTYPE_LINK: imageSrc = '../images/link.png'; break; case MAILTYPE_CLIPBOARD: imageSrc = '../images/clipboard.png'; break; default: // empty } // Add content cells to rows jQuery('').appendTo(tr); jQuery('' + this.fields[z][3] + '').appendTo(tr); jQuery('' + this.fields[z][4] + '').appendTo(tr); // Add row to table jQuery('').appendTo('#dlTable'); } } this.getClick = function(row) { var _self = this; return function() { for (i = 0; i < _self.fields.length; i++) { jQuery('#' + _self.fields[i][0]).removeClass('selectedRow') .removeClass('overRow') .addClass('rows'); } _self.selectedRow = row.attr('id'); row.addClass('selectedRow'); } } this.getMouseOver = function(row) { var _self = this; return function() { for (i = 0; i < _self.fields.length; i++) { jQuery('#' + _self.fields[i][0]).removeClass('overRow') .addClass('rows'); } row.addClass('overRow'); } } this.getMouseOut = function(row) { var _self = this; return function() { row.removeClass('overRow'); row.addClass('rows'); } } this.getFieldIndex = function(id) { var foundIndex = null; for (i = 0; i < this.fields.length; i++) { if (this.fields[i][0] == id) { foundIndex = i; } } return foundIndex; } } var EndController = function(logoUrl) { this.dialog = null; this.logoUrl = logoUrl; this.closeDialog = function() { this.dialog.dialog('close'); } this.openDialog = function() { if ( hasUsercustomization == true) { this.dialog.dialog('open'); } } this.setMessage = function(message) { this.message = message; jQuery('#endDialog-message').html(message); hasUsercustomization = true; } this.setUrl = function(url) { this.url = url; jQuery('#endDialog-url').attr("href", url); jQuery('#endDialog-url').html(url); hasUsercustomization = true; } this.setEmail = function(email) { this.email = email; jQuery('#endDialog-email').attr("href","mailto:'"+ email+"'"); jQuery('#endDialog-email').html(email); hasUsercustomization = true; } this.setHeadline = function(headline) { this.headline = headline; jQuery('#endDialog-headline').html(headline); hasUsercustomization = true; } this.setLogoUrl = function() { jQuery('#endDialog-picture').attr("src", this.logoUrl); hasUsercustomization = true; } } var CloseDialogController = function() { this.dialog = null; this.closeDialog = function() { this.dialog.dialog('close'); } this.openDialog = function() { this.dialog.dialog('open'); } } var MessageDialogController = function(message) { this.message = message; this.dialog = null; this.closeDialog = function() { this.dialog.dialog('close'); } this.openDialog = function() { this.dialog.dialog('open'); } this.setMessage = function(message) { this.message = message; jQuery('#messageDialog-message').html(message); } } //********************************************************************************** // Content Processing //********************************************************************************** var ContentProcessor = function(urlString) { this.imageProcessor = null; this.imageGrid = null; this.timeOut = AJAX_TIMEOUT; this.errorCount = 0; this.urlString = urlString; this.stopApplication = false; this.message = ''; this.start = 0; this.timeoutCount = 0; this.lastSuccess = null; this.logout = function(cleanupApplication) { lDController.removeDialog(); fDController.removeDialog(); cDController.removeDialog(); clDController.openDialog(); if (cleanupApplication) { //this.end('Sie haben sich aus der laufenden Sitzung abgemeldet.'); this.stopApplication = true; dProcessor.stopContent(); } jQuery.ajax( { cache: false, dataType: 'json', error: function(XMLHttpRequest, textStatus, errorThrown) { }, success: function(data, textStatus) { log(data); log(textStatus); }, timeout: AJAX_TIMEOUT, url: logoutUrl } ); } this.remoteDeleteFile = function(fileId) { jQuery.ajax( { cache: false, dataType: 'json', error: function(XMLHttpRequest, textStatus, errorThrown) { }, success: function(data, textStatus) { log(data); log(textStatus); }, timeout: AJAX_TIMEOUT, url: deleteFileUrl + '/id/' + fileId } ); } this.getNextContent = function() { var _self = this; //log('nextPHPContent'+ _self.urlString); if (!this.stopApplication) { jQuery.ajax( { cache: false, dataType: 'json', error: function(XMLHttpRequest, textStatus, errorThrown) { _self.onGetNextContentError(XMLHttpRequest, textStatus, errorThrown); }, success: function(data, textStatus) { _self.onGetNextContentSuccess(data, textStatus) }, timeout: 40000, url: _self.urlString } ); } } this.onGetNextContentSuccess = function(data, textStatus) { this.errorCount = 0; this.timeoutCount = 0; var date = new Date(); this.successTimestamp = date.getTime(); if(this.lastSuccess === null) { this.lastSuccess = date.getTime(); } else if ((this.successTimestamp - this.lastSuccess) > 90000) { this.end('Session wegen Timout geschlossen.'); data = null; } else { this.lastSuccess = date.getTime(); } var images_for_loading = new Array(); if (data != null && data.result != null) { var imageLoading = false; for (i = 0; i < data.result.length; i++) { switch(data.result[i].type) { case 'imageGridChanged': //log("New ImageGrid"); this.imageGrid.newDimension (data.result[i].params.screenWidth,data.result[i].params.screenHeight,data.result[i].params.segmentWidth,data.result[i].params.segmentHeight); break; case 'newMail': this.processNewMail(data.result[i].params) break; case 'removedMail': //log('removedMail: ' + data.result[i].params.fileId); fDController.deleteData(data.result[i].params.fileId); break; case 'userCustomization': //log('userCustomization'); //log(data.result[i]); eDController.setMessage(data.result[i].params.text) eDController.setUrl(data.result[i].params.url) eDController.setEmail(data.result[i].params.email) eDController.setHeadline(data.result[i].params.title) eDController.setLogoUrl() break; case 'noHlgAllowed': log('noHlgAllowed'); log(data.result[i]); this.end('Webgäste sind in dieser Sitzung nicht zugelassen.'); break; case 'sessionEnded': log('sessionsEnded'); log(data.result[i]); // BK Changed document.getElementById('gridContainer').style.display='none'; document.getElementById('mouselayer0').style.display='none'; document.getElementById('ssm').style.display='none'; this.end('Die Sitzung wurde beendet.'); break; case 'userNotFound': log('userNotFound'); log(data.result[i]); // BK Changed document.getElementById('gridContainer').style.display='none'; document.getElementById('mouselayer0').style.display='none'; document.getElementById('ssm').style.display='none'; this.end('Sie wurden aus der Sitzung ausgeschlossen.'); break; default: // empty } } } else if (this.start == 0) { //log('dProcesser wir erste mal gestartet'); dProcessor.getNextContent(); this.start++; } // immediately poll content again //this.getNextContent(); // poll content with timeout this.nextContentTimeout(40000); } this.onGetNextContentError = function(XMLHttpRequest, textStatus, errorThrown) { var jetzt = new Date(); log("Fehler 17 " + jetzt.getTime()); log(XMLHttpRequest); log("textStatus: " + textStatus); log("errorThrown: " + errorThrown); if(textStatus == "timeout") { this.timeoutCount++; } else { this.errorCount++; } log("TimeoutCount: " + this.timeoutCount); log("ErrorCount: " + this.errorCount); if (this.errorCount < MAX_ERRORS && this.timeoutCount < 15) { this.getNextContent(); } else { this.end('Fehler 17: Verbindung zum Server abgebrochen.'); } } this.processNewMail = function (params) { switch (params.mailType) { case MAILTYPE_FILE: fDController.addField(params); fDController.openDialog(); break; case MAILTYPE_LINK: lDController.setLink(params.nameOrContent); fDController.addField(params); lDController.openDialog(); break; case MAILTYPE_CLIPBOARD: cDController.setContent(params.nameOrContent); fDController.addField(params); cDController.openDialog(); break; default: } } this.unload = function() { if (this.stopApplication) { // application is stopped yet, no need for action return; } else { // App still running when window closed or site left. // Announce headless_client this.logout(false); } } this.end = function(message) { if(message) { mDController.setMessage(message); mDController.openDialog(); } //log('CONNECTIONeND'); this.stopApplication = true; dProcessor.stopContent(); jQuery('#ssm').removeAttr("onmouseover"); //clDController.openDialog(); } this.checkNextContent = function(ms) { var date = new Date(); var now = date.getTime(); if((now - this.successTimestamp) >= ms) { this.getNextContent(); } else { this.nextContentTimeout(ms); } } this.nextContentTimeout = function (ms) { // TODO: Was ist das? Manchmal kommt nicht als erstes der ImageGrid über den Socket, und dann bleibt 40 Sekunden das Bild schwarz, geschiet so nicht(oder soll es anders?) var _self = this; if (this.start == 0) { var ms = 100; } //setTimeout(function(ms){ _self.getNextContent(); }, ms); setTimeout(function(){ _self.checkNextContent(ms); }, 1000); } } //********************************************************************************** // Direct Content Processing //********************************************************************************** var DirectContentProcessor = function(urlString) { this.imageProcessor = null; this.timeOut = AJAX_TIMEOUT; this.errorCount = 0; this.timeoutCount = 0; this.urlString = urlString; this.stopApplication = false; this.message = ''; this.imageTimestamp = new Object(); this.mouses = new Object(); this.lastGlobalContent = null; this.now = null; this.begin = null; this.stopContent = function() { //log('stopdirectContent'); this.stopApplication = true; } this.getNextContent = function() { var _self = this; if (!this.stopApplication) { jQuery.ajax( { url: _self.urlString, cache: false, dataType: 'json', error: function(XMLHttpRequest, textStatus, errorThrown) { _self.onGetNextContentError(XMLHttpRequest, textStatus, errorThrown); }, success: function(data, textStatus) { _self.onGetNextContentSuccess(data, textStatus) }, timeout: _self.timeOut } ); } else { lDController.removeDialog(); fDController.removeDialog(); cDController.removeDialog(); //clDController.openDialog(); this.stopApplication = true; jQuery('#ssm').removeAttr("onmouseover"); } } this.onGetNextContentSuccess = function(data, textStatus) { //log(data); this.errorCount = 0; this.timeoutCount = 0; // poll content with timeout var date = new Date(); if (this.begin === null) { this.begin = date.getTime(); } else { this.now = date.getTime(); var difference = this.now - this.begin; if (difference < 1200) // BK changed Anfragen runtersetzten { difference = 1200; // - difference; // BK changed Anfragen runtersetzten } else { difference = 0; } this.begin = date.getTime(); } this.nextContentTimeout(difference); var images_for_loading = new Array(); if (data != null) { var imageLoading = false; for (var type in data) { if (data['global_content']) { if (data['global_content'] != this.lastGlobalContent) { cProcessor.getNextContent(); this.lastGlobalContent = data['global_content']; } } switch(type) { case 'images': this.changeImages(data['images']); break; case 'mice': this.changeMouse(data['mice']); break; // TODO: Warum hier auskommentiert und oben extra??->wenn neue ImageGrid brauch er die alten bilder ja nicht mehr laden. /*case 'globalContent': cProcessor.getNextContent(); break; */ default: // empty } } } // immediately poll content again // this.getNextContent(); for (var i = 0; i < images_for_loading.length; i++) { this.imageProcessor.getNextImage(images_for_loading[i]); } } this.changeImages = function(data) { //////////////////////////////////////////// //////////////////////////////////////////// // AUTOZOOM SETZTEN //////////////////////////////////////////// //////////////////////////////////////////// if (zoomzoom == 1 && this.screenWidth != 0) { zoomzoom = 0; iGrid.rerun_fun(true); } //////////////////////////////////////////// //////////////////////////////////////////// // AUTOZOOM SETZTEN ENDE //////////////////////////////////////////// //////////////////////////////////////////// for (var idJ in data) { //log(idJ); var issetImageArray = false; for (var idA in this.imageTimestamp) { if (idA == idJ) { if (this.imageTimestamp[idA] == data[idJ]) { //nichts issetImageArray = true; } else { //log('nummer hat sich geändert'+idA+'und idJ'+idJ); this.imageTimestamp[idJ] = data[idJ]; iProcessor.getNextImage(idA); issetImageArray = true; } } else if(typeof(idA) == undefined) { //log('wenn idA undefinde ist'); this.imageTimestamp[idJ] = data[idJ]; iProcessor.getNextImage(idJ); issetImageArray = true; } } if (!issetImageArray) { //log('test nicht gegeben'+idJ); this.imageTimestamp[idJ] = data[idJ]; iProcessor.getNextImage(idJ); } } } this.changeMouse = function(data) { //log(data); for (var userIdJ in data) { var issetMouseArray = false; for (var userIdA in this.mouses) { if (this.mouses[userIdA] != null) { if (userIdA == userIdJ) { //log('change' + userIdA +userIdJ); var mickey = mList.getMouseByUserId(userIdJ); if (this.mouses[userIdA]['pos']['x'] == data[userIdJ]['pos']['x'] && this.mouses[userIdA]['pos']['y'] == data[userIdJ]['pos']['y']) { //do nothing issetMouseArray = true; } else { mickey.setPosition(data[userIdJ]['pos']['x'], data[userIdJ]['pos']['y']); this.mouses[userIdA]['pos']['x'] = data[userIdJ]['pos']['x']; this.mouses[userIdA]['pos']['y'] = data[userIdJ]['pos']['y']; issetMouseArray = true; } } else if(typeof (this.mouses[userIdJ]) == undefined) { var mickey = new Mouse(data[userIdJ], data[userIdJ]['name'], data[userIdJ]['pos']['x'], data[userIdJ]['pos']['y']); this.mouses[userIdJ] = data[userIdJ]; issetMouseArray = true; } else if(data[userIdA] == undefined) { //log('remove' + userIdA); var mickey = mList.getMouseByUserId(userIdA); //log(mickey); if (mickey !=null) { mickey.removeLayer(userIdA, this.mouses[userIdA]['name']); mList.removeMouse(userIdA); this.mouses[userIdA] = null; data[userIdA] = null; } issetMouseArray = true; } } } if(!issetMouseArray) { var mickey = new Mouse(userIdJ, data[userIdJ]['name'], data[userIdJ]['pos']['x'], data[userIdJ]['pos']['y']); this.mouses[userIdJ] = data[userIdJ]; } } } this.onGetNextContentError = function(XMLHttpRequest, textStatus, errorThrown) { var jetzt = new Date(); log("Fehler 16 " + jetzt.getTime()); log(XMLHttpRequest); log("textStatus: " + textStatus); log("errorThrown: " + errorThrown); //this.getNextContent(); //return; if(textStatus == "timeout") { this.timeoutCount++; } else { this.errorCount++; } log("errorCount: " + this.errorCount); log("timeoutCount: " + this.timeoutCount); if (this.errorCount < MAX_ERRORS && this.timeoutCount < 15) { this.getNextContent(); } else { cProcessor.end('Fehler 16: Verbindung zum Server abgebrochen'); } } this.nextContentTimeout = function (ms) { var _self = this; setTimeout(function(ms){ _self.getNextContent(); }, ms); } } //********************************************************************************** // Image Processing //********************************************************************************** var ImageProcessor = function(urlString) { this.contentProcessor = null; this.stop = false; this.urlString = urlString; this.loadingImages = new Array(); if(urlString !== null) { this.getInvisibleImage = function(imageId) { // alert("getInvisibleImage"); var elementId = 'conferenceImage_' + imageId; //log(imageId+'image'); //log(elementId+'element'); img1 = document.getElementById(elementId+'_0'); //dump(img1); if (img1.style.visibility == 'hidden') { return img1; } img2 = document.getElementById(elementId+'_1'); return img2; } this.getNextImage = function(imageId) { //neues bild alert("getNextImage"); var actImg = this.getInvisibleImage(imageId); this.loadingImages[imageId] = this.loadingImages[imageId] + 1; // do we have more than image to load // >1 also we are currently loading there sth if (this.loadingImages[imageId] > 1) { return; } // assemble url and call image var url = this.urlString + imageId + '.png?_='+(new Date()).getTime(); actImg.src = url; } } } var SetContainerSize = function (id, width, height) { jQuery('#' + id).width(width); jQuery('#' + id).height(height); } var GetDimensions = function (id) { this.positions = jQuery('#' + id).position(); gridToTop = this.positions['top']; gridToLeft = this.positions['left']; gridWidth = jQuery('#' +id).innerWidth(); gridHeight = jQuery('#' +id).innerHeight(); //alert(this.top + ' to top ' + this.left + ' to left ' + this.right + ' right' + this.height + ' Höhe'); } var ImageGrid = function() { this.screenWidth = 0; this.screenHeight = 0; this.segmentWidth = 0; this.segmentHeight = 0; this.contentProcessor = null; this.imageProcessor = null; //////////////////////////////////////////// //////////////////////////////////////////// // Funktion f�r den ZOOM START //////////////////////////////////////////// //////////////////////////////////////////// this.set_zoom = function() { factor_y = Fensterhoehe() / this.screenHeight; factor_x = Fensterweite() / this.screenWidth; factor_y < factor_x ? zoomfactor = factor_y : zoomfactor = factor_x; if (zoomfactor > 1) { zoomfactor = 1; } } this.rerun_fun = function(flip) { if (flip) { if (zoomfactor == 1) { this.set_zoom(); } else { zoomfactor = 1; } } else { zoomfactor == 1 ? zoomfactor = 1 : this.set_zoom(); } this.newDimension (this.screenWidth, this.screenHeight, this.segmentWidth, this.segmentHeight); var i = 0; var x = this.screenWidth/this.segmentWidth*this.screenHeight/this.segmentHeight; while (i < x) { iProcessor.getNextImage(i); i = i+1; } } //////////////////////////////////////////// //////////////////////////////////////////// // Funktion f�r den ZOOM Ende //////////////////////////////////////////// //////////////////////////////////////////// this.newDimension = function(screenWidth, screenHeight, segmentWidth, segmentHeight) { //alert(screenWidth + ", " + screenHeight + ", " + segmentWidth + ", " + segmentHeight); this.screenWidth = screenWidth; this.screenHeight = screenHeight; this.segmentWidth = segmentWidth; this.segmentHeight = segmentHeight; SetContainerSize('gridContainer', this.screenWidth*zoomfactor, this.screenHeight*zoomfactor); // BK : CHANGED //cleanup the old cruft if exists jQuery("img[id^='conferenceImage_']").remove(); jQuery("div[id^='conferenceDiv_']").remove(); var srcWidth = this.screenWidth; var srcHeight = this.screenHeight; var top = 0; var left = 0; var counter = 0; // Calculate the 'rest' in height var rest = this.screenHeight % this.segmentHeight; var firstRowHeight = this.segmentHeight + rest; var row = 0; while (srcHeight > 0) { if (row == 0) { sgmntHeight = firstRowHeight; srcHeight = srcHeight - firstRowHeight; } else if (srcHeight < this.segmentHeight) { //log("THIS MUST NOT HAPPEN! REST IN GRID HEIGHT!"); sgmntHeight = srcHeight; srcHeight = 0; } else { sgmntHeight = this.segmentHeight; srcHeight = srcHeight - this.segmentHeight; } srcWidth = this.screenWidth; while (srcWidth > 0) { if (srcWidth < this.segmentWidth) { sgmntWidth = srcWidth; srcWidth = 0; } else { sgmntWidth = this.segmentWidth; srcWidth = srcWidth - this.segmentWidth; } // Bilder //log("sgmnWidth: " + sgmntWidth + "srcWidth: " + srcWidth + "sgmnHeight: " + sgmntHeight + "srcHeight: " + srcHeight); //log("here1: "+counter); // Fix by BK Zoom runden, damit die Pixelfehler verschwinden IE Opera Safari IRON // heightrounded = Math.round (sgmntHeight*zoomfactor); widthrounded = Math.round (sgmntWidth*zoomfactor); // Fix Ende // jQuery('#gridContainer').append ('
'); var divs = jQuery("#conferenceDiv_" + counter); var div = divs.get(0); div.style.width = widthrounded + "px"; // BK : CHANGED div.style.height = heightrounded + "px"; // BK : CHANGED div.style.top = top + "px"; div.style.left = left + "px"; divs.append (""); var imgs1 = jQuery("#conferenceImage_" + counter + "_0"); var img1 = imgs1.get(0); img1.style.width = widthrounded + "px"; // BK : CHANGED img1.style.height = heightrounded + "px"; // BK : CHANGED img1.style.top = "0px"; img1.style.left = "0px"; img1.style.visibility = "visible"; divs.append (""); var imgs2 = jQuery("#conferenceImage_" + counter + "_1"); var img2 = imgs2.get(0); img2.style.width = widthrounded + "px"; // BK : CHANGED img2.style.height = heightrounded + "px"; // BK : CHANGED img2.style.top = "0px"; img2.style.left = "0px"; img2.style.visibility = "hidden"; imgs1.load(onImageLoaded (this.contentProcessor, this.imageProcessor, counter, img1, img2)); imgs2.load(onImageLoaded (this.contentProcessor, this.imageProcessor, counter, img2, img1)); imgs1.error(onImageError (this.contentProcessor, this.imageProcessor, counter)); imgs2.error(onImageError (this.contentProcessor, this.imageProcessor, counter)); left = left + widthrounded; // BK : CHANGED counter++; } left = 0; top = top + heightrounded; // BK : CHANGED row++; } GetDimensions('gridContainer'); } } var onImageLoaded = function (contentProcessor, imageProcessor, id, img1, img2) { var x = function () { img1.style.visibility = 'visible'; img2.style.visibility = 'hidden'; imageProcessor.loadingImages[id] = imageProcessor.loadingImages[id] - 1; if (imageProcessor.loadingImages[id] > 0) { imageProcessor.getNextImage(id); } } return x; } var onImageError = function (contentProcessor, imageProcessor, id) { var y = function () { //imageProcessor.loadingImages[id] = imageProcessor.loadingImages[id] - 1; if (imageProcessor.loadingImages[id] > 0) { log("ImageError: ID '" + id + "'"); imageProcessor.getNextImage(id); } } return y; } //********************************************************************************** // Mouse //********************************************************************************** var MouseList = function() { this.mouses = new Array(null, null ,null, null, null,null); this.registerMouse = function(mouse) { //log(mouse.id); if (this.mouses[mouse.id] == null) { //log(mouse.id); //log('if'); if (mouse.id > this.mouses.length) { for (var i = mouse.id - this.mouses.length; i > 0; i--) { this.mouses.push('null'); } } this.mouses.splice(mouse.id, 1, mouse); } else { //log('else'); for (var i = 0; i <= mouse.id; i++) { if (!this.mouses[i]) { this.mouses.splice(i, 1, null); } } this.mouses.splice(mouse.id, 1, mouse); } } this.removeMouse = function(id) { this.mouses.splice(id, 1, null); } this.getMouseByUserId = function(id) { //log(this.mouses); //log(id); for (var i = 0; i < this.mouses.length; i++) { if (this.mouses[i] != null) { if (this.mouses[i].id == id) { return this.mouses[i]; break; } } } } this.getMouseLayerNumber = function(mouse) { //log(this.mouses); for (var i = 0; i <= this.mouses.length; i++) { if (this.mouses[i] != null) { if (this.mouses[i].id == mouse.id) { //log(i); return i; break; } } } } } var Mouse = function(id, name, posX, posY) { this.id = id; this.name = name.replace (/ id:'+id+' name:'+name+' posx:'+posX+' posY:'+posY); this.createMouseLayer = function(id) { this.layer = jQuery('#mouselayer' + id).length; if (this.layer != 0) { //log('false'); return false; } else { jQuery('body').append ('
'); return true; } } this.removeLayer = function(id, name) { //id += 1; //log('removeLayer' + id + name); jQuery('#mouselayer'+id).remove(); } this.setVisible = function() { this.element.style.visibility = 'visible'; } this.setPosition = function(posX, posY) { //log ("Set position posX: " + posX + " posY: " + posY); this.posX = Math.round (posX*zoomfactor); // BK : CHANGED this.posY = Math.round (posY*zoomfactor); // BK : CHANGED //log ("GridToLeft " + GRID_TO_LEFT + " GridT " + GRID_WIDTH + " posY: " + posY); if (this.posX<=gridWidth && this.posY<=gridHeight && posX >= 0 && posY >= 0 ) { posX = posX + gridToLeft; posY = posY + gridToTop; this.element.style.left = Math.round (posX*zoomfactor)+'px'; // BK : CHANGED this.element.style.top = Math.round (posY*zoomfactor)+'px'; // BK : CHANGED //log(this.element); // log ("set position posX: " + posX + " posY: " + posY); this.setVisible(); } else { this.element.style.visibility = 'hidden'; } } this.setName = function () { this.name_element.innerHTML = this.name; } //dump(this); if (this.createMouseLayer(this.id)) { mList.registerMouse(this); this.layerNumber = mList.getMouseLayerNumber(this); this.element = document.getElementById('mouselayer' + this.layerNumber); this.name_element = document.getElementById('nameMouselayer' + this.layerNumber); this.setPosition(posX, posY); if (this.posX <= gridWidth && posX >= 0 ) {this.setVisible();} this.setName(); } } //********************************************************************************** // Initializations and Defaults //********************************************************************************** var iProcessor = new ImageProcessor(imageUrl); var iGrid = new ImageGrid(); var eDController = new EndController(logoUrl); var cProcessor = new ContentProcessor(nextContentUrl); var dProcessor = new DirectContentProcessor(directContentUrl); var mList = new MouseList(); var fDController = new FileDialogController(); var lDController = new LinkDialogController(); var cDController = new ClipboardDialogController(); var clDController = new CloseDialogController(); var mDController = new MessageDialogController(); cProcessor.imageProcessor = iProcessor; cProcessor.imageGrid = iGrid; iProcessor.contentProcessor = cProcessor; iGrid.contentProcessor = cProcessor; iGrid.imageProcessor = iProcessor;