Skip to content

Commit

Permalink
Merge pull request #8 from RTa-scp/feat/add_debounce
Browse files Browse the repository at this point in the history
Feat/add debounce
  • Loading branch information
r74tech authored May 27, 2022
2 parents d51b3f1 + 556f718 commit 56f81bb
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 28 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"esbuild": "^0.14.39",
"eslint": "^8.16.0",
"sass": "^1.52.1",
"throttle-typescript": "^1.1.0",
"ts-debounce": "^4.0.0",
"typescript": "^4.6.4",
"vite": "^2.9.9",
"yaml": "^2.1.0"
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 33 additions & 8 deletions src/css/wikidot.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
clear: both;
}

table.wiki-content-table, table.wj-table {
table.wiki-content-table,
table.wj-table {
border-collapse: collapse;
border-spacing: 0;
margin: .5em auto;
}
table.wiki-content-table td, table.wj-table td {

table.wiki-content-table td,
table.wj-table td {
border: 1px solid #666666;
padding: .3em .7em;
}
table.wiki-content-table th, table.wj-table th {

table.wiki-content-table th,
table.wj-table th {
border: 1px solid #666666;
padding: .3em .7em;
background-color: #eeeeee;
Expand All @@ -20,12 +25,15 @@ table.wiki-content-table th, table.wj-table th {
.wj-align-center {
text-align: center;
}

.wj-align-left {
text-align: left;
}

.wj-align-right {
text-align: right;
}

.wj-align-justify {
text-align: justify;
}
Expand All @@ -41,7 +49,7 @@ table.wiki-content-table th, table.wj-table th {

#toc .title {
font-weight: bold;
margin: .2em 0 ;
margin: .2em 0;
padding: 0 2em;
text-align: center;
}
Expand All @@ -53,16 +61,19 @@ table.wiki-content-table th, table.wj-table th {
#toc-list {
margin: .5em 0;
}

#toc.floatright {
float: right;
margin: 1em;
}

#toc.floatleft {
float: left;
margin: 1em;
}

.code, code {
.code,
code {
border: 1px dashed #999999;
background-color: #333333;
font-family: "Andale Mono", "Courier New", Courier, monospace;
Expand All @@ -72,13 +83,20 @@ table.wiki-content-table th, table.wj-table th {
}


.footnote .f-heading, .equation .e-heading, .reference .r-heading {
.footnote .f-heading,
.equation .e-heading,
.reference .r-heading {
font-weight: bold;
}
.footnote .f-content, .reference .r-content {

.footnote .f-content,
.reference .r-content {
margin: .5em 0;
}
.footnote .f-footer, .equation .e-footer, .reference .r-footer {

.footnote .f-footer,
.equation .e-footer,
.reference .r-footer {
font-size: 90%;
}

Expand All @@ -88,11 +106,18 @@ table.wiki-content-table th, table.wj-table th {
/*border-top: 1px solid #CCC;*/
height: 1%;
}

.footnotes-footer .title {
margin: .5em 0;
font-size: 130%;
font-weight: bold;
}

a.footnoteref {
display: inline-block;
}

a#account-topbutton:active + div#account-options,
a#account-topbutton:focus + div#account-options {
display: block !important;
}
14 changes: 7 additions & 7 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ <h2><span></span></h2>
</span>
<img class="wj-user-info-avatar small" src="/files--static/media/default-avatar.png" alt="Default">
</a>Default</span>

| <a id="my-account" href="javascript:;">My accounts</a> <a id="account-topbutton" href="javascript:;"></a>
<div id="account-options">
<div id="account-options" style="display: none;">
<ul>
<li><a href="javascript:;">account</a></li>
<li><a href="javascript:;">Private Messages</a></li>
<li><a href="javascript:;">my contacts</a></li>
<li><a href="javascript:;">notifications</a></li>
<li><a href="javascript:;">logout</a></li>
<li><a href="https://www.wikidot.com/account/activity">Activity</a></li>
<li><a href="https://www.wikidot.com/account/messages">Messages</a></li>
<li><a href="https://www.wikidot.com/account/sites">Sites</a></li>
<li><a href="https://www.wikidot.com/account/settings">Settings</a></li>
<li><a href="https://www.wikidot.com/account/upgrade">Upgrade</a></li>
<li><a href="javascript:;">Sign out</a></li>
</ul>
</div>
</div>
Expand Down
29 changes: 16 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import css from './css/wikidot.css';
import init from './css/init.css';
import collapsible from './css/collapsible.css';
import YAML from 'yaml'
import { debounce } from "ts-debounce";
import { throttle } from 'throttle-typescript';
import ftmlWorker from './ftml.web.worker.js?bundled-worker&dataurl';

let ftml = new Worker(ftmlWorker, {
Expand Down Expand Up @@ -76,19 +78,19 @@ const editsideField: HTMLInputElement = <HTMLInputElement>document.getElementByI
const editsaveButton: HTMLInputElement = <HTMLInputElement>document.getElementById('actionarea-save')!;
const langSelect: HTMLInputElement = <HTMLInputElement>document.getElementById('lang-select')!;

editpageField.addEventListener('input', (event) => {
const { target } = event;
if (!(target instanceof HTMLTextAreaElement)) {
return;
}
const value = target.value;
const type = "page"
const FtmlStorageItem = { title: edittitleField.value, page: editpageField.value, side: editsideField.value };
localStorage.setItem("FtmlStorage", JSON.stringify(FtmlStorageItem));
ftml.postMessage({ value: value, type: type });
});
editpageField.addEventListener('input', debounce((event) => {
const { target } = event;
if (!(target instanceof HTMLTextAreaElement)) {
return;
}
const value = target.value;
const type = "page"
const FtmlStorageItem = { title: edittitleField.value, page: editpageField.value, side: editsideField.value };
localStorage.setItem("FtmlStorage", JSON.stringify(FtmlStorageItem));
ftml.postMessage({ value: value, type: type });
}, 1000));

editsideField.addEventListener('input', (event) => {
editsideField.addEventListener('input', debounce((event) => {
const { target } = event;
if (!(target instanceof HTMLTextAreaElement)) {
return;
Expand All @@ -98,7 +100,7 @@ editsideField.addEventListener('input', (event) => {
const FtmlStorageItem = { title: edittitleField.value, page: editpageField.value, side: editsideField.value };
localStorage.setItem("FtmlStorage", JSON.stringify(FtmlStorageItem));
ftml.postMessage({ value: value, type: type });
});
}, 1000));

edittitleField.addEventListener('input', (event) => {
const { target } = event;
Expand All @@ -110,6 +112,7 @@ edittitleField.addEventListener('input', (event) => {
const FtmlStorageItem = { title: edittitleField.value, page: editpageField.value, side: editsideField.value };
localStorage.setItem("FtmlStorage", JSON.stringify(FtmlStorageItem));
});

langSelect.addEventListener('change', function () {
const lang = this.value;
loadlocales(lang);
Expand Down
Binary file added src/public/files--static/media/black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 56f81bb

Please sign in to comment.