Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactoring

  • Loading branch information...
commit 4499f532c5e14796b88cc66fb87b25d419ca6062 1 parent aa8d5fa
@jeromeetienne authored
View
0  CNAME.tmp → CNAME
File renamed without changes
View
6 Makefile
@@ -14,7 +14,7 @@ server:
$(GAE_ROOT)/dev_appserver.py .
minify:
- closurec --js web/easyWebSocket.js --js_output_file web/easyWebSocket-min.js
+ closurec --js easyWebSocket.js --js_output_file easyWebSocket-min.js
deploy : minify deployAppEngine deployGhPage
@@ -25,6 +25,6 @@ deployGhPage:
rm -rf /tmp/EasyWebsocketGhPages
(cd /tmp && git clone git@github.com:jeromeetienne/EasyWebsocket.git EasyWebsocketGhPages)
(cd /tmp/EasyWebsocketGhPages && git checkout gh-pages)
- cp -a index.html CNAME ./web ./example /tmp/EasyWebsocketGhPages
+ cp -a *.html *.js CNAME ./web ./example /tmp/EasyWebsocketGhPages
(cd /tmp/EasyWebsocketGhPages && git add . && git commit -a -m "Another deployement" && git push origin gh-pages)
- rm -rf /tmp/EasyWebsocketGhPages
+ #rm -rf /tmp/EasyWebsocketGhPages
View
0  web/easyWebSocket-min.js → easyWebSocket-min.js
File renamed without changes
View
28 web/easyWebSocket.js → easyWebSocket.js
@@ -18,28 +18,28 @@ EasyWebSocket = function(url, protocols)
// extract resource from the url
// - the domain part is ignored
// - TODO i should take the whole url
- this.resource = this.url.match(/.*:\/\/[^/]*\/(.+)/)[1];
+ //this.resource = this.url.match(/.*:\/\/[^/]*\/(.+)/)[1];
+ this.resource = this.url;
- if( false ){ // for devel
- this.iframeOrigin = "http://localhost:8080";
- }else{ // for prod
- this.iframeOrigin = "http://easywebsocket.appspot.com";
- }
- this.iframeUrl = this.iframeOrigin + "/web/iframe.html";
+ // define the class logging function
+ this.log = false ? function(){ console.log.apply(console, arguments) } : function(){};
+
+ this.iframeOrigin = true ? "http://localhost:8080" : "http://easywebsocket.org";
+ this.iframeUrl = this.iframeOrigin + "/web/iframe.html";
this._iframeCtor();
this.onopen = function(){
- console.log("default onopen")
+ self.log("default onopen")
}
this.onmessage = function(event){
- console.log("default onmessage")
+ self.log("default onmessage")
}
this.onerror = function(){
- console.log("default onerror")
+ self.log("default onerror")
}
this.onclose = function(){
- console.log("default onclose")
+ self.log("default onclose")
}
// bind the "message" dom event
@@ -59,7 +59,7 @@ EasyWebSocket.prototype._onWindowMessage = function(domEvent)
var eventType = eventFull.type;
var eventData = eventFull.data;
// log the event
- console.log("recevied message from iframe", eventFull)
+ this.log("recevied message from iframe", eventFull)
if( eventType == "connected" ){
this.onopen();
@@ -113,7 +113,7 @@ EasyWebSocket.prototype._iframeCtor = function()
iframe.style.width = iframe.style.height = "0";
// bind onload
iframe.onload = function(event){
- console.log("iframe loaded")
+ self.log("iframe loaded")
self._iframeSendConnect()
}
// append the iframe to <body>
@@ -134,7 +134,7 @@ EasyWebSocket.prototype._iframeExist = function()
EasyWebSocket.prototype._iframeSendRaw = function(data)
{
- console.log("iframeSendRaw(",data,")")
+ this.log("iframeSendRaw(",data,")")
var iframeEl = document.getElementById(this.iframeId).contentWindow;
var targetOrigin= "*"; // TODO not sure about this
iframeEl.postMessage(JSON.stringify(data), targetOrigin);
View
2  example/example.html
@@ -2,7 +2,7 @@
<head>
</head>
<body>
- <script src="http://jeromeetienne.github.com/EasyWebsocket/web/easyWebSocket-min.js"></script>
+ <script src="http://easywebsocket.org/web/easyWebSocket-min.js"></script>
<script>
var socket = new EasyWebSocket("ws://example.com/resource");
socket.onopen = function(){
View
6 index.html
@@ -54,7 +54,7 @@
<body>
<div id="container">
<h1>
- <a href="http://jeromeetienne.github.com/EasyWebsocket">Easy WebSocket</a>
+ <a href="http://easywebsocket.org">Easy WebSocket</a>
</h1>
<div class="description">
like WebSocket but no server setup and available in any browser
@@ -84,7 +84,7 @@
<p>No server setup, no cross-origin issue to care about... nothing!
</p>
<p>You are done,
- see it <a href="http://jeromeetienne.github.com/EasyWebsocket/example/example.html">live</a>.
+ see it <a href="http://easywebsocket.org/example/example.html">live</a>.
</p>
<p>
The API is copied on the <a href="http://dev.w3.org/html5/websockets/">standard API</a>, thus
@@ -92,7 +92,7 @@
</p>
<h2>Demo</h2>
<p>
- Seeing it work is always nice. Here is a <a href="http://jeromeetienne.github.com/EasyWebsocket/example/demo.html">demo</a>
+ Seeing it work is always nice. Here is a <a href="http://easywebsocket.org/example/demo.html">demo</a>
of a little chat application on top of EasyWebSocket.
</p>
<h2>Code</h2>
View
5 web/iframe.html
@@ -7,6 +7,11 @@
IFRAME content
<script>
jQuery(function(){
+ if( true ){ // to disable all the logging
+ console = {}
+ console.log = function(){}
+ }
+
/**
* TODO to the clientAlive call periodically
* TODO rewrite this code it is dirty
Please sign in to comment.
Something went wrong with that request. Please try again.