Quantcast
Channel: User FoxInFlame - Stack Overflow
Viewing all articles
Browse latest Browse all 35

Answer by FoxInFlame for Minecraft Color Formatting

$
0
0

Recently I was creating a website for a Minecraft Server, and I ran into the same problem as you. Because I couldn't find a easy solution, I made myself a simple JS library.

It is not the one you linked, but it is a library I made in about 10 minutes.Link: Click Here for Github Link

The Usage is on the GitHub page, but I will also post it here...

var yourMOTD = "§d§lnerd.nu§8: §6§oCreative Rev 28";var myHTMLMotd = replaceColorCodes(yourMOTD);console.log(myHTMLMotd);

EDIT: The function replaceColorCodes has been changed by me in Version 3.0. Now the function needs to have the MOTD, and the output div ID.

The JavaScript function now is as the following:

var yourMOTD = "§d§lnerd.nu§8: §6§oCreative Rev 28";

replaceColorCodes(yourMOTD, "outputDiv");

The HTML:

<div id="outputDiv"></div>

Basically, you just place the string of your MOTD in the function, and you're done.

Hope this library helped you, and will help many more people seeking to do the same thing.

Example Snippet:

function changeColor() {  var yourMOTD = document.getElementById("myLittleInputThing").value;  replaceColorCodes(yourMOTD, "myLittleOutputThing");}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script src="https://cdn.rawgit.com/FoxInFlame/MinecraftColorCodes/master/MinecraftColorCodes.3.0.js"></script><input placeholder="Place your Minecraft text here" id="myLittleInputThing" /><button onclick="changeColor();">Go!</button><p id="myLittleOutputThing">Output is going to come here</p>

Viewing all articles
Browse latest Browse all 35

Trending Articles