17 Commits

9 changed files with 133 additions and 54 deletions

View File

@@ -5,3 +5,5 @@ a2c92b262f339f82eb01c8d92dda252a27432255 release-1.1.0
d14041daa7bbbd37ea2ff47aa978b9595af67ca3 release-1.1.1
7278eb0d067d8ed2a653de6a1feeeb7f76fb9891 release-1.1.2
6cbd9d59630372c0dff430e3dc6c1fbd7dcee734 release-1.1.3
76c178b8f27ec894e79b8f73649fcb3e45a73729 release-1.1.4
0eeab5594ba4d683e6a268ef971675c73b226bd0 release-1.2.0

View File

@@ -2,7 +2,8 @@ package main
type Config struct {
App struct {
MotdHTML string `json:"motd"`
MotdHTML string `json:"motd"`
ContentedServer string `json:"contented_server"`
}
Web struct {

View File

@@ -13,6 +13,15 @@ Tags: nmdc
=CHANGELOG=
2017-10-16 1.2.1
- Enhancement: Increase scrollback buffer size
- Fix an issue with missing `contented` upload link once logged in
- Fix a cosmetic issue with `(0)` appearing in page title
2017-10-15 1.2.0
- Feature: Add `contented` integration (set `app.contented_server` in config file)
- Fix a cosmetic issue with the menu icon on devices without unicode font coverage
2017-02-11 1.1.4
- Update libnmdc to 0.14

4
build.sh Normal file → Executable file
View File

@@ -162,11 +162,9 @@ main() {
fi
php clientpack.php
go-bindata -nomemcopy -prefix clientpack clientpack
GOARCH=amd64 GOOS=windows single_build "$version"
GOARCH=386 GOOS=windows single_build "$version"
GOARCH=amd64 GOOS=linux single_build "$version"
GOARCH=386 GOOS=linux single_build "$version"
# Also make source tarball

View File

@@ -71,10 +71,15 @@ html,body {
color:black;
font-weight:bold;
line-height:18px;
line-height:0;
height:18px;
width:18px;
text-align:center;
}
.menubutton svg {
width: 18px;
height: 18px;
}
.menubutton:hover {
background:white;
}
@@ -397,4 +402,4 @@ html,body {
.position-panel {
display:block;
}
}
}

View File

@@ -4,10 +4,10 @@
"use strict";
var SENTINEL_PASSWORD = "************";
var CHAT_SCROLLBACK_LIMIT = 50; // Once over 2x $limit, the first $limit will be trimmed off the list
var CHAT_SCROLLBACK_LIMIT = 200; // Once over 2x $limit, the first $limit will be trimmed off the list
var EXTERN_ROOT = window.location.protocol + "//" + window.location.host + "/";
var $ = function(s) {
var el = function(s) {
// There used to be a querySelectorAll implementation, but, better that we don't have
// potentially-incompatible implementations if this one does actually work.
// i'm not writing a selector engine...
@@ -179,7 +179,7 @@ var notify = function(title, body, tab) {
/* Tab writers */
var write = function(tab) {
var $tab = $('#inner-'+tab);
var $tab = el('#inner-'+tab);
return {
'cls': function() {
$tab.innerHTML = '';
@@ -255,7 +255,7 @@ var userlist = {
'add': function(u) {
if (this.has(u)) return;
var userlists = $(".userlist");
var userlists = el(".userlist");
for (var l = 0, e = userlists.length; l !== e; ++l) {
var userlist = userlists[l];
@@ -284,7 +284,7 @@ var userlist = {
return this;
},
'del': function(u) {
var userlists = $(".userlist");
var userlists = el(".userlist");
for (var l = 0, e = userlists.length; l !== e; ++l) {
if (! userlists[l].children) continue;
var userlist = userlists[l];
@@ -301,7 +301,7 @@ var userlist = {
return this;
},
'clear': function() {
var userlists = $(".userlist");
var userlists = el(".userlist");
for (var i in userlists) {
if (! userlists[i].children) continue;
var userlist = userlists[i];
@@ -314,7 +314,7 @@ var userlist = {
return this;
},
'names': function() {
var userlist = $(".userlist")[0].children;
var userlist = el(".userlist")[0].children;
var ret = [];
for (var i = 0, e = userlist.length; i < e; ++i) {
ret.push( textContent(userlist[i]) );
@@ -322,14 +322,14 @@ var userlist = {
return ret;
},
'has': function(u) {
return $(".user-" + b64(u)).length !== 0; /* there are two - large and non-large */
return el(".user-" + b64(u)).length !== 0; /* there are two - large and non-large */
},
'count': function() {
return $(".userlist")[0].children.length;
return el(".userlist")[0].children.length;
},
'setInfo': function(nick, props) {
var baseClass = "user-" + b64(nick);
var $el = $("." + baseClass);
var $el = el("." + baseClass);
var prop_str = [];
if (props.Description.length > 0) {
prop_str.push(props.Description);
@@ -358,7 +358,7 @@ var userlist = {
};
var submit = function() {
var str = $("#chatbox").value;
var str = el("#chatbox").value;
if (! str.length) return;
if (hub_state === STATE_READY_FOR_LOGIN) {
@@ -401,7 +401,7 @@ var submit = function() {
write("tab-main").system("Invalid internal state.");
}
$("#chatbox").value = '';
el("#chatbox").value = '';
};
/* page visibility */
@@ -448,13 +448,13 @@ var pagevis_setup = function(fnActive, fnInactive) {
*/
var tab_set = function(tab) {
var tabs = $(".tabpane");
var tabs = el(".tabpane");
for (var i in tabs) {
try {
tabs[i].style.display = (tabs[i].id === tab ? 'block' : 'none');
} catch (e) {};
}
var tabitems = $(".tabitem");
var tabitems = el(".tabitem");
for (var i in tabitems) {
try {
// Update UNREAD/SELECTED flags for the target
@@ -482,13 +482,13 @@ var tab_set = function(tab) {
updateTitle();
write(tab).scroll();
$("#chatbox").focus();
el("#chatbox").focus();
last_tab = tab;
};
var tab_new = function(id, name) {
appendInnerHTML($("#bar"),
appendInnerHTML(el("#bar"),
' <div class="tabitem" data-tab="tab-ext-'+id+'" id="tabitem-tab-ext-'+id+'">'+
'<span class="tab-label">'+
hesc(name)+
@@ -496,7 +496,7 @@ var tab_new = function(id, name) {
'<a class="tab-closer" data-tab="tab-ext-'+id+'">&times;</a>'+
'</div> '
);
appendInnerHTML($("#extratabs"),
appendInnerHTML(el("#extratabs"),
' <div class="tabpane content placement-mid" id="tab-ext-'+id+'" style="display:none;">'+
'<div class="content-inner" id="inner-tab-ext-'+id+'"></div>'+
'</div>'
@@ -509,10 +509,10 @@ var tab_free = function(id) {
if (id === "tab-main") return;
// remove tab item and body
var el = $("#tabitem-"+id);
var el = el("#tabitem-"+id);
el.parentNode.removeChild(el);
var el = $("#"+id);
var el = el("#"+id);
el.parentNode.removeChild(el);
// clear from PM tabs
@@ -547,7 +547,7 @@ var noprop = function(ev) {
}
var tab_addHandlers = function() {
var tabitems = $(".tabitem");
var tabitems = el(".tabitem");
for (var i = 0; i < tabitems.length; i++) {
if (! tabitems[i]) continue;
@@ -558,7 +558,7 @@ var tab_addHandlers = function() {
};
}
var tabclosers = $(".tab-closer");
var tabclosers = el(".tab-closer");
for (var i = 0; i < tabclosers.length; i++) {
if (! tabclosers[i]) continue;
@@ -598,7 +598,7 @@ var tabcomplete_state = '';
var tabcompletion_start = function(direction) {
var cursor = $("#chatbox").value.replace(/^.*\s([^\s]+)$/, '$1');
var cursor = el("#chatbox").value.replace(/^.*\s([^\s]+)$/, '$1');
if (tabcomplete_state === '') {
// new tab completion
@@ -634,10 +634,10 @@ var tabcompletion_start = function(direction) {
// Replace in textbox
var chatprefix = $("#chatbox").value.substr(0, $("#chatbox").value.length - cursor.length);
var chatprefix = el("#chatbox").value.substr(0, el("#chatbox").value.length - cursor.length);
$("#chatbox").value = chatprefix + targetName;
$("#chatbox").focus();
el("#chatbox").value = chatprefix + targetName;
el("#chatbox").focus();
};
var tabcompletion_inactive = function() {
@@ -686,10 +686,17 @@ MenuList.prototype.toggle = function() {
/* */
var menu = new MenuList($("#menubutton"));
var menu = new MenuList(el("#menubutton"));
menu.reset = function() {
this.clear();
if (contented_url.length > 0) {
menu.add("Upload", function() {
contented_load();
});
}
this.add(joinparts_getstr(), toggle_joinparts);
this.add(desktop_notifications_fmtstr(), desktop_notifications_toggle);
this.add(warnonclose_fmtstr(), warnonclose_toggle);
@@ -782,14 +789,18 @@ var toggle_joinparts = function(ev) {
var updateTitle = function() {
var prefix = "";
var unrTabs = $(".unread");
var unrTabs = el(".unread");
if (unrTabs.length === 1 && unrTabs[0].getAttribute('data-tab') == "tab-main") {
prefix = "[" + mainchat_unread_count + " NEW] "
} else if (unrTabs.length > 0) {
prefix = "[NEW PM] "
}
document.title = prefix + hub_hubname + " ("+userlist.count()+")"
var suffix = "";
if (userlist.count() > 0) {
suffix = " ("+userlist.count()+")";
}
document.title = prefix + hub_hubname + suffix;
};
var sock = {};
@@ -883,7 +894,7 @@ var scrollback_move = function(delta) {
}
}
$("#chatbox").value = chat_scrollback[chat_scrollback_index];
el("#chatbox").value = chat_scrollback[chat_scrollback_index];
};
/* */
@@ -908,25 +919,25 @@ var transition = function(new_state) {
switch(new_state) {
case STATE_DISCONNECTED: {
userlist.clear();
$("#chatbox").disabled = true;
$("#chatbox").value = ''; // clear
el("#chatbox").disabled = true;
el("#chatbox").value = ''; // clear
} break;
case STATE_READY_FOR_LOGIN: {
userlist.clear();
$("#chatbox").spellcheck = false;
$("#chatbox").disabled = false;
$("#chatbox").value = ''; // clear
el("#chatbox").spellcheck = false;
el("#chatbox").disabled = false;
el("#chatbox").value = ''; // clear
} break;
case STATE_CONNECTING: {
$("#chatbox").disabled = true;
el("#chatbox").disabled = true;
} break;
case STATE_ACTIVE: {
write("tab-main").system("Now talking on "+hub_hubname);
$("#chatbox").disabled = false;
$("#chatbox").spellcheck = true;
el("#chatbox").disabled = false;
el("#chatbox").spellcheck = true;
} break;
}
};
@@ -936,12 +947,49 @@ var tab_is_visible = function(tabref) {
}
var tab_mark_unread = function(tabref) {
if ($("#tabitem-"+tabref).className.indexOf('unread') === -1) {
$("#tabitem-"+tabref).className += " unread";
if (el("#tabitem-"+tabref).className.indexOf('unread') === -1) {
el("#tabitem-"+tabref).className += " unread";
updateTitle();
}
}
//
var contented_url = "";
var contented_loaded_sdk = false;
var contented_load = function() {
if (contented_url.length === 0) {
return;
}
var onceSDKLoaded = function() {
contented.init("#inner-tab-main", function(items) {
var val = el("#chatbox").value;
for (var i = 0; i < items.length; ++i) {
if (val.length > 0) {
val += " ";
}
val += contented.getPreviewURL(items[i]);
}
el("#chatbox").value = val;
});
};
if (contented_loaded_sdk) {
onceSDKLoaded();
} else {
var scriptElement = document.createElement('script');
scriptElement.onload = function() {
contented_loaded_sdk = true;
onceSDKLoaded();
};
scriptElement.src = contented_url + "sdk.js";
document.body.appendChild(scriptElement);
}
};
//
window.onload = function() {
write("tab-main").system("Communicating with server...");
@@ -951,13 +999,13 @@ window.onload = function() {
// HTML event handlers
$("#form-none").onsubmit = function(ev) {
el("#form-none").onsubmit = function(ev) {
submit();
return noprop(ev); // don't submit form
};
$("#chatbox").onkeydown = function(ev) {
el("#chatbox").onkeydown = function(ev) {
if (ev.keyCode === 9 /* Tab */) {
tabcompletion_start( ev.shiftKey ? -1 : 1 );
return noprop(ev);
@@ -985,7 +1033,7 @@ window.onload = function() {
usermenu.hide();
};
$("#menubutton").onclick = function(ev) {
el("#menubutton").onclick = function(ev) {
menu.toggle();
return noprop(ev);
};
@@ -1043,7 +1091,7 @@ window.onload = function() {
if (pre_login.indexOf(":") !== -1) {
pre_login = pre_login.substr(0, pre_login.indexOf(":")) + ":" + SENTINEL_PASSWORD;
}
$("#chatbox").value = pre_login;
el("#chatbox").value = pre_login;
if (have_cleared_once) {
// re-log-in automatically
@@ -1137,6 +1185,10 @@ window.onload = function() {
sock.on('usercommand', function(data) {
process_usercommand(data);
});
sock.on('contented', function(url) {
contented_url = url;
menu.reset(); // sent before login
});
};
//IIFEMODE:})();

View File

@@ -6,12 +6,16 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="/dcwebui.css">
<link rel="stylesheet" href="/dcwebui.css">
<title>Loading...</title>
</head>
<body>
<div class="tabbar placement-top" id="bar">
<div class="menubutton" id="menubutton">&#9776;</div>
<div class="menubutton" id="menubutton">
<svg viewBox="0 0 24 24">
<path fill="#000000" d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" />
</svg>
</div>
<div class="tabitem selected" data-tab="tab-main" id="tabitem-tab-main">
<span class="tab-label">
Main
@@ -55,4 +59,4 @@
<script type="text/javascript" src="/socket.io-1.7.2.js"></script>
<script type="text/javascript" src="/dcwebui.js"></script>
</body>
</html>
</html>

8
clientpack.php Normal file → Executable file
View File

@@ -3,7 +3,7 @@
# Dependencies:
# - PHP
# - Uglifyjs (`npm install -g uglifyjs`)
# - Uglifyjs (`npm install -g uglify-js`)
# - Lessc (`npm install -g less`)
# - Lessc minifier (`npm install -g less-plugin-clean-css`)
# - HTML minifier (`npm install -g html-minifier`)
@@ -51,6 +51,10 @@ file_put_contents('clientpack/index.htm', $html_content);
// Clean up files
`rm clientpack/{index.htm,dcwebui{.min,}.js,dcwebui{.min,}.css}`;
unlink('clientpack/index.htm');
unlink('clientpack/dcwebui.js');
unlink('clientpack/dcwebui.min.js');
unlink('clientpack/dcwebui.css');
unlink('clientpack/dcwebui.min.css');
unlink('clientpack/'.SIO_NAME);
rename('clientpack/index.min.htm', 'clientpack/index.htm');

View File

@@ -170,6 +170,10 @@ func (this *App) SocketIOServer(so socketio.Socket) {
so.Emit("raw", this.cfg.App.MotdHTML+"<br>")
so.Emit("sys", "Enter a name to connect as (or name:pass for a registered nick)")
if len(this.cfg.App.ContentedServer) > 0 {
so.Emit("contented", this.cfg.App.ContentedServer)
}
doneChan := make(chan struct{}, 0)
so.On("hello", func(data map[string]string) {