docs: explain CatWar mod page handlers

This commit is contained in:
nyan404 committed 2026-08-25 04:31:26 +03:00
1 parent 31275b0ae6
commit de7c9321d2
1 file changed
+38 -18
+38 -18
View File
@@ -506,7 +506,8 @@ catch (err) {
return dateToString(birthday + age); return dateToString(birthday + age);
} }
function changeAllBlogsPages() { // Applies shared enhancements to blog listings, reports, and comments.
function changeAllBlogsPages() {
addBBcode(1); addBBcode(1);
let css = ` let css = `
#blogs-reload > a, .poll-hasAnswered1 { color: black; } #blogs-reload > a, .poll-hasAnswered1 { color: black; }
@@ -596,7 +597,8 @@ function changeAllBlogsPages() {
}); });
} }
function changeMainPage() { // Enhances the CatWar main page and mounts configured controls.
function changeMainPage() {
$('#search > form > input[type="text"]').attr('placeholder', 'Поиск по ключевым словам'); $('#search > form > input[type="text"]').attr('placeholder', 'Поиск по ключевым словам');
$('#search').append(`<p><input id="search-tag" type="text" size="35" placeholder="Поиск по тегу"> <input id="search-ok" type="button" value="Искать"></p>`); $('#search').append(`<p><input id="search-tag" type="text" size="35" placeholder="Поиск по тегу"> <input id="search-ok" type="button" value="Искать"></p>`);
$('#search-ok').click(function() { $('#search-ok').click(function() {
@@ -610,7 +612,8 @@ function changeMainPage() {
}); });
} }
function changeViewPage() { // Enhances a cat profile page with metadata and actions.
function changeViewPage() {
const p = $('#send_comment_form > p:last-child'); const p = $('#send_comment_form > p:last-child');
p.prepend(`<input type="button" id="comment-preview" value="Предпросмотр"> `); p.prepend(`<input type="button" id="comment-preview" value="Предпросмотр"> `);
$('#send_comment_form').after(` $('#send_comment_form').after(`
@@ -703,19 +706,22 @@ function changeViewPage() {
}); });
} }
function hideCommentPreview() { // Removes the expanded comment preview from the composer.
function hideCommentPreview() {
$('#comment-preview-hide').hide(); $('#comment-preview-hide').hide();
$('#comment-preview-div').empty().hide(); $('#comment-preview-div').empty().hide();
} }
function changeComments() { // Adds configured formatting, avatars, and reply behavior to comments.
function changeComments() {
addAnswerButtons(); addAnswerButtons();
if (globals.blogAvatars) { if (globals.blogAvatars) {
addCommentAvatars(); addCommentAvatars();
} }
} }
function addCommentAvatars() { // Resolves commenter IDs and inserts avatar thumbnails.
function addCommentAvatars() {
$('.view-comment:not(.has-avatar)').each(function() { $('.view-comment:not(.has-avatar)').each(function() {
$(this).prepend('<div class="comment-avatar"></div>'); $(this).prepend('<div class="comment-avatar"></div>');
const commentId = $(this).data('id'); const commentId = $(this).data('id');
@@ -737,7 +743,8 @@ function addCommentAvatars() {
}); });
} }
function addAnswerButtons() { // Adds reply buttons that prefill the editor with a citation.
function addAnswerButtons() {
const answerButton = isDesktop ? 'Ответить' : '🗨'; const answerButton = isDesktop ? 'Ответить' : '🗨';
const citeButton = isDesktop ? 'Цитировать' : '💬'; const citeButton = isDesktop ? 'Цитировать' : '💬';
const addAnswer = globals.blogAnswerButton; const addAnswer = globals.blogAnswerButton;
@@ -757,7 +764,8 @@ function addAnswerButtons() {
}); });
} }
function answerComment(comment, cite, selectionInfo) { // Inserts a selected comment quote and author reference into the editor.
function answerComment(comment, cite, selectionInfo) {
const commentInfo = comment.children('.comment-info'); const commentInfo = comment.children('.comment-info');
const num = commentInfo.children('b').children('.num').text(); const num = commentInfo.children('b').children('.num').text();
let author; let author;
@@ -779,7 +787,8 @@ function answerComment(comment, cite, selectionInfo) {
textarea.focus(); textarea.focus();
} }
function changeCreationPage() { // Enhances the blog creation form with editor and preview helpers.
function changeCreationPage() {
if (globals.creationAlert) addSaveAlert(); if (globals.creationAlert) addSaveAlert();
if (isPage('blogs?creation', true) || isPage('sniff?creation', true)) { if (isPage('blogs?creation', true) || isPage('sniff?creation', true)) {
const blogsTags = ` const blogsTags = `
@@ -904,11 +913,13 @@ function changeCreationPage() {
} }
} }
function searchByTag(tag) { // Filters visible blog entries by the selected tag.
function searchByTag(tag) {
window.location.href = window.location.href.split('?')[0] + '?tag=' + tag; window.location.href = window.location.href.split('?')[0] + '?tag=' + tag;
} }
function changeCatPage() { // Enhances a cat page with notes, identity data, and controls.
function changeCatPage() {
addCSS(`#info { color: black; } #age_icon, #age2_icon, #act_icon, img[src^="medal"] { cursor: pointer; }`); addCSS(`#info { color: black; } #age_icon, #age2_icon, #act_icon, img[src^="medal"] { cursor: pointer; }`);
moonCalc(); moonCalc();
if ($('[src="img/icon_kraft.png"]').length) { if ($('[src="img/icon_kraft.png"]').length) {
@@ -991,7 +1002,8 @@ function changeCatPage() {
} }
} }
function changeChatPage() { // Installs chat formatting, mentions, and notification behavior.
function changeChatPage() {
addCSS(`.tabName, #confirm_text, .mess_tr[style^="background: rgb(255, 204, 153)"] { color: black; } .mess_tr[style^="background: rgb(255, 204, 153)"] a { color: #003; }`); addCSS(`.tabName, #confirm_text, .mess_tr[style^="background: rgb(255, 204, 153)"] { color: black; } .mess_tr[style^="background: rgb(255, 204, 153)"] a { color: #003; }`);
addBBcode(1); addBBcode(1);
const key = 'cwmod_saved_chat'; const key = 'cwmod_saved_chat';
@@ -1010,7 +1022,8 @@ function changeChatPage() {
}); });
} }
function changeCW3Page() { // Coordinates the full feature set for the CW3 game layout.
function changeCW3Page() {
const menu = $('.small').first(); const menu = $('.small').first();
//const isMale = /Мой кот/.test(menu.text()); //const isMale = /Мой кот/.test(menu.text());
const target = globals.newPageMenu ? 'target="_blank"' : ''; const target = globals.newPageMenu ? 'target="_blank"' : '';
@@ -1484,6 +1497,7 @@ input, select { background-color: var(--input-bg) !important; color: var(--input
let isSnow = false; let isSnow = false;
let sky = null; let sky = null;
// Creates one animated snow layer for the seasonal effect.
function snow() { function snow() {
console.log("Создаем снежинку"); console.log("Создаем снежинку");
const randomSnowflake = snowSVG[Math.floor(Math.random() * snowSVG.length)]; const randomSnowflake = snowSVG[Math.floor(Math.random() * snowSVG.length)];
@@ -1518,6 +1532,7 @@ input, select { background-color: var(--input-bg) !important; color: var(--input
$('body').append(snowflakeDiv); $('body').append(snowflakeDiv);
} }
// Starts the seasonal animation loop for snow layers.
function runSnow() { function runSnow() {
console.log("Запускаем runSnow"); console.log("Запускаем runSnow");
snow(); snow();
@@ -1795,7 +1810,8 @@ input, select { background-color: var(--input-bg) !important; color: var(--input
} }
} }
function snow() { // Builds the alternate snow implementation for the legacy layout.
function snow() {
const id = Date.now() const id = Date.now()
, flake = 'https://porch.website/cwmod/snow/' + Math.ceil(Math.random() * 20) + '.png' , flake = 'https://porch.website/cwmod/snow/' + Math.ceil(Math.random() * 20) + '.png'
, pos_x = Math.ceil(Math.random() * 98) , pos_x = Math.ceil(Math.random() * 98)
@@ -1822,7 +1838,8 @@ function snow() {
}); });
} }
function changeFaePage() { // Enhances the fairy/resource page with configured display adjustments.
function changeFaePage() {
if (globals.enableFaeNotes) { if (globals.enableFaeNotes) {
const observer = new MutationObserver(function(mutations) { const observer = new MutationObserver(function(mutations) {
mutations.forEach(function() { mutations.forEach(function() {
@@ -1858,11 +1875,13 @@ function changeFaePage() {
} }
} }
function changeIdeasPage() { // Enhances the ideas page with filtering and presentation helpers.
function changeIdeasPage() {
addCSS(`.vote[style="color:#000"] { color: inherit !important; } .idea { color: black; } .idea a, .idea a:hover { color: #005 !important; }`); addCSS(`.vote[style="color:#000"] { color: inherit !important; } .idea { color: black; } .idea a, .idea a:hover { color: #005 !important; }`);
} }
function changeIndexPage() { // Enhances the index page with configured navigation shortcuts.
function changeIndexPage() {
let css = ` let css = `
#act_name b { color: black; } #act_name b { color: black; }
#info { color: black; background: rgba(255, 255, 255, 0.5); } #info { color: black; background: rgba(255, 255, 255, 0.5); }
@@ -1880,7 +1899,8 @@ function changeIndexPage() {
if (globals.indexSaveAlert) addSaveAlert(); if (globals.indexSaveAlert) addSaveAlert();
} }
function activityCalc(catId) { // Calculates and displays activity timing information for a cat.
function activityCalc(catId) {
const actStages = [{ const actStages = [{
name: 'пустое место' name: 'пустое место'
, fromZero: -5000 , fromZero: -5000