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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

            
              <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Elo</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
   <h1>🎮 Yerel Depolama 🎮</h1>
  <p>Bu script, aşağıdaki sayıyı çerezlere kaydeder.</p> 
  <p>Sayfayı kapatıp tekrar açtığınızda kaldığınız yerden devam eder.</p>
    <div class="cnt">
        <div class="disp">0</div>
        <div class="btns">
            <button id="btnAdd" class="btn btn--add">+ Artı</button>
            <button id="btnRemove" class="btn">- Eksi</button>
            <button id="btnClear" class="btn btn--danger">Sıfırla</button>
        </div>
        <div class="msg"></div>
    </div>

    <script src="fun.js"></script>
</body>
</html>
            
          
!
            
              * {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

html {
  font-size: 62.5%;
}

body {
  background: #000;
  color: #eee;
  font-size: 2.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: cente;
}

.cnt {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-left: auto;
  margin-right: auto;
  margin-top: 5rem;
  border: 1px solid #bada55;
  padding: 1em;
}

.disp {
  margin-bottom: 5rem;
  font-size: 6.4rem;
}

.btns {
  display: flex;
}

.btn {
  font-size: 2rem;
  font-weight: bold;
  padding: 1em;
  background: transparent;
  color: #b00b55;
  border-color: #b00b55;
  transition: all .3s ease
}

.btn:hover {
  cursor: pointer;
  background: transparent;
  color: #eee;
  border-color: transparent;
}

.btn--add {
  background: #bada55;
  border-color: #bada55;
  color: #111;
}

.btn--danger {
  background: #b00b55;
  color: #eee;
}

.msg {
  margin-top: 3rem;
}
            
          
!
            
              document.addEventListener('DOMContentLoaded', function() {
    // Get all elements
    const cnt = document.querySelector('.cnt'),
        disp = cnt.querySelector('.disp'),
        btnAdd = cnt.querySelector('#btnAdd'),
        btnRemove = cnt.querySelector('#btnRemove'),
        btnClear = cnt.querySelector('#btnClear'),
        msg = cnt.querySelector('.msg');

    // Skor objesi
    // RegisterListener() yöntemi sayesinde skor değişikliklerini izleyebilirim
    const score = {
        aInternal: 0,
        aListener: function(val) {},
        set digit(val) {
            this.aInternal = val;
            this.aListener(val);
        },
        get digit() {
            return this.aInternal;
        },
        registerListener: function(listener) {
            this.aListener = listener;
        }
    }

    // Skoru yerel depolama biriminden alak (değilse, 0 olarak ayarlayın)
    score.digit = localStorage.getItem('counter') || 0;

    // skor
    disp.textContent = score.digit;

    // 1 ekleyin ve puanı güncelleyin
    const add = () => {
        score.digit++;
        disp.textContent = score.digit;
        localStorage.setItem('counter', score.digit);
    }

    // 1 azaltın ve puanı güncelleyin
    const subtract = () => {
        score.digit--;
        disp.textContent = score.digit;
        localStorage.setItem('counter', score.digit);
    }

    // skoru sıfırlamak
    const clearScore = () => {
        if (confirm('CIDDI MISIN !!?!?')){
            score.digit = 0;
            disp.textContent = score.digit;
            localStorage.removeItem('counter');
        }
    }

    // etkileşim ekle
    btnAdd.addEventListener( 'click', add );
    btnRemove.addEventListener( 'click', subtract );
    btnClear.addEventListener( 'click', clearScore );

    // skor değiştikçe mesaj yazdırma
    (showMsg = () => {
        switch (true) {
            case (score.digit < 0): msg.textContent = "yanlış yoldasın"; break;
            case (score.digit < 10): msg.textContent = "hadi!! sayıyı arttır!"; break;
            case (score.digit < 20): msg.textContent = "devam!!! devam!!!"; break;
            case (score.digit < 40): msg.textContent = "efsanesin!!!"; break;
            case (score.digit < 60): msg.textContent = "fareyi kıracaksın!!!"; break;
            case (score.digit < 80): msg.textContent = "SÜPERRRRR!!!"; break;
            case (score.digit < 100): msg.textContent = "ADAMSINNN!!!"; break;
            case (score.digit < 150): msg.textContent = "!!! - - tamam, zirvede bırak sen kazandın - - !!!"; break;
            default: msg.textContent = "cidden YETER!"; break;
        }
    })();

    // Watch for score change and fire showMsg() function
    score.registerListener(function() {
        showMsg()
    });
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console