remove extra /conf/ request

This commit is contained in:
mappu 2017-02-06 16:25:49 +13:00
parent 3448cb7eeb
commit a28e5ce9b0
3 changed files with 5 additions and 24 deletions

View File

@ -786,7 +786,7 @@ var updateTitle = function() {
var sock = {}; var sock = {};
var hub_state = 0; // [disconnected, sent-nick, connected] var hub_state = 0; // [disconnected, sent-nick, connected]
var hub_last_nick = ''; var hub_last_nick = '';
var hub_hubname = DCWEBUI_CONF.title; var hub_hubname = "Loading...";
var pm_tabs = {}; // nick => tabid var pm_tabs = {}; // nick => tabid
var next_tabid = 1; var next_tabid = 1;
@ -919,6 +919,7 @@ var transition = function(new_state) {
} break; } break;
case STATE_ACTIVE: { case STATE_ACTIVE: {
write("tab-main").system("Now talking on "+hub_hubname);
$("#chatbox").disabled = false; $("#chatbox").disabled = false;
$("#chatbox").spellcheck = true; $("#chatbox").spellcheck = true;
} break; } break;
@ -941,7 +942,7 @@ window.onload = function() {
show_joins = persistence_get("show_joins", false); show_joins = persistence_get("show_joins", false);
document.title = DCWEBUI_CONF.title; document.title = hub_hubname; // "Loading...";
// HTML event handlers // HTML event handlers
@ -1063,7 +1064,6 @@ window.onload = function() {
} }
}); });
sock.on('hubname', function(s) { sock.on('hubname', function(s) {
write("tab-main").system("Now talking on "+s);
hub_hubname = s; hub_hubname = s;
updateTitle(); updateTitle();
}); });

View File

@ -53,7 +53,6 @@
</div> </div>
<script type="text/javascript" src="/socket.io-1.7.2.js"></script> <script type="text/javascript" src="/socket.io-1.7.2.js"></script>
<script type="text/javascript" src="/conf"></script>
<script type="text/javascript" src="/dcwebui.js"></script> <script type="text/javascript" src="/dcwebui.js"></script>
</body> </body>
</html> </html>

20
main.go
View File

@ -164,6 +164,7 @@ func (this *App) SocketIOServer(so socketio.Socket) {
log.Printf("[%s] Client connected", so.Id()) log.Printf("[%s] Client connected", so.Id())
so.Emit("cls") so.Emit("cls")
so.Emit("hubname", this.cfg.Web.Title)
so.Emit("raw", this.cfg.App.MotdHTML+"<br>") so.Emit("raw", this.cfg.App.MotdHTML+"<br>")
so.Emit("sys", "Enter a name to connect as (or name:pass for a registered nick)") so.Emit("sys", "Enter a name to connect as (or name:pass for a registered nick)")
@ -185,22 +186,6 @@ func (this *App) customFaviconHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "favicon.ico") http.ServeFile(w, r, "favicon.ico")
} }
func (this *App) ConfigRequestHandler(w http.ResponseWriter, r *http.Request) {
confStruct := struct {
Title string `json:"title"`
}{
Title: this.cfg.Web.Title,
}
confBytes, _ := json.Marshal(confStruct)
//
w.Header().Set("Content-Type", "text/javascript")
w.WriteHeader(200)
fmt.Fprintf(w, "var DCWEBUI_CONF = %s;\n", string(confBytes))
}
func (this *App) StaticRequestHandler(w http.ResponseWriter, r *http.Request) { func (this *App) StaticRequestHandler(w http.ResponseWriter, r *http.Request) {
fileName := r.URL.Path[1:] fileName := r.URL.Path[1:]
if fileName == "" { if fileName == "" {
@ -250,9 +235,6 @@ func (this *App) RunServer() {
}) })
http.Handle("/socket.io/", server) http.Handle("/socket.io/", server)
// Configuration handler
http.HandleFunc("/conf", this.ConfigRequestHandler)
if this.cfg.Web.CustomFavicon { if this.cfg.Web.CustomFavicon {
http.HandleFunc("/favicon.ico", this.customFaviconHandler) http.HandleFunc("/favicon.ico", this.customFaviconHandler)
} }