[tor-commits] [snowflake/master] Begin embeddable snowflake badge (issue #16)
serene at torproject.org
serene at torproject.org
Thu Feb 4 05:43:27 UTC 2016
commit 7677707249ef92d51a6f00236158a4fad62201ea
Author: Serene Han <keroserene+git at gmail.com>
Date: Wed Feb 3 20:28:31 2016 -0800
Begin embeddable snowflake badge (issue #16)
---
proxy/Cakefile | 6 ++++++
proxy/proxypair.coffee | 4 ++--
proxy/snowflake.coffee | 21 ++++++++++++---------
proxy/static/embed.html | 35 +++++++++++++++++++++++++++++++++++
4 files changed, 55 insertions(+), 11 deletions(-)
diff --git a/proxy/Cakefile b/proxy/Cakefile
index 499de94..fa37ce1 100644
--- a/proxy/Cakefile
+++ b/proxy/Cakefile
@@ -33,6 +33,12 @@ task 'test', 'snowflake unit tests', ->
throw err if err
console.log stdout + stderr
+# task 'build:embed', 'build the snowflake badge', ->
+ # exec 'mkdir -p build'
+ # concatCoffeeFiles()
+ # copyStaticFiles()
+ # compileCoffee()
+
task 'build', 'build the snowflake proxy', ->
exec 'mkdir -p build'
concatCoffeeFiles()
diff --git a/proxy/proxypair.coffee b/proxy/proxypair.coffee
index ca9dcca..ac65ac5 100644
--- a/proxy/proxypair.coffee
+++ b/proxy/proxypair.coffee
@@ -59,7 +59,7 @@ class ProxyPair
channel.onopen = =>
log 'Data channel opened!'
snowflake.state = MODE.WEBRTC_READY
- $msglog.className = 'active';
+ $msglog.className = 'active' if $msglog
# This is the point when the WebRTC datachannel is done, so the next step
# is to establish websocket to the server.
@connectRelay()
@@ -67,7 +67,7 @@ class ProxyPair
log 'Data channel closed.'
Status.set 'disconnected.'
snowflake.state = MODE.INIT
- $msglog.className = ''
+ $msglog.className = '' if $msglog
# Change this for multiplexing.
snowflake.reset()
channel.onerror = -> log 'Data channel error!'
diff --git a/proxy/snowflake.coffee b/proxy/snowflake.coffee
index 99a9698..b59c35a 100644
--- a/proxy/snowflake.coffee
+++ b/proxy/snowflake.coffee
@@ -232,19 +232,22 @@ log = (msg) -> # Log to the message window.
# Status bar
Status =
- set: (msg) -> $status.innerHTML = 'Status: ' + msg
+ set: (msg) ->
+ $status.innerHTML = 'Status: ' + msg if $status
init = ->
- $status = document.getElementById('status')
- $msglog = document.getElementById('msglog')
- $msglog.value = ''
+ $badge = document.getElementById('badge')
+ if !badge
+ $status = document.getElementById('status')
+ $msglog = document.getElementById('msglog')
+ $msglog.value = ''
- $send = document.getElementById('send')
- $send.onclick = Interface.acceptInput
+ $send = document.getElementById('send')
+ $send.onclick = Interface.acceptInput
- $input = document.getElementById('input')
- $input.focus()
- $input.onkeydown = (e) -> $send.onclick() if 13 == e.keyCode # enter
+ $input = document.getElementById('input')
+ $input.focus()
+ $input.onkeydown = (e) -> $send.onclick() if 13 == e.keyCode # enter
log '== snowflake browser proxy =='
log 'Copy-Paste mode detected.' if COPY_PASTE_ENABLED
diff --git a/proxy/static/embed.html b/proxy/static/embed.html
new file mode 100644
index 0000000..ae361c6
--- /dev/null
+++ b/proxy/static/embed.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+<head>
+ <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
+ <script type="text/javascript" src="snowflake.js"></script>
+ <style>
+ * {
+ box-sizing: border-box;
+ -webkit-transition: all 0.3s;
+ -moz-transition: all 0.3s;
+ transition: all 0.3s;
+ }
+ body {
+ position: absolute;
+ width: 100%; height: 100%; top: 0; margin: 0 auto;
+ background-color: #424;
+ color: #000;
+ text-align: center;
+ font-size: 16px;
+ font-variant: small-caps;
+ }
+ #badge {
+ margin: auto;
+ width: 88px; height: 31px;
+ background-image: url('koch.jpg');
+ color: #fff;
+ }
+ </style>
+</head>
+<body>
+ <div id="badge">
+ Snowflake
+ </div>
+</body>
+</html>
More information about the tor-commits
mailing list