Permalink
Browse files

adding 3.3.1 release

  • Loading branch information...
1 parent 56cde80 commit 215e498172f70f327e870c326d4ab7a418d51bbf geremy cohen committed Nov 12, 2012
Showing with 2,718 additions and 170 deletions.
  1. +127 −0 javascript/3.3.1/README.md
  2. BIN javascript/3.3.1/comet.swf
  3. +4 −0 javascript/3.3.1/crossdomain.xml
  4. +110 −0 javascript/3.3.1/examples/detailed_history/index.html
  5. +27 −0 javascript/3.3.1/examples/detailed_history/js/jquery.example.min.js
  6. +118 −0 javascript/3.3.1/examples/presence/index.html
  7. +27 −0 javascript/3.3.1/examples/presence/js/jquery.example.min.js
  8. +119 −0 javascript/3.3.1/examples/simple-chat.js
  9. +54 −0 javascript/3.3.1/modules/player.js
  10. +1 −0 javascript/3.3.1/modules/player.min.js
  11. +216 −0 javascript/3.3.1/modules/sprite.js
  12. +3 −0 javascript/3.3.1/modules/sprite.min.js
  13. +121 −0 javascript/3.3.1/modules/utility.js
  14. +3 −0 javascript/3.3.1/modules/utility.min.js
  15. 0 javascript/{pubnub-3.3.js → 3.3.1/pubnub-3.3.1.js}
  16. BIN javascript/3.3.1/pubnub-3.3.1.min.js
  17. +47 −0 javascript/3.3.1/pubnub.as
  18. BIN javascript/3.3.1/pubnub.swf
  19. +40 −0 javascript/3.3.1/tests/head-test.htm
  20. +8 −0 javascript/3.3.1/tests/head.load.min.js
  21. +52 −0 javascript/3.3.1/tests/mailto-fix.html
  22. +60 −0 javascript/3.3.1/tests/presence-ssl.html
  23. +54 −0 javascript/3.3.1/tests/ssl-test.html
  24. +81 −0 javascript/3.3.1/tests/test.js
  25. +41 −0 javascript/3.3.1/tests/test.sh
  26. +246 −0 javascript/3.3.1/tests/unit-test.html
  27. +59 −96 javascript/3.3/pubnub-3.3.js
  28. +19 −20 javascript/3.3/pubnub-3.3.min.js
  29. +7 −34 javascript/README.md
  30. +1,074 −0 javascript/pubnub-3.3.1.js
  31. BIN javascript/pubnub-3.3.1.min.js
  32. +0 −20 javascript/pubnub-3.3.min.js
View
@@ -0,0 +1,127 @@
+# YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
+http://www.pubnub.com/account
+
+## TESTLING - (OPTIONAL)
+PubNub JavaScript API for Web Browsers
+uses Testling Cloud Service for QA and Deployment.
+http://www.testling.com/
+
+You need this to run './test.sh' unit test.
+This is completely optional, however we love Testling.
+
+
+## PubNub 3.3.1 Real-time Cloud Push API - JAVASCRIPT
+http://www.pubnub.com - PubNub Real-time Push Service in the Cloud.
+http://www.pubnub.com/tutorial/javascript-push-api
+
+PubNub is a blazingly fast cloud-hosted messaging service for building
+real-time web and mobile apps. Hundreds of apps and thousands of developers
+rely on PubNub for delivering human-perceptive real-time
+experiences that scale to millions of users worldwide. PubNub delivers
+the infrastructure needed to build amazing MMO games, social apps,
+business collaborative solutions, and more.
+
+## SIMPLE EXAMPLE
+```html
+<div id=pubnub pub-key=demo sub-key=demo></div>
+<script src=http://cdn.pubnub.com/pubnub-3.3.1.min.js ></script>
+<script>
+
+ // LISTEN
+ PUBNUB.subscribe({
+ channel : "hello_world",
+ callback : alert
+ })
+
+ // SEND
+ PUBNUB.publish({
+ channel : "hello_world",
+ message : "Hi."
+ })
+
+</script>
+```
+
+## ADVANCED STYLE
+```html
+<div id=pubnub pub-key=demo sub-key=demo></div>
+<script src=http://cdn.pubnub.com/pubnub-3.3.1.min.js ></script>
+<script>(function(){
+ // LISTEN FOR MESSAGES
+ PUBNUB.subscribe({
+ channel : "hello_world", // CONNECT TO THIS CHANNEL.
+ restore : false, // STAY CONNECTED, EVEN WHEN BROWSER IS CLOSED
+ // OR WHEN PAGE CHANGES.
+ callback : function(message) { // RECEIVED A MESSAGE.
+ alert(message)
+ },
+ connect : function() { // CONNECTION ESTABLISHED.
+ PUBNUB.publish({ // SEND A MESSAGE.
+ channel : "hello_world",
+ message : "Hi from PubNub."
+ })
+ },
+ disconnect : function() { // LOST CONNECTION.
+ alert(
+ "Connection Lost." +
+ "Will auto-reconnect when Online."
+ )
+ },
+ reconnect : function() { // CONNECTION RESTORED.
+ alert("And we're Back!")
+ }
+ })
+})();</script>
+```
+
+## SSL MODE
+
+```html
+<div id=pubnub ssl=on></div>
+<script src=https://pubnub.a.ssl.fastly.net/pubnub-3.3.1.min.js></script>
+<script>(function(){
+
+ var pubnub = PUBNUB({
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ origin : 'pubsub.pubnub.com',
+ ssl : true
+ });
+
+ pubnub.subscribe({
+ channel : 'my_channel',
+ connect : function() { /* ... */ },
+ callback : function(message) {
+ alert(JSON.stringify(message));
+ }
+ });
+
+})();</script>
+```
+
+## Using the PUBNUB init() Function
+
+Sometimes you want to use create a PubNub Instance directly in JavaScript
+and pass the PubNub API Keys without using a DOM element.
+To do this, simply follow this `init` example:
+
+```html
+<script src=http://cdn.pubnub.com/pubnub-3.3.1.min.js ></script>
+<script>(function(){
+
+ // INIT PubNub
+ var pubnub = PUBNUB.init({
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ origin : 'pubsub.pubnub.com'
+ });
+
+ // LISTEN
+ pubnub.subscribe({ channel : "hello_world", callback : alert })
+
+ // SEND
+ pubnub.publish({ channel : "hello_world", message : "Hi." })
+
+})();</script>
+```
+
View
Binary file not shown.
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<cross-domain-policy>
+ <allow-access-from domain="*" secure="false" />
+</cross-domain-policy>
@@ -0,0 +1,110 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>PubNub Detailed History Demo</title>
+
+ <style>
+ body { height: auto; bottom:0; top:0; font-family: Verdana, Geneva, sans-serif; }
+ table { border:2px solid #000; width: 100%; height:100%; border-collapse:collapse; }
+ td { border:2px solid #000; vertical-align: top; padding: 10px; }
+ #publish-result{ width: 25%; }
+ #detailed-history-result { width: 75%; }
+ td.detailed-history .message { clear:both; font-size:12px; }
+ td.detailed-history .message .sender { width: 150px; float:left; /*border:1px solid #000;*/ overflow: hidden; white-space: nowrap; font-weight: bold; }
+ td.detailed-history .message .text { margin-left:155px; /*border:1px solid #000;*/ }
+
+ td.publish { height: 19px; padding:0; }
+ td.publish input { margin:0; }
+ td.detailed-history .join { text-align: center; color: gray; font-style: italic; font-size:12px; }
+ td.publish input { width: 100%; }
+ input.example { color: #666; }
+ </style>
+</head>
+<body>
+
+<table>
+ <tr>
+ <td class="detailed-history" id="publish-result">
+ </td>
+ <td class="detailed-history" id="detailed-history-result" >
+ </td>
+ </tr>
+ <tr>
+ <td class="publish">
+ <input type="text"/>
+ </td>
+ <td class="detailed-history-inputs">
+ <input id="detailed-history-button" type="button" value="Detailed History" />
+ <input id="detailed-history-count" type="text" value="5"/>
+ <input id="detailed-history-start" type="text" value=""/>
+ <input id="detailed-history-end" type="text" value=""/>
+ <input id="detailed-history-channel" type="text" value="hello_world"/>
+ <input id="detailed-history-reverse" type="checkbox" name="reverse" value="true">Reverse ?</input>
+ </select>
+ </td>
+ </tr>
+</table>
+
+
+<div pub-key="demo" sub-key="demo" ssl="off" origin="pubsub.pubnub.com" id="pubnub"></div>
+<script src="../../pubnub-3.3.1.js"></script>
+
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
+<script src="js/jquery.example.min.js"></script>
+<script>
+var publish_help = "Publish Here";
+var count_help = "Count (default: 100)";
+var start_help = "Start Time Stamp";
+var end_help = "End Time Stamp";
+
+
+function messageEvent(message) {
+ $("#publish-result").append($("<div class='message'><div class='sender'>"+message['sender']+"</div><div class='text'>"+message['text']+"</div></div>"));
+}
+function detailedHistoryEvent(message) {
+ $("#detailed-history-result").append($("<div class='text'>" + JSON.stringify(message) + "</div>"));
+}
+$("#detailed-history-button").click(function(){
+ var paramobj = {};
+ paramobj["channel"] = "detailed-history-demo-channel";
+ paramobj["callback"] = function(history) {
+ for (var i=0; i<history.length; i++) {
+ detailedHistoryEvent(history[i]);
+ }
+ };
+ if ($("#detailed-history-reverse:checked").val())
+ paramobj["reverse"] = true;
+
+ if ($("#detailed-history-count").val() != count_help)
+ paramobj["count"] = $("#detailed-history-count").val();
+ else
+ paramobj["count"] = 100;
+
+ paramobj["channel"] = $("#detailed-history-channel").val();
+
+
+ if ($("#detailed-history-start").val() != start_help)
+ paramobj["start"] = $("#detailed-history-start").val();
+
+ if ($("#detailed-history-end").val() != end_help)
+ paramobj["end"] = $("#detailed-history-end").val();
+
+ PUBNUB.detailedHistory(paramobj);
+
+});
+
+$("td.publish input").example(publish_help);
+$("#detailed-history-count").example(count_help);
+$("#detailed-history-start").example(start_help);
+$("#detailed-history-end").example(end_help);
+$('td.publish input').keypress(function(e){
+ if(e.which == 13){
+ message = {sender:PUBNUB.db.get($("#pubnub").attr('sub-key')+'uuid'), text:$("td.publish input").val()};
+ PUBNUB.publish({channel:$("#detailed-history-channel").val(),message:message});
+ messageEvent(message);
+ $("td.publish input").val("");
+ }
+});
+</script>
+</body>
+</html>
@@ -0,0 +1,27 @@
+/*
+ * jQuery Form Example Plugin 1.6.0
+ * Populate form inputs with example text that disappears on focus.
+ *
+ * e.g.
+ * $('input#name').example('Bob Smith');
+ * $('input[@title]').example(function () {
+ * return $(this).attr('title');
+ * });
+ * $('textarea#message').example('Type your message here', {
+ * className: 'example_text'
+ * });
+ *
+ * Copyright (c) Paul Mucur (http://mudge.name), 2007-2012.
+ * Dual-licensed under the BSD (BSD-LICENSE.txt) and GPL (GPL-LICENSE.txt)
+ * licenses.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */(function(a){"use strict";var b;a.fn.on?b=function(b,c,d){a("body").on(c,b,d)}:a.fn.delegate?b=function(b,c,d){a("body").delegate(b,c,d)}:a.fn.live?b=function(b,c,d){a(b).live(c,d)}:b=function(b,c,d){a(b).bind(c,d)},a.fn.example=function(c,d){var e=a.isFunction(c),f=a.extend({},d,{example:c});return this.each(function(){var c,d=a(this);a.metadata?c=a.extend({},a.fn.example.defaults,d.metadata(),f):c=a.extend({},a.fn.example.defaults,f),a.fn.example.boundClassNames[c.className]||(a(window).bind("unload.example",function(){a("."+c.className).val("").removeClass(c.className)}),b("form","submit.example example:resetForm",function(){a(this).find("."+c.className).val("").removeClass(c.className)}),a.fn.example.boundClassNames[c.className]=!0),d.val()!==this.defaultValue&&(e||d.val()===c.example)&&d.val(this.defaultValue),d.val()===""&&!d.is(":focus")&&d.addClass(c.className).val(e?c.example.call(this):c.example),d.bind("focus.example",function(){a(this).is("."+c.className)&&a(this).val("").removeClass(c.className)}).bind("change.example",function(){a(this).is("."+c.className)&&a(this).removeClass(c.className)}).bind("blur.example",function(){a(this).val()===""&&a(this).addClass(c.className).val(e?c.example.call(this):c.example)})})},a.fn.example.defaults={className:"example"},a.fn.example.boundClassNames=[]})(jQuery);
@@ -0,0 +1,118 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>PubNub Presence Demo</title>
+
+ <style>
+ body { height: auto; bottom:0; top:0; font-family: Verdana, Geneva, sans-serif; }
+ table { border:2px solid #000; width: 100%; height:100%; border-collapse:collapse; }
+ td { border:2px solid #000; vertical-align: top; padding: 10px; }
+ td.history { width: 80%; }
+ td.history .message { clear:both; font-size:12px; }
+ td.history .message .sender { width: 150px; float:left; /*border:1px solid #000;*/ overflow: hidden; white-space: nowrap; font-weight: bold; }
+ td.history .message .text { margin-left:155px; /*border:1px solid #000;*/ }
+ td.chat { height: 19px; padding:0; }
+ td.chat input { margin:0; }
+ td.users { width: 20%; font-size: 14px; }
+ td.users ul { padding-left: 20px; }
+ td.history .join { text-align: center; color: gray; font-style: italic; font-size:12px; }
+ td.chat input { width: 100%; }
+ td.occupancy { text-align: right; padding: 0 10; vertical-align: middle; font-size: 14px; }
+ input.example { color: #666; }
+ </style>
+</head>
+<body>
+
+<table>
+ <tr>
+ <td class="history">
+ </td>
+ <td class="users">
+ <h3>Currently Here</h3>
+ <ul class="list">
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td class="chat">
+ <input />
+ </td>
+ <td class="occupancy">
+ <span class='number'>0</span> people here now
+ </td>
+ </tr>
+</table>
+
+
+<div pub-key="demo" sub-key="demo" ssl="off" origin="pubsub.pubnub.com" id="pubnub"></div>
+<script src="../../pubnub-3.3.1.js"></script>
+
+<script>(function(){
+
+ // LISTEN FOR MESSAGES
+ PUBNUB.subscribe({
+ channel : "hello_world", // CONNECT TO THIS CHANNEL.
+
+ restore : true, // STAY CONNECTED, EVEN WHEN BROWSER IS CLOSED
+ // OR WHEN PAGE CHANGES.
+
+ callback : function(message) { // RECEIVED A MESSAGE.
+ if (message['sender'] != PUBNUB.db.get($("#pubnub").attr('sub-key')+'uuid')) {
+ messageEvent(message);
+ }
+ },
+ connect : function() { // CONNECTION ESTABLISHED.
+
+ PUBNUB.history({channel: "hello_world", limit:100, callback: function(history) {
+ for (i=0; i<history.length; i++) {
+ messageEvent(history[i]);
+ }
+ }});
+
+ PUBNUB.here_now({channel:'hello_world', callback:function(message) {
+ $("td.occupancy .number").text(message['occupancy']);
+ for (i=0; i<message['uuids'].length; i++) {
+ $(".users .list").append($("<li class='"+message['uuids'][i]+"'>"+message['uuids'][i]+"</li>"));
+ }
+ }});
+
+ },
+ presence : function(message) {
+ presenceEvent(message, true);
+ }
+ })
+})();</script>
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
+<script src="js/jquery.example.min.js"></script>
+<script>
+function presenceEvent(message, announce) {
+ if (announce == undefined) announce = true;
+ //console.log("Got presence event: ", message, " announce ", announce);
+ if (message['action'] == 'join') {
+ $(".users .list").append($("<li class='"+message['uuid']+"'>"+message['uuid']+"</li>"));
+ if (announce) $(".history").append($("<div class='join "+message['uuid']+"'>"+message['uuid']+" joined the channel</li>"));
+ } else if (message['action'] == 'leave') {
+ $(".users .list li."+message['uuid']).remove();
+ if (announce) $(".history").append($("<div class='join "+message['uuid']+"'>"+message['uuid']+" left the channel</li>"));
+ } else if (message['action'] == 'timeout') {
+ $(".users .list li."+message['uuid']).remove();
+ if (announce) $(".history").append($("<div class='join "+message['uuid']+"'>"+message['uuid']+" timed out</li>"));
+ }
+ $("td.occupancy .number").text(message['occupancy']);
+}
+function messageEvent(message) {
+ //console.log("Got message: ", message);
+ $(".history").append($("<div class='message'><div class='sender'>"+message['sender']+"</div><div class='text'>"+message['text']+"</div></div>"));
+}
+$("td.chat input").example("Chat here");
+$('td.chat input').keypress(function(e){
+ if(e.which == 13){
+ message = {sender:PUBNUB.db.get($("#pubnub").attr('sub-key')+'uuid'), text:$("td.chat input").val()};
+ PUBNUB.publish({channel:'hello_world',message:message});
+ messageEvent(message);
+ $("td.chat input").val("");
+ }
+});
+</script>
+</body>
+</html>
Oops, something went wrong.

0 comments on commit 215e498

Please sign in to comment.