Created
January 17, 2012 14:55
-
-
Save Pistos/1626931 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var windowFocus = true; | |
| var username = 'Me'; // TO CHANGE: User.name | |
| var originalTitle; | |
| var blinkOrder = 0; | |
| var chatboxFocus = new Array(); | |
| var newMessages = new Array(); | |
| var newMessagesWin = new Array(); | |
| var chatBoxes = new Array(); | |
| var logout = 0; | |
| <<<<<<< HEAD | |
| // Object to manage Chatboxes | |
| function chatBox(name, minimized, text) { | |
| this.name = name; | |
| this.minimized = minimized; | |
| this.text = text; | |
| } | |
| ======= | |
| var MINI_TITLE = null; | |
| >>>>>>> e9485c6... auth based on cookie instead of password | |
| // Unloading the page | |
| $(window).unload(function() { | |
| if(logout){ | |
| Chat.disconnect(); | |
| }else{ | |
| Chat.pause(); | |
| storeConnectionInfo(); | |
| } | |
| }); | |
| $(window).bind('beforeunload', function(){ | |
| Chat.send($pres({ | |
| 'type':'unavailable' | |
| })); | |
| Chat.bosh.flush(); | |
| }) | |
| // Page loaded | |
| <<<<<<< HEAD | |
| $(document).ready(function(){ | |
| $('a').click(function() { | |
| window.onbeforeunload = null; | |
| ======= | |
| $(document).ready(function () { | |
| // Save the page title | |
| MINI_TITLE = document.title; | |
| // Sets the good roster max-height | |
| jQuery(window).resize(adaptRosterMini); | |
| // Logouts when Jappix is closed | |
| if (BrowserDetect.browser == 'Opera') { | |
| // Emulates onbeforeunload on Opera (link clicked) | |
| jQuery('a[href]:not([onclick])').click(function () { | |
| // Link attributes | |
| var href = jQuery(this).attr('href') || ''; | |
| var target = jQuery(this).attr('target') || ''; | |
| // Not new window or JS link | |
| if (href && !href.match(/^#/i) && !target.match(/_blank|_new/i)) saveSessionMini(); | |
| }); | |
| // Emulates onbeforeunload on Opera (form submitted) | |
| jQuery('form:not([onsubmit])').submit(saveSessionMini); | |
| } | |
| $('a').click(function () { | |
| window.onbeforeunload = null; | |
| }); | |
| $("#logout").click(function () { | |
| logout = 1; | |
| }); | |
| // Get connection state | |
| var sid = localStorage.getItem("sid"); | |
| var rid = localStorage.getItem("rid"); | |
| var jid = localStorage.getItem("jid"); | |
| var suspended = false; | |
| // Check if connection state is valid | |
| if (sid != null && rid != null && jid != null) { | |
| suspended = true; | |
| Chat.attach(jid, sid, rid); | |
| // Try to restore the DOM | |
| var dom = localStorage.getItem("dom"); | |
| var stamp = localStorage.getItem("stamp"); | |
| // Invalid stored DOM? | |
| if (dom && isNaN(jQuery(dom).find('a.jm_pane.jm_button span.jm_counter').text())) dom = null; | |
| // get last rosters | |
| Chat.rosters = $.makeArray(JSON.parse(localStorage.getItem("roster"))); | |
| } else { | |
| var user = localStorage.getItem("user"); | |
| localStorage.removeItem("user"); | |
| var cookie = unescape(document.cookie.split((escape("_diaspora_session") + '='))[1].split(';')[0]); | |
| // Create HTML chat menu | |
| dom = '<div class="jm_position">' + '<div class="jm_conversations"></div>' + '<div class="jm_starter">' + '<div class="jm_roster">' + '<div class="jm_actions">' + '<a class="jm_logo jm_images" href="javascript:void(0)"></a>' + '<a class="jm_one-action jm_available jm_images" title="Go offline" href="javascript:void(0)"></a>' + '</div>' + '<div class="jm_buddies"></div>' + '</div>' + '<a class="jm_pane jm_button jm_images" href="#">' + '<span class="jm_counter jm_images">Please wait...</span>' + '</a>' + '</div>' + '</div>'; | |
| Chat.start(user, cookie); | |
| } | |
| // Create the DOM | |
| jQuery('body').append('<div id="jappix_mini">' + dom + '</div>'); | |
| // Adapt roster height | |
| adaptRosterMini(); | |
| // The click events | |
| jQuery('#jappix_mini a.jm_button').click(function () { | |
| // Using a try/catch override IE issues | |
| try { | |
| // Presence counter | |
| var counter = '#jappix_mini a.jm_pane.jm_button span.jm_counter'; | |
| // Cannot open the roster? | |
| if (jQuery(counter).text() == "Please wait...") return false; | |
| // Not yet connected? | |
| if (jQuery(counter).text() == "Chat") { | |
| // Remove the animated bubble | |
| jQuery('#jappix_mini div.jm_starter span.jm_animate').stopTime().remove(); | |
| // Add a waiting marker | |
| jQuery(counter).text("Please wait..."); | |
| } | |
| // Normal actions | |
| if (!jQuery(this).hasClass('jm_clicked')) showRosterMini(); | |
| else hideRosterMini(); | |
| } catch (e) {} finally { | |
| return false; | |
| } | |
| }); | |
| jQuery('#jappix_mini div.jm_actions a.jm_available, #jappix_mini div.jm_actions a.jm_unavailable').click(function () { | |
| if (Chat.presence == 0) { | |
| Chat.offline(); | |
| jQuery(this).removeClass('jm_available'); | |
| jQuery(this).addClass('jm_unavailable'); | |
| jQuery(this).attr("title","Go online"); | |
| } else { | |
| Chat.online(); | |
| jQuery(this).removeClass('jm_unavailable'); | |
| jQuery(this).addClass('jm_available'); | |
| jQuery(this).attr("title","Go offline"); | |
| } | |
| }); | |
| // Hides the roster when clicking away of Jappix Mini | |
| jQuery(document).click( | |
| function (evt) { | |
| if (!jQuery(evt.target).parents('#jappix_mini').size() && !exists('#jappix_popup')) hideRosterMini(); | |
| }); | |
| // Hides all panes double clicking away of Jappix Mini | |
| jQuery(document).dblclick( | |
| function (evt) { | |
| if (!jQuery(evt.target).parents('#jappix_mini').size() && !exists('#jappix_popup')) switchPaneMini(); | |
| }); | |
| // Suspended session resumed? | |
| if (suspended) { | |
| // Restore chat input values | |
| jQuery('#jappix_mini div.jm_conversation input.jm_send-messages').each( | |
| function () { | |
| var chat_value = jQuery(this).attr('data-value'); | |
| if (chat_value) jQuery(this).val(chat_value); | |
| >>>>>>> e9485c6... auth based on cookie instead of password | |
| }); | |
| $("#logout").click(function(){ | |
| logout = 1; | |
| }); | |
| originalTitle = document.title; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <<<<<<< HEAD | |
| var pod_url = document.URL.split('/')[2].split( ':' )[0].split('/')[0]; | |
| var BOSH_URL = 'http://'+pod_url+':5280/http-bind'; | |
| ======= | |
| var pod_url = window.location.hostname; | |
| var BOSH_URL = 'http://' + pod_url + ':5280/http-bind'; | |
| >>>>>>> e9485c6... auth based on cookie instead of password | |
| // Object to manage Rosters | |
| function rosterState(jid, nick, resource) { | |
| this.jid = jid; | |
| this.nick = nick; | |
| this.resource = resource; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment