/** Instance of kiwi.model.PanelList */\r
this.panels = null;\r
\r
+ /** kiwi.view.Application */\r
+ this.view;\r
+\r
+ /** kiwi.view.StatusMessage */\r
+ this.message;\r
+\r
/* Address for the kiwi server */\r
this.kiwi_server = null;\r
\r
\r
this.topicbar = new kiwi.view.TopicBar({el: $('#topic')[0]});\r
\r
+ this.message = new kiwi.view.StatusMessage({el: $('#status_message')[0]});\r
+\r
\r
this.panels.server.view.show();\r
\r
});\r
\r
\r
+ (function () {\r
+ var gw_stat = 0;\r
+\r
+ gw.on('disconnect', function (event) {\r
+ that.message.text('You have been disconnected. Attempting to reconnect..');\r
+ gw_stat = 1;\r
+ });\r
+ gw.on('reconnecting', function (event) {\r
+ that.message.text('You have been disconnected. Attempting to reconnect again in ' + (event.delay/1000) + ' seconds..');\r
+ });\r
+ gw.on('connect', function (event) {\r
+ if (gw_stat !== 1) return;\r
+\r
+ that.message.text('It\'s OK, you\'re connected again :)', {timeout: 5000});\r
+ gw_stat = 0;\r
+ });\r
+ })();\r
+\r
+\r
gw.on('onjoin', function (event) {\r
var c, members, user;\r
c = that.panels.getByName(event.channel);\r
\r
this.socket.on('connect', function () {\r
this.emit('irc connect', that.get('nick'), host, port, ssl, password, callback);\r
+ that.trigger('connect', {});\r
console.log("kiwi.gateway.socket.on('connect')");\r
});\r
\r
this.socket.on('message', this.parse);\r
\r
this.socket.on('disconnect', function () {\r
- this.emit("disconnect", {});\r
+ that.trigger("disconnect", {});\r
console.log("kiwi.gateway.socket.on('disconnect')");\r
});\r
\r
\r
this.socket.on('reconnecting', function (reconnectionDelay, reconnectionAttempts) {\r
console.log("kiwi.gateway.socket.on('reconnecting')");\r
- this.emit("reconnecting", {delay: reconnectionDelay, attempts: reconnectionAttempts});\r
+ that.trigger("reconnecting", {delay: reconnectionDelay, attempts: reconnectionAttempts});\r
});\r
\r
this.socket.on('reconnect_failed', function () {\r
\r
\r
\r
+kiwi.view.StatusMessage = Backbone.View.extend({\r
+ /* Timer for hiding the message */\r
+ tmr: null,\r
+\r
+ initialize: function () {\r
+ this.$el.hide();\r
+ },\r
+\r
+ text: function (text, opt) {\r
+ // Defaults\r
+ opt = opt || {};\r
+ opt.type = opt.type || '';\r
+\r
+ this.$el.text(text).attr('class', opt.type);\r
+ this.$el.slideDown(kiwi.app.view.doLayout);\r
+\r
+ if (opt.timeout) this.doTimeout(opt.timeout);\r
+ },\r
+\r
+ html: function (html, opt) {\r
+ // Defaults\r
+ opt = opt || {};\r
+ opt.type = opt.type || '';\r
+\r
+ this.$el.html(text).attr('class', opt.type);\r
+ this.$el.slideDown(kiwi.app.view.doLayout);\r
+\r
+ if (opt.timeout) this.doTimeout(opt.timeout);\r
+ },\r
+\r
+ hide: function () {\r
+ this.$el.slideUp(kiwi.app.view.doLayout);\r
+ },\r
+\r
+ doTimeout: function (length) {\r
+ if (this.tmr) clearTimeout(this.tmr);\r
+ var that = this;\r
+ this.tmr = setTimeout(function () { that.hide(); }, length);\r
+ }\r
+});\r
+\r
+\r
+\r
\r
-// This *may* be needed in future\r
kiwi.view.Application = Backbone.View.extend({\r
initialize: function () {\r
$(window).resize(this.doLayout);\r
<div id="topic">
<input type="text" />
</div>
+
+ <div id="status_message"></div>
</div>
<div id="panels">
#toolbar .panellist li img.icon { left:5px; top:2px; height:auto; width:auto; }
+#status_message {
+ background: #FEEFB3; color: #9F6000;
+ border-bottom: 1px solid;
+ padding: 0.9em;
+ text-align: center; font-size:1.1em;
+}
+#status_message.err { color:#D8000C; background:#FFBABA; }
+
.panel_container { overflow-y:scroll; height:100%; }