Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: AJAX chat, JS question  (Read 2980 times)

0 Members and 1 Guest are viewing this topic.

neljan

    Topic Starter


    Adviser

    Thanked: 1
    • Yes
  • Experience: Familiar
  • OS: Windows XP
AJAX chat, JS question
« on: October 14, 2009, 11:10:27 PM »
Hello,

(sorry, nub here)

I'd like to implement a BB Code button into my AJAX Chat (php/js chatbox) whereby a video is played within the chat using [VIDEO] tags, as one would similarly use [IMG] tags to display an image within the chat.

I've found where I need to add the JS code, and I have the HTML replacement code (which I use in my PHPBB forum) I just need to know what JS code I add to the chats JS file?

To give you a better idea, heres the chats JS [IMG] code:

Code: [Select]
replaceBBCodeImage: function(url) {
if(this.settings['bbCodeImages']) {
if (!arguments.callee.regExpUrl) {
arguments.callee.regExpUrl = new RegExp(
this.regExpMediaUrl,
''
);
}
if(!url || !url.match(arguments.callee.regExpUrl))
return url;
url = url.replace(/\s/gm, this.encodeText(' '));
var maxWidth = this.dom['chatList'].offsetWidth-50;
var maxHeight = this.dom['chatList'].offsetHeight-50;
return '<a href="'
+url
+'" onclick="window.open(this.href); return false;">'
+'<img class="bbCodeImage" style="max-width:'
+maxWidth
+'px; max-height:'
+maxHeight
+'px;" src="'
+url
+'" alt="" onload="ajaxChat.updateChatlistView();"/></a>';
}
return url;
},

Heres what I added, using the [IMG] as a sort of template:

Code: [Select]
replaceBBCodeVideo: function(url) {
if(this.settings['bbCodeVideo']) {
if (!arguments.callee.regExpUrl) {
arguments.callee.regExpUrl = new RegExp(
this.regExpMediaUrl,
''
);
}
if(!url || !url.match(arguments.callee.regExpUrl))
return url;
url = url.replace(/\s/gm, this.encodeText(' '));
var maxWidth = this.dom['chatList'].offsetWidth-50;
var maxHeight = this.dom['chatList'].offsetHeight-50;
return '<a href="'
+url
+'" onclick="window.open(this.href); return false;">'
+'<img class="bbCodeVideo" style="max-width:'
+maxWidth
+'px; max-height:'
+maxHeight
+'px;" src="video.php?link={URL}">'
+url
+'" alt="" onload="ajaxChat.updateChatlistView();"/></a>';
}
return url;
},

And heres the HTML replacement that I'd like to implement somehow:

Code: [Select]
<script type="text/javascript" src="video.php?link={URL}"></script>
the BBcode buttons are all ready, the [VIDEO] tags are displayed in chat when I hit the button and everything, I just need to figure out where/how to add the HTML replacement.

Thanks for any help :)

« Last Edit: October 16, 2009, 01:08:37 AM by neljan »