2022-09-14 15:31:16 +03:00
|
|
|
import copyToClipboard from '../utils/copyToClipboard';
|
|
|
|
|
2018-10-20 17:54:15 +03:00
|
|
|
/**
|
|
|
|
* @class Page
|
|
|
|
* @classdesc Class for page module
|
|
|
|
*/
|
2022-07-26 18:49:30 +03:00
|
|
|
export default class Page {
|
2018-10-20 17:54:15 +03:00
|
|
|
/**
|
|
|
|
* Creates base properties
|
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
this.codeStyler = null;
|
2022-07-26 18:49:30 +03:00
|
|
|
this.tableOfContent = null;
|
2018-10-20 17:54:15 +03:00
|
|
|
}
|
|
|
|
|
2022-09-14 15:31:16 +03:00
|
|
|
/**
|
|
|
|
* CSS classes used in the codes
|
|
|
|
*
|
|
|
|
* @returns {Record<string, string>}
|
|
|
|
*/
|
|
|
|
static get CSS() {
|
|
|
|
return {
|
2022-11-29 14:02:31 +03:00
|
|
|
page: 'page'
|
2022-09-14 15:31:16 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-10-20 17:54:15 +03:00
|
|
|
/**
|
|
|
|
* Called by ModuleDispatcher to initialize module from DOM
|
|
|
|
*/
|
2022-07-26 18:49:30 +03:00
|
|
|
init() {
|
2018-10-20 17:54:15 +03:00
|
|
|
this.codeStyler = this.createCodeStyling();
|
2022-07-26 18:49:30 +03:00
|
|
|
this.tableOfContent = this.createTableOfContent();
|
2022-09-14 15:31:16 +03:00
|
|
|
|
|
|
|
/**
|
2022-11-29 14:02:31 +03:00
|
|
|
* Add click event listener
|
2022-09-14 15:31:16 +03:00
|
|
|
*/
|
|
|
|
const page = document.querySelector(`.${Page.CSS.page}`);
|
|
|
|
|
2022-11-29 14:02:31 +03:00
|
|
|
page.addEventListener('click', (event) => { });
|
2022-07-26 18:49:30 +03:00
|
|
|
}
|
2018-10-20 17:54:15 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Init code highlighting
|
|
|
|
*/
|
|
|
|
async createCodeStyling() {
|
Authentication (#22)
* Authorization added
* added secret to password, md5 hashing, removed promise from verifyToken, deleted links when not authorized
* added dbinsert script
* turned verifyToken to middleware, added description for dbinsert, added hidden csrf field in auth form
* added middlewares, user model and controller
* JSDoc fix
* wrong password processing fix
* added comments to dbinsert script, moved salt and passHash to singe db doc
* Moved salt to .env, upgradedscript for generating password was, fixed comments and JSDoc
* Deleted using salt (now user is only one), changed verifying password to bcrypt.compare, added httpyOnly property to jwt cookie
2019-03-06 13:22:57 +03:00
|
|
|
const { default: CodeStyler } = await import(/* webpackChunkName: "code-styling" */ './../classes/codeStyler');
|
2018-10-20 17:54:15 +03:00
|
|
|
|
2022-07-26 18:49:30 +03:00
|
|
|
try {
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new CodeStyler({
|
|
|
|
selector: '.block-code__content',
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error); // @todo send to Hawk
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init table of content
|
|
|
|
*
|
|
|
|
* @returns {Promise<TableOfContent>}
|
|
|
|
*/
|
|
|
|
async createTableOfContent() {
|
|
|
|
const { default: TableOfContent } = await import(/* webpackChunkName: "table-of-content" */ '../classes/table-of-content');
|
|
|
|
|
|
|
|
try {
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new TableOfContent({
|
2022-11-29 14:02:31 +03:00
|
|
|
tagSelector: '.block-header',
|
2022-07-26 18:49:30 +03:00
|
|
|
appendTo: document.getElementById('layout-sidebar-right'),
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error); // @todo send to Hawk
|
|
|
|
}
|
|
|
|
}
|
2018-10-20 17:54:15 +03:00
|
|
|
}
|