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 getCss (el, cssName) { | |
if (el.style[cssName]) { | |
return el.style[cssName]; | |
} else if (el.currentStyle) { | |
return el.currentStyle[cssName]; | |
} else if (document.defaultView && document.defaultView.getComputedStyle) { | |
cssName = cssName.replace(/([A-Z])/g, '-$1'); | |
cssName = cssName.toLowerCase(); | |
var s = document.defaultView.getComputedStyle(el, ''); | |
return s && s.getPropertyValue(cssName); |
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
define(function () { | |
'use strict'; | |
(function () { | |
var tictac = { | |
//当前时间 | |
_currentTime: 0, | |
//上次执行callback的时间 |
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
<div class="broadcast-box" id="broadcast_box"> | |
<ul class="broadcast-detail" id="broadcast_detail"> | |
<li>年会还剩两天就要来了,你准备好中大奖了么?</li> | |
<li>最后两天!再不报销本季度的钱再也拿不回来了你家里人造么?</li> | |
<li>星际2电竞娱乐化RPG地图入选“线上冠军赛</li> | |
</ul> | |
</div> | |
<script type="text/javascript"> | |
var broadcast_div = document.getElementById('broadcast_div'); | |
if (broadcast_div) { |
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 ajax (options) { | |
var type = (options.type || 'GET').toLocaleLowerCase(), | |
url = options.url, | |
data = options.data, | |
dataType = (options.dataType || 'json').toLocaleLowerCase(), | |
success = options.success; | |
//IE10以下 | |
if (window.XDomainRequest) { | |
// 创建ajax引擎对象 |
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 dateFormat(date, format) { | |
if(format === undefined){ | |
format = date; | |
date = new Date(); | |
} | |
var opt = { | |
"M+": date.getMonth() + 1, //月 | |
"d+": date.getDate(), //日 | |
"h+": date.getHours(), //時 | |
"m+": date.getMinutes(), //分 |
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 getIp(req) { | |
var ipAddress; | |
var headers = req.headers; | |
var forwardedIpsStr = headers['x-real-ip'] || headers['x-forwarded-for']; | |
ipAddress = forwardedIpsStr ? forwardedIpsStr : ''; | |
if (!ipAddress) { | |
ipAddress = req.connection.remoteAddress; | |
} | |
if (ipAddress.indexOf(':') !== -1) { | |
ipAddress = ipAddress.split(':')[0]; |
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 run(){ | |
* //run. | |
* } | |
* | |
* windowOnload(run); | |
*/ | |
function windowOnload(fun) { | |
var oldonload = window.onload; |
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 safeString(string) { | |
if(!string) { | |
return ""; | |
} | |
var escape = { | |
"&": "&", | |
"<": "<", | |
">": ">", | |
'"': """, | |
"'": "'", |
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 templateEngine(tpl, data) { | |
var reg = /\{\{(?!\}\})(.*?)\}\}/g, | |
regOut = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g, | |
code = 'var r=[];\n', | |
cursor = 0, | |
match; | |
var add = function(line, js) { | |
js ? (code += line.match(regOut) ? line + '\n' : 'r.push(' + line + ');\n') : | |
(code += line !== '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : ''); |
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 fs = require('fs'), | |
path = require('path'), | |
filePath = path.join(__dirname, 'log.txt'), //抓取结果写入log.txt文件 | |
http = require('http'); | |
var page = 1, //开始页码 | |
maxPage = 100, //结束页码 | |
search, | |
next, | |
run; |
OlderNewer