/** * msg.php * * @copyright © 2006 The Open University * @author a.little@open.ac.uk * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package block_msg * * Javascript & AJAX functions for setting MSG presence status * All these functions are adapted from the MSG standalone functions. * It's a PHP file so that the displayed text strings and URLs etc * can be generated from the Moodle code. */ MSGAPIconf.imgroot = "http://moodle.ethompson.org/blocks/msg/images/"; MSGAPIconf.msg_jabberurl = "http://community.ethompson.org:8080/buddyxml"; MSGAPIconf.msg_host = "communty.ethompson.org"; MSGAPIconf.msg_jabberui = "http://community.ethompson.org:8080/msg"; MSGAPIconf.stateText['online'] = "Online"; MSGAPIconf.stateText['away'] = "Away"; MSGAPIconf.stateText['chat'] = "Online"; MSGAPIconf.stateText['dnd'] = "Do not disturb"; MSGAPIconf.stateText['offline'] = "Offline"; MSGAPIconf.stateText['xa'] = "Away"; MSGAPIconf.peekTimeoutNoInterrupt = 5000; MSGAPIconf.peekTimeoutInterrupt = 30000; MSGAPIconf.checkLoginTimeout = 2000; MSGAPIconf.str_oneMessageUnread = "1 unread message"; MSGAPIconf.str_messagesUnread = " unread messages"; MSGAPIconf.str_popupRead = "[[popupRead]]"; MSGAPIconf.str_popupClose = "[[popupClose]]"; MSGAPIconf.maxLoginAttempts = 5; MSGAPIconf.global_online_url = "http://community.ethompson.org:8080/buddyxml/mashup.jsp?data=sessions&verbose=true&type=json"; MSGAPIconf.global_total_url = "http://community.ethompson.org:8080/buddyxml/mashup.jsp?data=counters&type=json"; MSGAPIconf.global_online_counter_id = 'block_msg_global_online'; MSGAPIconf.global_counter_id = 'block_msg_global_total'; MSGAPIconf.personal_online_url = "http://moodle.ethompson.org/blocks/msg/services/getpersonalcontacts.php"; MSGAPIconf.personal_online_counter_id = 'block_msg_personal_online'; MSGAPIconf.personal_counter_id = 'block_msg_personal_total'; MSGAPIconf.global_online_refresh_rate = 1000; MSGAPIconf.personal_online_refresh_rate = 1000; MSGAPIconf.clientWindowName = "MSGClientWindow"; MSGAPIconf.clientWindowProps = "width=500,height=400,scrollbars=yes,resizable=yes"; MSGAPIconf.str_popupBlocked = "MSG tried to open as a popup window, but you have blocked popups.\n\n You can unblock popups via the 'Tools... (Internet) Options...' menu in your browser."; MSGAPIconf.user_sessions_url = "http://community.ethompson.org:8080/buddyxml/mashup.jsp?data=sessions&verbose=true&type=json"; authArr = new Array(); authArr['resource'] = "Moodle"; authArr['username'] = "MoodleSession"; authArr['password'] = "checkthecookie"; authArr['MoodleSession'] = "6sopln8f6so9ni5cu9dqsqqb93"; authArr['MoodleSessionTest'] = "2TznNm4Wpz"; initMSG(authArr,"0"," "); myMSG.enableMSGLinks = EnableLinks; myMSG.disableMSGLinks = DisableLinks; map = null; /** * */ function EnableLinks(){ enableLink("MSGLaunchLink","javascript:launchClick();"); enableLink("MSGLaunchMapLink",MSGAPIconf.msg_jabberui+"/map"); var mme = document.getElementById("msg_map_enlarge"); if(mme){ mme.innerHTML = ""; var anch = document.createElement("a"); anch.setAttribute("target","MSGPresenceMap"); anch.setAttribute("href",MSGAPIconf.msg_jabberui+"/map"); anch.setAttribute("title","Interact with map"); anch.appendChild(document.createTextNode("[Zoom/interact]")); mme.appendChild(anch); } } /** * */ function DisableLinks(){ disableLink("MSGLaunchLink"); disableLink("MSGMapLink"); var mme = document.getElementById("msg_map_enlarge"); if(mme){ mme.innerHTML = ""; } } /** * Start MSG */ function startMSG(){ checkLogin(); monitorGlobalOnline(); loadMap(); } /** * Monitor only */ function monitorMSG(){ monitorGlobalOnline(); loadMap(); } /** * Load the Google map */ function loadMap(){ if(document.getElementById("block_msg_googlemap") != null){ if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("block_msg_googlemap")); map.addControl(new GSmallZoomControl()); // set default centre map.setCenter(new GLatLng(17.383,11.183), 0); } // load users and display on map loadSessionUsers(); } } function MoodleBlockZoomToLocation(){ // move map to user location and add on a marker for the user if(map!= null && conf_currentUserLat != 0 && conf_currentUserLng != 0){ var point = new GLatLng(conf_currentUserLat, conf_currentUserLng); map.setCenter(point, 8); map.addOverlay(new GMarker(point, new MoodleBlockMapMarker())); } } function MoodleBlockMapMarker(){ var icon = new GIcon(); icon.image = "http://moodle.ethompson.org/blocks/msg/images/not-logged-in-icon.png"; icon.shadow = "http://moodle.ethompson.org/blocks/msg/images/not-logged-in-shad.png"; icon.iconSize = new GSize(22, 15); icon.shadowSize = new GSize(22, 15); icon.iconAnchor = new GPoint(11, 14); icon.infoWindowAnchor = new GPoint(13,5); return icon; } function loadSessionUsers(){ request = MSGAPIconf.user_sessions_url + "&callback=loadSessionUsersCallback"; aObj = new JSONscriptRequest(request); aObj.buildScriptTag(); aObj.addScriptTag(); } function loadSessionUsersCallback(jData){ if(!jData){ return; } // loop thru returned data var sessions = jData.children[0].children; for(var i=0; i