Skip to content

Instantly share code, notes, and snippets.

@stpettersens
Created August 5, 2015 23:42
Show Gist options
  • Save stpettersens/27dc5163b63ebca8dd53 to your computer and use it in GitHub Desktop.
Save stpettersens/27dc5163b63ebca8dd53 to your computer and use it in GitHub Desktop.
Long string formatter tool
<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