Forum version : Phpbb2
Position : Administrator
Concerned browser(s) : Google Chrome
Who the problem concerns : all
Forum link : http://gamemunity.team-talk.net/
So i want similar to youtube button but i want to add html code because youtube videos so i made this code but its kinda wrong ( im learning javascript im not that good xD) so here's the code i have:
I need some help to finish
Position : Administrator
Concerned browser(s) : Google Chrome
Who the problem concerns : all
Forum link : http://gamemunity.team-talk.net/
So i want similar to youtube button but i want to add html code because youtube videos so i made this code but its kinda wrong ( im learning javascript im not that good xD) so here's the code i have:
- Code:
$(function() {
if ($.sceditor) {
$.sceditor.command.set("vid-facebook", {
// drop down
_dropDown: function(editor, caller, handleIdFunc) {
var matches, content = $('<div><div><label for="youtubeurl">' + editor._("URL:") + '</label> <input type="text" id="youtubeurl" class="url" placeholder="http://" value="" /></div><div><input type="button" value="' + editor._("Insert") + '" class="button"></div>');
content.find('.button').click(function(e) {
var val = content.find("#youtubeurl").val().replace("http://", "");
if (val !== "") {
matches = val.match(/(?:v=|v\/|embed\/|youtu.be\/)(.{11})/);
if (matches) {
val = matches[1]
}
if (/^[a-zA-Z0-9_\-]{11}$/.test(val)) {
handleIdFunc(val)
} else {
alert(editor._('Invalid YouTube video'))
}
}
editor.closeDropDown(true);
e.preventDefault()
});
editor.createDropDown(caller, "insertlink", content)
},
// wysiwyg mode
exec: function(caller) {
var editor = this;
$.sceditor.command.get('vid-facebook')._dropDown(editor, caller, function(id) {
editor.wysiwygEditorInsertHtml('<iframe width="560" height="315" src="http://www.youtube.com/embed/' + id + '?wmode=opaque" data-youtube-id="' + id + '" frameborder="0" allowfullscreen></iframe>')
})
},
// source mode
txtExec : function(caller) {
var editor = this;
$.sceditor.command.get('vid-facebook')._dropDown(editor, caller, function(id) {
editor.insert('[youtube]' + id + '[/youtube]')
})
},
tooltip: "Insert a YouTube video"
});
// add button to editor toolbar
toolbar += ',vid-facebook';
}
});
I need some help to finish