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

Auto Save

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

              
                <html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div class="heading_group">
    <h2>手配中の人(行方不明者込み)</h2>
    <div class="buttons">
      <button onclick="movePage(false)">前へ</button>
      <p id="nowPage"></p>
      <button onclick="movePage(true)">次へ</button>
    </div>
  </div>
  <div id="contents" class="wrap">
  </div>

  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</body>
</html>
              
            
!

CSS

              
                .heading_group {
      width: 95%;
      margin: auto;
      margin: 30px 0;
    }
    .buttons {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 20px;
      margin-top: 20px;
    }
    .buttons > button {
      display: block;
      height: 40px;
      width: 100px;
    }
    h2 {
      text-align: center;
    }
    .wrap {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 10px;
    }
    .contents {
      width: 90%;
      margin: auto;
    }
    .content_name {
      width: 250px;
      font-size: 14px;
    }
    .content_image {
      display: block;
      width: 250px;
      height: 250px;
    }
              
            
!

JS

              
                
    const imageArray = []
    let pageCount = Number(localStorage.getItem('pageCount') ?? 1)

    const onMovePageButtonClicked = (pageCount) => {
      localStorage.setItem('pageCount', pageCount)

      axios.get('https://api.fbi.gov/wanted/v1/list', {
        params: {
          page : pageCount,
        }
      })
      .then(response => {
        const nowPage = document.getElementById('nowPage')
        nowPage.textContent = `ページ:${pageCount}`
        const contentElement = document.getElementById('contents')
        contentElement.innerHTML = '';
        response.data.items.forEach((item, index) => {
          const box = document.createElement('div')

          const subject = document.createElement('p')
          subject.className = 'content_subject'
          subject.textContent = `状態:${getSubject(item.subjects[0])}`
          box.prepend(subject)

          const name = document.createElement('p')
          name.className = 'content_name'
          name.textContent = `名前:${item.title}`
          box.prepend(name)

          const img = document.createElement('img')
          img.className = 'content_image'
          img.src = item.images[0].original
          box.prepend(img)

          contentElement.prepend(box)
        })
      })
    }

    const movePage = (isNext) => {
      if (isNext) {
        onMovePageButtonClicked(pageCount += 1)
      } else {
        if (pageCount - 1 >= 1) {
          onMovePageButtonClicked(pageCount -= 1)
        }
      }
    }

    const getSubject = (englishSubject) => {
      switch (englishSubject) {
        case 'Kidnappings and Missing Persons':
          return '誘拐と行方不明者'
        case 'Seeking Information':
          return '情報を求める'
        case 'Criminal Enterprise Investigations':
          return '犯罪企業の捜査'
        case 'ViCAP Missing Persons':
          return '行方不明者'
        case "Cyber's Most Wanted":
          return 'サイバーの最重要指名手配'
        case 'White-Collar Crime':
          return '横領や収賄'
        case 'Counterintelligence':
          return '防諜'
        case 'ViCAP Unidentified Persons':
          return '身元不明者'
        case 'Additional Violent Crimes':
          return 'その他の暴力犯罪'
        case 'ViCAP Homicides and Sexual Assaults':
          return '殺人と性的暴行'
        case 'Kidnappins and Missing Persons':
          return '誘拐犯と行方不明者'
        case 'Violent Crime - Murders':
          return '暴力犯罪 - 殺人'
        case 'Seeking Information - Terrorism':
          return '情報を求める - テロリズム'
        default :
          return englishSubject
      }
    }

    window.onload = function() {
      onMovePageButtonClicked(pageCount)
    }
              
            
!
999px

Console