Skip to content

Instantly share code, notes, and snippets.

View yue1123's full-sized avatar

dh yue1123

  • 12:01 (UTC)
View GitHub Profile
@yue1123
yue1123 / js
Last active August 31, 2025 16:35
theme init
(function () {
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
const setting = localStorage.getItem('color-schema') || 'auto'
if (setting === 'dark' || (prefersDark && setting !== 'light'))
document.documentElement.classList.toggle('dark', true)
})()
@yue1123
yue1123 / isEventSupported.js
Last active April 19, 2024 15:39
Determining whether a browser supports an event
function is( obj, type ) {
return typeof obj === type;
}
var isEventSupported = (function() {
var TAGNAMES = {
'select': 'input', 'change': 'input',
'submit': 'form', 'reset': 'form',
'error': 'img', 'load': 'img', 'abort': 'img'
@yue1123
yue1123 / angularAnyOrderParamsInject.js
Last active April 19, 2024 15:59
Angular.js any order function params Inject
const instance = {
$scope: '我是$scope',
$state: '我是$state',
$timeout: '我是$timeout',
$uibModal: '我是$uibModal'
}
let FN_ARGS = /^[^\(]*\(\s*([^\)]*)\)/m
let FN_ARG_SPLIT = /,/
let FN_ARG = /^\s*(_?)(\S+?)\1\s*$/