Fix Asciinema plugin

This commit is contained in:
Lorenz Hübschle-Schneider 2015-02-08 11:16:55 +01:00
parent 6522cd72d3
commit 18c0db6c4f
1 changed files with 13 additions and 7 deletions

View File

@ -312,15 +312,21 @@ plugins.factory('userPlugins', function() {
/*
* Asciinema plugin
*/
var asciinemaPlugin = new Plugin(function(message) {
var regexp = /^https?:\/\/(www\.)?asciinema.org\/a\/(\d+)/;
var match = message.match(regexp);
var asciinemaPlugin = new Plugin(urlPlugin(function(url) {
var regexp = /^https?:\/\/(?:www\.)?asciinema.org\/a\/(\d+)/i;
var match = url.match(regexp);
if (match) {
var id = match[3];
return "<script type='text/javascript' src='https://asciinema.org/a/" + id + ".js' id='asciicast-" + id + "' async></script>";
var id = match[1];
return function() {
var element = this.getElement();
var scriptElem = document.createElement('script');
scriptElem.src = 'https://asciinema.org/a/' + id + '.js';
scriptElem.id = 'asciicast-' + id;
scriptElem.async = true;
element.appendChild(scriptElem);
};
}
});
}));
asciinemaPlugin.name = "ascii cast";
var yrPlugin = new Plugin(