2018-07-06 18:15:15 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const Vue = require("vue").default;
|
|
|
|
const App = require("../components/App.vue").default;
|
|
|
|
const roundBadgeNumber = require("./libs/handlebars/roundBadgeNumber");
|
2018-07-08 10:50:11 +00:00
|
|
|
const tz = require("./libs/handlebars/tz");
|
|
|
|
const localetime = require("./libs/handlebars/localetime");
|
|
|
|
const localedate = require("./libs/handlebars/localedate");
|
|
|
|
const friendlydate = require("./libs/handlebars/friendlydate");
|
2018-07-10 11:57:11 +00:00
|
|
|
const friendlysize = require("./libs/handlebars/friendlysize");
|
2018-07-08 10:50:11 +00:00
|
|
|
const colorClass = require("./libs/handlebars/colorClass");
|
2018-07-06 18:15:15 +00:00
|
|
|
|
2018-07-08 10:50:11 +00:00
|
|
|
Vue.filter("tz", tz);
|
|
|
|
Vue.filter("localetime", localetime);
|
|
|
|
Vue.filter("localedate", localedate);
|
|
|
|
Vue.filter("friendlydate", friendlydate);
|
2018-07-10 11:57:11 +00:00
|
|
|
Vue.filter("friendlysize", friendlysize);
|
2018-07-08 10:50:11 +00:00
|
|
|
Vue.filter("colorClass", colorClass);
|
2018-07-06 18:15:15 +00:00
|
|
|
Vue.filter("roundBadgeNumber", roundBadgeNumber);
|
|
|
|
|
|
|
|
const vueApp = new Vue({
|
|
|
|
el: "#viewport",
|
|
|
|
data: {
|
2018-09-09 13:09:19 +00:00
|
|
|
activeChannel: null,
|
|
|
|
appName: document.title,
|
|
|
|
currentUserVisibleError: null,
|
2018-07-15 20:23:49 +00:00
|
|
|
initialized: false,
|
2018-09-09 13:03:37 +00:00
|
|
|
isAutoCompleting: false,
|
2018-09-09 13:09:19 +00:00
|
|
|
isConnected: false,
|
|
|
|
isFileUploadEnabled: false,
|
|
|
|
isNotified: false,
|
2018-07-06 18:15:15 +00:00
|
|
|
networks: [],
|
2018-07-08 14:57:02 +00:00
|
|
|
settings: {
|
|
|
|
syncSettings: false,
|
|
|
|
advanced: false,
|
|
|
|
autocomplete: true,
|
|
|
|
nickPostfix: "",
|
|
|
|
coloredNicks: true,
|
|
|
|
desktopNotifications: false,
|
|
|
|
highlights: [],
|
|
|
|
links: true,
|
|
|
|
motd: true,
|
|
|
|
notification: true,
|
|
|
|
notifyAllMessages: false,
|
|
|
|
showSeconds: false,
|
|
|
|
statusMessages: "condensed",
|
|
|
|
theme: document.getElementById("theme").dataset.serverTheme,
|
|
|
|
media: true,
|
|
|
|
userStyles: "",
|
|
|
|
},
|
2018-07-06 18:15:15 +00:00
|
|
|
},
|
2018-07-10 09:40:55 +00:00
|
|
|
mounted() {
|
|
|
|
Vue.nextTick(() => window.vueMounted());
|
|
|
|
},
|
2018-07-06 18:15:15 +00:00
|
|
|
render(createElement) {
|
|
|
|
return createElement(App, {
|
|
|
|
props: this,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
function findChannel(id) {
|
|
|
|
for (const network of vueApp.networks) {
|
|
|
|
for (const channel of network.channels) {
|
|
|
|
if (channel.id === id) {
|
|
|
|
return {network, channel};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-07-18 18:40:09 +00:00
|
|
|
function initChannel(channel) {
|
2018-09-09 12:23:12 +00:00
|
|
|
channel.pendingMessage = "";
|
|
|
|
channel.inputHistoryPosition = 0;
|
|
|
|
channel.inputHistory = [""];
|
2018-07-18 18:40:09 +00:00
|
|
|
channel.historyLoading = false;
|
|
|
|
channel.scrolledToBottom = true;
|
|
|
|
|
|
|
|
if (channel.type === "channel") {
|
|
|
|
channel.usersOutdated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-06 18:15:15 +00:00
|
|
|
module.exports = {
|
|
|
|
vueApp,
|
|
|
|
findChannel,
|
2018-07-18 18:40:09 +00:00
|
|
|
initChannel,
|
2018-07-06 18:15:15 +00:00
|
|
|
};
|