Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script id="handlebars-template" type="text/x-handlebars-template">
  {{#each lectures}}
    <li class="list-group-item d-flex justify-content-between align-items-start">
      <div class="ms-2 me-auto">
        <strong class="list_stock" data-stock="{{stock}}">
          {{#if article}}<span class="list_info">{{article}}</span>{{/if}}<!--
          --><span class="list_titre">{{titre}}</span>
        </strong>
        <br>
        Note : <stron class="list_note">{{note}}</stron>/10<br>
        {{#if info}}
          <span class="list_info">{{info}}</span>
        {{/if}}
      </div>
      <span class="badge bg-primary list_statut" data-statut="{{statut}}">
        {{#ifEquals statut "Terminé"}}
          <i class="fas fa-flag-checkered"></i>
        {{/ifEquals}}
        {{#ifEquals statut "En cours"}}
          <i class="fas fa-coins"></i>
        {{/ifEquals}}
        {{#ifEquals statut "Abandonné"}}
          <i class="fas fa-hand-paper"></i>
        {{/ifEquals}}
       &nbsp;{{volume}}
      </span>
    </li>
  {{/each}}
</script>

<div class="container" id="lectures" data-ready="">

  <div class="input-group my-2">
    <input class="search form-control" placeholder="Rechercher" />
    <button class="sort btn btn-primary js--init asc" data-sort="list_titre" title="Trier par titre">
      <i class="fas fa-font"></i>
      <span class="sr-only">Titre</span>
    </button>
    <button class="sort btn btn-primary" data-sort="list_note" title="Trier par note">
      <i class="fas fa-star-half-alt"></i>
      <span class="sr-only">Note</span>
    </button>
  </div>

  <div class="btn-toolbar mb-2" role="toolbar" aria-label="Toolbar with button groups">
    <div class="input-group me-2">
      <button class="btn btn-secondary" onClick="listeLecture.sort('list_trie', { order: 'asc' });listeLecture.search();" title="Réinitialiser">
        <i class="fas fa-undo-alt"></i>
        <span class="sr-only">Réinitialiser</span>
      </button>
    </div>
    <div class="input-group me-2">
      <button class="btn btn-secondary" onClick="listeLecture.search('Terminé', ['list_statut'])" title="Série terminé">
        <i class="fas fa-flag-checkered"></i>
        <span class="sr-only">Série terminé</span>
      </button>
      <button class="btn btn-secondary" onClick="listeLecture.search('En cours', ['list_statut'])" title="Série en cours">
        <i class="fas fa-cart-arrow-down"></i>
        <span class="sr-only">Série en cours</span>
      </button>
      <button class="btn btn-secondary" onClick="listeLecture.search('Abandonné', ['list_statut'])" title="Série abandonné">
        <i class="fas fa-hand-paper"></i>
        <span class="sr-only">Série abandonné</span>
      </button>
    </div>
    <div class="input-group">
      <button class="btn btn-secondary" onClick="listeLecture.search('Possédé', ['list_stock'])" title="Série possédé">
        <i class="fas fa-book"></i>
        <span class="sr-only">Série possédé</span>
      </button>
      <button class="btn btn-secondary" onClick="listeLecture.search('Vendu', ['list_stock'])" title="Série vendu">
        <i class="fas fa-coins"></i>
        <span class="sr-only">Série vendu</span>
      </button>
    </div>
  </div>

  <ol class="list-group list" id="handlebars-output"></ol>

</div>
              
            
!

CSS

              
                .sort.asc::after {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #fff;
  content:"";
  position: relative;
  top:13px;
  right:-5px;
  }
.sort.desc::after {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid #fff;
  content:"";
  position: relative;
  top:-10px;
  right:-5px;
  }

.sort:not(.asc):not(.desc) {
  background-color: #6c757d;
  border-color: #6c757d;
}
              
            
!

JS

              
                const url = 'https://docs.google.com/spreadsheets/d/';
const ssid = '1-IyaPWlN7d0blaMAvYTBNsqMI-w_lM023tiJb8YynGU';
const query1 = `/gviz/tq?`
const endpoint1 = `${url}${ssid}${query1}`;

fetch(endpoint1)
.then(res => res.text())
.then(data => {
  
  const temp = data.substr(47).slice(0,-2);
  const json = JSON.parse(temp);
  const rows = json.table.rows;
  
  var formatted = rows.map(function (originalItem) {
    return {
      /*
      article: originalItem.c.[0]?.v,
      titre: originalItem.c.[1]?.v,
      volume: originalItem.c.[2]?.v,
      note: originalItem.c.[3]?.v,
      info: originalItem.c[4]?.v,
      statut: originalItem.c.[5]?.v,
      stock: originalItem.c.[6]?.v,
      */
      article: originalItem.c[0] === null ? '' : originalItem.c[0].v,
      titre: originalItem.c[1] === null ? '' : originalItem.c[1].v,
      volume: originalItem.c[2] === null ? '' : originalItem.c[2].v,
      note: originalItem.c[3] === null ? '' : originalItem.c[3].v,
      info: originalItem.c[4] === null ? '' : originalItem.c[4].v,
      statut: originalItem.c[5] === null ? '' : originalItem.c[5].v,
      stock: originalItem.c[6] === null ? '' : originalItem.c[6].v,
    }
  });
  //console.log(formatted);
  
  Handlebars.registerHelper('ifEquals', function(arg1, arg2, options) {
    return (arg1 == arg2) ? options.fn(this) : options.inverse(this);
  });
  
  var data = { 
    "lectures" : formatted
  };

  var template = Handlebars.compile(document.querySelector('#handlebars-template').innerHTML);
  var filled = template(data);
  document.querySelector('#handlebars-output').innerHTML = filled;
  
})
.then(function(listjs) {
  
  var options = {
    valueNames: [ 
      'list_article',
      'list_titre', 
      'list_note', 
      'list_info',
      { attr: 'data-statut', name: 'list_statut' },
      { attr: 'data-stock', name: 'list_stock' },
    ]
  };

  window.listeLecture = new List('lectures', options);
 
})




              
            
!
999px

Console