From Our World of Text Wiki
Jump to navigation
Jump to search
Our World Of Text
Code Documentation
OWOT.js
Functions:
Variables:
Name
|
Description
|
Example Usage
|
Code
|
YourWorld
|
An object containing the users current text color, cell background color, and chat nick name.
|
//Sets the users color to a random one.
YourWorld.Color = Math.round((Math.random()*16777215));
|
var YourWorld = {
Color: window.localStorage ? +localStorage.getItem("color") : 0,
BgColor: -1,
Nickname: state.userModel.username
};
|
owot
|
The DOM canvas element
|
//Hides the owot canvas.
owot.style.opacity = 0;
|
owot = document.getElementById("owot");
|
owotCtx
|
The CanvasRenderingContext2D of the owot canvas
|
//Clears all the rendered tiles from the view.
owotCtx.clearRect(0, 0, owotWidth, owotHeight);
|
owotCtx = owot.getContext("2d");
|
textInput
|
The DOM textarea element used for writing to the owot canvas.
|
//Paste "hello world" at the current cursor position.
textInput.value = `hello world`;
|
textInput = document.getElementById("textInput");
|
linkElm
|
The DOM link element used for user link clicks.
|
//logs to the console whether or not the link is a javascript link.
linkElm.addEventListener(`click`,function(){
console.log(linkParams.protocol === `javascript`);
})
|
linkElm = elm.link_element;
|
link_div
|
The DOM link div element used to scale the linkElm to the same size as a cell within the owot canvas.
|
//Highlights the URL being hovered over.
linkDiv.style.background = `rgba(255,255,0,0.5)`
|
|
colorInput, colorInputBg
|
The DOM color inputs to select text and cell background color.
|
//Generate a random color on the text color input field.
const randomColor = Math.floor(Math.random()*16777215).toString(16).toUpperCase();
colorInput.jscolor.fromString(`#${randomColor}`);
|
colorInputBg = modal.addEntry("Cell color", "color").input;
colorInput = modal.addEntry("Text color", "color").input;
|
colorShortcuts, colorShortcutsBg
|
A DOM div container used as a color pallet for quick access.
|
//Randomize all color palette colors.
const colorButtons = colorShortcuts.querySelectorAll('.color_btn');
colorButtons.forEach(button => {
if (button.title !== 'Random color') {
const randomColor = `#${Math.floor(Math.random()*16777215).toString(16).toUpperCase()}`;
button.style.backgroundColor = randomColor;
button.title = randomColor;
}
});
|
for(var i = 0; i < colors.length; i++) {
var color = colors[i];
colorShortcuts.appendChild(createColorButton(color));
}
|