Created
March 8, 2012 18:58
-
-
Save gerad/2002710 to your computer and use it in GitHub Desktop.
snapengage async jquery plugin
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
| ;// http://www.snapengage.com/docs/asyncload.jsp | |
| // usage: $.snapengage() | |
| // loads snapengage asynchronously. A click on any link with class 'snapengage' | |
| // will cause the chat to open. | |
| !function($, window, undefined) { | |
| var widgetid = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX'; | |
| $.snapengage = function() { | |
| var protocol = window.location.protocol | |
| , base = /^https/.test(protocol) ? "https://snapabug.appspot.com" : "http://www.snapengage.com"; | |
| $(document.body).append('<div id="SnapABug_W"></div><div id="SnapABug_WP"></div><div id="SnapABug_Applet"></div>'); | |
| $.getScript(base + "/snapabug.js", function() { | |
| SnapABug.initAsync(widgetid); | |
| $('a.snapengage').live('click', function(e) { | |
| e.preventDefault(); | |
| SnapABug.startLink(); | |
| }); | |
| }); | |
| }; | |
| }(jQuery, window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a quick note, seems like it isn't that known, but instead of asking for the protocol to determine HTTPS or not you can simply set base to be '//snapabug.appspot.com'. Yup, all I did is dropeed the 'http:' from the URL. This tells the browser to use the current protocol. Too easy :)