Created
August 5, 2015 23:42
-
-
Save stpettersens/27dc5163b63ebca8dd53 to your computer and use it in GitHub Desktop.
Long string formatter tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function format() { | |
var text = document.getElementById('formatter').value; | |
text = '\'' + text + '\'' | |
i = 0 | |
x = 1 | |
var newText = ''; | |
for(var i = 0; i < text.length; i++) { | |
if(x == 40) { | |
newText += text[i] + '\'+\''; | |
x = 1; | |
} | |
else { | |
newText += text[i]; | |
} | |
x++; | |
} | |
var formatter = document.getElementById('formatter') | |
formatter.value = ''; | |
formatter.value = newText; | |
} | |
</script> | |
<textarea id="formatter" rows="50", cols="140"> | |
</textarea><br/> | |
<button onclick="format();">Format</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment