Explorar el Código

fix oembed for non-successful requests.

Lucas Stadler %!s(int64=11) %!d(string=hace) años
padre
commit
658acc23cb
Se han modificado 1 ficheros con 1 adiciones y 2 borrados
  1. 1 2
      js/babl/public/index.html

+ 1 - 2
js/babl/public/index.html

45
				var xhr = new XMLHttpRequest();
45
				var xhr = new XMLHttpRequest();
46
				xhr.open('GET', oembedEndpoint + '?format=json&maxwidth=450&url=' + url);
46
				xhr.open('GET', oembedEndpoint + '?format=json&maxwidth=450&url=' + url);
47
				xhr.onreadystatechange = function() {
47
				xhr.onreadystatechange = function() {
48
					if (xhr.readyState == XMLHttpRequest.DONE) {
49
						console.log(url, xhr.status);
48
					if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
50
						var tmpEl = document.createElement('div');
49
						var tmpEl = document.createElement('div');
51
						tmpEl.innerHTML = JSON.parse(xhr.responseText).html;
50
						tmpEl.innerHTML = JSON.parse(xhr.responseText).html;
52
						el.parentElement.replaceChild(tmpEl.firstChild, el);
51
						el.parentElement.replaceChild(tmpEl.firstChild, el);