112014
 

在很多项目中都会有在前端展现数据图表的需求,而在开发过程中,开发者往往会使用一些JavaScript库,从而更有效地达到想要的目标。最近,TechSlide上的一篇文章总结了50种用于展现图表的JavaScript库,并对每种库做了简要的说明。这对于想要选择合适JavaScript库的开发者很有参考意义。 继续阅读 »

142013
 

文 / 尤雨溪

近年来随着Web应用交互复杂度的提升,前端开发也迎来了一个高速发展的时期。除了一些老牌框架纷纷推出改动较大的升级之外,还涌现出一批新生代的开源库和框架,推动着Web应用开发理念向越来越强调前端架构的方向发展。当下的前端技术可以说是处在一个新旧交替的过程之中,同时存在着许多不同的观念和实践。

本文试图对目前数量繁多的前端框架进行一些较笼统的分析和比较,抛砖引玉,希望能为大家在选择前端的技术架构时提供一些有益的参考。需要明确的是,本文探讨的前端架构是以JavaScript为主。有一些主要关注CSS层面的前端框架,如Bootstrap,不在本文的讨论范围之内。 继续阅读 »

212013
 
	function timeConvert(ss){
		if(!ss || ss < 0) 			return '0时0分0秒'; 		if(ss >=0 && ss < 60)
			return parseInt(ss) + '秒';
		else if(ss == 60 || ss < 60*60)
			return  parseInt(ss /60.0) +'分'+ parseInt((parseFloat(ss/60.0) - parseInt(ss/60.0))*60) +'秒';
		else if(ss == 60*60 || ss < 60*60*24) 			return parseInt(ss /60.0/60.0) +'时' +  				parseInt((parseFloat(ss/60.0/60.0) - parseInt(ss/60.0/60.0))*60) +'分' +  				parseInt((parseFloat(ss/60.0) - parseInt(ss/60.0))*60) + '秒'; 		else if(ss >= 60*60*24)
			return parseInt(ss/60.0/60.0/24.0) + '天' + 
				parseInt((parseFloat(ss/60.0/60.0/24.0) - parseInt(ss/60.0/60.0/24.0)) * 24) + '小时' + 
				parseInt((parseFloat(ss/60.0/60.0) - parseInt(ss/60.0/60.0)) * 60) + '分' + 
				parseInt((parseFloat(ss/60.0) - parseInt(ss/60.0))*60) + '秒';
	}

将毫秒数转换为易读的字符串

console.log(timeConvert(26047));
182013
 
//判断是否属手机
function is_mobile() {
	$user_agent = $_SERVER['HTTP_USER_AGENT'];
	$mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte");
	$is_mobile = false;
	foreach ($mobile_agents as $device) {
		if (stristr($user_agent, $device)) {
			$is_mobile = true;
			break;
		}
	}
	return $is_mobile;
}
//使用很简单
if( is_mobile() ){
//Your Code
}

转自:http://levi.cg.am/?p=2214