AngularJs Angularjs中整合KindEditor
第一步:引入 kindeditor.js
<script src="/static/libs/kindeditor/kindeditor-all-min.js"></script> <script src="/static/libs/kindeditor/lang/zh-CN.js"></script>
PHP PHP多种情况下生成随机字符串
/**
* 生成随机字符串
* @param integer $length 长度
* @param boolean $int 是否纯数字
* @param integer $level 字符串强度[1-4]
* @return [type] [description]
*/
if (!function_exists('randoms')) {
function randoms($length=6,$int=false,$level=2) {
$character = [
'number' => '0123456789',
'letter' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'symbol' => '!@#$%^&*()-_[]{}<>~+=/?|',
'filter' => '0OIl1'
];
HTML5 网页变灰CSS实现
全站变灰CSS
body,.gray{
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
}图片变灰CSS
img {
opacity: 0.8;
-webkit-transition: all 0.3s ease-out;
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
}PHP php目录遍历
/**
* 遍历路径下文件存为数组
* @param String $path 要遍历文件的路径
* @return Array 返回存入全局作用域中的数组
*/
function traverse($path='.'){
static $files_list = array();
foreach ($files = array_diff(scandir($path),array('.','..')) as $file) {
$filename = $path.'/'.$file;
if (is_dir($filename)) {
traverse($filename);
}else{
$files_list[] = $fPHP php转换字符串编码
/**
* 转换字符串编码
* @param String $string 要编码的字符串
* @param String $encoding 要转换成的编码类型 参考:mbstring模块支持的编码
* @return String 编码后的字符串
*/
function str_encoding_convert($string,$encoding='UTF-8'){
$encoding_list = array('UTF-8','ASCII','GBK','GB2312','GB18030','BIG5');
$string_encoding = mb_detect_encoding($string,'auto');
$encoding = strtoupper($encoding);
// 判断是否等同所设置编码
if ($string_encoding === $encoding) {
return $string;
&nbPHP PHP语言的PclZip压缩和解压缩类标准方法。
<?php
include_once('include/pclzip.lib.php');
$archive = new PclZip('archive.zip');
//解压缩到extract/folder/这个目录中
$list = $archive->extract(PCLZIP_OPT_PATH, "extract/folder/");
//增加这个目录在压缩档中,完成以后压缩档里面会有backup这个目录,backup里面会有这两个档案
$list = $archive->create("file.txt,image.gif",PCLZIP_OPT_ADD_PATH, "backup");
//去掉部份的路径,这里完成后会变成test/file.txt
$list = $archive->add("/usr/local/user/test/file.txt",PCLZIP_OPT_REMOVE_PATH, "/usr/local/user");
//把所有路径都去掉,这个压缩档建立完后,里面就只会有file.txt跟image.gif,不会有目录了
$list = $archive->create("data/file.txt images/image.gif",PCLZIP_OPT_REMOVE_ALL_PATH);
//把解压缩出来的档案的CHMOD设成0777
$list = $archive->extract(PCLZIP_OPT_SET_CHMOD, 0777);
//解压缩部份的档案,这个参数是使用档案名称判别
//引数可以用下面这样的阵列
$rule_list[0] = 'test/aaa.txt';
$rule_list[1] = 'test/dPHP PHP创建或者生成GUID
什么是 GUID?
全球唯一标识符 (GUID) 是一个字母数字标识符,用于指示产品的唯一性安装。在许多流行软件应用程序(例如 Web 浏览器和媒体播放器)中,都使用 GUID。
GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中每个 x 是 0-9 或 a-f 范围内的一个十六进制的数字。例如:{D19F0B53-D538-F56A-C70E-675DF2A804B7} 即为有效的 GUID 值。
为什么要用GUID?
世界上的任何两台计算机都不会生成重复的 GUID 值。GUID 主要用于在拥有多个节点、多台计算机的网络或系统中,分配必须具有唯一性的标识符。在 Windows 平台上,GUID 应用非常广泛:注册表、类及接口标识、数据库、甚至自动生成的机器名、目录名等。
function create_guid(){
if (function_exists('com_create_guid')){
return com_create_guid();
}else{
mt_srand((double)microtime()*10000);
$unid = strtoupper(md5(uniqid(rand(),true)));
return '{'.substr($unid,0,8).'-'.substr($unid,8,4).'-'.substr($unid,12,4).'-'.substr($unid,16,4).'-'.substr($unid,20,12).'}';
}
}
echo create_guid();HTML5 改用"em"使IE可以调整字体大小
1. IE无法调整那些使用px作为单位的字体大小;
2. 国外的大部分网站能够调整的原因在于其使用了em作为字体单位;
3. Firefox能够调整px和em,但是96%以上的中国网民使用IE浏览器(或内核)。这意味这中国网站的字体大小可以被认为不可调。
95%的中国网站需要重写CSS
在我所观察的中国网站中,包括三大门户,以及“引领”中国网站设计潮流的蓝色理想,ChinaUI等都是使用了px作为字体单位。只有百度好歹做了个可调的表率。
而在大洋彼岸,几乎所有的主流站点都使用em作为字体单位,也就是可调的。
没错,px比em更加容易使用,我也敢打赌大部分读者不知道em为何物或者它相当于多少px。
国外人士如此重视网站易用性(Accessibility),不仅因为其根生蒂固的人文精神,直接原因可能是因为有一部法律来约束他们—例如美国的Section 508,强制网站达到一定的易用性。所以没有哪个主流站点愿意被那些视力下降或是残缺的人告上法庭。
注: 在中国, 可能把微软告上法庭来的更简单点,为什么IE对于px那么死板。
PHP NDlog RC1.2网站信息小工具
jQuery jQuery中live()变更
开始的时候在jQuery.1.7.1中使用了.live()觉得很好用,特别是在绑定事件之后再加入的元素的事件绑定上很方便(第一次live之后以后添加的元素就不需要绑定啦)
后来jQuery更新到1.9.1,页面中的.live报错:"has no method live", 后来查了文档才知道在新版本中做了修改。
//jQuery.1.8.3:
$("#liveID").live("click",function(){alert("live click");});
//jQuery.1.9.1:
$(document).on("click","#liveID",function(){alert("live click");});
jQuery网站上这么说的:
As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().
HTML5 CSS3制作莲花开放
jQuery jQuery原理(原型)
(function(){
var jQuery = window.jQuery = window.$ = function( selector, context ) {
return new jQuery.fn.init( selector, context);
};
jQuery.fn = jQuery.prototype = {
init:function(selector, context){
alert(selector);
},
add : function() {
return this;
}
}
jQuery.fn.init.prototype = jQuery.fn;
})();
//$("dd").add();jQuery jQuery获取浏览器中的分辨率
$ (document).ready(function(){
//浏览器当前窗口可视区域高度
alert($ (window).height());
//浏览器当前窗口文档的高度
alert($ (document).height());
//浏览器当前窗口文档body的高度
alert($ (document.body).height());
//浏览器当前窗口文档body的总高度 包括border padding margin
alert($ (document.body).outerHeight(true));
//浏览器当前窗口可视区域宽度
alert($ (window).width());
//浏览器当前窗口文档对象宽度
alert($ (document).width());
//浏览器当前窗口文档body的高度
alert($ (document.body).width());
//浏览器当前窗口文档body的总宽度 包括border padding margin
alert($ (document.body).outerWidth(true));
//显示器分辨率,只能用JavaScript代码获取
alert(screen.height);
alert(screen.width);
})
jQuery Uncaught ReferenceError: xl_chrome_menu is not defined
最近chrome "审查元素" 的时候下面总提示错误:
"Uncaught ReferenceError: xl_chrome_menu is not defined"
查了下,是安装的迅雷下载插件的问题,卸载了后就没有提示这个错误了
之前有些提出过卸载插件,是可以去掉,但是使用这个插件的情况下怎么避免错误消息呢?
看下了,发现只是变量未定义,试了下,可以自己修正,下面发一个手动解决方法如下:
一、打开插件的目录,(我的是 Thunder Download Extension for Chrome 1.7 ,Windows 7 x64旗舰版系统)(图1)