yahoo api yql

In this example below you will see how to do a yahoo api yql with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by DenVdmj, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright DenVdmj ©
  • HTML
  • CSS
  • JavaScript
    <pre><code class="lang-javascript"></code></pre>
<script>
((qs, sel) => {
  document.addEventListener('DOMContentLoaded', e => {
    qs(sel).textContent = qs('body>script:not(src):last-of-type').textContent;
 		hljs.highlightBlock(qs(sel), hljs.tabReplace, false, true);
  });
})(sel => document.querySelector(sel), 'pre > code');
</script>

/*Downloaded from https://www.codeseek.co/DenVdmj/yahoo-api-yql-dMzWqp */
    @import url(https://be5invis.github.io/Iosevka/fonts.css);

:root, body, pre, code {
  font: 14px/1.5 'Condensed-Coding', 'IosevkaWEB', monospace;
  font-stretch: ultra-condensed;
  color: #fff;
}
body, ::-webkit-scrollbar {
  background: #1d1f21;
}
body {
  color: #fff;
}

@font-face {
  font-family: 'Condensed-Coding';
  font-style: normal;
  font-weight: 400;
  src: 
    url(https://cdn.rawgit.com/frantisek-sodomka-gomorrka/fonts/3063e30b/condensed-coding.r-webfont.woff2?raw=true) format('woff2'),
    url(https://cdn.rawgit.com/frantisek-sodomka-gomorrka/fonts/3063e30b/condensed-coding.r-webfont.woff?raw=true) format('woff'),
    url(https://cdn.rawgit.com/frantisek-sodomka-gomorrka/fonts/3063e30b/condensed-coding.r-webfont.ttf?raw=true) format('truetype');
}



/*Downloaded from https://www.codeseek.co/DenVdmj/yahoo-api-yql-dMzWqp */
    
var yql = {
  url: '//query.yahooapis.com/v1/public/yql?q=%s&format=json',
  get: function(query, callback) {
    this.ajax(this.format(this.url, query), callback);
  },
  ajax: function(url, callback) {
    var req = new window.XMLHttpRequest;
    req.onload = function(e) {
      try {
        callback(req);
      } catch (err) {
        setTimeout(function(err) {
          throw err;
        }, 0, err);
      }
    };
    req.open('GET', url, true);
    req.send();
  },
  format: function(string) {
    var argv = arguments, i = 1;
    return string.replace(/\%s/g, function(_, pos) {
      return argv[i++];
    });
  }
};



Comments