Skip to content

Instantly share code, notes, and snippets.

@nowri
nowri / jquery.redux.js
Last active January 15, 2020 01:59
jQueryでFluxライブラリreduxを使えるようになるPlugin
/*! jquery.redux.js | Copyright (c) 2015 nowri | The MIT License (MIT) */
(function(factory) {
if(typeof exports === 'object') {
factory(require('jquery'));
} else if(typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(jQuery);
}
}(function($) {
@nowri
nowri / gist:1916187
Last active October 12, 2017 07:10
URLからクエリ値取得
/**
* @see http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx
*/
<script type="text/jscript" language="javascript">
function getQuerystring(key, default_)
{
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
@nowri
nowri / util.js
Last active May 8, 2017 20:16
inputフォームのvalueをHH:mm形式にフォーマットする
import moment from 'moment'
export default {
formInputTime (val = '') {
let h, m, ar
val = val.replace(/(^\s+)|(\s+$)/g, '').replace(/\n/g, '')
ar = val.split(':')
if (ar.length === 2) {
h = ar[0]
m = ar[1]
} else {
@nowri
nowri / sphover.js
Created April 17, 2017 06:26
スマホブラウザでホバーエフェクト。Androidブラウザのtouchend対応
var hoverEffect = function($dom, timerIdList) {
var CLASS_HOVER = "hover",
touthStart = (Modernizr.touch)? "touchstart" : "mouseover",
touthEnd = (Modernizr.touch)? "touchend" : "mouseout",
isAndroid = isMobile.Android();
$dom.each(function(i, el){
@nowri
nowri / es6timer.js
Created July 15, 2016 07:55
ES6Timer
const STATE_READY = 1;
const STATE_PLAYING = 2;
const STATE_PAUSE = 3;
const STATE_END = 0;
class Timer {
constructor(updateFunc, sec) {
this.sec = sec;
this.updateFunc = updateFunc;
this.state = STATE_READY;
{
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "lower",
"block-indent": " ",
"color-shorthand": false,
"element-case": "lower",
"eof-newline": true,
"leading-zero": true,
"quotes": "double",
const NumberUtil = (function() {
"use strict";
function normalize(value, minimum, maximum) {
return (value - minimum) / (maximum - minimum);
}
function interpolate(normValue, minimum, maximum) {
@nowri
nowri / window load
Last active March 17, 2016 09:37
クロスブラウザDOMContentLoaded
var onReady = function(func){
function IEDOMContentLoaded(){
try {
(new Image()).doScroll();
func();
} catch(err) {
setTimeout(IEDOMContentLoaded, 64);
}
}
if (typeof window.getSelection === "function") {
function getPrefix( prop ){
var vendorPrefixes = ['Moz','Webkit','Khtml','O','ms'],
style = document.createElement('div').style,
upper = prop.charAt(0).toUpperCase() + prop.slice(1),
pref, len = vendorPrefixes.length;
while( len-- ){
if((vendorPrefixes[len] + upper) in style){
pref = (vendorPrefixes[len]);
}
}
// Template
// (c) 2011 Jason Byrne, MileSplit
// May be freely distributed under the MIT license, with attribution.
//
// ** Usage **
//
// HTML:
// <script type="text/html" id="tmplArticle"><h1>${Title}</h1></script>
//
// JavaScript: