Skip to content

Commit

Permalink
dynamic counting
Browse files Browse the repository at this point in the history
  • Loading branch information
colevandersWands committed Dec 11, 2024
1 parent 1dc3b3e commit 99a8ff7
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 55 deletions.
90 changes: 45 additions & 45 deletions public/bundle/min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions public/src/filter-snip-pets/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { countSnippets } from '../utils/count-snippets.js';

import { state } from '../state.js';

import { persistToParams } from './persist-to-params.js';
Expand Down Expand Up @@ -62,4 +64,6 @@ export const filterSnipPets = (snippetTitle = '') => {
}

persistToParams();

countSnippets(state.snippets.filter((snippet) => snippet.display).length);
};
2 changes: 0 additions & 2 deletions public/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ window.state = state;

import './init/comments.js';

import './init/count-snippets.js';

import './init/mdn-potluck.js';

import './init/outlinks.js';
Expand Down
8 changes: 0 additions & 8 deletions public/src/init/count-snippets.js

This file was deleted.

11 changes: 11 additions & 0 deletions public/src/utils/count-snippets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let counterval = 0;

export const countSnippets = (countTo = 0) => {
if (counterval) clearInterval(counterval);

let counted = 0;
counterval = setInterval(function countingSnippets() {
document.title = 'Snippetry #' + counted;
if (++counted > countTo) clearInterval(counterval);
}, 1000);
};

0 comments on commit 99a8ff7

Please sign in to comment.