Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*!
- chat.js
- Created by David Rowe on 20 Jul 2015.
- Copyright 2015 David Rowe.
- Information: http://ctrlaltstudio.com/hifi/chat
- License: http://ctrlaltstudio.com/hifi/chat/license
- */
- function a() {
- function d(t) {
- n.setVisible(t);
- t && (n.raise(), v = Date.now());
- u = t
- }
- function g() {
- return u && Date.now() - v < k
- }
- function nt(t) {
- n.setTitle(t)
- }
- function tt(t) {
- n.emitScriptEvent(JSON.stringify({
- type: "messages",
- messages: t
- }))
- }
- function it(t, i) {
- n.emitScriptEvent(JSON.stringify({
- type: "message",
- user: t,
- message: i
- }))
- }
- function rt() {
- n.emitScriptEvent(JSON.stringify({
- type: "clear"
- }))
- }
- function ut() {
- var t, i;
- t = Settings.getValue(HMD.active ? c : h);
- HMD.active && t === "" && (t = p);
- i = Settings.getValue(HMD.active ? s : o);
- i === "" && (i = {
- width: l,
- height: a
- });
- t !== "" && n.setPosition(t)
- }
- function b(n) {
- var t = JSON.parse(n);
- t.type === "message" ? y(t.message) : t.type === "close" ? g() || e() : t.type === "loaded" && f !== null && f()
- }
- function ft(n) {
- i !== undefined && Script.clearTimeout(i);
- i = Script.setTimeout(function() {
- Settings.setValue(HMD.active ? s : o, n);
- i = undefined
- }, w)
- }
- function et(n) {
- u && (r !== undefined && Script.clearTimeout(r), t = n, r = Script.setTimeout(function() {
- Settings.setValue(HMD.active ? c : h, t);
- r = undefined
- }, w))
- }
- function ot() {
- e()
- }
- function st(i, r, u, v) {
- var k, w;
- k = Script.resolvePath("html/chat.html");
- w = Settings.getValue(HMD.active ? s : o);
- w === "" && (w = {
- width: l,
- height: a
- });
- t = Settings.getValue(HMD.active ? c : h);
- f = r;
- y = u;
- e = v;
- n = new OverlayWebWindow(i, k, w.width, w.height, !1);
- HMD.active && t === "" && (t = p);
- t !== "" && n.setPosition(t);
- n.setVisible(!1);
- n.webEventReceived.connect(b);
- n.moved.connect(et);
- n.resized.connect(ft);
- n.closed.connect(ot)
- }
- function ht() {
- n.webEventReceived.disconnect(b)
- }
- var n, l = 400,
- a = 600,
- t, u = !1,
- v, k = 1e3,
- f, y, e, o = "Chat Window Size Desktop",
- s = "Chat Window Size",
- h = "Chat Window Position Desktop",
- c = "Chat Window Position",
- p = {
- x: 2e3,
- y: 200
- },
- i, r, w = 500;
- return {
- z1: d,
- z2: nt,
- z3: ut,
- z4: tt,
- z5: it,
- z6: rt,
- za: st,
- zb: ht
- }
- }
- var o = function() {
- function c() {
- return "Local Chat @ " + Window.location.hostname + (i ? "" : " (NOT CONNECTED)")
- }
- function l() {
- Script.setTimeout(function() {
- var t;
- h || (t = c(), n.z2(t))
- }, 1e3)
- }
- function r(i) {
- i !== f && (Menu.setIsOptionChecked(t, i), i ? n.z4(e) : n.z6(), n.z1(i), f = i)
- }
- function v(n) {
- n === t && r(Menu.isOptionChecked(t))
- }
- function g() {
- r(!1)
- }
- function y(n) {
- if (n.key === s) {
- r(!Menu.isOptionChecked(t));
- return
- }
- }
- function nt(t, i) {
- e[e.length] = {
- user: t,
- message: i
- };
- f && n.z5(t, i)
- }
- function p(n, t, i) {
- var r;
- n === u && (r = AvatarManager.getAvatar(i).displayName, nt(r, t))
- }
- function tt(n) {
- Messages.sendMessage(u, n)
- }
- function w() {
- l();
- n.z6()
- }
- function it() {
- n.z3()
- }
- function b() {
- i !== Window.location.isConnected && (i = !i, l())
- }
- function rt() {
- n = a();
- Window.location.hostChanged.connect(w);
- i = Window.location.isConnected;
- n.za(c(), null, tt, g);
- Menu.addMenuItem({
- menuName: o,
- menuItemName: t,
- afterItem: k,
- shortcutKey: d,
- isCheckable: !0
- });
- Menu.menuItemEvent.connect(v);
- HMD.displayModeChanged.connect(it);
- Messages.subscribe(u);
- Messages.messageReceived.connect(p);
- Controller.captureKeyEvents({
- key: s
- });
- Controller.keyPressEvent.connect(y);
- r(Menu.isOptionChecked(t));
- Script.update.connect(b)
- }
- function ut() {
- h = !0;
- r(!1);
- Script.update.disconnect(b);
- Controller.keyPressEvent.disconnect(y);
- Messages.unsubscribe(u);
- Messages.messageReceived.disconnect(p);
- Menu.menuItemEvent.disconnect(v);
- Window.location.hostChanged.disconnect(w);
- n.zb();
- Menu.removeMenuItem(o, t)
- }
- var n, f = !1,
- i, o = "View",
- t = "Local Chat...",
- k = "Mini Mirror",
- d = "\\",
- s = 92,
- u = "chat",
- e = [],
- h = !1;
- rt();
- Script.scriptEnding.connect(ut)
- }()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement