Commit 27727a69 authored by 神楽坂玲奈's avatar 神楽坂玲奈

candy libs

parent f6b0a765
......@@ -23,11 +23,24 @@ $.fn.init = new Proxy($.fn.init, {
window['jQuery'] = $;
const Mustache = require('mustache');
window['Mustache'] = Mustache;
import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, ViewEncapsulation} from '@angular/core';
import {LoginService} from './login.service';
import {SettingsService} from './settings.sevices';
import {App} from './app';
import 'node_modules/candy/libs.min.js';
// candy libs
import 'strophe.js';
import 'strophejs-plugin-disco';
import 'strophejs-plugin-roster';
import 'strophejs-plugin-muc';
import 'strophejs-plugin-caps';
import 'jquery-i18n';
import 'date.format.js';
// candy
import 'node_modules/candy/candy.min.js';
import 'node_modules/candy-shop/notifyme/candy.js';
import 'node_modules/candy-shop/namecomplete/candy.js';
......@@ -35,15 +48,34 @@ import 'node_modules/candy-shop/modify-role/candy.js';
import 'node_modules/candy-shop/me-does/candy.js';
import 'node_modules/candy-shop/notifications/candy.js';
import 'node_modules/candy-shop/refocus/candy.js';
// @ts-ignore
// window.Base64 = {
// encode: (data: string) => Buffer.from(data).toString('base64'),
// decode: (data: string) => Buffer.from(data, 'base64').toString()
// };
import * as crypto from 'crypto';
delete window['jQuery'];
// Candy fix
declare const Candy: any, CandyShop: any, Base64: any;
declare const Candy: any, CandyShop: any;
window['MD5'] = {
hexdigest(s: string) {
return crypto.createHash('sha256').update(s).digest('hex');
}
};
Base64.encode = (data: string) => Buffer.from(data).toString('base64');
Base64.decode = (data: string) => Buffer.from(data, 'base64').toString();
Mustache.to_html = function (template, view, partials, send) {
const result = Mustache.render(template, view, partials);
if (typeof send === 'function') {
send(result);
} else {
return result;
}
};
Candy.Util.getPosLeftAccordingToWindowBounds = new Proxy(Candy.Util.getPosLeftAccordingToWindowBounds, {
apply(target, thisArg, argumentsList) {
......@@ -63,9 +95,9 @@ Candy.View.Pane.Roster.joinAnimation = function () {
};
// 性能优化:禁用用户排序
declare const Mustache: any;
Candy.View.Pane.Roster._insertUser = function (roomJid: string, roomId: string, user: any, userId: string, currentUser: any) {
let contact = user.getContact();
// @ts-ignore
let html = Mustache.to_html(Candy.View.Template.Roster.user, {
roomId: roomId,
userId: userId,
......@@ -98,8 +130,8 @@ Candy.View.Pane.Chat.increaseUnreadMessages = function (roomJid: string) {
// 性能优化:将收到消息时的滚动放进requestIdleCallback
declare const requestIdleCallback: Function;
Candy.View.Pane.Message.
show = function (roomJid: any, name: any, message: any, xhtmlMessage: any, timestamp: any, from: any, carbon: any, stanza: any) {
// tslint:disable-next-line:max-line-length
Candy.View.Pane.Message.show = function (roomJid: any, name: any, message: any, xhtmlMessage: any, timestamp: any, from: any, carbon: any, stanza: any) {
message = Candy.Util.Parser.all(message.substring(0, Candy.View.getOptions().crop.message.body));
if (Candy.View.getOptions().enableXHTML === true && xhtmlMessage) {
xhtmlMessage = Candy.Util.parseAndCropXhtml(xhtmlMessage, Candy.View.getOptions().crop.message.body);
......@@ -152,6 +184,7 @@ Candy.View.Pane.Message.
stanza: stanza
};
$(Candy).triggerHandler('candy:view.message.before-render', renderEvtData);
// @ts-ignore
let html = Mustache.to_html(renderEvtData.template, renderEvtData.templateData);
Candy.View.Pane.Room.appendToMessagePane(roomJid, html);
let elem = Candy.View.Pane.Room.getPane(roomJid, '.message-pane').children().last();
......@@ -340,6 +373,7 @@ export class CandyComponent implements OnInit, OnChanges {
$('#restore').hide();
$('#maximize').show();
}
restore(): void {
$('#candy').attr('data-minormax', 'default');
document.getElementById('candy-wrapper')!.style!.height = this.height_default_window;
......@@ -357,7 +391,7 @@ export class CandyComponent implements OnInit, OnChanges {
maximize(): void {
$('#candy').attr('data-minormax', 'max');
document.getElementById('candy-wrapper')!.style!.height = 'calc( 100% - 180px )' ;
document.getElementById('candy-wrapper')!.style!.height = 'calc( 100% - 180px )';
$('#mobile-roster-icon').css('display', 'block');
$('#chat-toolbar').css('display', 'block');
$('#chat-rooms').css('display', 'block');
......
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
* MIT license
*
* Includes enhancements by Scott Trenda <scott.trenda.net>
* and Kris Kowal <cixar.com/~kris.kowal/>
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*/
var dateFormat = function () {
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
timezoneClip = /[^-+\dA-Z]/g,
pad = function (val, len) {
val = String(val);
len = len || 2;
while (val.length < len) val = "0" + val;
return val;
};
// Regexes and supporting functions are cached through closure
return function (date, mask, utc) {
var dF = dateFormat;
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
mask = date;
date = undefined;
}
// Passing date through Date applies Date.parse, if necessary
date = date ? new Date(date) : new Date;
if (isNaN(date)) throw SyntaxError("invalid date");
mask = String(dF.masks[mask] || mask || dF.masks["default"]);
// Allow setting the utc argument via the mask
if (mask.slice(0, 4) == "UTC:") {
mask = mask.slice(4);
utc = true;
}
var _ = utc ? "getUTC" : "get",
d = date[_ + "Date"](),
D = date[_ + "Day"](),
m = date[_ + "Month"](),
y = date[_ + "FullYear"](),
H = date[_ + "Hours"](),
M = date[_ + "Minutes"](),
s = date[_ + "Seconds"](),
L = date[_ + "Milliseconds"](),
o = utc ? 0 : date.getTimezoneOffset(),
flags = {
d: d,
dd: pad(d),
ddd: dF.i18n.dayNames[D],
dddd: dF.i18n.dayNames[D + 7],
m: m + 1,
mm: pad(m + 1),
mmm: dF.i18n.monthNames[m],
mmmm: dF.i18n.monthNames[m + 12],
yy: String(y).slice(2),
yyyy: y,
h: H % 12 || 12,
hh: pad(H % 12 || 12),
H: H,
HH: pad(H),
M: M,
MM: pad(M),
s: s,
ss: pad(s),
l: pad(L, 3),
L: pad(L > 99 ? Math.round(L / 10) : L),
t: H < 12 ? "a" : "p",
tt: H < 12 ? "am" : "pm",
T: H < 12 ? "A" : "P",
TT: H < 12 ? "AM" : "PM",
Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
};
return mask.replace(token, function ($0) {
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
});
};
}();
// Some common format strings
dateFormat.masks = {
"default": "ddd mmm dd yyyy HH:MM:ss",
shortDate: "m/d/yy",
mediumDate: "mmm d, yyyy",
longDate: "mmmm d, yyyy",
fullDate: "dddd, mmmm d, yyyy",
shortTime: "h:MM TT",
mediumTime: "h:MM:ss TT",
longTime: "h:MM:ss TT Z",
isoDate: "yyyy-mm-dd",
isoTime: "HH:MM:ss",
isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};
// Internationalization strings
dateFormat.i18n = {
dayNames: [
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
};
// For convenience...
Date.prototype.format = function (mask, utc) {
return dateFormat(this, mask, utc);
};
This diff is collapsed.
......@@ -70,7 +70,6 @@ System.config({
// other node.js libraries
"electron": "@node/electron",
"ini": "@node/ini",
"mustache": "@node/mustache",
"lodash": "@node/lodash",
"mkdirp": "@node/mkdirp",
"aria2": "@node/aria2",
......@@ -83,9 +82,15 @@ System.config({
'reconnecting-websocket': 'npm:reconnecting-websocket/dist/index.js',
'popper.js': 'npm:popper.js/dist/umd/popper.min.js',
// 'typeahead.js': '@node/typeahead.js'
'raven-js': 'npm:raven-js',
'raven-js': 'npm:raven-js'
'strophe.js': 'npm:strophe.js/dist/strophe.umd.js',
'strophejs-plugin-disco': 'npm:strophejs-plugin-disco/lib/strophe.disco.js',
'strophejs-plugin-roster': 'npm:strophejs-plugin-roster/lib/strophe.roster.js',
'strophejs-plugin-muc': 'npm:strophejs-plugin-muc/lib/strophe.muc.js',
'strophejs-plugin-caps': 'npm:strophejs-plugin-caps/lib/strophe.caps.js',
'jquery-i18n': 'npm:jquery-i18n/jquery.i18n.js',
"mustache": "npm:mustache/mustache.js"
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment