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 {any} value 需要转换的值 | |
* @returns {string} | |
*/ | |
function toTrimedString(value) { | |
if (typeof value !== 'string') { | |
if (value === null || value === undefined) { | |
value = ''; |
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
/** | |
* 获取指定月份日历视图中的 42 个日期对象。 | |
* | |
* @param {number} year 完整的年份数字,如 `2019` 即代表 2019 年。 | |
* @param {number} month 月份数字,如 `11` 即代表 11 月。 | |
* @param {number} [startWeekDay=0] 可选的参数,默认为 `0`(星期日),表示日历中的第一列为星期几(一般为星期日或者星期一)。其中 `0` 表 | |
* 示星期日,`1` 表示星期一,后面以此类推。 | |
* @returns {Date[]} 返回一个数组,包含 42 个 `Date` 对象。 | |
*/ | |
function getCalendarDateList(year, month, startWeekDay) { |
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
/** | |
* Convert rgb formatted color string to hash formatted color string | |
* | |
* @example | |
* // @returns #ff00ff | |
* rgb2hash('rgb(255, 0, 255)'); | |
* | |
* @param {string} rgbColorStr The rgb formatted color string |
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
/** | |
* 复制数据结构定义(definition)中指定的内容 | |
* | |
* @param {Object.<string, *>} definition 数据结构定义 | |
* @param {Object.<string, *>} dataSource 数据源 | |
* @param {Object.<string, *>} [options] (可选)附加选项 | |
* @param {any} [options.defaultObject=null] (可选)当数据源中没有定义中的对象时使用的默认值 | |
* @param {any} [options.defaultArray=[]] (可选)当数据源中没有定义中的数组时使用的默认值 | |
* @returns {Object.<string, *>} 返回过滤后的数据 | |
*/ |
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
/** | |
* 主域名跨标签轻量级事件通知机制 | |
* | |
* 主要用于具有相同主域名的多个浏览器标签之间的事件通知。比如现在浏览器中有两个标签, | |
* 第一个标签的域名为: site1.example.com;第二个标签的域名为:site2.example.com。 | |
* 两个标签中都可以进行登录操作,但在登录之后需要通知另一个标签。此时便可以使用这个类。 | |
* | |
* 注意: | |
* | |
* 1. 这个类使用 cookie 作为通信媒介 |
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
var onceTransitionEnd = function (node, time, callback) { | |
var finished = false; | |
var timer = setTimeout(listener, time + 50); | |
var listener = function () { | |
if (finished === false) { | |
removeListener(); | |
node = null; | |
time = null; | |
listener = null; | |
removeListener = null; |
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
/** | |
* @see https://gist.github.com/john-yuan/e53f55d3e8ec63c3b55ceb502bf5ce36 | |
*/ | |
var ICibaDictionary = (function () { | |
'use strict'; | |
var BASE_URL = 'http://dict-co.iciba.com/api/dictionary.php'; | |
var TYPE_JSON = 'json'; | |
var TYPE_XML = 'xml'; |
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
/** | |
* 模板函数 | |
* | |
* @author John Yuan <https://github.com/john-yuan> | |
* @see {@link https://gist.github.com/john-yuan/40994d24f366bda7c98a7ede994afa71} | |
* @param {string} template 模板字符串 | |
* @param {Object.<string, *>} data 数据对象 | |
* @returns {string} 编译之后的文本 | |
*/ | |
var template = function (template, data) { |
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
/** | |
* An util to encode object to query string or decode query string to object. | |
* | |
* API: | |
* | |
* * `QS.encode(object: Object.<string, *>, keepArrayIndex?: boolean) => string` | |
* * `QS.decode(string: string) => Object.<string, *>` | |
* | |
* @author John Yuan <https://github.com/john-yuan> | |
* @see {@link https://gist.github.com/john-yuan/fac5c91a6f7b6b6dea4e73f00f5636e2} |
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
/** | |
* Merge the `source` into the `target`. This function will do deep copy, and | |
* modify the target object. | |
* | |
* @param {Object.<string, *>|any[]} target The target to merge into | |
* @param {Object.<string, *>|any[]} srouce The source to copy | |
* @returns {Object.<string, *>|any[]} returns The modified target | |
*/ | |
var merge = function(target, source) { | |
var toString = Object.prototype.toString; |