Hi,
I’m trying to create a custom BBCode for a HTML5 slideshow (Monokai's Monoslideshow) from post attachments, media gallery and img.
In the HTML Replacement, I have the following code:
The code is handling uploaded attachment, media gallery and img.
When I try to post with the BBCode tag that I have created, the browser hangs and do not stop loading.
But if I stop the loading manually, and refresh/re-enter the thread URL, the replacement has been handled and the slideshow is displaying. Is this lag/hang a result of using javascript in the HTML Replacement?
I’m trying to create a custom BBCode for a HTML5 slideshow (Monokai's Monoslideshow) from post attachments, media gallery and img.
In the HTML Replacement, I have the following code:
Code:
<script type="text/javascript" src="../monoslideshow.js"></script>
<script type="text/javascript">
var param = '{text}';
var attroot = 'http://<domain.com>/forum/index.php?attachments/';
var gallroot = 'http://<domain.com>/forum/index.php?media/';
var timestamp = Number(new Date());
var divid = 'postSlideshow_' + timestamp;
document.write('<div id="' + divid + '" style="width: 500px; height: 400px;"></div>');
String.prototype.replaceAll = function(target, replacement) {
return this.split(target).join(replacement);
};
param = param.replace(/\s+/g, '').replace(/\r?\n|\r/g, '').replaceAll('<br />', '');
param = param.replace(/(\[ATTACH\])([^\n\r[]*?)\[\/ATTACH\]/ig, ',' + attroot + '$2');
param = param.replace(/(\[IMG\])([^\n\r[]*?)\[\/IMG\]/ig, ',$2');
param = param.replace(/(\[GALLERY=media,)([0-9]+)\][^\n\r[]*?\[\/GALLERY\]/ig, ',' + gallroot + '$2/full');
param = param.split(",");
param.splice(0, 1);
var xmlimg = '';
var arrayLength = param.length;
for (var i = 0; i < arrayLength; i++) {
xmlimg += '<image source="' + param[i] + '" thumbnail="' + param[i] + '" title="" />';
}
var xml = '<?xml version="1.0" encoding="utf-8"?>' +
'<album>' +
'<configuration backgroundColor="#000000" delay="4" scaleMode="downscaleToFit">' +
'<transition performOutro="true" />' +
'<caption displayMode="never" />' +
'</configuration>' +
'<contents>' +
xmlimg +
'</contents>' +
'</album>';
var mss = new Monoslideshow(divid, { showLogo: false, showRegistration: false });
mss.loadXMLString(xml);
</script>
The code is handling uploaded attachment, media gallery and img.
When I try to post with the BBCode tag that I have created, the browser hangs and do not stop loading.
But if I stop the loading manually, and refresh/re-enter the thread URL, the replacement has been handled and the slideshow is displaying. Is this lag/hang a result of using javascript in the HTML Replacement?