removed generated js files
This commit is contained in:
parent
4a8e409539
commit
8b3774de8e
1
chatto/.gitignore
vendored
1
chatto/.gitignore
vendored
@ -37,3 +37,4 @@ bundle.js
|
|||||||
bundle.min.js
|
bundle.min.js
|
||||||
src/main/javascript/node/
|
src/main/javascript/node/
|
||||||
dist
|
dist
|
||||||
|
out
|
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@ -1,66 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
require("../model/AbstractModel");
|
|
||||||
require("../model/UserModel");
|
|
||||||
require("../view/AbstractView");
|
|
||||||
require("../view/UserView");
|
|
||||||
var ChatMessageViewModel_1 = require("../viewmodel/ChatMessageViewModel");
|
|
||||||
var ChatController = /** @class */ (function () {
|
|
||||||
function ChatController(model, view) {
|
|
||||||
this._model = model;
|
|
||||||
this._view = view;
|
|
||||||
}
|
|
||||||
Object.defineProperty(ChatController.prototype, "model", {
|
|
||||||
/**
|
|
||||||
* Getter model
|
|
||||||
* @return {Model}
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this._model;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Setter model
|
|
||||||
* @param {Model} value
|
|
||||||
*/
|
|
||||||
set: function (value) {
|
|
||||||
this._model = value;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(ChatController.prototype, "view", {
|
|
||||||
/**
|
|
||||||
* Getter view
|
|
||||||
* @return {View}
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this._view;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Setter view
|
|
||||||
* @param {View} value
|
|
||||||
*/
|
|
||||||
set: function (value) {
|
|
||||||
this._view = value;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* eventHandler
|
|
||||||
*/
|
|
||||||
ChatController.prototype.eventHandler = function (vm) {
|
|
||||||
this.model.someBusinessMethod(vm);
|
|
||||||
};
|
|
||||||
ChatController.prototype.test = function () {
|
|
||||||
var chatMessageViewModels = [];
|
|
||||||
var chatMessageViewModelMock = new ChatMessageViewModel_1.ChatMessageViewModel();
|
|
||||||
chatMessageViewModelMock.fromUser = "user1";
|
|
||||||
chatMessageViewModelMock.toUser = "user2";
|
|
||||||
chatMessageViewModelMock.messageCipher = "";
|
|
||||||
chatMessageViewModelMock.messageTime = new Date();
|
|
||||||
chatMessageViewModels.push(chatMessageViewModelMock);
|
|
||||||
};
|
|
||||||
return ChatController;
|
|
||||||
}());
|
|
||||||
exports.ChatController = ChatController;
|
|
@ -1,71 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
require("../model/AbstractModel");
|
|
||||||
require("../model/UserModel");
|
|
||||||
require("../view/AbstractView");
|
|
||||||
require("../view/UserView");
|
|
||||||
var ActiveUserViewModel_1 = require("../viewmodel/ActiveUserViewModel");
|
|
||||||
var UserController = /** @class */ (function () {
|
|
||||||
function UserController(model, view) {
|
|
||||||
this._model = model;
|
|
||||||
this._view = view;
|
|
||||||
}
|
|
||||||
Object.defineProperty(UserController.prototype, "model", {
|
|
||||||
/**
|
|
||||||
* Getter model
|
|
||||||
* @return {Model}
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this._model;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Setter model
|
|
||||||
* @param {Model} value
|
|
||||||
*/
|
|
||||||
set: function (value) {
|
|
||||||
this._model = value;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(UserController.prototype, "view", {
|
|
||||||
/**
|
|
||||||
* Getter view
|
|
||||||
* @return {View}
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this._view;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Setter view
|
|
||||||
* @param {View} value
|
|
||||||
*/
|
|
||||||
set: function (value) {
|
|
||||||
this._view = value;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* eventHandler
|
|
||||||
*/
|
|
||||||
UserController.prototype.eventHandler = function (vm) {
|
|
||||||
this.model.someBusinessMethod(vm);
|
|
||||||
};
|
|
||||||
UserController.prototype.test = function () {
|
|
||||||
var activeUsersMock = [];
|
|
||||||
var activeUserViewModelMock = new ActiveUserViewModel_1.ActiveUserViewModel();
|
|
||||||
activeUserViewModelMock.userName = "some user";
|
|
||||||
activeUserViewModelMock.lastActive = "3 hrs ago";
|
|
||||||
activeUserViewModelMock.online = true;
|
|
||||||
activeUsersMock.push(activeUserViewModelMock);
|
|
||||||
activeUserViewModelMock = new ActiveUserViewModel_1.ActiveUserViewModel();
|
|
||||||
activeUserViewModelMock.lastActive = "3 hrs ago";
|
|
||||||
activeUserViewModelMock.online = true;
|
|
||||||
activeUserViewModelMock.userName = "some user 2";
|
|
||||||
activeUsersMock.push(activeUserViewModelMock);
|
|
||||||
this.eventHandler(activeUsersMock);
|
|
||||||
};
|
|
||||||
return UserController;
|
|
||||||
}());
|
|
||||||
exports.UserController = UserController;
|
|
@ -1,58 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var UserModel_1 = require("./model/UserModel");
|
|
||||||
var UserView_1 = require("./view/UserView");
|
|
||||||
var UserController_1 = require("./controller/UserController");
|
|
||||||
var Handlebars = __importStar(require("handlebars"));
|
|
||||||
var markdownit = require("markdown-it");
|
|
||||||
var ChatModel_1 = require("./model/ChatModel");
|
|
||||||
var ChatView_1 = require("./view/ChatView");
|
|
||||||
var ChatController_1 = require("./controller/ChatController");
|
|
||||||
var JsonAPI_1 = require("./singleton/JsonAPI");
|
|
||||||
// import log = require('loglevel')
|
|
||||||
// import * as log from 'loglevel';
|
|
||||||
var loglevel_1 = __importDefault(require("loglevel"));
|
|
||||||
var SJCLEncryptionService_1 = require("./service/SJCLEncryptionService");
|
|
||||||
// var markdownit = require('markdown-it');
|
|
||||||
var md = new markdownit();
|
|
||||||
var userBox = document.getElementById('contacts-box');
|
|
||||||
loglevel_1.default.setLevel("TRACE");
|
|
||||||
var chatModel = new ChatModel_1.ChatModel();
|
|
||||||
var userModel = new UserModel_1.UserModel();
|
|
||||||
// const userModel = ModelFactory.createModel("USER");
|
|
||||||
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
|
|
||||||
var userView = new UserView_1.UserView(userModel, chatModel, userBox);
|
|
||||||
// console.log(userBox);
|
|
||||||
userModel.attach(userView);
|
|
||||||
// userView.model
|
|
||||||
var userController = new UserController_1.UserController(userModel, userView);
|
|
||||||
userController.test();
|
|
||||||
// userModel.someBusinessMethod(activeUsersMock);
|
|
||||||
loglevel_1.default.info("hello");
|
|
||||||
var chatArea = document.getElementById('chat-area-new');
|
|
||||||
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
|
|
||||||
var chatView = new ChatView_1.ChatView(chatModel, chatArea);
|
|
||||||
var chatController = new ChatController_1.ChatController(chatModel, chatView);
|
|
||||||
function someFunc(vm) {
|
|
||||||
// log.info(vm);
|
|
||||||
// logger.info(vm)
|
|
||||||
}
|
|
||||||
loglevel_1.default.info("test");
|
|
||||||
// someFunc(activeUserViewModelMock);
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
var source = document.getElementById("msg_container_template").innerHTML;
|
|
||||||
var msgContainerTemplate = Handlebars.compile(source);
|
|
||||||
JsonAPI_1.JsonAPI.ACTIVE_USERS_GET + 'aef';
|
|
||||||
var encryptionService = new SJCLEncryptionService_1.SJCLEncryptionService();
|
|
||||||
var ct = encryptionService.encrypt("password", "data");
|
|
||||||
console.log(encryptionService.decrypt("password", ct));
|
|
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@ -1,162 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
||||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
||||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
||||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
||||||
function step(op) {
|
|
||||||
if (f) throw new TypeError("Generator is already executing.");
|
|
||||||
while (_) try {
|
|
||||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
||||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
||||||
switch (op[0]) {
|
|
||||||
case 0: case 1: t = op; break;
|
|
||||||
case 4: _.label++; return { value: op[1], done: false };
|
|
||||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
||||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
||||||
default:
|
|
||||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
||||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
||||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
||||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
||||||
if (t[2]) _.ops.pop();
|
|
||||||
_.trys.pop(); continue;
|
|
||||||
}
|
|
||||||
op = body.call(thisArg, _);
|
|
||||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
||||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var FetchErrorHandler_1 = require("./FetchErrorHandler");
|
|
||||||
var JsonAPI_1 = require("../singleton/JsonAPI");
|
|
||||||
var log = require("loglevel");
|
|
||||||
var ChatModel = /** @class */ (function () {
|
|
||||||
function ChatModel() {
|
|
||||||
/**
|
|
||||||
* @type {Observer[]} List of subscribers. In real life, the list of
|
|
||||||
* subscribers can be stored more comprehensively (categorized by event
|
|
||||||
* type, etc.).
|
|
||||||
*/
|
|
||||||
this.observers = [];
|
|
||||||
// @ts-ignore: Cannot find name 'hostAddress'.
|
|
||||||
this.getActiveUsersUrl = "";
|
|
||||||
this.state = null;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* The subscription management methods.
|
|
||||||
*/
|
|
||||||
ChatModel.prototype.attach = function (observer) {
|
|
||||||
console.log('Subject: Attached an observer.');
|
|
||||||
this.observers.push(observer);
|
|
||||||
};
|
|
||||||
ChatModel.prototype.detach = function (observer) {
|
|
||||||
var observerIndex = this.observers.indexOf(observer);
|
|
||||||
this.observers.splice(observerIndex, 1);
|
|
||||||
console.log('Subject: Detached an observer.');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Trigger an update in each subscriber.
|
|
||||||
*/
|
|
||||||
ChatModel.prototype.notify = function () {
|
|
||||||
console.log('Subject: Notifying observers...');
|
|
||||||
for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
|
|
||||||
var observer = _a[_i];
|
|
||||||
observer.update(this.state);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ChatModel.prototype.someBusinessMethod = function (activeuserList) {
|
|
||||||
this.state = activeuserList;
|
|
||||||
this.helperMethod();
|
|
||||||
console.log("Subject: My state has just changed");
|
|
||||||
console.log(activeuserList);
|
|
||||||
this.notify();
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* getActiveUsers
|
|
||||||
*/
|
|
||||||
ChatModel.prototype.getMessages = function () {
|
|
||||||
var _this = this;
|
|
||||||
this.getAllMessagesAjax(":")
|
|
||||||
.then(function (data) {
|
|
||||||
// // activeUsers = data;
|
|
||||||
// sessionStorage.setItem('activeUsers', JSON.stringify(data));
|
|
||||||
// console.log(sessionStorage.getItem('activeUsers'));
|
|
||||||
console.log("Subject: received ajax active users");
|
|
||||||
_this.state = data;
|
|
||||||
_this.notify();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
ChatModel.prototype.getAllMessagesAjax = function (authToken2) {
|
|
||||||
return __awaiter(this, void 0, Promise, function () {
|
|
||||||
var headers, response, data;
|
|
||||||
return __generator(this, function (_a) {
|
|
||||||
switch (_a.label) {
|
|
||||||
case 0:
|
|
||||||
headers = new Headers();
|
|
||||||
// headers.append('Authorization', basicAuthToken);
|
|
||||||
if (JsonAPI_1.JsonAPI.authToken == null) {
|
|
||||||
log.error("authToken null");
|
|
||||||
return [2 /*return*/];
|
|
||||||
}
|
|
||||||
;
|
|
||||||
headers.append('X-AUTH-TOKEN', JsonAPI_1.JsonAPI.authToken);
|
|
||||||
return [4 /*yield*/, fetch(this.getActiveUsersUrl, {
|
|
||||||
method: 'GET',
|
|
||||||
headers: headers
|
|
||||||
})];
|
|
||||||
case 1:
|
|
||||||
response = _a.sent();
|
|
||||||
console.log(response.clone());
|
|
||||||
if (FetchErrorHandler_1.fetchErrorHandler(response.clone())) {
|
|
||||||
return [2 /*return*/, null];
|
|
||||||
}
|
|
||||||
return [4 /*yield*/, response.json()];
|
|
||||||
case 2:
|
|
||||||
data = _a.sent();
|
|
||||||
return [2 /*return*/, data];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
ChatModel.prototype.getNewMessages = function (authToken, toUser, lastMessageTimeStamp) {
|
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
|
||||||
var headers, response, data;
|
|
||||||
return __generator(this, function (_a) {
|
|
||||||
switch (_a.label) {
|
|
||||||
case 0:
|
|
||||||
headers = new Headers();
|
|
||||||
// headers.append('Authorization', basicAuthToken);
|
|
||||||
headers.append('X-AUTH-TOKEN', authToken);
|
|
||||||
return [4 /*yield*/, fetch("" + JsonAPI_1.JsonAPI.CHAT_MESSAGES_GET + toUser + "/" + lastMessageTimeStamp, {
|
|
||||||
method: 'GET',
|
|
||||||
headers: headers
|
|
||||||
})];
|
|
||||||
case 1:
|
|
||||||
response = _a.sent();
|
|
||||||
console.log(response.clone());
|
|
||||||
if (FetchErrorHandler_1.fetchErrorHandler(response.clone())) {
|
|
||||||
return [2 /*return*/, null];
|
|
||||||
}
|
|
||||||
return [4 /*yield*/, response.json()];
|
|
||||||
case 2:
|
|
||||||
data = _a.sent();
|
|
||||||
return [2 /*return*/, data];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
ChatModel.prototype.helperMethod = function () { };
|
|
||||||
ChatModel.prototype.populateMessages = function () {
|
|
||||||
};
|
|
||||||
return ChatModel;
|
|
||||||
}());
|
|
||||||
exports.ChatModel = ChatModel;
|
|
@ -1,22 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
function fetchErrorHandler(response) {
|
|
||||||
// alertify.success('Current position : ' + alertify.get('notifier', 'position'));
|
|
||||||
if (!response.ok) {
|
|
||||||
return response.text().catch(function (err) {
|
|
||||||
// the status was not ok and there is no json body
|
|
||||||
// throw new Error(response.statusText);
|
|
||||||
// window.alert(sprintf('Some error occured. Http code is %s', response.status));
|
|
||||||
// alertify.error(sprintf('Some error occured. Http code is %s', response.status));
|
|
||||||
return true;
|
|
||||||
}).then(function (json) {
|
|
||||||
// the status was not ok but there is a json body
|
|
||||||
// throw new Error(json.error.message); // example error message returned by a REST API
|
|
||||||
// window.alert(sprintf('Error: %s (Http code %s)', json, response.status));
|
|
||||||
// alertify.error(sprintf('Some error occured. Http code is %s', response.status));
|
|
||||||
console.log(json);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.fetchErrorHandler = fetchErrorHandler;
|
|
@ -1,17 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var UserModel_1 = require("./UserModel");
|
|
||||||
var ModelFactory = /** @class */ (function () {
|
|
||||||
function ModelFactory() {
|
|
||||||
}
|
|
||||||
ModelFactory.createModel = function (modelName) {
|
|
||||||
switch (modelName) {
|
|
||||||
case "USER":
|
|
||||||
return new UserModel_1.UserModel();
|
|
||||||
break;
|
|
||||||
default: throw new Error("Invalid model name");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return ModelFactory;
|
|
||||||
}());
|
|
||||||
exports.ModelFactory = ModelFactory;
|
|
@ -1,126 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
||||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
||||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
||||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
||||||
function step(op) {
|
|
||||||
if (f) throw new TypeError("Generator is already executing.");
|
|
||||||
while (_) try {
|
|
||||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
||||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
||||||
switch (op[0]) {
|
|
||||||
case 0: case 1: t = op; break;
|
|
||||||
case 4: _.label++; return { value: op[1], done: false };
|
|
||||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
||||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
||||||
default:
|
|
||||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
||||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
||||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
||||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
||||||
if (t[2]) _.ops.pop();
|
|
||||||
_.trys.pop(); continue;
|
|
||||||
}
|
|
||||||
op = body.call(thisArg, _);
|
|
||||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
||||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var FetchErrorHandler_1 = require("./FetchErrorHandler");
|
|
||||||
var JsonAPI_1 = require("../singleton/JsonAPI");
|
|
||||||
var UserModel = /** @class */ (function () {
|
|
||||||
function UserModel() {
|
|
||||||
/**
|
|
||||||
* @type {Observer[]} List of subscribers. In real life, the list of
|
|
||||||
* subscribers can be stored more comprehensively (categorized by event
|
|
||||||
* type, etc.).
|
|
||||||
*/
|
|
||||||
this.observers = [];
|
|
||||||
// @ts-ignore: Cannot find name 'hostAddress'.
|
|
||||||
this.getActiveUsersUrl = "";
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* The subscription management methods.
|
|
||||||
*/
|
|
||||||
UserModel.prototype.attach = function (observer) {
|
|
||||||
console.log('Subject: Attached an observer.');
|
|
||||||
this.observers.push(observer);
|
|
||||||
};
|
|
||||||
UserModel.prototype.detach = function (observer) {
|
|
||||||
var observerIndex = this.observers.indexOf(observer);
|
|
||||||
this.observers.splice(observerIndex, 1);
|
|
||||||
console.log('Subject: Detached an observer.');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Trigger an update in each subscriber.
|
|
||||||
*/
|
|
||||||
UserModel.prototype.notify = function () {
|
|
||||||
console.log('Subject: Notifying observers...');
|
|
||||||
for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
|
|
||||||
var observer = _a[_i];
|
|
||||||
observer.update(this.state);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
UserModel.prototype.someBusinessMethod = function (activeuserList) {
|
|
||||||
this.state = activeuserList;
|
|
||||||
this.helperMethod();
|
|
||||||
console.log("Subject: My state has just changed");
|
|
||||||
console.log(activeuserList);
|
|
||||||
this.notify();
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* getActiveUsers
|
|
||||||
*/
|
|
||||||
UserModel.prototype.getActiveUsers = function () {
|
|
||||||
var _this = this;
|
|
||||||
this.getActiveUsersAjax("", JsonAPI_1.JsonAPI.ACTIVE_USERS_GET)
|
|
||||||
.then(function (data) {
|
|
||||||
// // activeUsers = data;
|
|
||||||
// sessionStorage.setItem('activeUsers', JSON.stringify(data));
|
|
||||||
// console.log(sessionStorage.getItem('activeUsers'));
|
|
||||||
console.log("Subject: received ajax active users");
|
|
||||||
_this.state = data;
|
|
||||||
_this.notify();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
UserModel.prototype.getActiveUsersAjax = function (authToken2, URL) {
|
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
|
||||||
var headers, response, data;
|
|
||||||
return __generator(this, function (_a) {
|
|
||||||
switch (_a.label) {
|
|
||||||
case 0:
|
|
||||||
headers = new Headers();
|
|
||||||
// headers.append('Authorization', basicAuthToken);
|
|
||||||
headers.append('X-AUTH-TOKEN', authToken2);
|
|
||||||
return [4 /*yield*/, fetch(this.getActiveUsersUrl, {
|
|
||||||
method: 'GET',
|
|
||||||
headers: headers
|
|
||||||
})];
|
|
||||||
case 1:
|
|
||||||
response = _a.sent();
|
|
||||||
console.log(response.clone());
|
|
||||||
if (FetchErrorHandler_1.fetchErrorHandler(response.clone())) {
|
|
||||||
return [2 /*return*/, null];
|
|
||||||
}
|
|
||||||
return [4 /*yield*/, response.json()];
|
|
||||||
case 2:
|
|
||||||
data = _a.sent();
|
|
||||||
return [2 /*return*/, data];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
UserModel.prototype.helperMethod = function () { };
|
|
||||||
return UserModel;
|
|
||||||
}());
|
|
||||||
exports.UserModel = UserModel;
|
|
@ -1,64 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
/**
|
|
||||||
* The Subject owns some important state and notifies observers when the state
|
|
||||||
* changes.
|
|
||||||
*/
|
|
||||||
// class ConcreteSubject implements Subject {
|
|
||||||
// /**
|
|
||||||
// * @type {number} For the sake of simplicity, the Subject's state, essential
|
|
||||||
// * to all subscribers, is stored in this variable.
|
|
||||||
// */
|
|
||||||
// public state: number;
|
|
||||||
// /**
|
|
||||||
// * @type {Observer[]} List of subscribers. In real life, the list of
|
|
||||||
// * subscribers can be stored more comprehensively (categorized by event
|
|
||||||
// * type, etc.).
|
|
||||||
// */
|
|
||||||
// private observers: Observer[] = [];
|
|
||||||
// /**
|
|
||||||
// * The subscription management methods.
|
|
||||||
// */
|
|
||||||
// public attach(observer: Observer): void {
|
|
||||||
// console.log('Subject: Attached an observer.');
|
|
||||||
// this.observers.push(observer);
|
|
||||||
// }
|
|
||||||
// public detach(observer: Observer): void {
|
|
||||||
// const observerIndex = this.observers.indexOf(observer);
|
|
||||||
// this.observers.splice(observerIndex, 1);
|
|
||||||
// console.log('Subject: Detached an observer.');
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * Trigger an update in each subscriber.
|
|
||||||
// */
|
|
||||||
// public notify(): void {
|
|
||||||
// console.log('Subject: Notifying observers...');
|
|
||||||
// for (const observer of this.observers) {
|
|
||||||
// observer.update(this);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * Usually, the subscription logic is only a fraction of what a Subject can
|
|
||||||
// * really do. Subjects commonly hold some important business logic, that
|
|
||||||
// * triggers a notification method whenever something important is about to
|
|
||||||
// * happen (or after it).
|
|
||||||
// */
|
|
||||||
// public someBusinessLogic(): void {
|
|
||||||
// console.log('\nSubject: I\'m doing something important.');
|
|
||||||
// this.state = Math.floor(Math.random() * (10 + 1));
|
|
||||||
// console.log(`Subject: My state has just changed to: ${this.state}`);
|
|
||||||
// this.notify();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * The client code.
|
|
||||||
// */
|
|
||||||
// const subject = new ConcreteSubject();
|
|
||||||
// const observer1 = new ConcreteObserverA();
|
|
||||||
// subject.attach(observer1);
|
|
||||||
// const observer2 = new ConcreteObserverB();
|
|
||||||
// subject.attach(observer2);
|
|
||||||
// subject.someBusinessLogic();
|
|
||||||
// subject.someBusinessLogic();
|
|
||||||
// subject.detach(observer2);
|
|
||||||
// subject.someBusinessLogic();
|
|
@ -1,27 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// /**
|
|
||||||
// * The Observer interface declares the update method, used by subjects.
|
|
||||||
// */
|
|
||||||
// interface Observer {
|
|
||||||
// // Receive update from subject.
|
|
||||||
// update(subject: Subject): void;
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * Concrete Observers react to the updates issued by the Subject they had been
|
|
||||||
// * attached to.
|
|
||||||
// */
|
|
||||||
// class ConcreteObserverA implements Observer {
|
|
||||||
// public update(subject: Subject): void {
|
|
||||||
// if (subject.state < 3) {
|
|
||||||
// console.log('ConcreteObserverA: Reacted to the event.');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// class ConcreteObserverB implements Observer {
|
|
||||||
// public update(subject: Subject): void {
|
|
||||||
// if (subject.state === 0 || subject.state >= 2) {
|
|
||||||
// console.log('ConcreteObserverB: Reacted to the event.');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
@ -1,64 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
/**
|
|
||||||
* The Subject owns some important state and notifies observers when the state
|
|
||||||
* changes.
|
|
||||||
*/
|
|
||||||
// class ConcreteSubject implements Subject {
|
|
||||||
// /**
|
|
||||||
// * @type {number} For the sake of simplicity, the Subject's state, essential
|
|
||||||
// * to all subscribers, is stored in this variable.
|
|
||||||
// */
|
|
||||||
// public state: number;
|
|
||||||
// /**
|
|
||||||
// * @type {Observer[]} List of subscribers. In real life, the list of
|
|
||||||
// * subscribers can be stored more comprehensively (categorized by event
|
|
||||||
// * type, etc.).
|
|
||||||
// */
|
|
||||||
// private observers: Observer[] = [];
|
|
||||||
// /**
|
|
||||||
// * The subscription management methods.
|
|
||||||
// */
|
|
||||||
// public attach(observer: Observer): void {
|
|
||||||
// console.log('Subject: Attached an observer.');
|
|
||||||
// this.observers.push(observer);
|
|
||||||
// }
|
|
||||||
// public detach(observer: Observer): void {
|
|
||||||
// const observerIndex = this.observers.indexOf(observer);
|
|
||||||
// this.observers.splice(observerIndex, 1);
|
|
||||||
// console.log('Subject: Detached an observer.');
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * Trigger an update in each subscriber.
|
|
||||||
// */
|
|
||||||
// public notify(): void {
|
|
||||||
// console.log('Subject: Notifying observers...');
|
|
||||||
// for (const observer of this.observers) {
|
|
||||||
// observer.update(this);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * Usually, the subscription logic is only a fraction of what a Subject can
|
|
||||||
// * really do. Subjects commonly hold some important business logic, that
|
|
||||||
// * triggers a notification method whenever something important is about to
|
|
||||||
// * happen (or after it).
|
|
||||||
// */
|
|
||||||
// public someBusinessLogic(): void {
|
|
||||||
// console.log('\nSubject: I\'m doing something important.');
|
|
||||||
// this.state = Math.floor(Math.random() * (10 + 1));
|
|
||||||
// console.log(`Subject: My state has just changed to: ${this.state}`);
|
|
||||||
// this.notify();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * The client code.
|
|
||||||
// */
|
|
||||||
// const subject = new ConcreteSubject();
|
|
||||||
// const observer1 = new ConcreteObserverA();
|
|
||||||
// subject.attach(observer1);
|
|
||||||
// const observer2 = new ConcreteObserverB();
|
|
||||||
// subject.attach(observer2);
|
|
||||||
// subject.someBusinessLogic();
|
|
||||||
// subject.someBusinessLogic();
|
|
||||||
// subject.detach(observer2);
|
|
||||||
// subject.someBusinessLogic();
|
|
@ -1,27 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// /**
|
|
||||||
// * The Observer interface declares the update method, used by subjects.
|
|
||||||
// */
|
|
||||||
// interface Observer {
|
|
||||||
// // Receive update from subject.
|
|
||||||
// update(subject: Subject): void;
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * Concrete Observers react to the updates issued by the Subject they had been
|
|
||||||
// * attached to.
|
|
||||||
// */
|
|
||||||
// class ConcreteObserverA implements Observer {
|
|
||||||
// public update(subject: Subject): void {
|
|
||||||
// if (subject.state < 3) {
|
|
||||||
// console.log('ConcreteObserverA: Reacted to the event.');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// class ConcreteObserverB implements Observer {
|
|
||||||
// public update(subject: Subject): void {
|
|
||||||
// if (subject.state === 0 || subject.state >= 2) {
|
|
||||||
// console.log('ConcreteObserverB: Reacted to the event.');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@ -1,23 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var sjcl = __importStar(require("sjcl"));
|
|
||||||
var SJCLEncryptionService = /** @class */ (function () {
|
|
||||||
function SJCLEncryptionService() {
|
|
||||||
this.params = { mode: "gcm", ts: 128, adata: "", iter: 10000 };
|
|
||||||
}
|
|
||||||
SJCLEncryptionService.prototype.encrypt = function (passphrase, plainText) {
|
|
||||||
return sjcl.encrypt(passphrase, plainText, this.params);
|
|
||||||
};
|
|
||||||
SJCLEncryptionService.prototype.decrypt = function (passphrase, cipher) {
|
|
||||||
return sjcl.decrypt(passphrase, cipher, undefined, undefined);
|
|
||||||
};
|
|
||||||
return SJCLEncryptionService;
|
|
||||||
}());
|
|
||||||
exports.SJCLEncryptionService = SJCLEncryptionService;
|
|
@ -1,4 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.authToken = null;
|
|
||||||
// localStorage.getItem('authToken')
|
|
@ -1,9 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var JsonAPI;
|
|
||||||
(function (JsonAPI) {
|
|
||||||
// @ts-ignore: Cannot find name 'hostAddress'.
|
|
||||||
JsonAPI.authToken = null;
|
|
||||||
JsonAPI.ACTIVE_USERS_GET = "/api/chat/get/active-users/";
|
|
||||||
JsonAPI.CHAT_MESSAGES_GET = "";
|
|
||||||
})(JsonAPI = exports.JsonAPI || (exports.JsonAPI = {}));
|
|
@ -1,14 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var TemplateFactory = /** @class */ (function () {
|
|
||||||
function TemplateFactory() {
|
|
||||||
}
|
|
||||||
TemplateFactory.getTemplate = function () {
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
var source = document.getElementById("user-contact-online-template").innerHTML;
|
|
||||||
var msgContainerTemplate = Handlebars.compile(source);
|
|
||||||
return msgContainerTemplate;
|
|
||||||
};
|
|
||||||
return TemplateFactory;
|
|
||||||
}());
|
|
||||||
exports.TemplateFactory = TemplateFactory;
|
|
@ -1 +0,0 @@
|
|||||||
"use strict";
|
|
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@ -1,103 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var TemplateFactory_1 = require("../template/TemplateFactory");
|
|
||||||
var ChatView = /** @class */ (function () {
|
|
||||||
// private userBoxes: any[] = [];
|
|
||||||
function ChatView(model, element) {
|
|
||||||
this._model = model;
|
|
||||||
this._element = element;
|
|
||||||
}
|
|
||||||
Object.defineProperty(ChatView.prototype, "model", {
|
|
||||||
/**
|
|
||||||
* Getter model
|
|
||||||
* @return {Model}
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this._model;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(ChatView.prototype, "element", {
|
|
||||||
/**
|
|
||||||
* Getter element
|
|
||||||
* @return {any}
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this._element;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
// /**
|
|
||||||
// * Setter model
|
|
||||||
// * @param {Model} value
|
|
||||||
// */
|
|
||||||
// public set model(value: Model) {
|
|
||||||
// this._model = value;
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * Setter element
|
|
||||||
// * @param {any} value
|
|
||||||
// */
|
|
||||||
// public set element(value: any) {
|
|
||||||
// this._element = value;
|
|
||||||
// }
|
|
||||||
ChatView.prototype.update = function (data) {
|
|
||||||
var template = TemplateFactory_1.TemplateFactory.getTemplate();
|
|
||||||
var html = "";
|
|
||||||
data.forEach(function (element) {
|
|
||||||
html += template(element);
|
|
||||||
});
|
|
||||||
this.element.innerHTML = html;
|
|
||||||
this.addUserCallBacks();
|
|
||||||
console.log(this.element.innerHTML);
|
|
||||||
};
|
|
||||||
ChatView.prototype.helper = function () {
|
|
||||||
};
|
|
||||||
ChatView.prototype.addUserCallBacks = function () {
|
|
||||||
var userBoxes = document.getElementsByClassName('user-box');
|
|
||||||
for (var i = 0; i < userBoxes.length; i++) {
|
|
||||||
var userBox = userBoxes[i];
|
|
||||||
userBoxes[i].addEventListener('click', this.userCallBack.bind(this, userBox));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ChatView.prototype.userCallBack = function (el) {
|
|
||||||
var current = document.getElementsByClassName('user-box active');
|
|
||||||
var passphrase = "";
|
|
||||||
if (current.length > 0) {
|
|
||||||
if (passphrase == '') {
|
|
||||||
// alert('Please input passphrase')
|
|
||||||
// alertify.error('Please enter a passphrase');
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
current[0].className = current[0].className.replace(" active", "");
|
|
||||||
}
|
|
||||||
// Add the active class to the current/clicked button
|
|
||||||
else if (current.length == 0) {
|
|
||||||
var elem_1 = document.getElementById('passphrase-initial');
|
|
||||||
passphrase = "";
|
|
||||||
if (passphrase == '') {
|
|
||||||
// // alert('Please input passphrase')
|
|
||||||
// // alertify.error('Please enter a passphrase');
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
document.getElementById('no-user-selected').hidden = true;
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
document.getElementById('chat-card').hidden = false;
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
elem_1.hidden = true;
|
|
||||||
}
|
|
||||||
// console.log(this.getElementsByClassName('to-user-span'));
|
|
||||||
var elem = el.getElementsByClassName('to-user-span')[0];
|
|
||||||
var userName = elem.innerText;
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
document.getElementById('user-name-span').innerText = userName;
|
|
||||||
// populateMessages(userName, passphrase);
|
|
||||||
sessionStorage.setItem('selectedUser', userName);
|
|
||||||
el.className += " active";
|
|
||||||
};
|
|
||||||
return ChatView;
|
|
||||||
}());
|
|
||||||
exports.ChatView = ChatView;
|
|
@ -1,104 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var TemplateFactory_1 = require("../template/TemplateFactory");
|
|
||||||
var UserView = /** @class */ (function () {
|
|
||||||
// private userBoxes: any[] = [];
|
|
||||||
function UserView(model, chatModel, element) {
|
|
||||||
this._model = model;
|
|
||||||
this._chatModel = chatModel;
|
|
||||||
this._element = element;
|
|
||||||
}
|
|
||||||
Object.defineProperty(UserView.prototype, "model", {
|
|
||||||
/**
|
|
||||||
* Getter model
|
|
||||||
* @return {Model}
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this._model;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(UserView.prototype, "element", {
|
|
||||||
/**
|
|
||||||
* Getter element
|
|
||||||
* @return {any}
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this._element;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
// /**
|
|
||||||
// * Setter model
|
|
||||||
// * @param {Model} value
|
|
||||||
// */
|
|
||||||
// public set model(value: Model) {
|
|
||||||
// this._model = value;
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * Setter element
|
|
||||||
// * @param {any} value
|
|
||||||
// */
|
|
||||||
// public set element(value: any) {
|
|
||||||
// this._element = value;
|
|
||||||
// }
|
|
||||||
UserView.prototype.update = function (data) {
|
|
||||||
var template = TemplateFactory_1.TemplateFactory.getTemplate();
|
|
||||||
var html = "";
|
|
||||||
data.forEach(function (element) {
|
|
||||||
html += template(element);
|
|
||||||
});
|
|
||||||
this.element.innerHTML = html;
|
|
||||||
this.addUserCallBacks();
|
|
||||||
console.log(this.element.innerHTML);
|
|
||||||
};
|
|
||||||
UserView.prototype.helper = function () {
|
|
||||||
};
|
|
||||||
UserView.prototype.addUserCallBacks = function () {
|
|
||||||
var userBoxes = document.getElementsByClassName('user-box');
|
|
||||||
for (var i = 0; i < userBoxes.length; i++) {
|
|
||||||
var userBox = userBoxes[i];
|
|
||||||
userBoxes[i].addEventListener('click', this.userCallBack.bind(this, userBox));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
UserView.prototype.userCallBack = function (el) {
|
|
||||||
var current = document.getElementsByClassName('user-box active');
|
|
||||||
var passphrase = "";
|
|
||||||
if (current.length > 0) {
|
|
||||||
if (passphrase == '') {
|
|
||||||
// alert('Please input passphrase')
|
|
||||||
// alertify.error('Please enter a passphrase');
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
current[0].className = current[0].className.replace(" active", "");
|
|
||||||
}
|
|
||||||
// Add the active class to the current/clicked button
|
|
||||||
else if (current.length == 0) {
|
|
||||||
var elem_1 = document.getElementById('passphrase-initial');
|
|
||||||
passphrase = "";
|
|
||||||
if (passphrase == '') {
|
|
||||||
// // alert('Please input passphrase')
|
|
||||||
// // alertify.error('Please enter a passphrase');
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
document.getElementById('no-user-selected').hidden = true;
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
document.getElementById('chat-card').hidden = false;
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
elem_1.hidden = true;
|
|
||||||
}
|
|
||||||
// console.log(this.getElementsByClassName('to-user-span'));
|
|
||||||
var elem = el.getElementsByClassName('to-user-span')[0];
|
|
||||||
var userName = elem.innerText;
|
|
||||||
// @ts-ignore: Object is possibly 'null'.
|
|
||||||
document.getElementById('user-name-span').innerText = userName;
|
|
||||||
// populateMessages(userName, passphrase);
|
|
||||||
sessionStorage.setItem('selectedUser', userName);
|
|
||||||
el.className += " active";
|
|
||||||
};
|
|
||||||
return UserView;
|
|
||||||
}());
|
|
||||||
exports.UserView = UserView;
|
|
@ -1,8 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var ActiveUserViewModel = /** @class */ (function () {
|
|
||||||
function ActiveUserViewModel() {
|
|
||||||
}
|
|
||||||
return ActiveUserViewModel;
|
|
||||||
}());
|
|
||||||
exports.ActiveUserViewModel = ActiveUserViewModel;
|
|
@ -1,8 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var ChatMessageViewModel = /** @class */ (function () {
|
|
||||||
function ChatMessageViewModel() {
|
|
||||||
}
|
|
||||||
return ChatMessageViewModel;
|
|
||||||
}());
|
|
||||||
exports.ChatMessageViewModel = ChatMessageViewModel;
|
|
Loading…
Reference in New Issue
Block a user