cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="masthead">
    <div class="container">
      <h1 class="title">Instagram Photo <span class="red">&hearts;</span> Checker</h1>
      <p class="subtitle">
        Find out who liked your Instagram photos the most.
      </p>
    </div>
  </div>

  <div class="container">


    <div class="content">

      <form class="form-inline">
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">Instagram Username:</div>
            <input type="text" class="form-control" id="input" placeholder="e.g. heiswayi.nrird">
          </div>
        </div>
        <button type="submit" class="btn btn-primary" id="button">Check</button>
      </form>

      <div id="contents"></div>

    </div>


    <footer class="colophon">
      <p>&copy; <a href="https://heiswayi.github.io">Heiswayi Nrird</a></p>
    </footer>

  </div>
  <!-- /close container -->

  <div id="popover"></div>
            
          
!
            
              * {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
html,
body {
    margin: 0;
    padding: 0;
}
body {
    color: #515151;
    background-color: #fff;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    background: #f8f8f8;
}
a {
    color: #069;
    text-decoration: none;
}
a strong {
    color: inherit;
}
a:hover,
a:focus {
    text-decoration: underline;
}
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-bottom: .5em;
    font-weight: bold;
    line-height: 1.25;
    color: #313131;
    text-rendering: optimizeLegibility;
}
h1 {
    font-size: 2em;
}
h2 {
    margin-top: 1.5em;
    font-size: 1.5em;
}
h3 {
    margin-top: 1.5em;
    font-size: 1.25em;
}
h4,
h5,
h6 {
    margin-top: 1em;
    font-size: 1em;
}
p {
    margin-top: 0;
    margin-bottom: 1em;
}
strong {
    color: #303030;
}
ul,
ol,
dl {
    margin-top: 0;
    margin-bottom: 1em;
}
dt {
    font-weight: bold;
}
dd {
    margin-bottom: .5em;
}
hr {
    position: relative;
    margin: 1.5em 0;
    border: 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #fff;
}
.container {
    max-width: 800px;
    padding-left: 1em;
    padding-right: 1em;
    margin-left: auto;
    margin-right: auto;
}
.masthead {
    padding-top: 1em;
    padding-bottom: 1em;
    margin-bottom: 3em;
}
.masthead-title {
    margin-top: 0;
    margin-bottom: 0;
    color: #505050;
}
.masthead-title a {
    color: #505050;
}
.masthead-title small {
    font-size: 75%;
    font-weight: 400;
    color: #c0c0c0;
    letter-spacing: 0;
}
.content {
    margin-bottom: 1em;
}
iframe {
    border: 0;
}
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 400;
}
h2,
h3,
h4 {
    font-weight: 500;
}
.masthead {
    position: relative;
    padding: 2em 1em;
    font-weight: 300;
    color: rgba(255, 255, 255, .8);
    text-align: center;
    text-shadow: 0 1px 0 rgba(0, 0, 0, .1);
    background-color: #2c3e50;
}
.masthead a,
.masthead h1 {
    font-weight: 400;
    color: #fff;
}
.masthead h1 {
    margin-top: 0;
    margin-bottom: .25em;
    font-size: 3em;
    font-weight: 700;
}
@media (min-width: 768px) {
    .masthead {
        padding: 3em 0 4em;
    }
}
.top {
    text-align: center;
    margin: 2em auto 1em auto;
}
.colophon:before {
    display: block;
    content: '';
    height: 1px;
    margin: 2em auto;
    background-color: #ddd;
}
.colophon p {
    text-align: center;
    font-size: .75em;
    color: #999;
    margin-bottom: 2em;
}
.red {
    color: #e00;
}
#contents {
    margin-bottom: 150px;
}
#popover{
    position: absolute;
    background: white;
    display: none;
}
.alert {
    margin-top: 20px;
}
.item {
    margin-bottom: 10px;
    border: 1px dashed #ddd;
    padding: 10px;
    background: #fff;
}
.avatar {
    border: 1px solid #069;
    display: inline-block;
}
.username {
    width: 120px;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    background: #069;
    color: #fff;
    padding: 5px 10px;
}
.username:hover {
    color: #fff;
    text-decoration: none;
    background: #2980b9;
}
.like-count {
    margin-right: 10px;
    display: inline-block;
    vertical-align: middle;
    background: #c0392b;
    padding: 5px 10px;
    color: #fff;
    font-weight: bold;
    width: 50px;
    text-align: center;
}
.photo {
    margin-right: 3px;
    display: inline-block;
    position: relative;
}
#popover {
    position: absolute;
    z-index: 10;
    border: 1px solid #069;
}
            
          
!
            
              d3.jsonp = function(url, callback) {
    function rand() {
      var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
        c = '',
        i = -1;
      while (++i < 15) c += chars.charAt(Math.floor(Math.random() * 52));
      return c;
    }
    function create(url) {
      var e = url.match(/callback=d3.jsonp.(\w+)/),
        c = e ? e[1] : rand();
      d3.jsonp[c] = function(data) {
        callback(data);
        delete d3.jsonp[c];
        script.remove();
      };
      return 'd3.jsonp.' + c;
    }
    var cb = create(url),
      script = d3.select('head')
      .append('script')
      .attr('type', 'text/javascript')
      .attr('src', url.replace(/(\{|%7B)callback(\}|%7D)/, cb));
  };
  var _ignoreHashChange = false;
  function go(user_name) {
    d3.select("#contents")
      .html("");
    var client_id = "5ed94236ab0b46d28eb672967eb861f4"
    d3.jsonp("https://api.instagram.com/v1/users/search?callback={callback}&q=" + user_name + "&client_id=" + client_id, function(userdata) {
      var user;
      if (userdata.data.length === 0) {
        d3.select("#contents")
          .html('<div class="alert alert-danger" role="alert"><span class="label label-danger">Error!</span> Username Not Found</div>');
        return;
      }
      for (i = 0; i < userdata.data.length; i++) {
        if (userdata.data[i].username == user_name) {
          user = userdata.data[i];
        }
      }
      d3.select("#contents")
        .html('<div class="alert alert-success" role="alert"><span class="label label-success">User Found!</span> Username: <strong>' + user.username + '</strong></div>');
      d3.jsonp("https://api.instagram.com/v1/users/" + user.id + "/media/recent/?count=50&callback={callback}&client_id=" + client_id, function(mediadata) {
        if (mediadata.meta.code == 400) {
          d3.select("#contents")
            .html('<div class="alert alert-success" role="alert"><span class="label label-success">User Found!</span> Username: <strong>' + user.username + '</strong></div><div class="alert alert-danger" role="alert"><span class="label label-danger">Oh Sad!</span> User set his/her account as a private account.</div>');
          return;
        }
        var allLikes = d3.merge(mediadata.data.map(function(d) {
          return d.likes.data.map(function(e) {
            var ret = {};
            ret.photo = {
              "id": d.id,
              "thumbimg": d.images.thumbnail,
              "regularimg": d.images.standard_resolution,
              "link": d.link
            }
            ret.user = e;
            return ret;
          })
        }));
        var folded = d3.map(allLikes.reduce(function(o, d) {
            if (o[d.user.id]) {
              o[d.user.id].liked.push(d.photo)
            } else {
              o[d.user.id] = {
                user: d.user,
                liked: [d.photo]
              }
            }
            return o;
          }, {}))
          .entries()
          .sort(function(a, b) {
            return b.value.liked.length - a.value.liked.length
          })
        var margin = {
          top: 20,
          right: 0,
          bottom: 50,
          left: 0
        };
        var rowHeight = 30,
          width = 33 * rowHeight,
          height = rowHeight * folded.length;
        var wrapper = d3.select("#contents")
          .append("div")
          .attr("width", width + margin.left + margin.right)
          .attr("height", height + margin.top + margin.bottom)
        var rows = wrapper.selectAll(".item")
          .data(folded)
          .enter()
          .append("div")
          .attr("class", function(_, i) {
            return "item row-" + i * rowHeight;
          })
        rows.append("img")
          .attr("class", "avatar")
          .attr("src", function(d) {
            return d.value.user.profile_picture
          })
          .attr("height", rowHeight)
          .attr("width", rowHeight)
          .on("click", function(d) {
            go(d.value.user.username);
          });
        rows.append("a")
          .attr("class", "username")
          .attr("href", function(d) {
            return "https://instagram.com/" + d.value.user.username
          })
          .text(function(d) {
            return "" + d.value.user.username
          })
        rows.append("span")
          .attr("class", "like-count")
          .text(function(d) {
            return "" + d.value.liked.length
          })
        rows.selectAll(".photo")
          .data(function(d) {
            return d.value.liked
          })
          .enter()
          .append("img")
          .attr("class", "photo")
          .attr("src", function(d) {
            return d.thumbimg.url
          })
          .attr("id", function(_, i) {
            return "photo-" + rowHeight + 10 + (i * rowHeight)
          })
          .attr("width", rowHeight)
          .attr("height", rowHeight)
          .on("mouseover", function(d) {
            var popover = d3.select("#popover");
            popover.style("display", "block")
              .style("left", (d3.event.pageX+20)+"px")
              .style("top", (d3.event.pageY-320)+"px")
            popover.append("img")
              .attr("src", d.regularimg.url);
          })
          .on("mouseout", function(d) {
            var popover = d3.select("#popover");
            popover.style("display", "none")
              .html("")
          })
      });
    });
    if (window.location.hash !== "#" + user_name) {
      _ignoreHashChange = true;
      window.location.hash = user_name
      _ignoreHashChange = false;
    }
    document.getElementById("input")
      .value = user_name;
  }
  d3.select("#button")
    .on("click", function() {
      d3.event.preventDefault();
      go(document.getElementById("input")
        .value);
    });
  if (window.location.hash.length > 0) {
    go(window.location.hash.slice(1))
  } else {
    go("aydajebat")
  }
  d3.select(window)
    .on("hashchange", function hashchange() {
      if (_ignorehashchange) {
        return;
      }
      var that = d3.select(this)
        .on("hashchange", null);
      if (window.location.hash.length > 0) {
        go(window.location.hash.slice(1))
      }
      that.on("hashchange", hashchange);
    });
            
          
!
999px
Loading ..................

Console