$(function () { if ($('#wmd-button-row').length > 0) { $('#wmd-button-row').append('
  • '); } $(document).on('click', '#wmd-meting-button', function () { $('body').append( '
    ' + '
    ' + '
    ' + '
    ' + '

    插入视频

    ' + '

    在下方输入参数

    ' + '

    ' + '

    ' + '

    ' + '

    开启弹幕

    ' + '

    自动播放

    ' + '
    ' + '
    ' + '' + '' + '
    ' + '
    ' + '
    '); }); //cancel $(document).on('click', '#cancel', function () { $('#DPlayer-Panel').remove(); $('textarea').focus(); }); //ok $(document).on('click', '#ok', function () { var DP_url = document.getElementById('DP-url').value, DP_pic = document.getElementById('DP-pic').value, DP_danmu = document.getElementById('DP-danmu').checked ? true : false, DP_autoplay = document.getElementById('DP-autoplay').checked ? true : false, DP_addition = document.getElementById('DP-addition').value; var tag = '[dplayer url="' + DP_url + '" pic="' + DP_pic + '" '; if (!DP_danmu) tag += 'danmu="' + DP_danmu + '" '; if (DP_autoplay) tag += 'autoplay="' + DP_autoplay + '" '; if (DP_addition) tag += 'addition="' + DP_addition + '" '; tag += '/]\n'; myField = document.getElementById('text'); if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = tag; myField.focus(); } else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; var cursorPos = startPos; myField.value = myField.value.substring(0, startPos) + tag + myField.value.substring(endPos, myField.value.length); cursorPos += tag.length; myField.focus(); myField.selectionStart = cursorPos; myField.selectionEnd = cursorPos; } else { myField.value += tag; myField.focus(); } $('#DPlayer-Panel').remove(); }) });