From 5c58f2a7a3801457304c07337b0fd95e7d635176 Mon Sep 17 00:00:00 2001 From: Wenqi Zhang Date: Wed, 19 Feb 2014 14:43:08 -0800 Subject: [PATCH 01/15] Update index.html changed Google analytics tracking code to new domain. --- index.html | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 67f3562..1c83f8e 100755 --- a/index.html +++ b/index.html @@ -14,17 +14,14 @@ - From a94875961f2f4136ffe2217b8e11bfafbb783200 Mon Sep 17 00:00:00 2001 From: Henry Hu Date: Wed, 20 Nov 2013 12:33:51 -0500 Subject: [PATCH 02/15] handle connect errors --- js/jquery/jquery.xmpp.js | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/js/jquery/jquery.xmpp.js b/js/jquery/jquery.xmpp.js index 0153dd0..a149914 100644 --- a/js/jquery/jquery.xmpp.js +++ b/js/jquery/jquery.xmpp.js @@ -155,7 +155,13 @@ } } - }, 'text'); + }, 'text').fail(function(XMLHttpRequest, textStatus, errorThrown) { + console.log("initial connect() error: " + errorThrown); + if(xmpp.onError != null){ + xmpp.onError({error: errorThrown, data:textStatus}); + } + xmpp.errorCount = xmpp.errorCount + 1; + }); }, /** @@ -482,14 +488,38 @@ options.onConnect(data); } xmpp.listen(); - }, 'text'); - }, 'text'); - }, 'text'); + }, 'text').fail(function(XMLHttpRequest, textStatus, errorThrown) { + if(xmpp.onError != null){ + xmpp.onError({error: errorThrown, data:textStatus}); + } + console.log("session create error: " + errorThrown); + xmpp.errorCount = xmpp.errorCount + 1; + }); + }, 'text').fail(function(XMLHttpRequest, textStatus, errorThrown) { + if(xmpp.onError != null){ + xmpp.onError({error: errorThrown, data:textStatus}); + } + console.log("bind error: " + errorThrown); + xmpp.errorCount = xmpp.errorCount + 1; + }); + }, 'text').fail(function(XMLHttpRequest, textStatus, errorThrown) { + if(xmpp.onError != null){ + xmpp.onError({error: errorThrown, data:textStatus}); + } + console.log("restart after auth error: " + errorThrown); + xmpp.errorCount = xmpp.errorCount + 1; + }); }else{ if(options.onError != null) options.onError({error: "Invalid credentials", data:data}); } - }, 'text'); + }, 'text').fail(function(XMLHttpRequest, textStatus, errorThrown) { + if(xmpp.onError != null){ + xmpp.onError({error: errorThrown, data:textStatus}); + } + console.log("auth error: " + errorThrown); + xmpp.errorCount = xmpp.errorCount + 1; + }); }, From a849d8e01b5820dcbfceebbac18fe6455f195e2f Mon Sep 17 00:00:00 2001 From: Henry Hu Date: Wed, 7 May 2014 19:59:22 -0400 Subject: [PATCH 03/15] generate session key each time. support multi-tab coexist --- js/bbs/bbs_xmpp.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/js/bbs/bbs_xmpp.js b/js/bbs/bbs_xmpp.js index 57a47fa..b05bec3 100644 --- a/js/bbs/bbs_xmpp.js +++ b/js/bbs/bbs_xmpp.js @@ -9,6 +9,7 @@ var xmpp_panel_left = 0; var XMPP_TITLE_CHANGE_INTERVAL = 1000; var XMPP_CHAT_TITLE_ACTIVE_COLOR = '#5BB75B'; var XMPP_CHAT_TITLE_INACTIVE_COLOR = 'rgb(91, 191, 222)'; +var xmpp_session_key = ""; function xmpp_jid_normalize(jid) { return jid.replace(/[\.@\/]/g, '_'); @@ -72,7 +73,7 @@ function xmpp_connect() { $('#xmpp-panel').show(); xmpp_show_loading(bbs_string.xmpp_connecting); $.xmpp.connect({ - resource: bbs_query.xmpp_resource + bbs_session.substr(0, 4), + resource: bbs_query.xmpp_resource + xmpp_session_key, domain: bbs_query.xmpp_domain, token: bbs_session, url: bbs_query.bosh_url, @@ -394,7 +395,19 @@ function xmpp_chat_min_click(jid_bare) { } } +function xmpp_gen_session_key() { + var x = Math.random(); + var ret = ""; + for (var i = 0; i < 4; i ++) { + x = x * 10; + ret += String(Math.floor(x)); + x = x - Math.floor(x); + } + return ret; +} + function xmpp_ui_init() { + xmpp_session_key = xmpp_gen_session_key(); $('#xmpp-panel').hide(); $('#xmpp-panel-handle').click(xmpp_panel_toggle); xmpp_onresize(); From 68d86af644d758313b2dde3b69bb2d997a2502f2 Mon Sep 17 00:00:00 2001 From: Henry Hu Date: Wed, 7 May 2014 20:00:26 -0400 Subject: [PATCH 04/15] fix disconnectSync(), call it in onError --- js/bbs/bbs_xmpp.js | 1 + js/jquery/jquery.xmpp.js | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/js/bbs/bbs_xmpp.js b/js/bbs/bbs_xmpp.js index b05bec3..903d1f3 100644 --- a/js/bbs/bbs_xmpp.js +++ b/js/bbs/bbs_xmpp.js @@ -227,6 +227,7 @@ function xmpp_error(error) { xmpp_user_list = {} $('#xmpp-user-list').empty(); xmpp_show_loading(bbs_string.xmpp_error); + $.xmpp.disconnectSync(); setTimeout(function() { console.log("xmpp error. reconnecting..."); xmpp_connect(); diff --git a/js/jquery/jquery.xmpp.js b/js/jquery/jquery.xmpp.js index a149914..aff9ebd 100644 --- a/js/jquery/jquery.xmpp.js +++ b/js/jquery/jquery.xmpp.js @@ -248,14 +248,31 @@ xmpp.listening = false; //Do not listen anymore! //Two callbacks - if(callback != null) - callback(data); - if(xmpp.onDisconnect != null) + if(callback != null) { + callback(data); + } + if(xmpp.onDisconnect != null) { + xmpp.onDisconnect(data); + } xmpp.connected = false; - xmpp.onDisconnect(data); }, dataType: 'text', async:false + }).fail(function(XMLHttpRequest, textStatus, errorThrown) { +/* if(xmpp.onError != null){ + xmpp.onError({error: errorThrown, data:textStatus}); + }*/ + console.log("disconnectSync() error: " + errorThrown); + if (xmpp.__lastAjaxRequest != null) { + xmpp.__lastAjaxRequest.abort(); + } + xmpp.connections = xmpp.connections - 1; + if (xmpp.debug) { + console.log("connection-- = " + xmpp.connections + ": disconnectSync.error"); + } + xmpp.listening = false; + xmpp.connected = false; + xmpp.errorCount = xmpp.errorCount + 1; }); }, From 3345fa32d8f2368f308c6f11bf2fd99e55f9fe43 Mon Sep 17 00:00:00 2001 From: Henry Hu Date: Mon, 19 May 2014 17:26:28 -0400 Subject: [PATCH 05/15] also reset watchdog timer in sendCommand. fix disconnect problem --- js/jquery/jquery.xmpp.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/js/jquery/jquery.xmpp.js b/js/jquery/jquery.xmpp.js index aff9ebd..02bb54f 100644 --- a/js/jquery/jquery.xmpp.js +++ b/js/jquery/jquery.xmpp.js @@ -574,8 +574,7 @@ xmpp = this; if(xmpp.connections === 0) { //To detect networks problems - clearTimeout(xmpp._jsTimeout); - xmpp._jsTimeout = setTimeout(xmpp.__networkError,xmpp._timeoutMilis); + xmpp.refreshTimer(); // this.rid = this.rid+1; xmpp.connections = xmpp.connections + 1; @@ -631,6 +630,8 @@ sendCommand: function(rawCommand, callback){ var self = this; + self.refreshTimer(); + this.rid = this.rid + 1; this.listening = true; this.connections = this.connections + 1; @@ -817,6 +818,21 @@ ret += " type='result'/>"; xmpp.sendCommand(ret); + }, + + /** + * Reset the watchdog timer + */ + refreshTimer: function() { + var xmpp = this; + if (xmpp.debug) { + console.log("clear timeout " + xmpp._jsTimeout); + } + clearTimeout(xmpp._jsTimeout); + xmpp._jsTimeout = setTimeout(xmpp.__networkError,xmpp._timeoutMilis); + if (xmpp.debug) { + console.log("new timeout set " + xmpp._jsTimeout); + } } } })(jQuery); From b274e1e9539d5caf8d298422ff61296870c6866d Mon Sep 17 00:00:00 2001 From: mrroach9 Date: Mon, 19 Jan 2015 14:38:47 -0800 Subject: [PATCH 06/15] Fetch contributor list from Github automatically. --- css/style.css | 29 ++++++++++++++++++++++++++++- index.html | 27 ++++++--------------------- js/bbs/bbs_UI.js | 16 ++++++++++++++++ js/bbs/bbs_utility.js | 26 ++++++++++++++++++++++++++ js/bbs/bbs_widgets.js | 17 +++++++++++++++++ js/bbs/config.js | 2 ++ 6 files changed, 95 insertions(+), 22 deletions(-) diff --git a/css/style.css b/css/style.css index a100a92..6b7f837 100644 --- a/css/style.css +++ b/css/style.css @@ -738,4 +738,31 @@ input[type="file"].fileuploadbox { .unread-inside { display: block; position: relative; -} \ No newline at end of file +} + +.ctrbtr-list-panel { + padding: 0 10px 5px 10px; +} + +.github-author-container { + display: inline-block; + padding: 5px; + min-width: 160px; +} + +.github-avatar-container { + display: inline-block; +} + +.github-avatar { + width: 40px; + height: 40px; + border-radius: 20px; + box-shadow: 2px 2px 3px #CCC; +} + +.github-name-container { + display: inline-block; + margin-left: 10px; + font-size: 16px; +} diff --git a/index.html b/index.html index 1c83f8e..9025a71 100755 --- a/index.html +++ b/index.html @@ -426,27 +426,12 @@

发表新文章

Rowell开发者名单