~ubuntu-branches/debian/stretch/psi-plus/stretch

« back to all changes in this revision

Viewing changes to themes/chatview/adium/adapter.js

  • Committer: Package Import Robot
  • Author(s): Boris Pek
  • Date: 2013-10-23 02:42:20 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20131023024220-bk2hyoenqkwfhpgw
Tags: 0.16.242-1
* New upstream release:
  fixed the problem of initialization of private conversation when both
  sides use libotr 4.0.x. (Closes: #724880)
* Update debian/watch: sources were moved.
* Delete psi-plus-content-downloader package and update all related files.
  This plugin is in psi-plus-plugins package now.
* Update debian/control:
  - remove all currently unneeded Replaces and Breaks fields
  - add build dependency on libidn11-dev
* Update debian/rules: simplify get-orig-source section.
* Update debian/copyright:
  - update Source field due to changes in sources location
  - remove copyright holders whose code was deleted from source tree
    (bundled libidn library was removed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
window[chatServer.jsNamespace()].adapter = {
4
4
        loadTheme : function() {
 
5
                chatServer.setCaseInsensitiveFS();
5
6
                var chat = window[chatServer.jsNamespace()];
6
7
                //chat.console("DEBUG: loading " + chatServer.themeId());
7
8
                var resources = ["Template.html", "FileTransferRequest.html",
8
9
                "Footer.html", "Header.html", "Status.html", "Topic.html", "Content.html",
9
10
                "Incoming/Content.html", "Incoming/NextContent.html",
10
 
                "Incoming/Context.html", "Incoming/NextContext.html", 
 
11
                "Incoming/Context.html", "Incoming/NextContext.html",
11
12
                "Outgoing/Content.html", "Outgoing/NextContent.html",
12
13
                "Outgoing/Context.html", "Outgoing/NextContext.html"];
13
14
                for (var i=0; i<resources.length; i++) {
14
 
                        var content = chatServer.getFileContents("Contents/Resources/" + resources[i]) ||
15
 
                                                chatServer.getFileContents("Contents/Resources/" + resources[i].toLowerCase());
 
15
                        var content = chatServer.getFileContents("Contents/Resources/" + resources[i]);
16
16
                        if (content.length) {
17
17
                                chatServer.toCache(resources[i], content);
18
18
                        }
97
97
        var chat = window[chatServer.jsNamespace()];
98
98
        var server = window.chatServer;
99
99
        var session = null;
100
 
        var dateFormat = "hh:mm";
 
100
        var dateFormat = "%H:%M";
101
101
        var cdata;
102
102
        var proxyEl = document.createElement("div");
103
 
        
 
103
 
104
104
        function TemplateVar(name, param) {
105
105
                this.name = name;
106
106
                this.param = param
107
107
        }
108
 
        
 
108
 
109
109
        TemplateVar.prototype = {
110
110
                toString : function() {
111
111
                        //chat.console("DEBUG: TemplateVar.prototype.toString " + session);
127
127
                        return d || "";
128
128
                }
129
129
        }
130
 
        
 
130
 
131
131
        function TemplateTimeVar(name, param) {
132
132
                this.name = name;
133
 
                if (param) {
134
 
                        var i, r = {y:'yy',Y:'yyyy',m:'MM',d:'dd',H:'hh',M:'mm',S:'ss'};
135
 
                        var m = param.split(/%([a-zA-Z]+)/)
136
 
                        for (i=0; i<m.length; i++) {
137
 
                                m[i] = r[m[i]] || m[i];
138
 
                        }
139
 
                        this.format = m.join("");
140
 
                } else {
141
 
                        this.format = dateFormat
142
 
                }
 
133
                this.param = param || dateFormat;
143
134
        }
144
 
        
 
135
 
145
136
        TemplateTimeVar.prototype.toString = function() {
146
 
                //chat.console("DEBUG: TemplateTimeVar.prototype.toString");
147
137
                return cdata[this.name] instanceof Date?
148
 
                        server.formatDate(cdata[this.name], this.format) : 
149
 
                        (cdata[this.name] ? cdata[this.name] : "");
 
138
                        server.strftime(cdata[this.name], this.param) :
 
139
                        server.strftime(new Date(), this.param);
150
140
        }
151
141
 
152
142
        function Template(raw) {
153
 
                var splitted = raw.split(/(%[\w]+(?:\{[\w:%]+\})?%)/), i;
 
143
                //chat.console("parsing '"+raw+"'");
 
144
                var splitted = raw.split(/(%[\w]+(?:\{[^\{]+\})?%)/), i;
154
145
                this.parts = [];
155
 
                
 
146
 
156
147
                for (i = 0; i < splitted.length; i++) {
157
 
                        var m = splitted[i].match(/%([\w]+)(?:\{([\w:%]+)\})?%/);
 
148
                        var m = splitted[i].match(/%([\w]+)(?:\{([^\{]+)\})?%/);
158
149
                        if (m) {
 
150
                                //chat.console("found var '"+m[1]+"'");
159
151
                                this.parts.push(m[1] in tvConstructors
160
152
                                        ? new tvConstructors[m[1]](m[1], m[2])
161
153
                                        : new TemplateVar(m[1], m[2]));
164
156
                        }
165
157
                }
166
158
        }
167
 
        
 
159
 
168
160
        Template.prototype.toString = function(data) {
169
161
                //chat.console("prepare Template.prototype.toString1");
170
162
                cdata = data || cdata;
174
166
                //chat.console("prepare Template.prototype.toString2");
175
167
                return proxyEl.innerHTML;
176
168
        }
177
 
        
 
169
 
178
170
        // Template variable constructors
179
171
        var tvConstructors = {
180
172
                time : TemplateTimeVar,
181
173
                timeOpened : TemplateTimeVar
182
174
        }
183
 
        
 
175
 
184
176
        function psiOption(name) {
185
177
                return eval("[" + server.psiOption(name) + "][0]")
186
178
        }
187
 
        
 
179
 
188
180
        return {
189
181
                getHtml : function() {
190
182
                        session = window.chatSession; // global session because Template needs it
191
 
                        
 
183
 
192
184
                        //chat.console("prepare html");
193
185
                        var html = server.cache("html");
194
186
                        //chat.console("cached Template.html: " + html);
232
224
                                        html = html.replace(/<head>/i, '<head><style type="text/css" media="screen,print">' +
233
225
                                                "body { background-color:#"+ip.DefaultBackgroundColor+" }</style>");
234
226
                        }
235
 
                        
 
227
 
236
228
                        var styles = [];
237
229
                        if (ip.DefaultFontFamily) {
238
230
                                styles.push("font-family:"+ip.DefaultFontFamily);
240
232
                        if (ip.DefaultFontSize) {
241
233
                                styles.push("font-size:"+ip.DefaultFontSize+"pt");
242
234
                        }
243
 
                        
 
235
 
244
236
                        html = html.replace("==bodyBackground==", styles.join(";"));
245
237
                        //chat.console("prepare html: " + html);
246
238
                        return html
255
247
                        var ip = server.cache("Info.plist");
256
248
                        var prevGrouppingData = null;
257
249
                        var groupping = !(ip.DisableCombineConsecutive == true);
258
 
                        
 
250
 
259
251
                        chat.adapter.receiveObject = function(data) {
260
252
                                cdata = data;
261
253
                                try {
265
257
                                                if (data.mtype != "message") {
266
258
                                                        prevGrouppingData = null;
267
259
                                                }
 
260
                                                data.messageClasses = cdata.local?"outgoing" : "incoming";
 
261
                                                data.messageClasses += cdata.alert?" mention" : "";
 
262
                                                data.messageClasses += cdata.spooled?" history" : "";
 
263
                                                data.messageClasses += cdata.mtype == "system"?" event" : "";
 
264
                                                // TODO consecutive, autoreply, focus, firstFocus, %status%
268
265
                                                switch (data.mtype) {
269
266
                                                        case "message":
 
267
                                                                data.messageClasses += " message";
270
268
                                                                data.nextOfGroup = groupping && !!(prevGrouppingData &&
271
269
                                                                        (prevGrouppingData.type == cdata.type) &&
272
270
                                                                        (prevGrouppingData.mtype == cdata.mtype) &&
273
271
                                                                        (prevGrouppingData.userid == cdata.userid) &&
274
272
                                                                        (prevGrouppingData.emote == cdata.emote) &&
275
273
                                                                        (prevGrouppingData.local == cdata.local));
276
 
                                                                        
 
274
                                                                data.messageClasses += data.nextOfGroup? " consecutive" : "";
 
275
 
277
276
                                                                if (data.nextOfGroup) {
278
277
                                                                        template = data.local?templates.outgoingNextContent:templates.incomingNextContent;
279
278
                                                                } else {
283
282
                                                                data.senderStatusIcon="icon:status/online"; //FIXME temporary hack
284
283
                                                                break;
285
284
                                                        case "status":
 
285
                                                                data.messageClasses += " status";
286
286
                                                        case "system":
287
287
                                                                if (data["usertext"]) {
288
288
                                                                        data["message"] += " (" + data["usertext"] + ")"
293
293
                                                                data["message"] = data["date"];
294
294
                                                                data["time"] = "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"; //fixes some themes =)
295
295
                                                                template = templates.status;
 
296
                                                                data.messageClasses += " event date_separator";
296
297
                                                                break;
297
298
                                                        case "subject": //its better to init with proper templates on start than do comparision like below
298
299
                                                                template = templates.status;
302
303
                                                                } else {
303
304
                                                                        data["message"] += ("<br/>" + data["usertext"]);
304
305
                                                                }
 
306
                                                                data.messageClasses += " event";
305
307
                                                                break;
306
308
                                                        case "urls":
307
309
                                                                var i, urls=[];
310
312
                                                                }
311
313
                                                                data["message"] = urls.join("<br/>");
312
314
                                                                template = templates.status;
 
315
                                                                data.messageClasses += " event";
313
316
                                                                break;
314
317
                                                }
315
318
                                                if (template) {
332
335
                                        chat.util.showCriticalError("APPEND ERROR: " + e + " \nline: " + e.line)
333
336
                                }
334
337
                        };
335
 
                        
 
338
 
336
339
                        var t = {};
337
340
                        var templates = {}
338
341
                        var tcList = ["Status.html", "Content.html",
339
342
                                "Incoming/Content.html", "Incoming/NextContent.html",
340
 
                                "Incoming/Context.html", "Incoming/NextContext.html", 
 
343
                                "Incoming/Context.html", "Incoming/NextContext.html",
341
344
                                "Outgoing/Content.html", "Outgoing/NextContent.html",
342
345
                                "Outgoing/Context.html", "Outgoing/NextContext.html"];
343
346
                        var i