<script type="text/javascript">
var parser = new Sakura.AJAX(),
textMax = {{ maxLength }},
form = document.getElementById("settingsEditor"),
preview = document.getElementById("settingsPreview");
parser.SetUrl("{{ route('helper.bbcode.parse') }}");
parser.ContentType("application/x-www-form-urlencoded");
function settingsPreview() {
var text = form.value;
if (text.length == 0) {
preview.innerHTML = "";
} else if (text.length > textMax) {
preview.innerHTML = "<span style='color: red;'>Too long!</span>";
} else {
parser.SetSend({"text":text});
parser.AddCallback(200, function () {
preview.innerHTML = parser.Response();
var codeBlocks = preview.querySelectorAll("pre code");
for (var _i in codeBlocks) {
if ((typeof codeBlocks[_i]).toLowerCase() === 'object') {
hljs.highlightBlock(codeBlocks[_i]);
}
});
parser.Start(Sakura.HTTPMethod.POST);
</script>