This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/resources/views/yuuno/settings/account/_preview.twig

36 lines
1.1 KiB
Twig
Raw Permalink Normal View History

<script type="text/javascript">
2016-07-31 19:36:13 +00:00
var parser = new Sakura.AJAX(),
textMax = {{ maxLength }},
form = document.getElementById("settingsEditor"),
preview = document.getElementById("settingsPreview");
2016-07-31 19:36:13 +00:00
parser.SetUrl("{{ route('helper.bbcode.parse') }}");
2016-12-09 18:09:33 +00:00
parser.Form();
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 {
2016-07-31 19:36:13 +00:00
parser.SetSend({"text":text});
2016-07-31 19:36:13 +00:00
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]);
}
}
});
2016-07-31 19:36:13 +00:00
parser.Start(Sakura.HTTPMethod.POST);
}
}
</script>