-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use typescript and remove unused stuff
- Loading branch information
Showing
28 changed files
with
1,079 additions
and
3,629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env"] | ||
"presets": ["@babel/preset-env", "@babel/preset-typescript"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
{ | ||
"name": "event-viewer", | ||
"version": "1.5.11", | ||
"version": "1.5.12", | ||
"description": "A event viewer script to modify dates in event stores such as suruga-ya to indicate event names", | ||
"main": "./src/index.js", | ||
"repository": "https://github.com/aikoofujimotoo/event-viewer", | ||
"author": "Aiko Fujimoto", | ||
"license": "MIT", | ||
"private": true, | ||
"dependencies": { | ||
"cash-dom": "^8.1.0", | ||
"luxon": "^2.0.1", | ||
"replaceall": "^0.1.6" | ||
"luxon": "^3.3.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.15.0", | ||
"@babel/preset-env": "^7.15.0", | ||
"babel-loader": "^8.2.2", | ||
"@babel/preset-typescript": "^7.21.4", | ||
"@types/luxon": "^3.3.0", | ||
"babel-loader": "^9.1.2", | ||
"typescript": "^5.0.4", | ||
"webpack": "^5.49.0", | ||
"webpack-cli": "^4.6.0" | ||
"webpack-cli": "^5.0.1" | ||
}, | ||
"scripts": { | ||
"build": "node ./scripts/prebuild.js && webpack && node ./scripts/postbuild.js" | ||
"build": "node ./scripts/prebuild.js && webpack --stats-error-details --config ./webpack.config.js && node ./scripts/postbuild.js", | ||
"build:script-only": "webpack --config ./webpack.config.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// ============================================================================ | ||
// Event Viewer | ||
// Copyright (C) 2023 Aiko Fujimoto & Contributors | ||
// | ||
// Licensed under MIT | ||
// ============================================================================ | ||
|
||
import { DateTime, Settings, Interval } from 'luxon'; | ||
import events from './events.json'; | ||
import { DateSupportType } from './support/dateSupportType'; | ||
|
||
type EventValueType = { | ||
evt: string; | ||
value: { | ||
from: string, | ||
to: string | ||
} | string; | ||
}; | ||
|
||
function updateContent(element: HTMLElement, obj: DateSupportType) { | ||
// If locale is specified, then set the default date locale. | ||
if (obj.locale) Settings.defaultLocale = obj.locale; | ||
|
||
// If regex fails, quit. | ||
const date = element.innerText.match(obj.date); | ||
if (!date) return; | ||
|
||
const dateFormat = obj.formatting || 'yyyy/MM/dd'; | ||
|
||
element.innerText += ' ' + events.filter((event: EventValueType) => { | ||
if (typeof event.value === 'object') { | ||
const from = DateTime.fromFormat(event.value.from, 'yyyy/MM/dd'); | ||
const to = DateTime.fromFormat(event.value.to, 'yyyy/MM/dd').plus(1); | ||
const current = DateTime.fromFormat(date[0], dateFormat); | ||
|
||
return Interval.fromDateTimes(from, to).contains(current); | ||
} | ||
|
||
const current = DateTime.fromFormat(date[0], dateFormat); | ||
const eventDate = DateTime.fromFormat(event.value, 'yyyy/MM/dd'); | ||
|
||
return current.equals(eventDate); | ||
}).map((event: EventValueType) => event.evt).join(' '); | ||
} | ||
|
||
export default function dateSupportHandler(obj: DateSupportType) { | ||
if (!window.location.href.match(obj.url)) return; | ||
obj.el.forEach(value => { | ||
const elements = document.querySelectorAll(value); | ||
|
||
for (const element of elements) { | ||
if (!(element as HTMLElement).innerText || !(element instanceof Element)) continue; | ||
updateContent(element as HTMLElement, obj); | ||
} | ||
}) | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// ============================================================================ | ||
// Event Viewer | ||
// Copyright (C) 2023 Aiko Fujimoto & Contributors | ||
// | ||
// Licensed under MIT | ||
// ============================================================================ | ||
|
||
import dateSupportHandler from './dateSupportHandler'; | ||
import surugaya from './support/dates/surugaya'; | ||
import melonbooks from './support/dates/melonbooks'; | ||
import discogs from './support/dates/discogs'; | ||
import { DateSupportType } from './support/dateSupportType'; | ||
|
||
function init(eventHandler: (obj: DateSupportType) => void, events: DateSupportType[]) { | ||
events.forEach(event => eventHandler(event)); | ||
} | ||
|
||
init(dateSupportHandler, [ | ||
...surugaya, | ||
...melonbooks, | ||
...discogs | ||
]); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.