proper TS module for account pages

pull/7246/head
Thibault Duplessis 2020-09-06 18:41:01 +02:00
parent 833b06ed7f
commit b79b8cb0a2
4 changed files with 44 additions and 3 deletions

View File

@ -17,7 +17,7 @@ object layout {
views.html.base.layout(
title = title,
moreCss = frag(cssTag("account"), evenMoreCss),
moreJs = frag(jsTag("account.js"), evenMoreJs)
moreJs = frag(jsModule("account"), evenMoreJs)
) {
def activeCls(c: String) = cls := active.activeO(c)
main(cls := "account page-menu")(

View File

@ -16,7 +16,7 @@ mkdir -p public/compiled
apps1="common"
apps2="chess ceval game tree chat nvui"
apps3="site swiss msg chat cli challenge notify learn insight editor puzzle round analyse lobby tournament tournamentSchedule tournamentCalendar simul dasher speech palantir serviceWorker"
site_plugins="tvEmbed puzzleEmbed analyseEmbed user modUser clas coordinate captcha expandText team"
site_plugins="tvEmbed puzzleEmbed analyseEmbed user modUser clas coordinate captcha expandText team forum account"
round_plugins="keyboardMove nvui"
analyse_plugins="nvui"

View File

@ -121,6 +121,9 @@ export default rollupProject({
forum: {
input: 'src/forum.ts',
output: 'forum',
name: 'forumStart'
},
account: {
input: 'src/account.ts',
output: 'account',
}
});

View File

@ -0,0 +1,38 @@
import * as xhr from 'common/xhr';
const li = window.lichess
li.load.then(() => {
const arrowSnapStore = li.storage.make('arrow.snap');
const courtesyStore = li.storage.make('courtesy');
$('.security table form').submit(function(this: HTMLFormElement) {
xhr.text(this.action, { method: 'post' });
$(this).parent().parent().remove();
return false;
});
$('form.autosubmit').each(function(this: HTMLFormElement) {
const form = this,
$form = $(form),
showSaved = () => $form.find('.saved').fadeIn();
$form.find('input').change(function(this: HTMLInputElement) {
if (this.name == 'behavior.arrowSnap') {
arrowSnapStore.set(this.value);
showSaved();
}
else if (this.name == 'behavior.courtesy') {
courtesyStore.set(this.value);
showSaved();
}
xhr.formToXhr(form).then(() => {
showSaved();
li.storage.fire('reload-round-tabs');
});
});
});
$(`#irbehavior_arrowSnap_${arrowSnapStore.get() || 1}`).prop('checked', true);
$(`#irbehavior_courtesy_${courtesyStore.get() || 0}`).prop('checked', true);
});