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
Record Auto semicolon macro and bind shortcut to it: | |
1. Edit -> Macros -> Start Macro Recording | |
2. In the editor go to the end of line by pressing End | |
3. put semicolon ';' | |
4. Edit -> Macros -> Stop Macro Recording | |
5. Give a name, for example 'Auto semicolon' | |
6. Open settings (Ctrl + Alt + s), select Keymap | |
7. Expand Macros node | |
8. Select 'Auto semicolon', in the context menu choose Add Keyboard Shortcut | |
9. Set Ctrl + ; as First keystroke |
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
let phoneReg = /^134[0-8]\d{7}$|^13[^4]\d{8}$|^14[5-9]\d{8}$|^15[^4]\d{8}$|^16[6]\d{8}$|^17[0-8]\d{8}$|^18[\d]{9}$|^19[8,9]\d{8}$/ | |
/** | |
* 格式化手机号码 | |
* @param {*} mobileNum 手机号码 | |
*/ | |
function split(mobileNum) { | |
let value = mobileNum.replace(/\D/g, '').substring(0, 11) | |
if (value.length === 11 && phoneReg.test(value)) { | |
value = value.replace(/^(...)(....)/g, '$1-$2-') | |
} |
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
/** | |
* | |
* @param {*} stringToSplit 字符串 | |
* @param {*} groupScale 分割的位数 | |
* @returns | |
*/ | |
function splitString(stringToSplit, groupScale) { | |
let arrayNum = 0, // 初始化arrayNum,计算得到的分组个数 | |
strArr = [] | |
let remainder = stringToSplit.length % groupScale |
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
function openNewPage(url) { | |
let a = document.createElement('a'); | |
a.href = url; | |
a.target="_blank"; | |
a.innerHTML = "链接"; | |
let d = a.getAttribute('href'); | |
try { | |
let e = document.createEvent('MouseEvents') | |
e.initEvent('click', true, true) //模拟点击操作 | |
d.dispatchEvent(e) |
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
document.getElementsByTagName('button')[0].onclick = function () { | |
scrollTo(document.body, 0, 1250); | |
} | |
function scrollTo(element, to, duration) { | |
var start = element.scrollTop, | |
change = to - start, | |
currentTime = 0, | |
increment = 20; | |
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
$.fn.scrollUnique = function() { | |
return $(this).each(function() { | |
let eventType = 'mousewheel' | |
// 火狐是DOMMouseScroll事件 | |
if (navigator.userAgent.indexOf('Firefox') > -1) { | |
eventType = 'DOMMouseScroll' | |
} | |
$(this).on(eventType, function(event) { | |
// 一些数据 | |
let scrollTop = this.scrollTop, |
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
<p> | |
Focus this tab and press <kbd>CTRL</kbd> + <kbd>V</kbd>. The image on your clipboard will be rendered on the canvas ! | |
</p> | |
<canvas style="border:1px solid grey;" id="mycanvas"> |
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
function getBase64Image(img, width, height) { | |
var canvas = document.createElement('canvas') | |
canvas.width = width ? width : img.width | |
canvas.height = height ? height : img.height | |
var ctx = canvas.getContext('2d') | |
ctx.drawImage(img, 0, 0, canvas.width, canvas.height) | |
var dataURL = canvas.toDataURL() | |
return dataURL | |
} |
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
(function (doc, win) { | |
var docEl = doc.documentElement | |
var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize' | |
function recalc() { | |
var designWidth = 750 | |
var clientWidth = docEl.clientWidth | |
if (!clientWidth || clientWidth > designWidth) return | |
docEl.style.fontSize = (100 * clientWidth / designWidth) + 'px' |
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
(function () { | |
var width = parseInt(window.screen.width) | |
var designWidth = 450 | |
var scale = width / designWidth | |
var userAgent = navigator.userAgent.toLowerCase() | |
var metaHead = '<meta name="viewport" content="width=' + designWidth + ',' | |
if (/android (\d+\.\d+)/.test(userAgent)) { | |
if (parseFloat(RegExp.$1) > 2.3) metaHead += 'minimum-scale=' + scale + ',maximum-scale=' + scale + ',' | |
} else { | |
metaHead += 'user-scalable=no,'; |
OlderNewer