concedo commited on
Commit
f8d3f0a
1 Parent(s): 54366a7

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +48 -4
index.html CHANGED
@@ -107,8 +107,9 @@ img {
107
  display: block;
108
  color: white;
109
  text-align: center;
110
- padding: 14px 20px;
111
  text-decoration: none;
 
112
  }
113
 
114
  /* Change color on hover */
@@ -603,6 +604,48 @@ function prunesel()
603
  displayTitles();
604
  }
605
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
606
  function exportsel()
607
  {
608
  const contentsDiv = document.getElementById('contents');
@@ -1018,8 +1061,9 @@ document.addEventListener("DOMContentLoaded", function () {
1018
  <button id="deselectall" onclick="selrange(false)">Deselect Range</button>
1019
  <button id="invertsel" onclick="invertsel()">Invert Selection</button>
1020
  </div><div style="padding: 2px; margin-top: 6px;">
1021
- <button onclick="erasesel()">Erase Selected</button></h3>
1022
- <button onclick="prunesel()">Prune To Selected</button></h3>
 
1023
  <button id="ngram" onclick="displayngram()">Calc. N-Gram</button>
1024
  </div>
1025
  </div>
@@ -1041,4 +1085,4 @@ document.addEventListener("DOMContentLoaded", function () {
1041
  </div>
1042
  </body>
1043
 
1044
- </html>
 
107
  display: block;
108
  color: white;
109
  text-align: center;
110
+ padding: 12px 14px;
111
  text-decoration: none;
112
+ font-size: 14px;
113
  }
114
 
115
  /* Change color on hover */
 
604
  displayTitles();
605
  }
606
 
607
+ function shuffle(array) {
608
+ for (let i = array.length - 1; i > 0; i--) {
609
+ // Generate a random index
610
+ const j = Math.floor(Math.random() * (i + 1));
611
+ // Swap elements i and j
612
+ [array[i], array[j]] = [array[j], array[i]];
613
+ }
614
+ return array;
615
+ }
616
+
617
+ function shufflesel()
618
+ {
619
+ const contentsDiv = document.getElementById('contents');
620
+ tempfileobj = [];
621
+ for(let i=0;i<currdbidxs.length;++i)
622
+ {
623
+ let ci = currdbidxs[i];
624
+ let box = document.getElementById(`itm${ci}`);
625
+ if(box && box.checked)
626
+ {
627
+ tempfileobj.push(db[ci]);
628
+ }
629
+ }
630
+
631
+ if(tempfileobj.length==0)
632
+ {
633
+ contentsDiv.innerText = "Error: You must select at least 1 item to erase!";
634
+ contentsDiv.scrollTop = 0;
635
+ return;
636
+ }
637
+
638
+ db = db.filter( ( el ) => !tempfileobj.includes( el ) );
639
+ shuffle(tempfileobj);
640
+ for(let i=0;i<tempfileobj.length;++i)
641
+ {
642
+ db.push(tempfileobj[i]);
643
+ }
644
+ selecteddb = {};
645
+ countsel();
646
+ displayTitles();
647
+ }
648
+
649
  function exportsel()
650
  {
651
  const contentsDiv = document.getElementById('contents');
 
1061
  <button id="deselectall" onclick="selrange(false)">Deselect Range</button>
1062
  <button id="invertsel" onclick="invertsel()">Invert Selection</button>
1063
  </div><div style="padding: 2px; margin-top: 6px;">
1064
+ <button onclick="erasesel()">Erase Selected</button>
1065
+ <button onclick="prunesel()">Prune To Selected</button>
1066
+ <button onclick="shufflesel()">Shuffle Selected</button>
1067
  <button id="ngram" onclick="displayngram()">Calc. N-Gram</button>
1068
  </div>
1069
  </div>
 
1085
  </div>
1086
  </body>
1087
 
1088
+ </html>