repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
beenotung/stencil-virtual-scroll
src/components/virtual-scroll-list/helpers.ts
export function getElementHeight(e: Element): number { return e.clientHeight || e.getBoundingClientRect().height }
beenotung/stencil-virtual-scroll
src/components/virtual-scroll-demo/virtual-scroll-demo.tsx
import { Component, h, Host } from '@stencil/core'; @Component({ tag: 'virtual-scroll-demo', styleUrl: 'virtual-scroll-demo.css', scoped: true, }) export class VirtualScrollDemo { render() { const N = 100000; const width = 250; const height = 150; return ( <Host> before <...
martinsung00/Frostbolt
src/utils/currentStatus.ts
import { CurrentStatus } from "../types"; const statuses: CurrentStatus = { failed_internal: "Internal Error", failed_external: "Input Error", success: "Operation Successful", }; export default statuses;
martinsung00/Frostbolt
src/utils/index.ts
import dataTypes from "./dataTypes"; import statuses from "./currentStatus"; export { dataTypes, statuses };
martinsung00/Frostbolt
src/utils/dataTypes.ts
<reponame>martinsung00/Frostbolt<gh_stars>0 const dataTypes = { postgres: [ "boolean", "varchar", "char", "int", "smallint", "bigint", "decimal", "numeric", "real", "double precision", "smallserial", "bigserial", "serial", "money", "text", "varying", ...
martinsung00/Frostbolt
test/src/plugin.test.ts
import Seeder from "../../src"; describe("Seeder Plugin Tests", () => { const mockUrl: string = "localhost:5432"; const mockSchema: { [key: string]: string; } = { cats: "varchar", dog: "int", }; let seeder: Seeder; beforeAll(() => { seeder = new Seeder(mockUrl, mockSchema); }); afterA...
martinsung00/Frostbolt
src/index.ts
<filename>src/index.ts import Seeder from "./plugin"; export default Seeder;
martinsung00/Frostbolt
src/types/currentStatus.ts
<filename>src/types/currentStatus.ts export type CurrentStatus = { failed_internal: string; failed_external: string; success: string; };
martinsung00/Frostbolt
src/plugin.ts
<reponame>martinsung00/Frostbolt<filename>src/plugin.ts import { statuses } from "./utils"; export default class Seeder { url: string; schema: { [key: string]: "string" | number; }; constructor(url: string, schema: {}) { this.url = url; this.schema = schema; } public seed = async (): Promise<...
martinsung00/Frostbolt
src/types/index.ts
import { CurrentStatus } from "./currentStatus"; export { CurrentStatus };
egoist/svelte-convert
src/vue.ts
<reponame>egoist/svelte-convert import { isServer } from './shared' export function convert(Component: any): any { if (isServer) { return { functional: true, render(h: any, ctx: any) { const { html, style } = Component.render(ctx.attrs) return h('div', {}, [ h('style', { dom...
egoist/svelte-convert
declarations.d.ts
declare module '*.svelte'
egoist/svelte-convert
test/react.test.tsx
<gh_stars>10-100 import React from 'react' import { renderToString } from 'react-dom/server' import SvelteCounter from './Counter.node.svelte' import { convert } from '../src/react' it('renders to string', () => { const Counter = convert<{ initialCount: number }>(SvelteCounter.default) const str = renderToString(<...
egoist/svelte-convert
vue.d.ts
<filename>vue.d.ts export * from './dist/vue'
egoist/svelte-convert
react.d.ts
<gh_stars>10-100 export * from './dist/react'
egoist/svelte-convert
src/react.tsx
import React from 'react' import { isServer } from './shared' export function convert<TProps = any>(Component: any): React.FC<TProps> { if (isServer) { return (props) => { const { html, css } = Component.render(props) return ( <> <style>{css.code}</style> <div dangerouslyS...
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/care-card/shared/care-plan-event.model.ts
import { CarePlanActivity } from "./care-plan-activity.model"; export class CarePlanEvent { occurrenceIndexOfDay: number; date: Date; activity: CarePlanActivity; value: number; constructor(activity: CarePlanActivity, date: Date, occurrenceIndexOfDay: number, value: number = 0) { this.activ...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/survey/survey-complete/survey-complete.component.ts
import { Component, OnInit } from "@angular/core"; import { RouterExtensions } from "nativescript-angular/router"; import { AppService } from "../../shared/app.service"; @Component({ selector: "Complete", templateUrl: "./survey-complete.component.html" }) export class SurveyCompleteComponent implements OnInit...
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/care-routing.module.ts
<reponame>rynop/nativescript-app-templates import { NgModule } from "@angular/core"; import { Routes } from "@angular/router"; import { NativeScriptRouterModule } from "nativescript-angular/router"; import { ActivityDetailComponent } from "./care-card/activity-detail/activity-detail.component"; import { CareComponent ...
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/care-card/shared/care-plan-activity-type.enum.ts
export const enum CarePlanActivityType { Activity = 0, Assessment = 1, ReadOnly = 2 }
rynop/nativescript-app-templates
packages/template-drawer-navigation-ts/app/shared/selected-page-service.ts
import { BehaviorSubject, Observable } from "rxjs"; export class SelectedPageService { static getInstance(): SelectedPageService { return SelectedPageService._instance; } private static _instance: SelectedPageService = new SelectedPageService(); selectedPage$: Observable<string>; private...
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/care-card/shared/care-card.service.ts
import { Injectable } from "@angular/core"; import { BehaviorSubject, Observable } from "rxjs"; import { CareCardActivityService } from "./care-card-activity.service"; import { CareCardEventService } from "./care-card-event.service"; import { CarePlanActivityType } from "./care-plan-activity-type.enum"; import { CareP...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/core/task-manager/steps/study-text-step.model.ts
<gh_stars>1-10 import { StudyStep } from "./study-step.model"; export class StudyTextStep extends StudyStep { results: Array<any>; saveable: boolean; identifier: string; constructor(identifier: string, textAnswer: string) { super(identifier); this.results = [ { ...
rynop/nativescript-app-templates
packages/template-master-detail-kinvey-ts/app/cars/car-detail-edit-page/car-detail-edit-view-model.ts
<reponame>rynop/nativescript-app-templates<filename>packages/template-master-detail-kinvey-ts/app/cars/car-detail-edit-page/car-detail-edit-view-model.ts import * as imagePicker from "nativescript-imagepicker"; import { Observable } from "tns-core-modules/data/observable"; import { Folder, knownFolders, path } from "tn...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/core/task-manager/steps/sign-up-step.model.ts
<gh_stars>1-10 export class SignUpStep { results: Array<any>; saveable: boolean; identifier: string; constructor(identifier: string) { this.results = []; this.saveable = false; this.identifier = identifier; } }
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/consent/consent-review/consent/consent-form.model.ts
export class ConsentForm { firstName: string; lastName: string; constructor() { this.firstName = ""; this.lastName = ""; } }
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/core/task-manager/steps/consent-sharing-step.model.ts
export class ConsentSharingStep { results: Array<any>; saveable: boolean; identifier: string; constructor(identifier: string, answer: boolean) { this.results = [{ choiceAnswers: [ answer ], questionType: "SingleChoice", saveable: f...
rynop/nativescript-app-templates
packages/template-master-detail-kinvey-ng/src/app/app.module.ts
<reponame>rynop/nativescript-app-templates import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; import { NativeScriptModule } from "nativescript-angular/nativescript.module"; // TODO: should be imported from kinvey-nativescript-sdk/angular but declaration file is currently missing import { KinveyModule } from "k...
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/connect/shared/patient.model.ts
<gh_stars>0 import { Contact } from "./contact.model"; export class Patient { name: string; monogram: string; userInfo: any; tintColor: string; careTeamContacts: Array<Contact>; constructor(options: any) { this.name = options.name; this.monogram = options.monogram; this...
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/login/registration/registration-form.model.ts
<reponame>rynop/nativescript-app-templates<filename>packages/template-patient-care-ng/src/login/registration/registration-form.model.ts export class RegistrationForm { email: string; password: string; passwordConfirm: string; givenName: string; familyName: string; gender: string; dateOfBirth...
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/care-card/shared/care-plan-activity.model.ts
<gh_stars>0 import { CarePlanActivityGroup } from "./care-plan-activity-group.enum"; import { CarePlanEvent } from "./care-plan-event.model"; export class CarePlanActivity { groupIdentifier: CarePlanActivityGroup; title: string; text: string; tintColor: any; instructions: string; schedule: any;...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/survey/survey-routing.module.ts
<reponame>rynop/nativescript-app-templates<filename>packages/template-health-survey-ng/src/app/survey/survey-routing.module.ts import { NgModule } from "@angular/core"; import { Routes } from "@angular/router"; import { NativeScriptRouterModule } from "nativescript-angular/router"; import { SurveyBooleanQuestionCompon...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/core/task-manager/steps/index.ts
<filename>packages/template-health-survey-ng/src/app/core/task-manager/steps/index.ts export * from "./consent-review-step.model"; export * from "./consent-sharing-step.model"; export * from "./registration-step.model"; export * from "./sign-up-step.model"; export * from "./study-boolean-step.model"; export * from "./s...
rynop/nativescript-app-templates
packages/template-master-detail-kinvey-ts/app/shared/config.ts
<filename>packages/template-master-detail-kinvey-ts/app/shared/config.ts export class Config { static kinveyAppKey = "kid_By1mL8fnb"; static kinveyAppSecret = "4b0c01a98ce942e89d04acecdfa8dcaa"; static kinveyUsername = "admin"; static kinveyPassword = "<PASSWORD>"; }
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/care-card/shared/care-card-activity.service.ts
import { Injectable } from "@angular/core"; // TODO: should be imported from kinvey-nativescript-sdk/angular but declaration file is currently missing import { DataStoreService, Errors } from "kinvey-nativescript-sdk/lib/angular"; import { CareCardEventService } from "./care-card-event.service"; import { CarePlanActiv...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/survey/survey-text-question.component.ts
import { Component } from "@angular/core"; import { RouterExtensions } from "nativescript-angular/router"; import { StudyTextStep } from "../core/task-manager/steps"; import { TaskManagerService } from "../core/task-manager/task-manager.service"; import { AppService } from "../shared/app.service"; @Component({ se...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/shared/shared.module.ts
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; import { NativeScriptUIDataFormModule } from "nativescript-ui-dataform/angular"; @NgModule({ imports: [ NativeScriptUIDataFormModule ], exports: [ NativeScriptUIDataFormModule ], providers: [], schemas: [ NO_ERR...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/core/task-manager/steps/consent-review-step.model.ts
export class ConsentReviewStep { results: Array<any>; saveable: boolean; identifier: string; constructor(identifier: string, givenName: string, familyName: string) { this.results = [{ identifier: "consentDocumentParticipantSignature", consented: true, saveabl...
rynop/nativescript-app-templates
packages/template-master-detail-kinvey-ts/app/cars/car-detail-page/car-detail-page.ts
import { topmost } from "tns-core-modules/ui/frame"; import { NavigatedData, Page } from "tns-core-modules/ui/page"; import { CarDetailViewModel } from "./car-detail-view-model"; /* *********************************************************** * This is the item details code behind in the master-detail structure. * Thi...
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/connect/shared/contact.model.ts
import { ContactInfo } from "./contact-info.model"; export class Contact { id: string; name: string; monogram: string; tintColor: string; relation: string; type: number; contactInfoItems: Array<ContactInfo>; constructor(options: any) { this.id = options._id; this.name =...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/shared/config.ts
export class Config { static kinveyAppKey: string = "<KEY>"; static kinveyAppSecret: string = "4440bad69221497e90051e761c97deed"; static kinveyApiHostname: string; static kinveyMicHostname: string; }
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/connect/shared/connect-item.model.ts
export class ConnectItem { id: string; name: string; shortName: string; title: string; phone: string; email: string; constructor(id, name, shortName, title, phone, email) { this.id = id; this.name = name; this.shortName = shortName; this.title = title; ...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/survey/survey.module.ts
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; import { NativeScriptCommonModule } from "nativescript-angular/common"; import { NativeScriptFormsModule } from "nativescript-angular/forms"; import { SharedModule } from "../shared/shared.module"; import { SurveyBooleanQuestionComponent } from "./survey-bool...
rynop/nativescript-app-templates
packages/template-master-detail-kinvey-ts/app/cars/cars-list-view-model.ts
<reponame>rynop/nativescript-app-templates import { Observable } from "tns-core-modules/data/observable"; import { ObservableArray } from "tns-core-modules/data/observable-array"; import { Config } from "../shared/config"; import { ObservableProperty } from "../shared/observable-property-decorator"; import { Car } fro...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/core/task-manager/steps/study-date-step.model.ts
import * as jsTimezone from "jstimezonedetect"; import { StudyStep } from "./study-step.model"; export class StudyDateStep extends StudyStep { private static getIsDaylightSavingTime(date: Date) { const januaryDate = new Date(date.getFullYear(), 0, 1); const julyDate = new Date(date.getFullYear(), 6...
rynop/nativescript-app-templates
packages/template-master-detail-kinvey-ng/src/app/cars/shared/car.service.ts
<reponame>rynop/nativescript-app-templates<gh_stars>1-10 import { Injectable } from "@angular/core"; // TODO: should be imported from kinvey-nativescript-sdk/angular but declaration file is currently missing import { DataStoreService, FilesService, UserService, Query } from "kinvey-nativescript-sdk/lib/angular"; import...
rynop/nativescript-app-templates
packages/template-drawer-navigation-ts/app/search/search-page.ts
import { RadSideDrawer } from "nativescript-ui-sidedrawer"; import * as app from "tns-core-modules/application"; import { EventData } from "tns-core-modules/data/observable"; import { NavigatedData, Page } from "tns-core-modules/ui/page"; import { SearchViewModel } from "./search-view-model"; export function onNaviga...
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/care-card/shared/care-plan-activity-group.enum.ts
export const enum CarePlanActivityGroup { Physical = "Physical Activity", Assessment = "Assessment", Medication = "Medications", Other = "Other" }
rynop/nativescript-app-templates
packages/template-patient-care-ng/src/care/care.module.ts
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; import { NativeScriptCommonModule } from "nativescript-angular/common"; import { NativeScriptFormsModule } from "nativescript-angular/forms"; import { NativeScriptUIGaugeModule } from "nativescript-ui-gauge/angular"; import { NativeScriptUIListViewModule } fro...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/core/task-manager/steps/registration-step.model.ts
export class RegistrationStep { results: Array<any>; saveable: boolean; identifier: string; constructor(identifier: string, registrationData: any) { this.results = [ { textAnswer: registrationData.email, questionType: "Text", saveable:...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/consent/consent-routing.module.ts
import { NgModule } from "@angular/core"; import { Routes } from "@angular/router"; import { NativeScriptRouterModule } from "nativescript-angular/router"; import { ConsentComponent } from "./consent-review/consent/consent.component"; import { ReviewComponent } from "./consent-review/review/review.component"; import {...
rynop/nativescript-app-templates
packages/template-master-detail-ts/app/cars/cars-list-page.ts
<filename>packages/template-master-detail-ts/app/cars/cars-list-page.ts<gh_stars>0 import { ListViewEventData } from "nativescript-ui-listview"; import { topmost } from "tns-core-modules/ui/frame"; import { NavigatedData, Page } from "tns-core-modules/ui/page"; import { CarsListViewModel } from "./cars-list-view-model...
rynop/nativescript-app-templates
packages/template-health-survey-ng/src/app/consent/consent.module.ts
<filename>packages/template-health-survey-ng/src/app/consent/consent.module.ts import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; import { NativeScriptCommonModule } from "nativescript-angular/common"; import { SharedModule } from "../shared/shared.module"; import { ConsentComponent } from "./consent-review/c...
SimonAlling/better-sweclockers
src/operations/actions/split-quote.ts
<reponame>SimonAlling/better-sweclockers import * as BB from "bbcode-tags"; import * as CONFIG from "~src/config"; import * as SITE from "~src/site"; import { r } from "~src/utilities"; import { insertIn, placeCursorIn } from "../logic/textarea"; export default function(textarea: HTMLTextAreaElement, undoSupport: bo...
SimonAlling/better-sweclockers
__tests__/browser.test.ts
import { check } from "jest-function"; import * as browser from "../src/browser"; import { sorted } from "./utilities"; // What Is My Browser (WIMB) Database: // https://developers.whatismybrowser.com/useragents/explore/software_type_specific/web-browser describe("Android detection", () => { it("is sound", () =...
SimonAlling/better-sweclockers
src/operations.ts
<reponame>SimonAlling/better-sweclockers<gh_stars>10-100 import { DOMCONTENTLOADED } from "userscripter/lib/environment"; import { Operation, operation } from "userscripter/lib/operations"; import * as CONFIG from "~src/config"; import { isInEditMode, isInEditMode_forum, isInEditMode_market, isInEditMo...
SimonAlling/better-sweclockers
__tests__/utilities.ts
<filename>__tests__/utilities.ts<gh_stars>10-100 // Pure (not in-place) sort function. export function sorted<T>(xs: readonly T[]): T[] { return xs.slice().sort(); }
SimonAlling/better-sweclockers
webpack.config.ts
<filename>webpack.config.ts import * as AppRootPath from "app-root-path"; import { createWebpackConfig, distFileName, DEFAULT_BUILD_CONFIG, DEFAULT_METADATA_SCHEMA, } from "userscripter/build"; import * as webpack from "webpack"; import { RawSource } from "webpack-sources"; import METADATA, { versionBa...
SimonAlling/better-sweclockers
src/preferences/keyboard.ts
import { ListPreference } from "ts-preferences"; import { Action } from "~src/actions"; import * as T from "~src/text"; export type ShortcutEntry = Readonly<{ shortcut: string, action: Action, }> export default new ListPreference<ShortcutEntry>({ key: "keyboard", label: T.preferences._.NO_LABEL, ...
SimonAlling/better-sweclockers
src/operations/preferences-menu.tsx
<reponame>SimonAlling/better-sweclockers import { h } from "preact"; import { insertAtTheEnd, renderIn } from "~src/operations/logic/render"; import { PreferencesForm } from "~src/preferences-menu"; import * as SITE from "~src/site"; import * as T from "~src/text"; import { yyyymmdd } from "~src/utilities"; export de...
SimonAlling/better-sweclockers
src/utilities.ts
<filename>src/utilities.ts export const r = String.raw; export function fromMaybeUndefined<T>(fallback: T, x?: T): T { return x === undefined ? fallback : x; } export function truncate(maxTotalLength: number, s: string): string { const REPLACEMENT = "[…]" as const; return ( s.length > maxTotalLeng...
SimonAlling/better-sweclockers
src/operations/autosave-draft.ts
import * as ms from "milliseconds"; import * as Storage from "ts-storage"; import { isNumber, isString } from "ts-type-guards"; import { log } from "userscripter"; import * as CONFIG from "~src/config"; import { insertAtTheEnd, renderIn } from "~src/operations/logic/render"; import { P, Preferences } from "~src/prefer...
SimonAlling/better-sweclockers
src/preferences/dark-theme.ts
import * as ms from "milliseconds"; import { BooleanPreference, IntegerRangePreference, } from "ts-preferences"; import * as CONFIG from "~src/config"; import * as T from "~src/text"; import { TimePreference } from "./TimePreference"; const auto = new BooleanPreference({ key: "dark_theme_auto", defau...
SimonAlling/better-sweclockers
src/text.ts
// This file cannot contain Webpack-resolved imports (e.g. "~src/foo"). import * as BB from "bbcode-tags"; import * as browser from "./browser"; import * as CONFIG from "./config"; import * as SITE from "./site"; import { InsertButtonDescription } from "./types"; function genitive(name: string): string { return ...
SimonAlling/better-sweclockers
src/operations/logic/render.ts
import { JSX, render } from "preact"; import { isString } from "ts-type-guards"; import { log } from "userscripter"; import { truncate } from "~src/utilities"; /** * A function assumed to insert `placeholder` in `parent`. */ type InsertIn<Parent extends Element> = ( /* This type has an object parameter inst...
SimonAlling/better-sweclockers
src/operations/preferences-shortcut.tsx
<reponame>SimonAlling/better-sweclockers import { h } from "preact"; import * as CONFIG from "~src/config"; import { insertAtTheBeginning, renderIn } from "~src/operations/logic/render"; import * as SITE from "~src/site"; import * as T from "~src/text"; export default (e: { notificationsBar: HTMLElement, }) => { ...
SimonAlling/better-sweclockers
src/search-engines.ts
export const enum SearchEngine { // Be careful! These strings are used in the UI. GOOGLE = "Google", DUCKDUCKGO = "DuckDuckGo", } function searchEngineURL(engine: SearchEngine): string { switch (engine) { case SearchEngine.GOOGLE: return "https://google.com/search?q="; case SearchEngine...
SimonAlling/better-sweclockers
src/lib/proofreading/index.ts
import { RULES, RULES_SUP, PATTERN_DOPPELGANGERS } from "@alling/sweclockers-writing-rules"; import { compose } from "@typed/compose"; import { proofreadWith, highlightWith } from "highlight-mistakes"; import C from "./classes"; type StringTransformer = (s: string) => string; export function processNodeWith(f: Strin...
SimonAlling/better-sweclockers
src/operations/developer-mode.tsx
import { Component, h, JSX, render } from "preact"; import * as Storage from "ts-storage"; import { log } from "userscripter"; import * as CONFIG from "~src/config"; import * as T from "~src/text"; export function logger(regularLogger: log.Logger, rootNode: Element): log.Logger { const initOpen = Storage.get_sess...
SimonAlling/better-sweclockers
src/operations/remember-location-in-market.ts
<filename>src/operations/remember-location-in-market.ts import { isString } from "ts-type-guards"; import { log } from "userscripter"; import { P, Preferences } from "~src/preferences"; export default (e: { city: HTMLElement, region: HTMLElement, saveButton: HTMLElement, }) => { const cityInput = e.city as ...
SimonAlling/better-sweclockers
src/preferences.ts
<gh_stars>10-100 import { PreferenceManager } from "ts-preferences"; import { loggingResponseHandler, subscriptable } from "userscripter/lib/preferences"; import * as CONFIG from "~src/config"; import * as darkTheme from "~src/dark-theme"; import * as T from "~src/text"; import U from "~src/userscript"; import advanc...
SimonAlling/better-sweclockers
src/operations/dark-theme.tsx
<gh_stars>10-100 import * as ms from "milliseconds"; import { h } from "preact"; import { isNull } from "ts-type-guards"; import { disable } from "userscripter/lib/stylesheets"; import * as CONFIG from "~src/config"; import * as darkTheme from "~src/dark-theme"; import iconDarkThemeToggle from "~src/icons/dark-theme-t...
SimonAlling/better-sweclockers
src/stylesheets/hide.ts
<gh_stars>10-100 import { isString } from "ts-type-guards"; import { r } from "~src/utilities"; export function hideById(i: string): string { return hideBySelector("#" + i); } export function hideByClass(c: string | readonly string[]): string { return hideBySelector(isString(c) ? "."+c : c.map(x => "."+x).jo...
SimonAlling/better-sweclockers
src/operations/improved-builtin-editing-tools.ts
import { insertIn, wrapIn } from "./logic/textarea"; declare namespace Tanuki { const Templates: any; } export default () => { /* SweClockers' built-in functions use `.value`, which kills undo history. This operation replaces them with our own `text-field-edit`-based versions, thereby reintroducing undo/r...
SimonAlling/better-sweclockers
src/dark-theme.ts
export const AUTHOR = "Soitora" as const; export const URL = { stylesheet: "https://soitora.com/SweClockers-Dark/sweclockers-dark.css", info: "/forum/trad/1515628", } as const;
SimonAlling/better-sweclockers
src/operations/table-toolbar-button.tsx
import { empty, end, start } from "bbcode-tags"; import { unlines } from "lines-unlines"; import { insertAtTheEnd, renderIn } from "~src/operations/logic/render"; import * as SITE from "~src/site"; import * as T from "~src/text"; import { toolbarButton } from "./logic/editing-tools"; import { indent, insert } from "....
SimonAlling/better-sweclockers
metadata.ts
import { Metadata } from "userscript-metadata"; import { BuildConfig, metadataUrl, } from "userscripter/build"; import U from "./src/userscript"; export default function(buildConfig: BuildConfig): Metadata { const hostedAt = buildConfig.hostedAt; return { name: U.name, version: version...
SimonAlling/better-sweclockers
src/operations/edit-mode.ts
<reponame>SimonAlling/better-sweclockers<gh_stars>10-100 import * as SITE from "~src/site"; // Examples include `@Alling: `, `@Alling:` and `@"---": `. const REGEX_POSSIBLY_CLEAN_SLATE_REPLY = /^@("?)([^"]+)\1: ?$/; // Examples include `@Alling: `, `@Alling:` and `@"Better SweClockers": `. export function isCleanSlat...
SimonAlling/better-sweclockers
src/operations/logic/click.ts
<filename>src/operations/logic/click.ts import { BUTTON_CLICK_EVENT } from "~src/operations/prevent-accidental-unload"; export function clickOn(element: HTMLElement): void { // Prevent accidental unload listens for these events: element.dispatchEvent(new Event(BUTTON_CLICK_EVENT)); // click() is necessary ...
SimonAlling/better-sweclockers
src/selectors.ts
<gh_stars>10-100 import "css.escape"; // It is side-effecty. import * as SITE from "~src/site"; const C = SITE.CLASS; const settingsNavigation = `ul.${C.settingsNavigation}`; const actionButtons = `button[name=action]`; const actionButtonsQuickReply = `#quickreply .controls button`; const forumPostContainer = "." +...
SimonAlling/better-sweclockers
src/operations/textarea-size-toggle.tsx
import { h, JSX } from "preact"; import { NumericPreference } from "ts-preferences"; import * as CONFIG from "~src/config"; import iconTextareaLarge from "~src/icons/textarea-large.svg"; import iconTextareaSmall from "~src/icons/textarea-small.svg"; import { insertAtTheEnd, renderIn } from "~src/operations/logic/rende...
SimonAlling/better-sweclockers
src/types.ts
<gh_stars>10-100 export interface InsertButtonDescription { insert: string tooltip: string label?: string }
SimonAlling/better-sweclockers
src/operations/actions/shibe.ts
<reponame>SimonAlling/better-sweclockers import * as BB from "bbcode-tags"; import { lines, unlines } from "lines-unlines"; import * as CONFIG from "~src/config"; import * as SITE from "~src/site"; import * as T from "~src/text"; import { insertIn, selectedTextIn } from "../logic/textarea"; export default function(t...
SimonAlling/better-sweclockers
src/time.ts
<reponame>SimonAlling/better-sweclockers export function timeIsWithin(interval: Readonly<{ start: number, end: number }>) { return (time: Date): boolean => { const t = timeOfDay(time); const start = interval.start; const end = interval.end; return ( end < start ...
SimonAlling/better-sweclockers
src/preferences/customize-content.ts
import { BooleanPreference, } from "ts-preferences"; import * as T from "~src/text"; export default { carousel: new BooleanPreference({ key: "customize_content_carousel", default: true, label: T.preferences.customize_content.carousel, }), social_media: new BooleanPreference({ ...
SimonAlling/better-sweclockers
src/operations/improved-corrections.ts
import * as SITE from "~src/site"; import { withMaybe } from "~src/utilities"; export default (e: { correctionsLink: HTMLElement }) => { e.correctionsLink.addEventListener("click", event => { withMaybe(document.querySelector("." + SITE.CLASS.proofDialog), proofDialog => { event.stopImmediatePro...
SimonAlling/better-sweclockers
src/operations/heading-toolbar-button.tsx
<reponame>SimonAlling/better-sweclockers<filename>src/operations/heading-toolbar-button.tsx import { insertAtTheEnd, renderIn } from "~src/operations/logic/render"; import * as SITE from "~src/site"; import * as T from "~src/text"; import { toolbarButton } from "./logic/editing-tools"; import { wrap_tag } from "./logi...
SimonAlling/better-sweclockers
src/operations/actions/search-link.ts
import * as BB from "bbcode-tags"; import { SearchEngine, searchURL } from "~src/search-engines"; import * as SITE from "~src/site"; import { selectedTextIn, wrapIn } from "../logic/textarea"; export default (engine: SearchEngine) => (textarea: HTMLTextAreaElement, _: boolean) => { const tagName = SITE.TAG.url; ...
SimonAlling/better-sweclockers
src/operations/keyboard-shortcuts/edit-mode.ts
import * as Mousetrap from "mousetrap"; import { Action } from "~src/actions"; import { clickOn } from "~src/operations/logic/click"; import { P, Preferences } from "~src/preferences"; import { insertIn } from "../logic/textarea"; const keyboardShortcuts = Preferences.get(P.keyboard); export function submit(e: { ...
SimonAlling/better-sweclockers
src/environment.ts
import * as CONFIG from "./config"; import * as SITE from "./site"; // NOTE: Be careful with document.head here, as it may be null at the time of // userscript execution (e.g. in a background tab in Firefox)! export const isOnBSCPreferencesPage = pathMatches(CONFIG.PATH.PREFERENCES.check(SITE.PATH.SETTINGS.check)); ...
SimonAlling/better-sweclockers
__tests__/editing-tools.test.ts
<reponame>SimonAlling/better-sweclockers<filename>__tests__/editing-tools.test.ts import * as smileys from "../src/operations/logic/smileys"; describe("smiley toolbar", () => { it("contains :)", () => { expect(smileys.SMILEYS).toContainEqual<smileys.Smiley>([ ":)", "smiley-smile" ]); }); });
SimonAlling/better-sweclockers
src/browser.ts
export function supportsUndo(userAgent: string): boolean { /* Hard to know for sure, but Gecko browsers don't support document.execCommand as of 2020-07-18 (Firefox 78). https://bugzilla.mozilla.org/show_bug.cgi?id=1220696 "Why not use feature detection?" Because document.execCommand can't be feature-de...
SimonAlling/better-sweclockers
src/stylesheets.ts
import * as ms from "milliseconds"; import { ALWAYS } from "userscripter/lib/environment"; import { Stylesheets, stylesheet } from "userscripter/lib/stylesheets"; import * as CONFIG from "~src/config"; import { isInEditMode, isOnBSCPreferencesPage, isOnSweclockersSettingsPage, isReadingThread } from "~src/environment"...
SimonAlling/better-sweclockers
src/operations/logic/textarea.ts
import * as BB from "bbcode-tags"; import * as textFieldEdit from "text-field-edit"; import { isNumber } from "ts-type-guards"; import * as CONFIG from "~src/config"; type InsertionResult = Readonly<{ textareaContent: string, startOfInserted: number, endOfInserted: number, }> type Insertion = Readonly<{ ...
SimonAlling/better-sweclockers
src/operations/link-to-top.tsx
<reponame>SimonAlling/better-sweclockers<filename>src/operations/link-to-top.tsx import { h } from "preact"; import { insertAtTheEnd, renderIn } from "~src/operations/logic/render"; import * as SITE from "~src/site"; import * as T from "~src/text"; export default (e: { parent: HTMLElement }) => { renderIn(e.paren...
SimonAlling/better-sweclockers
src/site.ts
// This file cannot contain Webpack-resolved imports (e.g. "~src/foo"). import U from "./userscript"; export const NAME = U.sitename; export const HOSTNAME = U.hostname; export const HOSTNAME_MOBILE = `m.` + HOSTNAME; export const STYLESHEET_URL = (yyyymmdd: string) => `/css/combine.min.sass.css?v=${yyyymmdd}`; exp...
SimonAlling/better-sweclockers
src/preferences/general.ts
<gh_stars>10-100 import { BooleanPreference, IntegerPreference, StringPreference, } from "ts-preferences"; import * as T from "~src/text"; export default { lock_heights: new BooleanPreference({ key: "lock_heights", default: true, label: T.preferences.general.lock_heights, ...
SimonAlling/better-sweclockers
src/operations/mention-everyone.tsx
import unique from "array-uniq"; import { h, JSX } from "preact"; import * as CONFIG from "~src/config"; import { mention } from "~src/operations/edit-mode"; import { insertBefore, renderIn } from "~src/operations/logic/render"; import SELECTOR from "~src/selectors"; import * as SITE from "~src/site"; import * as T f...
SimonAlling/better-sweclockers
src/operations/logic/smileys.ts
export type Smiley = readonly [string, string] export const SMILEYS: ReadonlyArray<Smiley> = [ // Pairs of BBCode code and CSS class: [ ":)", "smiley-smile" ], [ ";)", "smiley-wink" ], [ ":D", "smiley-biggrin" ], [ ":P", "smiley-tongue" ], [ ":O", "smiley-surprised" ], [ ":(", "smiley-frown...
SimonAlling/better-sweclockers
src/preferences/forum-threads.ts
<filename>src/preferences/forum-threads.ts import { BooleanPreference, StringPreference, } from "ts-preferences"; import * as T from "~src/text"; const quote_signature_buttons = new BooleanPreference({ key: "quote_signature_buttons", default: true, label: T.preferences.forum_threads.quote_signatur...