Compare commits

..

No commits in common. "1e4de11f4c2e11b9f181a45402d2d72dc864b057" and "809ae9c73745f83e9e8e459fd3fb1fc73f74d225" have entirely different histories.

2 changed files with 24 additions and 10 deletions

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>WAKI-LIBS</title>
<title>WAD-LIBS</title>
<style>
#inputs {
@ -60,9 +60,9 @@ button {
</style>
</head>
<body>
<h1>WAKI-LIBS: Wikipedia Ad-Libbed</h1>
<h1>WAD-LIBS: Wikipedia Ad-Libbed</h1>
<div id="inputs"></div>
<p><button id="show-article">WAKI-LIB!</button>
<p><button id="show-article">WAD-LIB!</button>
<div id="article">
<div id="header">
<span id="title"></span>

View File

@ -1,3 +1,19 @@
function parseArticleJSON_old() {
fetch('tokens.json')
.then((article) => article.json())
.then((article_json) => {
let output = ''
article_json.forEach(function(token) {
output += `${token.token} `
})
document.getElementById('article').innerHTML = output
})
.catch((error) => {
console.log(`Error fetching article: ${error}`)
document.getELementById('article').innerHTML = 'Error'
})
}
function createInputs(article) {
inputs = ''
article.tokens.forEach(function(token) {
@ -14,17 +30,16 @@ function createInputs(article) {
}
function showArticle(article) {
document.getElementById('title').innerHTML = article.title
document.getElementById('link').innerHTML = `[ <a href='${article.url}'>Original Article</a> ]`
let output = ''
let spaceBefore = false
const noSpaceBeforeTags = new Set(['.', ',', ')', ';', ':', '!', '?', "''", 'POS'])
const noSpaceBeforeTokens = new Set(["n't", ']'])
const noSpaceAfterTags = new Set(['(', '``'])
const noSpaceAfterTokens = new Set(['['])
document.getElementById('title').innerHTML = article.title
document.getElementById('link').innerHTML = `[ <a href='${article.url}'>Original Article</a> ]`
let output = ''
let spaceBefore = false
article.tokens.forEach(function(token) {
if(spaceBefore && !noSpaceBeforeTags.has(token.tag) && !noSpaceBeforeTokens.has(token.token)) {
output += ' '
}
@ -42,7 +57,6 @@ function showArticle(article) {
spaceBefore = false
}
})
document.getElementById('summary').innerHTML = output
document.getElementById('article').classList.add('visible')