Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
barcode/src/barcode-updater/bcupd.html
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
121 lines (92 sloc)
3.26 KB
This file contains 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
<!DOCTYPE html> | |
<html lang="en" style="height:100%;" > | |
<head> | |
<meta charset=utf-8 http-equiv="Content-Language" content="en"/> | |
<title>Minimal Websocket test app</title> | |
<style type="text/css"> | |
div.title { font-size:18pt; font: Arial; font-weight:normal; text-align:center; color:#000000; } | |
.group2 { width:600px; vertical-align:middle; text-align:center; background:#f0f0e0; padding:12px; -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; } | |
.explain { vertical-align:middle; text-align:center; background:#f0f0c0; padding:12px; -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; color:#404000; } | |
.content { vertical-align:top; text-align:center; background:#fffff0; padding:12px; -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; } | |
</style> | |
</head> | |
<body style="width:100%; height:100%;"> | |
<header></header> | |
<article height="100%" > | |
<table><tr><td> | |
</td></tr><tr><td> | |
<section id="increment" class="group2"> | |
<div class="title">libwebsockets "dumb-increment-protocol"</div> | |
<table><tr><td> | |
<table class="content" width="200px"> | |
<tr><td align=center><input type=button id=offset value="Reset counter" onclick="reset();" ></td></tr> | |
<tr><td width=200px align=center><div id=number> </div></td></tr> | |
<tr><td id=wsdi_statustd align=center class="explain"><div id=wsdi_status>Not initialized</div></td></tr> | |
</tr> | |
</table> | |
</td><td class="explain"> | |
The incrementing number is coming from the server and is individual for | |
each connection to the server... try opening a second browser window. | |
</td></tr></table> | |
</section> | |
<br> | |
</td></tr><tr><td> | |
</td></tr></table> | |
</article> | |
<object type="text/html" data="http://barcode.molgen.mpg.de/show" | |
style="width:100%; min-height:100%;"> | |
</object> | |
<script> | |
function get_appropriate_ws_url() | |
{ | |
var pcol; | |
var u = document.URL; | |
/* | |
* We open the websocket encrypted if this page came on an | |
* https:// url itself, otherwise unencrypted | |
*/ | |
if (u.substring(0, 5) == "https") { | |
pcol = "wss://"; | |
u = u.substr(8); | |
} else { | |
pcol = "ws://"; | |
if (u.substring(0, 4) == "http") | |
u = u.substr(7); | |
} | |
u = u.split('/'); | |
/* + "/xxx" bit is for IE10 workaround */ | |
return pcol + u[0] + "/xxx"; | |
} | |
/* document.getElementById("number").textContent = get_appropriate_ws_url(); */ | |
/* dumb increment protocol */ | |
var socket_di; | |
var ws_url = get_appropriate_ws_url(); | |
if (typeof MozWebSocket != "undefined") { | |
socket_di = new MozWebSocket(ws_url, | |
"dumb-increment-protocol"); | |
} else { | |
socket_di = new WebSocket(ws_url, | |
"dumb-increment-protocol"); | |
} | |
try { | |
socket_di.onopen = function() { | |
document.getElementById("wsdi_statustd").style.backgroundColor = "#40ff40"; | |
document.getElementById("wsdi_status").textContent = " websocket connection opened " + ws_url; | |
} | |
socket_di.onmessage =function got_packet(msg) { | |
document.getElementById("number").textContent = msg.data + "\n"; | |
/* location.reload(true); */ | |
} | |
socket_di.onclose = function(){ | |
document.getElementById("wsdi_statustd").style.backgroundColor = "#ff4040"; | |
document.getElementById("wsdi_status").textContent = " websocket connection CLOSED "; | |
} | |
} catch(exception) { | |
alert('<p>Error' + exception); | |
} | |
function reset() { | |
socket_di.send("reset\n"); | |
} | |
</script> | |
</body> | |
</html> |