|
346 | 346 | visual : false, //Show/hide the big preview image |
347 | 347 | download : false //Show/Hide download buttons |
348 | 348 | }, |
| 349 | + twitchtvEmbed:true, |
349 | 350 | beforePdfPreview : function () { //callback before pdf preview |
350 | 351 | }, |
351 | 352 | afterPdfPreview : function () { //callback after pdf preview |
|
420 | 421 | return a; |
421 | 422 | }; |
422 | 423 |
|
423 | | - /** |
424 | | - * FUNCTION insertfontSmiley |
425 | | - * @description |
426 | | - * Coverts the text into font emoticons |
427 | | - * |
428 | | - * @param {string} str |
429 | | - * |
430 | | - * @return {string} |
431 | | - */ |
432 | | - |
433 | | - function insertfontSmiley(str) { |
434 | | - var a = str.split(' '); |
435 | | - icons.forEach(function (icon) { |
436 | | - for (var i = 0; i < a.length; i++) { |
437 | | - if (a[i] === icon.text) { |
438 | | - a[i] = '<span class="icon-emoticon" title="' + icon.text + '">' + '&#x' + icon.code + '</span>'; |
| 424 | + var emoticonProcess={ |
| 425 | + insertfontSmiley:function(str){ |
| 426 | + var a = str.split(' '); |
| 427 | + icons.forEach(function (icon) { |
| 428 | + for (var i = 0; i < a.length; i++) { |
| 429 | + if (a[i] === icon.text) { |
| 430 | + a[i] = '<span class="icon-emoticon" title="' + icon.text + '">' + '&#x' + icon.code + '</span>'; |
| 431 | + } |
439 | 432 | } |
440 | | - } |
441 | | - }); |
442 | | - return a.join(' '); |
443 | | - } |
444 | | - |
445 | | - /** |
446 | | - * FUNCTION UrlEmbed |
447 | | - * @description |
448 | | - * Converts normal links written in the text into html anchor tags. |
449 | | - * |
450 | | - * @param {string} text |
451 | | - * |
452 | | - * @return {string} |
453 | | - */ |
| 433 | + }); |
| 434 | + return a.join(' '); |
| 435 | + }, |
454 | 436 |
|
| 437 | + insertEmoji:function(str){ |
| 438 | + var emojiRegex = new RegExp(':(' + emojiList.join('|') + '):', 'g'); |
| 439 | + return str.replace(emojiRegex, function (match, text) { |
| 440 | + return '<span class="emoticon emoticon-' + text + '" title=":' + text + ':"></span>'; |
| 441 | + }); |
| 442 | + } |
| 443 | + }; |
455 | 444 |
|
456 | 445 | function urlEmbed(str) { |
457 | 446 | var urlRegex = /((href|src)=["']|)(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; |
|
466 | 455 | return strReplaced; |
467 | 456 | } |
468 | 457 |
|
469 | | - /** |
470 | | - * FUNCTION insertEmoji |
471 | | - * |
472 | | - * @description |
473 | | - * Converts text into emojis |
474 | | - * |
475 | | - * @param {string} str |
476 | | - * |
477 | | - * @return {string} |
478 | | - */ |
479 | | - function insertEmoji(str) { |
480 | | - var emojiRegex = new RegExp(':(' + emojiList.join('|') + '):', 'g'); |
481 | | - return str.replace(emojiRegex, function (match, text) { |
482 | | - return '<span class="emoticon emoticon-' + text + '" title=":' + text + ':"></span>'; |
483 | | - }); |
484 | | - } |
485 | | - |
486 | 458 | var videoTemplate = ''; |
487 | 459 |
|
488 | 460 | function initVideoTemplate() { |
|
628 | 600 | str = str + template; |
629 | 601 | } |
630 | 602 | return str; |
| 603 | + }, |
| 604 | + |
| 605 | + twitchEmbed:function(rawStr,str,opts){ |
| 606 | + var twitchRegex=/www.twitch.tv\/([a-zA_Z0-9_]+)/gi; |
| 607 | + var matches=rawStr.match(twitchRegex)?rawStr.match(twitchRegex).getUnique():null; |
| 608 | + var videoDimensions=this.dimensions(opts); |
| 609 | + if(matches){ |
| 610 | + console.log(matches); |
| 611 | + console.log(RegExp.$1); |
| 612 | + var i=0; |
| 613 | + while(i<matches.length){ |
| 614 | + str=str+'<div class="ejs-video"><object bgcolor="#000000" data="//www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf" height="'+videoDimensions.height+'" id="clip_embed_player_flash" type="application/x-shockwave-flash" width="'+videoDimensions.width+'">'+ |
| 615 | + '<param name="movie" value="http://www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf" />'+ |
| 616 | + '<param name="allowScriptAccess" value="always" />'+ |
| 617 | + '<param name="allowNetworking" value="all" />'+ |
| 618 | + '<param name="allowFullScreen" value="true" />'+ |
| 619 | + '<param name="flashvars" value="channel='+matches[i].split('/')[1]+'&auto_play=false" />'+ |
| 620 | + '</object></div>'; |
| 621 | + i++; |
| 622 | + } |
| 623 | + } |
| 624 | + return str; |
631 | 625 | } |
632 | 626 | }; |
633 | 627 |
|
|
886 | 880 | var rawInput=input; |
887 | 881 |
|
888 | 882 | input = (settings.link) ? urlEmbed(input) : input; |
889 | | - input = insertfontSmiley(input); |
890 | | - input = insertEmoji(input); |
| 883 | + input = emoticonProcess.insertfontSmiley(input); |
| 884 | + input = emoticonProcess.insertEmoji(input); |
891 | 885 | input = (settings.pdfEmbed) ? pdfProcess.embed(rawInput,input) : input; |
892 | 886 | input = (settings.audioEmbed) ? audioProcess.basicEmbed(rawInput,input) : input; |
893 | 887 | input = (settings.highlightCode) ? codeProcess.highlight(input) : input; |
|
897 | 891 | input = (settings.jsfiddleEmbed) ? codeEmbedProcess.jsfiddleEmbed(rawInput,input, settings) : input; |
898 | 892 | input = (settings.jsbinEmbed) ? codeEmbedProcess.jsbinEmbed(rawInput,input, settings) : input; |
899 | 893 | input = (settings.soundCloudEmbed) ? audioProcess.soundCloudEmbed(rawInput,input, settings) : input; |
| 894 | + input=(settings.twitchtvEmbed)?videoProcess.twitchEmbed(rawInput,input,settings):input; |
900 | 895 |
|
901 | 896 | videoProcess.embed(input, settings).then( |
902 | 897 | function (d) { |
|
0 commit comments