Customizing Text & Content
Relevant source files
The following files were used as context for generating this wiki page:
The text and content management system centralizes all user-facing strings within a single configuration object. This architecture decouples the display logic from the HTML structure, allowing developers to modify messaging without altering the document framework. The system targets specific DOM elements and SweetAlert2 components to deliver a customized interactive experience.
Sources: js/myJs.js:1-15, index.html:43-52
Centralized Configuration Object
The application stores all textual content in the textConfig constant. This object maps unique keys to string values used across the landing page and interactive popups.
textConfig Mapping
The following table describes the keys used to populate the interface:
| Key | Usage Location | Description |
|---|---|---|
text1, text2 | Initial Popup | Title and body text for the first SweetAlert. |
text3, text4 | Main Header | Primary and secondary headings in the main content area. |
text5 | "No" Button | Label for the negative response button. |
text6 | "Yes" Button | Label for the positive response button. |
text7, text8 | Reason Popup | Question and button text for the follow-up modal. |
text9 | Input Trick | Predefined string injected during the text generation phase. |
text10, text11, text12 | Final Popup | Final message title, body, and confirmation button. |
Sources: js/myJs.js:1-15
Content Injection Logic
The application uses jQuery to inject content from textConfig into specific HTML elements during the initialization phase.
The diagram shows how the textConfig object distributes strings to various DOM elements and SweetAlert2 modals.
Sources: js/myJs.js:25-28, index.html:46-52
DOM Targeted Updates
When the document is ready, the script executes direct HTML replacements:
- The element
#text3receivestextConfig.text3. - The element
#text4receivestextConfig.text4. - The button
#noreceivestextConfig.text5. - The button
#yesreceivestextConfig.text6.
Sources: js/myJs.js:25-28
Dynamic Text Generation
The application implements a unique text injection feature in the "Reason" input field. This feature intercepts user keyboard input and replaces it with characters from textConfig.text9.
Implementation Details
When the user focuses on the #txtReason input, a setInterval function triggers the textGenerate() logic every 10 milliseconds.
function textGenerate() {
var n = "";
var text = " " + textConfig.text9;
var a = Array.from(text);
var textVal = $("#txtReason").val() ? $("#txtReason").val() : "";
var count = textVal.length;
if (count > 0) {
for (let i = 1; i <= count; i++) {
n = n + a[i];
}
}
$("#txtReason").val(n);
}
Sources: js/myJs.js:84-100, js/myJs.js:132-137
Visual Styling and Assets
The content presentation relies on external assets and CSS rules to maintain theme consistency.
Typography
The project uses the "Pacifico" font from Google Fonts for all header elements.
header h2uses a 80px font size.header h4uses centered alignment.- Media queries reduce
h2to 45px for screens smaller than 500px.
Sources: index.html:20, css/style.css:35-64
Media Integration
The interaction utilizes images and sound files referenced within the logic and styles:
- Background:
img/puung3.jpgis applied to the#bgelement with a 4px blur. - Modals:
img/cuteCat.jpgandimg/iput-bg.jpgserve as visual aids in popups. - Audio: Sound effects (
duck.mp3,Swish1.mp3,tick.mp3) provide feedback during content interactions.
Sources: css/style.css:17-29, js/myJs.js:34-37, js/myJs.js:47-48, js/myJs.js:105-106
Summary of Interaction Flow
The interaction sequence controls how text is revealed to the user:
The sequence diagram illustrates the lifecycle of text display from initial preloading to the final message.
Sources: js/myJs.js:18-43, js/myJs.js:104-140, css/spinload.css:1-55