docs: explain shared CatWar page helpers

This commit is contained in:
nyan404 committed 2026-08-25 04:28:15 +03:00
1 parent 67688052bd
commit 80b107cad3
1 file changed
+15
+15
View File
@@ -120,6 +120,7 @@
window.localStorage.removeItem(setting);
}
// Resets selected preferences to defaults and persists the resulting object.
function resetSettings(settingsToReset) {
for (var i = 0; i < settingsToReset.length; i++) {
let key = settingsToReset[i];
@@ -209,6 +210,7 @@
window.console.error('Варомод:', err);
}
// Writes the current settings object to the userscript storage backend.
function updateStorage() {
// 2.0
Object.keys(window.localStorage).forEach(function(key) {
@@ -227,6 +229,7 @@
});
}
// Applies common navigation and style enhancements across page types.
function changeAllPages() {
const white = $('body > span').first();
if (white.length) {
@@ -384,6 +387,7 @@
});
}
// Displays a temporary informational or error popup using the requested style.
function showCwmodPopup(type, text) {
$('#cwmod-popup-wrap').removeClass().addClass(type);
$('#cwmod-popup-text').html(text);
@@ -392,6 +396,7 @@
}
}
// Initializes the moon-age calculator form and its date conversions.
function moonCalc() {
if (!$('#info').length) return;
addCSS(`.calc-error { color: darkred; }`);
@@ -462,10 +467,12 @@
});
}
// Returns the grammatically correct Russian word for a moon count.
function updateMoonWord(moons) {
$('#moon-word').html(declOfNum(moons, ['луна', 'луны', 'лун']));
}
// Calculates elapsed moon cycles between two YYYY-MM-DD dates.
function getMoonsFromDate(birthDateString, dateString) {
const birthday = Date.parse(birthDateString);
const date = Date.parse(dateString);
@@ -473,6 +480,7 @@
return moons;
}
// Calculates the calendar date reached after a number of moon cycles.
function getDateStringFromMoons(birthDateString, moons) {
const birthday = Date.parse(birthDateString);
const age = Math.round(convertTime('d ms', moons * 4));
@@ -569,6 +577,7 @@
});
}
// Enhances the CatWar main page and mounts its configurable controls.
function changeMainPage() {
$('#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>`);
@@ -583,6 +592,7 @@
});
}
// Enhances a cat view/profile page with configured metadata and actions.
function changeViewPage() {
const p = $('#send_comment_form > p:last-child');
p.prepend(`<input type="button" id="comment-preview" value="Предпросмотр"> `);
@@ -676,11 +686,13 @@
});
}
// Removes the expanded comment preview from the blog composer.
function hideCommentPreview() {
$('#comment-preview-hide').hide();
$('#comment-preview-div').empty().hide();
}
// Adds configured formatting, avatars, and reply behavior to comments.
function changeComments() {
addAnswerButtons();
if (globals.blogAvatars) {
@@ -688,6 +700,7 @@
}
}
// Resolves commenter IDs and inserts their avatar thumbnails into rows.
function addCommentAvatars() {
$('.view-comment:not(.has-avatar)').each(function() {
$(this).prepend('<div class="comment-avatar"></div>');
@@ -710,6 +723,7 @@
});
}
// Adds reply buttons that prefill the comment composer with a citation.
function addAnswerButtons() {
const answerButton = isDesktop ? 'Ответить' : '🗨';
const citeButton = isDesktop ? 'Цитировать' : '💬';
@@ -730,6 +744,7 @@
});
}
// Inserts a selected comment quote and author reference into the editor.
function answerComment(comment, cite, selectionInfo) {
const commentInfo = comment.children('.comment-info');
const num = commentInfo.children('b').children('.num').text();