Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions files.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,10 @@ function layoutPDFClues(doc, style) {

let openPuzzleInput = document.getElementById('open-puzzle-input');
let openWordlistInput = document.getElementById('open-wordlist-input');
let addWordlistInput = document.getElementById('add-wordlist-input');
openPuzzleInput.addEventListener('change', openFile, false);
openWordlistInput.addEventListener('change', openWordlistFile, false);
addWordlistInput.addEventListener('change', addWordlistFile, false);
openPuzzleInput.onclick = function () {
this.value = null;
};
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ <h4>Export as:</h4>
<i class="fa fa-book fa-fw" aria-hidden="true"></i>
</button>
<input id="open-wordlist-input" class="hidden" type="file" accept=".txt"/>
<button id="add-wordlist" type="button" data-tooltip="Add wordlist" onclick="addWordlist()">
<i class="fa fa-plus-square fa-fw" aria-hidden="true"></i>
</button>
<input id="add-wordlist-input" class="hidden" type="file" accept=".txt"/>
<button id="auto-fill" type="button" data-tooltip="Auto-fill puzzle" onclick="autoFill()">
<i class="fa fa-magic fa-fw" aria-hidden="true"></i>
</button>
Expand Down
41 changes: 26 additions & 15 deletions wordlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,11 @@ function addToWordlist(newWords) {
}
}

function sortWordlist() {
for (let i = 3; i < wordlist.length; i++) {
wordlist[i].sort();
}
function addWordlist(){
document.getElementById("add-wordlist-input").click();
}

function openWordlist() {
document.getElementById("open-wordlist-input").click();
}

function openWordlistFile(e) {
wordlist = [
[], [], [], [], [],
[], [], [], [], [],
[], [], [], [], [], []
];

function addWordlistFile(e){
const file = e.target.files[0];
if (!file) {
return;
Expand All @@ -65,6 +53,29 @@ function openWordlistFile(e) {
reader.readAsText(file);
}

function clearWordlist(){
wordlist = [
[], [], [], [], [],
[], [], [], [], [],
[], [], [], [], [], []
];
}

function sortWordlist() {
for (let i = 3; i < wordlist.length; i++) {
wordlist[i].sort();
}
}

function openWordlist() {
document.getElementById("open-wordlist-input").click();
}

function openWordlistFile(e) {
clearWordlist();
addWordlistFile(e);
}

function openDefaultWordlist(url) {
let textFile = new XMLHttpRequest();
textFile.open("GET", url, true);
Expand Down