more xhr updates - WIP

pull/7246/head
Thibault Duplessis 2020-09-06 12:57:13 +02:00
parent efd65cc196
commit b555288b34
10 changed files with 23 additions and 18 deletions

View File

@ -2,9 +2,9 @@ function toBlurArray(player) {
return player.blurs && player.blurs.bits ? player.blurs.bits.split('') : [];
}
lichess.advantageChart = function(data, trans, el) {
lichess.loadScript('javascripts/chart/common.js').done(function() {
lichess.loadScript('javascripts/chart/division.js').done(function() {
lichess.chartCommon('highchart').done(function() {
lichess.loadScript('javascripts/chart/common.js').then(function() {
lichess.loadScript('javascripts/chart/division.js').then(function() {
lichess.chartCommon('highchart').then(function() {
lichess.advantageChart.update = function(d) {
$(el).highcharts().series[0].setData(makeSerieData(d));

View File

@ -2,7 +2,7 @@ lichess.highchartsPromise;
lichess.chartCommon = function(type) {
if (lichess.highchartsPromise) return lichess.highchartsPromise;
var file = type === 'highstock' ? 'highstock.js' : 'highcharts.js';
return lichess.highchartsPromise = lichess.loadScript('vendor/highcharts-4.2.5/' + file, { noVersion: true }).done(function() {
return lichess.highchartsPromise = lichess.loadScript('vendor/highcharts-4.2.5/' + file, { noVersion: true }).then(function() {
// Drop-in fix for Highcharts issue #8477 on older Highcharts versions. The
// issue is fixed since Highcharts v6.1.1.
Highcharts.wrap(Highcharts.Axis.prototype, 'getPlotLinePath', function(proceed) {

View File

@ -3,9 +3,9 @@ function toBlurArray(player) {
}
lichess.movetimeChart = function(data, trans) {
if (!data.game.moveCentis) return; // imported games
lichess.loadScript('javascripts/chart/common.js').done(function() {
lichess.loadScript('javascripts/chart/division.js').done(function() {
lichess.chartCommon('highchart').done(function() {
lichess.loadScript('javascripts/chart/common.js').then(function() {
lichess.loadScript('javascripts/chart/division.js').then(function() {
lichess.chartCommon('highchart').then(function() {
lichess.movetimeChart.render = function() {
$('#movetimes-chart:not(.rendered)').each(function() {
var $this = $(this).addClass('rendered');

View File

@ -1,7 +1,7 @@
lichess.ratingDistributionChart = function(data) {
const trans = lichess.trans(data.i18n);
lichess.loadScript('javascripts/chart/common.js').done(function() {
lichess.chartCommon('highchart').done(function() {
lichess.loadScript('javascripts/chart/common.js').then(function() {
lichess.chartCommon('highchart').then(function() {
var disabled = {
enabled: false
};

View File

@ -28,8 +28,8 @@ lichess.ratingHistoryChart = function(data, singlePerfName) {
var indexFilter = function(_, i) {
return !singlePerfName || i === singlePerfIndex;
};
lichess.loadScript('javascripts/chart/common.js').done(function() {
lichess.chartCommon('highstock').done(function() {
lichess.loadScript('javascripts/chart/common.js').then(function() {
lichess.chartCommon('highstock').then(function() {
// support: Fx when user bio overflows
var disabled = {
enabled: false

View File

@ -2,8 +2,8 @@ function loadShepherd(f) {
var theme = 'shepherd-theme-' + ($('body').hasClass('dark') ? 'default' : 'dark');
lichess.loadCss('vendor/shepherd/dist/css/' + theme + '.css');
lichess.loadCss('stylesheets/shepherd.css');
lichess.loadScript('vendor/shepherd/dist/js/tether.js', {noVersion:true}).done(function() {
lichess.loadScript('vendor/shepherd/dist/js/shepherd.min.js', {noVersion:true}).done(function() {
lichess.loadScript('vendor/shepherd/dist/js/tether.js', {noVersion:true}).then(function() {
lichess.loadScript('vendor/shepherd/dist/js/shepherd.min.js', {noVersion:true}).then(function() {
f(theme);
});
});

View File

@ -3,8 +3,8 @@ function loadShepherd(f) {
var theme = 'shepherd-theme-' + ($('body').hasClass('dark') ? 'default' : 'dark');
lichess.loadCss('vendor/shepherd/dist/css/' + theme + '.css');
lichess.loadCss('stylesheets/shepherd.css');
lichess.loadScript('vendor/shepherd/dist/js/tether.js', {noVersion: true}).done(function () {
lichess.loadScript('vendor/shepherd/dist/js/shepherd.min.js', {noVersion: true}).done(function () {
lichess.loadScript('vendor/shepherd/dist/js/tether.js', {noVersion: true}).then(function () {
lichess.loadScript('vendor/shepherd/dist/js/shepherd.min.js', {noVersion: true}).then(function () {
f(theme);
});
});

View File

@ -16,7 +16,7 @@ interface Lichess {
jsModule(name: string): string;
loadScript(url: string, opts?: AssetUrlOpts): Promise<void>;
hopscotch: any;
slider(): any;
slider(): Promise<void>;
makeChat(data: any): any;
numberFormat(n: number): string;
idleTimer(delay: number, onIdle: () => void, onWakeUp: () => void): void;

View File

@ -1,11 +1,15 @@
export const defined = <A>(v: A | undefined): v is A =>
typeof v !== 'undefined';
export const notNull = <T>(value: T | null | undefined): value is T =>
export const notNull = <T>(value: T | null | undefined): value is T =>
value !== null && value !== undefined;
export const isEmpty = (a: any): boolean => !a || a.length === 0;
/* export const foreach = <A>(a: A | undefined, f: (a: A) => void): void => { */
/* if (a) f(a); */
/* } */
export interface Prop<T> {
(): T
(v: T): T

View File

@ -1,3 +1,4 @@
import * as xhr from 'common/xhr';
import once from "./component/once";
import { hopscotch } from "./component/assets";
import loadInfiniteScroll from "./component/infinite-scroll";
@ -44,7 +45,7 @@ window.lichess.load.then(() => {
$content = $('.angle-content'),
browseTo = (path: string) => {
$('.angle-content .infinitescroll').infinitescroll('destroy');
$.get(path).then(html => {
xhr.text(path).then(html => {
$content.html(html);
window.lichess.pubsub.emit('content_loaded');
history.replaceState({}, '', path);