diff options
-rw-r--r-- | ship/lib/core | 30 | ||||
-rw-r--r-- | webchat/hello_web.js | 11 | ||||
-rw-r--r-- | webchat/public/client.js | 2 | ||||
-rw-r--r-- | webchat/public/reset.css | 37 |
4 files changed, 70 insertions, 10 deletions
diff --git a/ship/lib/core b/ship/lib/core index fb346f88..3a6b33ff 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -6,6 +6,17 @@ exists(){ type "$1" >/dev/null 2>/dev/null; } is_root(){ test $(id -u) -eq 0 } + +esudo(){ + # becomes root with sudo powers + # unless nosudo env is set + if test "${nosudo-false}" != true || is_root; then + echo "we're going sudo..." >&2 + exec sudo -E "$0" "$@" + exit 23 # go to hell + fi +} + get_hostname(){ # finds the current hostname # if ENV HOSTN is set echo $HOSTN @@ -30,3 +41,22 @@ get_hostname(){ line_to_dot(){ while read line; do printf .; done; } + + +get_os() +{ + # TODO: find all the release files + #if grep -q 'Linux' /etc/*release 2>/dev/null || grep -qe 'Linux' /etc/issue 2>/dev/null; then + if grep -q 'Linux' /etc/lsb-release 2>/dev/null || grep -q 'Linux' /etc/issue 2>/dev/null; then + echo 'linux' + elif exists getprop ; then + echo 'android' + elif test -e /etc/openwrt_release; then + echo 'openwrt' + elif uname -s | grep -qi 'darwin'; then + echo 'osx' + else + warn "Cannot determine your operating system, falling back to Linux" + echo 'linux' + fi +} diff --git a/webchat/hello_web.js b/webchat/hello_web.js index 6f658901..dd2f26e3 100644 --- a/webchat/hello_web.js +++ b/webchat/hello_web.js @@ -49,8 +49,8 @@ var echo = sockjs.createServer(); echo.on('connection', function(conn) { var origin = '['+conn.remoteAddress+':'+conn.remotePort+']'; Clients.push(conn); - irc_client.say("#krebs", name + ' has joined'); Clients.broadcast({from: 'system', message: origin + ' has joined'}) + irc_client.say("#krebs", origin + ' has joined'); conn.write(JSON.stringify({from: 'system', message: 'hello'})) conn.on('data', function(data) { console.log('data:',data); @@ -73,8 +73,8 @@ echo.on('connection', function(conn) { }); conn.on('close', function() { Clients.splice(Clients.indexOf(conn)); - irc_client.say("#krebs", name + ' has quit'); Clients.broadcast({from: 'system', message: origin + ' has quit'}) + irc_client.say("#krebs", origin + ' has quit'); }); }); @@ -93,11 +93,10 @@ var app = connect() res.write('<script src="sockjs-0.3.min.js"></script>'); res.write('<script src="jquery-2.0.3.min.js"></script>'); res.write('<script src="client.js"></script>'); - res.write('<div id=bg>'); + res.write('<div id=bg><div id=chatter>'); res.write('hello, this is #krebs:<br>'); - res.write('<table id="chatbox"></table>'); - res.end('<input type="text" id="input"><br>'); - res.write('</div>'); + res.write('<table id="chatbox"><tr id="foot"><td></td><td></td><td><input type="text" id="input"></td></tr></table>'); + res.end('</div></div>'); }) var server = http.createServer(options, app); diff --git a/webchat/public/client.js b/webchat/public/client.js index 95b67ad0..e13ab1f7 100644 --- a/webchat/public/client.js +++ b/webchat/public/client.js @@ -26,7 +26,7 @@ $(function connect() { var safe_message = $('<div/>').text(object.message).html(); safe_message = replaceURLWithHTMLLinks(safe_message); var safe_from = $('<div/>').text(object.from).html(); - $('#chatbox').append('<tr><td class="chat_from">'+safe_from+'</td><td class="chat_msg">'+safe_message+'</td></tr>'); + $('<tr><td class="chat_date">'+(new Date).getHours() + ':' + (new Date).getMinutes() + ':' + (new Date).getSeconds()+'</td><td class="chat_from">'+safe_from+'</td><td class="chat_msg">'+safe_message+'</td></tr>').insertBefore('#foot'); } catch (error) { console.log(error); diff --git a/webchat/public/reset.css b/webchat/public/reset.css index 46b52478..2b67f153 100644 --- a/webchat/public/reset.css +++ b/webchat/public/reset.css @@ -21,6 +21,7 @@ time, mark, audio, video { border: 0; font-size: 100%; font: inherit; + font-family: monospace; vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ @@ -47,16 +48,28 @@ q:before, q:after { #chatbox { border-collapse: collapse; border-spacing: 0; - border: solid 2px black; - background-color: white; - color: black; + background-color: black; + color: white; + border: 5px solid black; + width: 100%; + height:100%; + opacity: 0.8; +} +#input{ + width: 100%; + background-color: black; + border: 1px solid black; + color: white; } .chat_from { + color:grey; font-weight: bold; text-align: right; + font-size:12px; } .chat_from:after { content: ":"; + padding-right: 6px; } #bg { background-image: url(krebs.png); @@ -66,3 +79,21 @@ q:before, q:after { left: 0; right: 0; } +#chatter { + width: 75%; +} +.chat_date,.chat_from,.chat_msg{ +} +.chat_msg{ + width: 100%; +} +a { + color: red; +} +.chat_date { + color: green; +} +.chat_date:after { + content: ""; + padding-right: 4px; +}
\ No newline at end of file |