Больше дополнений

This commit is contained in:
2023-03-27 17:25:05 +04:00
parent f9cbc4461d
commit 8f79ec7f1b
6 changed files with 523 additions and 264 deletions
+58
View File
@@ -0,0 +1,58 @@
import { Joke, JokeSettings, StopableJoke } from "../joke";
import $ from "jquery";
/**
* **Бешеные запятые**
*
* Запятые после слов
*
* @author Kozhilya
*/
export class CrazyPunctuationJoke extends Joke {
settings: CrazyPunctuationJokeSettings;
private transform(text: string): string {
let newText = "";
for (let i = 0; i < text.length; i++) {
const currentChar = text[i];
const nextChar = text[i + 1];
if (this.settings.symbols.includes(currentChar)) {
newText += currentChar;
} else if (nextChar === " " || this.settings.symbols.includes(nextChar)) {
newText += currentChar;
}
}
return newText;
}
private process(node): void {
}
start(): void {
const items = $(this.settings.selector).find('*').contents().filter((_, node) => node.nodeType === Node.TEXT_NODE);
items.each((_, node) => {
console.log(node);
})
}
}
export class CrazyPunctuationJokeSettings implements JokeSettings {
chance: number = 20;
/**
* Селектор всех элементов, которые будут затронуты
*/
selector: string = '.post-content';
/**
* Мигрирующие знаки
*/
symbols: string = ',.;:?!-()[]{}\'"';
}
-1
View File
@@ -14,7 +14,6 @@ export class MirrorJoke extends Joke {
start(): void {
$('.post, .post h3, .post-links, .post-author, .post-content')
.css('transform', 'scaleX(-1)').css('-moz-transform', 'scaleX(-1)').css('-moz-transform', 'scaleX(-1)').css('filter', 'FlipH').css('-ms-filter', '"FlipH"');
$('#pun-title #title-logo').animate('')
$('.post-links, .post-links ul, .post h3 span').css('margin-left', '0');
$('.post h3 span').css('margin-right', '25em');
}
+10
View File
@@ -1,6 +1,11 @@
import { AprilFoolsJokeClass } from "./handler";
import { Joke } from "./joke";
import { ShakeJoke } from "./jokes/shake";
import { HumanitarianHellJoke } from "./jokes/humanitarian_hell";
import { MirrorJoke } from "./jokes/mirror";
import { CarnivalJoke } from "./jokes/carnival";
import { CrazyLettersJoke } from "./jokes/crazy_letters";
import { CrazyPunctuationJoke } from "./jokes/crazy_punctuation";
(window as any).AprilJokes = ((jokes: JokeClassList): AprilFoolsJokeClass => {
const cl = new AprilFoolsJokeClass();
@@ -12,6 +17,11 @@ import { ShakeJoke } from "./jokes/shake";
return cl;
})([
ShakeJoke,
HumanitarianHellJoke,
MirrorJoke,
CarnivalJoke,
CrazyLettersJoke,
CrazyPunctuationJoke,
]);
interface JokeClassList extends Array<new () => Joke> {}