在给input标签添加了属性 autocomplete="off"后,仍然显示历史记录,于是把属性一一移除进行排除,发现是 placeholder属性在搞的鬼。
近期评论
在给input标签添加了属性 autocomplete="off"后,仍然显示历史记录,于是把属性一一移除进行排除,发现是 placeholder属性在搞的鬼。
错误写法
$sql="select company_id from tplay_line where start like '%:start%' and end like '%:end%'";
$result =Db::query($sql,['start'=>$post['start'],'end'=>$post['end']]);
正确写法
$sql="select company_id from tplay_line where start like :start and end like :end";
$result =Db::query($sql,
[ 'start'=>'%'.$post['start'].'%',
'end'=>'%'.$post['end'].'%' ]);
JavaScript - 随机获取数组元素
var myArray = ['one', 'two', 'three', 'four', 'five'];
var rand = Math.floor(Math.random() * myArray.length);
var rValue = myArray[rand];
console.log(rValue)
查看了它的监听,并不是在初始化的时候定义句柄的
反而是需要用户在对象后面加个on事件
$("#city-picker1").citypicker({
}).on('cp:updated', function () {
console.log('updated', $(this).val());
});
citypicker里面的参数 只有省市区{
province: '江苏省',
city: '常州市',
district: '溧阳市'
},没有别的参数。
源码了设置了触发cp:updated事件,所以就在后面监听好了。
切换省份之后回调的值也是在html里通过data-render定义的,很奇怪的设定。
<span style="position: relative;display: inline-block;width: 160px;">
<input readonly id="city-picker1" type="text" style="padding-left: 10px;" data-render="code" data-spancss='{"height": "33px","line-height": "30px","border-radius":"4px"}' data-toggle="city-picker" placeholder="查找省份寺庙" data-level="province">
</span>
data-level设置的是支持几个层级 ,province是只显示省份,city,district
因为span的样式和placeholder不对齐,所以我加了个自定义的spancss
源码里加个设置即可:
public/assets/libs/fastadmin-citypicker/dist/js/city-picker.js
95行
var $select = this.$dropdown.find('.city-select');
下面加
var spanCss = this.$element.data('spancss') || '';
if(spanCss) {
this.$textspan.css(spanCss);
}
使用场景,我们在curl采集第三方站点时,会看到header返回的格式如下:
content-encoding:br
什么是br(Brotli)算法
Google 认为互联网用户的时间是宝贵的,他们的时间不应该消耗在漫长的网页加载中,因此在 2015 年 9 月 Google 推出了无损压缩算法 Brotli。Brotli 通过变种的 LZ77 算法、Huffman 编码以及二阶文本建模等方式进行数据压缩,与其他压缩算法相比,它有着更高的压塑压缩效率。启用 Brotli 压缩算法,对比 Gzip 压缩 CDN 流量再减少 20%。
来自科普:
https://www.cnblogs.com/wcrBlog/p/11805506.html
要解密,需要给宝塔环境安装php扩展
https://github.com/kjdev/php-ext-brotli
安装好后,php重启一下就可以运行以下代码解密curl获取到的内容了。
$compressed = \Brotli\compress('test');
echo $compressed;
echo '
';
$uncompressed = \Brotli\uncompress($compressed);
例子:https://github.com/kjdev/php-ext-brotli
宝塔编译php的脚本
./configure
但是因为宝塔有多个php版本,所以需要改成一下语句
./configure --with-php-config=/www/server/php/72/bin/php-config
https://cloud.tencent.com/developer/article/1557488
var_dump($object->TotalNum->__toString());
或
var_dump((string)$object->TotalNum);
解析gif
SuperGif解析的帧是空的。不知道什么原因,反正获取不到。
gifuct-js项目:
https://github.com/matt-way/gifuct-js
supergif:
https://github.com/tsmolka/supergif-chrome-extension
// 上传文件
vendor("aws.phar");
$credentials = new Credentials('key' , '密钥');
$s3Client = new S3Client([
'credentials' => $credentials,
'region' => 'us-west-2',//地区
'version' => 'latest',
'http' => ['verify' => false],
"use_path_style_endpoint"=>true
]);
$fileName = "/test.jpg";//存储的文件名
$bucketName = '桶名字';
try {
$status = $s3Client->putObject([
'Bucket' => $bucketName,
'Key' => $fileName,
'SourceFile' => ROOT_PATH . 'public/uploadfile/chosePt.png'
]);
echo "Uploaded $fileName to $bucketName.\n";
} catch (\Exception $exception) {
echo "Failed to upload $fileName with error: " . $exception->getMessage();
exit("Please fix error with file upload before continuing.");
}
//获取临时下载文件url
$cmd = $s3Client->getCommand('GetObject', [
'Bucket' => $bucketName,
'Key' => $fileName
]);
$request = $s3Client->createPresignedRequest($cmd, '+5 minutes');
// Get the actual presigned-url
$presignedUrl = (string)$request->getUri();
print_r($presignedUrl);
line:3610:
'table.ke-zeroborder td {border:1px dotted #AAA;}',
替换成,防止td内输入数字英文不会换行。
'table.ke-zeroborder td {border:1px dotted #AAA;word-wrap: break-word;word-break: break-all;}',
line:6865
imgPath = self.pluginsPath + name + '/images/',
下面加(定义删除图片的api):
delImgApi = K.undef(self.delImgApi, 'delurl'),
//配置时记得自定义参数:delImgApi:'https://xxxxxxx'
line:6884
'<div style="padding:10px 20px;">',
下面加
'<style type="text/css">',
'.relative{position:relative;}',
'.operate-box{',
' position:absolute;top:-100px;left:0px;',
' transition:top 0.6s;',
' -moz-transition:top 0.6s; /* Firefox 4 */',
' -webkit-transition:top 0.6s; /* Safari and Chrome */',
' -o-transition:top 0.6s; /* Opera */',
'}',
'.black_overlay{',
' background-color:black;-moz-opacity:0.8;opacity:.60;filter:alpha(opacity=80);position:absolute;left:0px;top:0px;',
' width: 100px;height: 100px;z-index:99;}',
'.operate{',
' position:absolute;left:0px;top:0px;',
' width: 100px;height: 100px;z-index:199;padding:0px 15px;}',
'.operate .left, .operate .right{width:30px;height:100px;line-height:100px;display:inline-block;text-align:center;}',
'.operate img{',
' width:20px;border-radius:12px;z-index:199;background:#fff;',
' transition:transform 0.6s;',
' -moz-transition:transform 0.6s; /* Firefox 4 */',
' -webkit-transition:transform 0.6s; /* Safari and Chrome */',
' -o-transition:transform 0.6s; /* Opera */',
'}',
'.operate img:hover{',
' transform:scale(1.5,1.5);',
' -ms-transform:scale(1.5,1.5); /* IE 9 */',
' -moz-transform:scale(1.5,1.5); /* Firefox */',
' -webkit-transform:scale(1.5,1.5); /* Safari and Chrome */',
' -o-transform:scale(1.5,1.5); /* Opera */',
'}',
'.operate .icon-add{border:1px solid #a6cc7a;}',
'.operate .icon-delete{border:1px solid #ef6455;}',
'</style>',
line:6937
el.click(function(e) {
clickFn.call(this, fileUrl, data.filename);
});
改成:
$(el).find(".icon-add").click(function(e) {
clickFn.call(this, fileUrl, data.filename);
});
line:7009
.mouseover(function(e) {
K(this).addClass('ke-on');
})
改成
.mouseout(function(e) {
K(this).removeClass('ke-on');
//删除图片功能:鼠标移出,让操作框向下滑出
$(K(this)).find(".operate-box").css({"top":"-100px"});
});
line:7018
var img = K('<img src="' + iconUrl + '" width="80" height="80" alt="' + data.filename + '" />');
if (!data.is_dir || data.has_file) {
photoDiv.css('cursor', 'pointer');
bindTitle(photoDiv, data);
bindEvent(photoDiv, result, data, createView);
} else {
photoDiv.attr('title', lang.emptyFolder);
}
photoDiv.append(img);
加个属性data-id
并且在img绑定事件之前 增加删除按钮
替换成
var img = K('<img src="' + iconUrl + '" data-id="' + data.id + '" width="80" height="80" alt="' + data.filename + '" />');
photoDiv.append(img);
//添加删除图片功能
var bgHtml = [
'<div class="operate-box">',
' <div class="black_overlay"></div>',
' <div class="operate">',
' <div class="left"><img src="'+imgPath+'add_24.png" alt="" class="icon-add"/></div>',
' <div class="right"><img src="'+imgPath+'delete_24.png" alt="" class="icon-delete"/></div>',
' </div>',
'</div>'
].join(" ");
photoDiv.append(bgHtml);
if (!data.is_dir || data.has_file) {
photoDiv.css('cursor', 'pointer');
bindTitle(photoDiv, data);
bindEvent(photoDiv, result, data, createView);
} else {
photoDiv.attr('title', lang.emptyFolder);
}
$(photoDiv).find(".icon-delete").click(function(event){
if(!confirm("确认删除该图片吗?")) return false;
var parentDiv = $(this).parents(".ke-item");
var id_ = $(this).parents(".ke-photo").find("img:first").attr("data-id");
//发送删除图片请求
$.post(delImgApi,{imgId: id_},function(json){
if(json.error===0) {
parentDiv.remove();
} else {
alert(json.message);
}
},"json");
});
最后补充两个icon在路径:
\kindeditor\plugins\filemanager\images
自己不喜欢可以替换