Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <h1 class="bandname">はっぴいえんど</h1>
<div class="spec">
  <section class="album">
    <h2 class="title"></h2>
    <p class="release"></p>
    <ol class="track"></ol>
  </section>
</div>
</section>
              
            
!

CSS

              
                
              
            
!

JS

              
                //jsonファイルURL
var dmain = 'dl.dropboxusercontent.com';
var directory = 's/x6tsr4ah8cfe9ta';
var file = 'happyend';
var url = 'https://' + dmain + '/' + directory + '/' + file + '.json';

//json読み込み
async function resJson () {
  const res = await fetch(url);
  const albums = await res.json();
  return albums;
}

// アルバム複製
function albumsClone(albums) {
  // DOM取得
  const spec = document.querySelector('.spec');

  //テンプレ複製
  //(アルバム枚数-1枚)
  for (let i=1; i < albums.length; i++) {
    let clone = spec.firstElementChild.cloneNode(true);
    spec.appendChild(clone);
  } 
}

// アルバム情報入力
function albumsInput(albums) {
  // Dom取得
  const specTitle = document.querySelectorAll('.title');
  const specRelease = document.querySelectorAll('.release');
  const specTrack = document.querySelectorAll('.track');

  //アルバムデータ入力(アルバム枚数分)
    for (var i=0; i < albums.length; i++) { 
      //タイトル入力
      specTitle[i].innerHTML = albums[i].title;
      //発売日入力
      specRelease[i].innerHTML = albums[i].release;
      //曲名入力(曲数分ループ)
      for(var t=0; t < albums[i].track.length; t++) {
        var list = document.createElement('li');
        list.innerHTML= albums[i].track[t];
       specTrack[i].appendChild(list);        
      }
    }
}

async function allAlbums() {
  // アルバム情報取得
  const albums = await resJson();
  // アルバム複製
  albumsClone(albums);
  // アルバム情報入力
  albumsInput(albums);
}

allAlbums();

              
            
!
999px

Console