Bladeren bron

support for soundcloud embeds via oembed.

nice.
Lucas Stadler 11 jaren geleden
bovenliggende
commit
31508c0d96
1 gewijzigde bestanden met toevoegingen van 23 en 0 verwijderingen
  1. 23 0
      js/babl/public/index.html

+ 23 - 0
js/babl/public/index.html

48
					return el;
48
					return el;
49
				}
49
				}
50
			}, {
50
			}, {
51
				re: /https?:\/\/.*soundcloud.com\/.*/,
52
				fn: function(match, msgEl) {
53
					var el = document.createElement('a');
54
					el.href = match[0];
55
					el.textContent = match[0];
56
57
					var xhr = new XMLHttpRequest();
58
					xhr.open('GET', 'https://soundcloud.com/oembed?format=json&maxwidth=450&maxheight=315&url=' + match[0]);
59
					xhr.onreadystatechange = function() {
60
						if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
61
							var data = JSON.parse(xhr.responseText);
62
63
							var tmpEl = document.createElement("div");
64
							tmpEl.innerHTML = data.html;
65
66
							msgEl.replaceChild(tmpEl.firstChild, el);
67
						}
68
					}
69
					xhr.send();
70
71
					return el;
72
				}
73
			}, {
51
				re: /https?:\/\/vimeo.com\/([0-9]+).*/,
74
				re: /https?:\/\/vimeo.com\/([0-9]+).*/,
52
				fn: function(match) {
75
				fn: function(match) {
53
					var el = document.createElement("iframe");
76
					var el = document.createElement("iframe");