(function(){ var h = function(t, e, n) { t.attachEvent ? t.attachEvent("on" + e, n) : t.addEventListener(e, n) }; var c = function(el, c) { if (el.getElementsByClassName) { return el.getElementsByClassName(c); } else { var r = []; var a = el.getElementsByTagName('*'); for (var i = 0; i < a.length; i++){ if (a[i].className == c){ r.push(a[i]); } } return r; } } var ajax = function(url, q, o) { var l = []; for (var k in q) { l.push(k + '=' + q[k]); } var u = url + '?' + l.join('&'); if (self.fetch) { fetch(u, { method: 'get', mode: 'cors' }) .then(function(r) { if (r.status === 200) { return r.json(); } else { console.error(r.statusText); } }) .then(function(json) { o(json); }) .catch(function (r) { console.error(r); }); } else { var r = new window.XMLHttpRequest(); r.open('get', u, true); r.responseType = 'json'; r.onload = function(e) { if (r.readyState === 4) { o(JSON.parse(r.response)); } else { console.error(r.statusText); } } r.onerror = function(e) { console.error(e.type); } r.send(null); } } var o = function() { var e = this; var q = { 'limit': e.getAttribute('data-limit') } ajax('https://page.nice-room.jp/api/rooms', q, function(t) { var r = t['rooms']; if (r == undefined) { console.error('JSON Parse error'); } var b = document.createElement('ul'); var max = r.length; for (var i = 0; i < max; i++) { var dat = r[i]; var img = '' if (dat['image']) { img = ''; } else { console.error('Could not fount Image'); } var title = dat['title']; if (title == '') { title = 'タイトルなし'; } var description = dat['description']; var l = document.createElement('li'); var a = document.createElement('a'); var html = ''; capture = ''; capture += '
' + img + '
'; capture += '
' + description + '
'; html += '
' + capture + '
'; html += '
' + title + '
'; a.innerHTML = html; a.setAttribute('href', dat['url']); a.setAttribute('target', '_blank'); l.appendChild(a); b.appendChild(l); } e.appendChild(b); }); } h(window,'load',function(){ var a = c(document,'niceroom-rooms'); var max = a.length; for (var i = 0; i < max; i++) { o.call(a[i]); } }); })(); (function(){ var link = document.createElement('link'); with(link){ type = 'text/css'; rel = 'stylesheet'; href = 'https://page.nice-room.jp/css/widgets.css'; } var head = document.getElementsByTagName('head'); head.item(0).appendChild(link); })();