Sha256: 29e33239e50c952df3058f1b4b644731dcd631a9bbae4ea8f1ee823cc631b512

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

"use strict";

var Index = (function() {
  var $;
  var inited = false;

  function entriesURL() {
    var sortable = $("th.sortable.sort-active");
    return `${location.pathname}?_servel_sort_method=${sortable.dataset.sortMethod}&_servel_sort_direction=${sortable.dataset.sortDirection}`;
  }

  function onEntriesLoad(callback) {
    if(inited) {
      Gallery.onEntriesUpdate();
      Listing.onEntriesUpdate();
    }
    else {
      inited = true;
      Gallery.onEntriesInit();
      Listing.onEntriesInit();
    }

    $("#loading").style.display = "none";
    if(callback) callback();
  }

  function loadEntries(callback) {
    $("#loading").style.display = "flex";

    var http = new XMLHttpRequest();
    http.open("GET", entriesURL());

    http.onreadystatechange = function() {
      if(http.readyState === 4 && http.status === 200) {
        window.entries = JSON.parse(http.responseText);
        setTimeout(function() {
          onEntriesLoad(callback);
        }, 0);
      }
    };

    http.setRequestHeader("Accept", "application/json");
    http.send();
  }

  window.addEventListener("DOMContentLoaded", function() {
    $ = document.querySelector.bind(document);
    loadEntries();
  });

  return {
    loadEntries: loadEntries
  };
})();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
servel-0.20.0 lib/servel/templates/js/index.js