This file contains hidden or 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
@mixin folded-corner($background, $size, $angle: 30deg) { | |
position: relative; | |
background: $background; | |
/* 回退样式 */ | |
background: linear-gradient($angle - 180deg, transparent $size, $background 0); | |
border-radius: .5em; | |
$x: $size / sin($angle); | |
$y: $size / cos($angle); | |
&::before { | |
content: ''; |
This file contains hidden or 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
# 左边表示匹配的文件,右边表示针对匹配的文件适用的换行符 | |
# text=auto 一般用来表示默认选项,表示由git确定换行符 | |
# text 表示匹配的文件的换行符转换为平台指定的换行符(windows: crlf | OS X and Linux: lf) | |
# text eol=crlf 用于将匹配的文件的换行符强制保留为crlf,即使是在OS X或者Linux上,一般用于指定Windows特定文件 | |
# text eol=lf 用于将匹配的文件的换行符强制保留为lf,即使是在Windows上,适用于大部分文本文件 | |
# binary 一般用于图片、视频等二进制文件,通知git不要对其做任何处理 | |
# Set the default behavior, in case people don't have core.autocrlf set. | |
* text=auto |
This file contains hidden or 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
/** | |
* 判断window.open打开页面是否被拦截 | |
* @return {boolean} true表示被拦截,false表示未被拦截 | |
*/ | |
function isWindowOpenBlocked() { | |
var isBlocked = false; | |
try { | |
var winRef = window.open(URL, WINDOWNAME[, WINDOWFEATURES]); | |
if(winRef == null) { // 浏览器拦截 | |
isBlocked = true; |
This file contains hidden or 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 partition(arr, left, right) { | |
var poivtIndex = Math.floor((left + right) / 2); // 中间位置作为分割点 | |
var leftIndex = left; | |
var rightIndex = right; | |
while(leftIndex <= rightIndex) { | |
while(arr[leftIndex] < arr[poivtIndex]) { // 分割点左边较小的跳过 | |
leftIndex += 1; | |
} | |
while(arr[rightIndex] > arr[poivtIndex]) { // 分割点右边较大的跳过 | |
rightIndex -= 1; |
This file contains hidden or 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 merge(left, right) { | |
var result = []; | |
while(left.length && right.length) { | |
if(left[0] > right[0]) result.push(right.shift()); | |
else result.push(left.shift()); | |
} | |
while(left.length) result.push(left.shift()); | |
while(right.length) result.push(right.shift()); | |
return result; | |
} |
This file contains hidden or 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
/** | |
* 插入排序,时间复杂度最坏O(n^2),最好(基本有序)O(n);空间复杂度O(1) | |
* @param {Array} arr 需要进行排序的数据源 | |
* @return {Array} arr 排序完成后的数组 | |
*/ | |
function insertSort(arr) { | |
var len = arr.length; | |
for(var i=1; i<len; i++) { | |
var sortedIndex = i - 1; | |
var unSortedData = arr[i]; |
This file contains hidden or 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
/** | |
* 冒泡排序,此方法每次固定头部最小值,即前方为有序区,时间复杂度O(n^2),空间复杂度O(1) | |
* @param {Array} arr 需要排序的数据源 | |
* @return {Array} arr 排序后数组 | |
*/ | |
function bubbleSort(arr) { | |
var len = arr.length; | |
for(var i=0; i<len-1; i++) { | |
for(var j=i+1; j<len; j++) { | |
if(arr[i] > arr[j]) { |
This file contains hidden or 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
/** | |
* 选择排序,时间复杂度O(n^2),空间复杂度O(1) | |
* @param {Array} arr 需要进行排序的数组 | |
* @return {Array} arr 排序完成后的数组 | |
*/ | |
function selectionSort(arr) { | |
if(Object.prototype.toString.call(arr) === "[object Array]") { | |
var len = arr.length; | |
var minIndex, temp; | |
for(var i=0; i<len-1; i++) { |
This file contains hidden or 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 {Array} arr 数据源 | |
* @param {number} prev 需交换的下标之一 | |
* @param {number} next 需交换的下标之一 | |
*/ | |
function swap(arr, prev, next) { | |
var temp = arr[prev]; | |
arr[prev] = arr[next]; | |
arr[next] = temp; |
This file contains hidden or 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
/** | |
* 是否支持localStorage | |
*/ | |
function isSupportStorage() { | |
if(!localStorage) return false; | |
try { | |
localStorage.setItem('__test__', '__test__'); | |
localStorage.removeItem('__test__'); | |
return true; | |
} catch(e) { |