(2016-09-17, 09:26 PM)alley Wrote: [ -> ]Does not work
Try the Event code again, it should work now.
I had to change it again since it was missing the for() loop. (I had a real trouble posting the code initially with constant anti-flood/bot/spam popping up from cloudflare every edit :/)
(2016-09-18, 03:50 AM)stryderunknown Wrote: [ -> ] (2016-09-17, 09:26 PM)alley Wrote: [ -> ]Does not work
Try the Event code again, it should work now.
I had to change it again since it was missing the for() loop. (I had a real trouble posting the code initially with constant anti-flood/bot/spam popping up from cloudflare every edit :/)
I did not use the eventhandler code, I used this one:
<script>
if (! url2media){
// don't edit url2media variable if you have the script exist multiple times in a page
var url2media="1";
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
if (links[i].href.search("mp3") !== -1) {
links[i].outerHTML ='<video id="mediamp3" controls=""><source src="'+links[i]+'" type="audio/mpeg"></video>';
}
}
</script>
Okay I can see the error (sorry for the inconvenience). It's part to do with my attempt to stop the code being created too many times and part to do with how javascript handles if !(variable)
So rather than using the original method I was trying to do, it's simpler just to use the eventhandler version as it will only call once, even if there are multiple issues of code inserted and it will be called when the document is loaded, so you could insert it nearly anywhere in a template.
If you check the
post with original code, I've edited it to reflect the changes (rather than keep quoting similar code multiple times)
Hey, thanks so much @stryderunknown ... it works!
stryderunknownstryderunknownstryderunknown
@stryderunknown
This is great, but I noticed that this code seems to put the mp3 player way down at the bottom of the post. Is there a way to have it display the mp3 player at the top of the post?
@Alley
Sorry for the delay in replying, Placement is done through the use of the CSS entry using a relative position and top/bottom/left/right adjustments.