mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 00:12:25 -04:00
format: formatted some code
This commit is contained in:
parent
bd9854c80e
commit
9f16a92056
12 changed files with 42 additions and 64 deletions
|
@ -221,7 +221,6 @@ class Preferences(QDialog):
|
|||
self.form.check_for_updates.setChecked(self.mw.pm.check_for_updates())
|
||||
qconnect(self.form.check_for_updates.stateChanged, self.mw.pm.set_update_check)
|
||||
|
||||
|
||||
self.update_login_status()
|
||||
qconnect(self.form.syncLogout.clicked, self.sync_logout)
|
||||
qconnect(self.form.syncLogin.clicked, self.sync_login)
|
||||
|
@ -359,8 +358,6 @@ class Preferences(QDialog):
|
|||
self.form.theme.setCurrentIndex(self.mw.pm.theme().value)
|
||||
qconnect(self.form.theme.currentIndexChanged, self.on_theme_changed)
|
||||
|
||||
|
||||
|
||||
self.form.styleComboBox.addItems(["Anki"] + (["Native"] if not is_win else []))
|
||||
self.form.styleComboBox.setCurrentIndex(self.mw.pm.get_widget_style())
|
||||
qconnect(
|
||||
|
@ -372,7 +369,9 @@ class Preferences(QDialog):
|
|||
qconnect(self.form.resetWindowSizes.clicked, self.on_reset_window_sizes)
|
||||
|
||||
self.form.color_blind.setChecked(self.mw.pm.color_blind())
|
||||
qconnect(self.form.color_blind.stateChanged, self.on_color_blind_checkbox_changed)
|
||||
qconnect(
|
||||
self.form.color_blind.stateChanged, self.on_color_blind_checkbox_changed
|
||||
)
|
||||
|
||||
self.setup_language()
|
||||
self.setup_video_driver()
|
||||
|
@ -387,7 +386,6 @@ class Preferences(QDialog):
|
|||
# checkbox is unchecked
|
||||
self.mw.pm.set_color_blind(False)
|
||||
|
||||
|
||||
def update_global(self) -> None:
|
||||
restart_required = False
|
||||
|
||||
|
|
|
@ -151,7 +151,6 @@ class NewDeckStats(QDialog):
|
|||
self.form.web.load_sveltekit_page("graphs")
|
||||
|
||||
|
||||
|
||||
class DeckStats(QDialog):
|
||||
"""Legacy deck stats, used by some add-ons."""
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ export function buildHistogram(
|
|||
const isColourBlindMode = (window as any).colorBlindMode;
|
||||
|
||||
// Changing color based on mode
|
||||
if(isColourBlindMode){
|
||||
if (isColourBlindMode) {
|
||||
adjustedRange = scaleLinear().range([0.3, 0.7]);
|
||||
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMax!, xMin!]);
|
||||
} else {
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
sum,
|
||||
} from "d3";
|
||||
|
||||
import {type GraphBounds } from "./graph-helpers";
|
||||
import { type GraphBounds } from "./graph-helpers";
|
||||
import { GraphRange } from "./graph-helpers";
|
||||
import { setDataAvailable } from "./graph-helpers";
|
||||
import { hideTooltip, showTooltip } from "./tooltip-utils.svelte";
|
||||
|
@ -167,7 +167,7 @@ export function renderButtons(
|
|||
let colour;
|
||||
|
||||
// Changing color based on mode
|
||||
if(isColourBlindMode){
|
||||
if (isColourBlindMode) {
|
||||
colour = scaleSequential(interpolateViridis).domain([1, 4]);
|
||||
} else {
|
||||
colour = scaleSequential(interpolateRdYlGn).domain([1, 4]);
|
||||
|
|
|
@ -10,6 +10,7 @@ import type { CountableTimeInterval } from "d3";
|
|||
import { timeHour } from "d3";
|
||||
import {
|
||||
interpolateBlues,
|
||||
interpolateMagma,
|
||||
pointer,
|
||||
scaleLinear,
|
||||
scaleSequentialSqrt,
|
||||
|
@ -20,7 +21,6 @@ import {
|
|||
timeSaturday,
|
||||
timeSunday,
|
||||
timeYear,
|
||||
interpolateMagma
|
||||
} from "d3";
|
||||
|
||||
import type { GraphBounds, SearchDispatch } from "./graph-helpers";
|
||||
|
@ -137,11 +137,10 @@ export function renderCalendar(
|
|||
}
|
||||
}
|
||||
const data = Array.from(dayMap.values());
|
||||
const cappedRange = scaleLinear().range([1,0]);
|
||||
const cappedRange = scaleLinear().range([1, 0]);
|
||||
|
||||
const isColorBlindMode = (window as any).colorBlindMode;
|
||||
|
||||
|
||||
let gradient;
|
||||
|
||||
if (isColorBlindMode) {
|
||||
|
|
|
@ -33,8 +33,7 @@ export interface GraphData {
|
|||
|
||||
let barColours;
|
||||
|
||||
if((window as any).colorBlindMode)
|
||||
{
|
||||
if ((window as any).colorBlindMode) {
|
||||
barColours = [
|
||||
colorBlindColors.new, /* new */
|
||||
colorBlindColors.learn, /* learn */
|
||||
|
@ -44,9 +43,7 @@ if((window as any).colorBlindMode)
|
|||
colorBlindColors.suspended, /* suspended */
|
||||
colorBlindColors.buried, /* buried */
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
barColours = [
|
||||
schemeBlues[5][2], /* new */
|
||||
schemeOranges[5][2], /* learn */
|
||||
|
|
|
@ -84,15 +84,11 @@ export function prepareData(
|
|||
.thresholds(ticks)(allEases.entries() as any);
|
||||
const total = sum(bins as any, getNumericMapBinValue);
|
||||
|
||||
|
||||
let colourScale;
|
||||
|
||||
if ((window as any).colorBlindMode)
|
||||
{
|
||||
if ((window as any).colorBlindMode) {
|
||||
colourScale = scaleSequential(interpolateViridis).domain([xMin, 300]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
colourScale = scaleSequential(interpolateRdYlGn).domain([xMin, 300]);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as tr from "@generated/ftl";
|
|||
import { localizedNumber } from "@tslib/i18n";
|
||||
import { dayLabel } from "@tslib/time";
|
||||
import type { Bin } from "d3";
|
||||
import { bin, extent, interpolateGreens, scaleLinear, scaleSequential, sum, interpolateViridis} from "d3";
|
||||
import { bin, extent, interpolateGreens, interpolateViridis, scaleLinear, scaleSequential, sum } from "d3";
|
||||
|
||||
import type { SearchDispatch, TableDatum } from "./graph-helpers";
|
||||
import { getNumericMapBinValue, GraphRange, numericMap } from "./graph-helpers";
|
||||
|
@ -115,7 +115,7 @@ export function buildHistogram(
|
|||
|
||||
let colourScale;
|
||||
|
||||
if(isColorBlindMode) {
|
||||
if (isColorBlindMode) {
|
||||
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMin!, xMax!]);
|
||||
adjustedRange = scaleLinear().range([0.0, 1]);
|
||||
} else {
|
||||
|
@ -123,11 +123,8 @@ export function buildHistogram(
|
|||
adjustedRange = scaleLinear().range([0.7, 0.3]);
|
||||
}
|
||||
|
||||
|
||||
const total = sum(bins as any, getNumericMapBinValue);
|
||||
|
||||
|
||||
|
||||
function hoverText(
|
||||
bin: Bin<number, number>,
|
||||
cumulative: number,
|
||||
|
@ -142,9 +139,6 @@ export function buildHistogram(
|
|||
return `${days}:<br>${cards}<br>${totalLabel}: ${localizedNumber(cumulative)}`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function onClick(bin: Bin<number, number>): void {
|
||||
const start = bin.x0!;
|
||||
// x1 in last bin is inclusive
|
||||
|
|
|
@ -117,5 +117,5 @@ export const colorBlindColors = {
|
|||
mature: "#882255",
|
||||
suspended: "#DDCC77",
|
||||
buried: "#332288",
|
||||
filtered: "#AA4499"
|
||||
filtered: "#AA4499",
|
||||
};
|
||||
|
|
|
@ -88,7 +88,7 @@ export function renderHours(
|
|||
let colour;
|
||||
const isColorBlindMode = (window as any).colorBlindMode;
|
||||
|
||||
if(isColorBlindMode) {
|
||||
if (isColorBlindMode) {
|
||||
cappedRange = scaleLinear().range([0.0, 1]);
|
||||
colour = scaleSequential((n) => interpolateViridis(cappedRange(n)!)).domain([
|
||||
0,
|
||||
|
|
|
@ -150,13 +150,10 @@ export function prepareIntervalData(
|
|||
let adjustedRange;
|
||||
let colourScale;
|
||||
|
||||
if ((window as any).colorBlindMode)
|
||||
{
|
||||
if ((window as any).colorBlindMode) {
|
||||
adjustedRange = scaleLinear().range([0.3, 0.7]);
|
||||
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMax!, xMin!]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
adjustedRange = scaleLinear().range([0.7, 0.3]);
|
||||
colourScale = scaleSequential((n) => interpolateBlues(adjustedRange(n)!)).domain([xMax!, xMin!]);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,10 @@ import {
|
|||
axisLeft,
|
||||
axisRight,
|
||||
bin,
|
||||
color,
|
||||
cumsum,
|
||||
curveBasis,
|
||||
hsl,
|
||||
interpolateBlues,
|
||||
interpolateGreens,
|
||||
interpolatePurples,
|
||||
|
@ -30,8 +32,6 @@ import {
|
|||
scaleSequential,
|
||||
select,
|
||||
sum,
|
||||
color,
|
||||
hsl
|
||||
} from "d3";
|
||||
|
||||
import { colorBlindColors, type GraphBounds, type TableDatum } from "./graph-helpers";
|
||||
|
@ -193,10 +193,9 @@ export function renderReviews(
|
|||
|
||||
const colorBlindMode = (window as any).colorBlindMode;
|
||||
|
||||
|
||||
function makeColorBlindGradient(baseHex: string, satAdjust = 0.02, lightAdjust = 0.02) {
|
||||
const base = color(baseHex);
|
||||
if (!base) {throw new Error(`Invalid color: ${baseHex}`)};
|
||||
if (!base) { throw new Error(`Invalid color: ${baseHex}`); }
|
||||
|
||||
const lighter = hsl(base);
|
||||
lighter.s = Math.min(1, lighter.s + satAdjust);
|
||||
|
@ -216,7 +215,7 @@ export function renderReviews(
|
|||
young: makeColorBlindGradient(colorBlindColors.young),
|
||||
suspended: makeColorBlindGradient(colorBlindColors.suspended),
|
||||
buried: makeColorBlindGradient(colorBlindColors.buried),
|
||||
filtered: makeColorBlindGradient(colorBlindColors.filtered)
|
||||
filtered: makeColorBlindGradient(colorBlindColors.filtered),
|
||||
};
|
||||
|
||||
Object.values(colorBlindScales).forEach(scale => scale.domain(x.domain() as any));
|
||||
|
@ -236,7 +235,6 @@ export function renderReviews(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function valueLabel(n: number): string {
|
||||
if (showTime) {
|
||||
return timeSpan(n / 1000, false, true, TimespanUnit.Hours);
|
||||
|
|
Loading…
Reference in a new issue