关于input file的文件过滤方法
限制只能选择图片: <input type="file" accept="image/*" />
限制只能选择视频: <input type="file" accept="video/*" />
限制只能选择音频: <input type="file" accept="audio/*" />
直接打开摄像头拍照: <input type="file" accept="image/*" capture="camera" />
直接打开摄像头录像: <input type="file" accept="video/*" capture="camera" />
MUI一个以IOS为参考的移动端前端框架
mui
性能和体验的差距,一直是mobile app开发者放弃HTML5的首要原因。 浏览器天生的切页白屏、不忍直视的转页动画、浮动元素的抖动、无法流畅下拉刷新等问题,这些都让HTML5开发者倍感挫败,尤其拿到Android低端机运行,摔手机的心都有; 另一方面,浏览器默认控件样式又少又丑,制作一个漂亮的控件非常麻烦,也有一些制作简单的ui框架但性能低下。
mui框架有效的解决了这些问题,这是一个可以方便开发出高性能App的框架,也是目前最接近原生App效果的框架。
参考文档
快速体验
在线下载或扫描如下二维码下载Hello MUI,可在手机上体验MUI的控件UI及能力展示;
在线交流
若你在使用过程中有任何经验、想法、疑惑,都可以在问答社区 发起文章,和其它mui用户一起交流;
License
mui遵循MIT License;
开发工具
mui组件已被封装成HBuilder代码块,只需要简单几个字符,就可以快速生成各个组件对应的HTML代码,因此和Hbuilder两个一起用,效果会更好;
一个markdown编辑器editor.md
Editor.md
Editor.md : The open source embeddable online markdown editor (component), based on CodeMirror & jQuery & Marked.
Features
- Support Standard Markdown / CommonMark and GFM (GitHub Flavored Markdown);
- Full-featured: Real-time Preview, Image (cross-domain) upload, Preformatted text/Code blocks/Tables insert, Code fold, Search replace, Read only, Themes, Multi-languages, L18n, HTML entities, Code syntax highlighting…;
- Markdown Extras : Support ToC (Table of Contents), Emoji, Task lists, @links.html"">@Links…;
- Compatible with all major browsers (IE8+), compatible Zepto.js and iPad;
- Support decode & fliter of the HTML tags & attributes;
- Support TeX (LaTeX expressions, Based on KaTeX), Flowchart and Sequence Diagram of Markdown extended syntax;
- Support AMD/CMD (Require.js & Sea.js) Module Loader, and Custom/define editor plugins;
Editor.md 是一款开源的、可嵌入的 Markdown 在线编辑器(组件),基于 CodeMirror、jQuery 和 Marked 构建。
主要特性
- 支持通用 Markdown / CommonMark 和 GFM (GitHub Flavored Markdown) 风格的语法,也可变身为代码编辑器;
- 支持实时预览、图片(跨域)上传、预格式文本/代码/表格插入、代码折叠、跳转到行、搜索替换、只读模式、自定义样式主题和多语言语法高亮等功能;
- 支持 ToC(Table of Contents)、Emoji表情、Task lists、@links.html">@链接等 Markdown 扩展语法;
- 支持 TeX 科学公式(基于 KaTeX)、流程图 Flowchart 和 时序图 Sequence Diagram;
- 支持识别和解析 HTML 标签,并且支持自定义过滤标签及属性解析,具有可靠的安全性和几乎无限的扩展性;
- 支持 AMD / CMD 模块化加载(支持 Require.js & Sea.js),并且支持自定义扩展插件;
- 兼容主流的浏览器(IE8+)和 Zepto.js,且支持 iPad 等平板设备;
Examples
https://pandao.github.io/editor.md/examples/index.html
Download & install
Bower install :
bower install editor.md
Usages
HTML:
```html
php时间区间
<?php
echo date("Ymd",strtotime("now")), "\n";
echo date("Ymd",strtotime("-1 week Monday")), "\n";
echo date("Ymd",strtotime("-1 week Sunday")), "\n";
echo date("Ymd",strtotime("+0 week Monday")), "\n";
echo date("Ymd",strtotime("+0 week Sunday")), "\n";
echo "*********第几个月:";
echo date('n');
echo "*********本周周几:";
echo date("w");
echo "*********本月天数:";
echo date("t");
echo "*********";
echo '<br>上周起始时间:<br>';
echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1-7,date("Y"))),"\n";
echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y"))),"\n";
echo '<br>本周起始时间:<br>';
echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"))),"\n";
echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"))),"\n";
echo '<br>上月起始时间:<br>';
echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")-1,1,date("Y"))),"\n";
echo date("Y-m-d H:i:s",mktime(23,59,59,date("m") ,0,date("Y"))),"\n";
echo '<br>本月起始时间:<br>';
echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),1,date("Y"))),"\n";
echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("t"),date("Y"))),"\n";
$season = ceil((date('n'))/3);//当月是第几季度
echo '<br>本季度起始时间:<br>';
echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y'))),"\n";
echo date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date("Y"))),date('Y'))),"\n";
$season = ceil((date('n'))/3)-1;//上季度是第几季度
echo '<br>上季度起始时间:<br>';
echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y'))),"\n";
echo date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date("Y"))),date('Y'))),"\n";
?>
php操作office文档
Apicloud的云推送api, php版
class ApicloudPush
{
public static $api = 'https://p.apicloud.com/api/push/message';
public static $appid = 'A6920463******';
public static $appkey = 'C******8-B6BB-3027-2C93-6C********29';
public static function post($post_data)
{
$appkey = sha1(self::$appid . "UZ" . self::$appkey . "UZ" . time()) . "." . time();
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_HTTPHEADER, [
'X-APICloud-AppId:'. self::$appid,
'X-APICloud-AppKey:' . $appkey
]);
curl_setopt($ch, CURLOPT_POST, count($post_data));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, self::$api);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
ob_start ();
curl_exec ($ch);
$result = ob_get_contents ();
ob_end_clean();
curl_close ($ch);
return $result;
}
}
$title = isset($_GET['title']) ? $_GET['title'] : '测试标题';
$content = isset($_GET['content']) ? $_GET['content'] : '测试内容';
var_dump(ApicloudPush::post([
'title' => $title,
'content' => $content,
'type' => 2, //– 消息类型,1:消息 2:通知
'platform' => 0, //0:全部平台,1:ios, 2:android
// 'groupName' => 'department', //推送组名,多个组用英文逗号隔开.默认:全部组。eg.group1,group2 .
// 'userIds' => 'shuai' //推送用户id, 多个用户用英文逗号分隔,eg. user1,user2。
]));
PhpStorm中文汉化
如果你本机的wamp什么都没动, 突然就Bad Gateway了
如果你本机的wamp什么都没动, 突然就Bad Gateway了, 要注意看一下是不是用了代理软件什么的, 关闭代理就可以访问了
一个翻译github的脚本
把下面的代码另存为github.user.js, 然后拖拽到chrome的插件管理界面, 打开github就可以看到中文的github了
(function() {
var url_has = function(str) {
return location.href.indexOf(str) >= 0;
}
var $ = function(selector) {
return document.querySelectorAll(selector);
};
var replace_dom = function(selector, num, attr, old_string, new_string) {
var selector_str = selector;
if (typeof selector == 'string') {
selector = $(selector);
}
var rep = function(str) {
str = str || '';
if (typeof new_string == 'undefined') {
for (var j in old_string) {
str = str.replace(old_string[j][0], old_string[j][1]);
}
} else {
str = str.replace(old_string, new_string);
}
return str;
}
if (num === 'each') {
for (var i in selector) {
selector[i][attr] = rep(selector[i][attr]);
}
} else if (selector.length && (num in selector) && (attr in selector[num])) {
selector[num][attr] = rep(selector[num][attr]);
}
if (typeof selector_str == 'string') {
setTimeout(function() {
replace_dom(selector_str, num, attr, old_string, new_string);
}, 1000);
}
};
if (!url_has('github.com')) {
return;
}
// 搜索框
replace_dom($('.header-search-input'), 0, 'placeholder', 'Search GitHub', '全站搜索');
// 翻译导航 Pull requests, Issues, Gist
replace_dom($('.header-nav a'), 2, 'innerHTML', 'Gist', '重点');
// 首页的两个大按钮
replace_dom($('.shelf-cta'), 0, 'innerHTML', 'Read the guide', '阅读指南');
replace_dom($('.shelf-cta'), 1, 'innerHTML', 'Start a project', '开始一个项目');
// 首页我贡献的
replace_dom($('[role=navigation] h3'), 0, 'innerHTML', 'Repositories you contribute to', '你有贡献的库');
// 首页我的仓库
replace_dom($('#your_repos'), 0, 'innerHTML', 'Your repositories', '你的仓库');
replace_dom($('#your_repos a'), 0, 'innerHTML', 'New repository', '新建仓库');
replace_dom($('.repo-filter'), 0, 'innerHTML', 'All', '全部');
replace_dom($('.repo-filter'), 1, 'innerHTML', 'Public', '公开');
replace_dom($('.repo-filter'), 2, 'innerHTML', 'Private', '私有');
replace_dom($('.repo-filter'), 3, 'innerHTML', 'Sources', '创建的');
replace_dom($('.repo-filter'), 4, 'innerHTML', 'Forks', '克隆的');
replace_dom($('#your-repos-filter'), 0, 'placeholder', 'Find a repository', '搜索仓库');
// document.querySelector('.file-navigation i').innerHTML = '分支:';
// 翻译提交时间
replace_dom('relative-time,time-ago', 'each', 'innerHTML', [
['minutes ago', '分钟前'],
['an hour ago', '1小时前'],
['hours ago', '小时前'],
['a day ago', '一天前'],
['days ago', '天前'],
['a month ago', '1个月前'],
['months ago', '个月前'],
[/^on\s(\d+)\sJan/, '1月$1号'],
[/^on\s(\d+)\sFeb/, '2月$1号'],
[/^on\s(\d+)\sMar/, '3月$1号'],
[/^on\s(\d+)\sApr/, '4月$1号'],
[/^on\s(\d+)\sMay/, '5月$1号'],
[/^on\s(\d+)\sJun/, '6月$1号'],
[/^on\s(\d+)\sJul/, '7月$1号'],
[/^on\s(\d+)\sAug/, '8月$1号'],
[/^on\s(\d+)\sSep/, '9月$1号'],
[/^on\s(\d+)\sOct/, '10月$1号'],
[/^on\s(\d+)\sNov/, '11月$1号'],
[/^on\s(\d+)\sDec/, '12月$1号']
]);
// 翻译提交时间
replace_dom($('.commit-group-title'), 'each', 'innerHTML', [
['Commits on', '提交时间: '],
[/Jan\s(\d+)\,\s(\d+)/, '$2年1月$1号'],
[/Feb\s(\d+)\,\s(\d+)/, '$2年2月$1号'],
[/Mar\s(\d+)\,\s(\d+)/, '$2年3月$1号'],
[/Apr\s(\d+)\,\s(\d+)/, '$2年4月$1号'],
[/May\s(\d+)\,\s(\d+)/, '$2年5月$1号'],
[/Jun\s(\d+)\,\s(\d+)/, '$2年6月$1号'],
[/Jul\s(\d+)\,\s(\d+)/, '$2年7月$1号'],
[/Aug\s(\d+)\,\s(\d+)/, '$2年8月$1号'],
[/Sep\s(\d+)\,\s(\d+)/, '$2年9月$1号'],
[/Oct\s(\d+)\,\s(\d+)/, '$2年10月$1号'],
[/Nov\s(\d+)\,\s(\d+)/, '$2年11月$1号'],
[/Dec\s(\d+)\,\s(\d+)/, '$2年12月$1号']
]);
// 创建新仓库页面
replace_dom($('.subhead-heading'), 0, 'innerHTML', 'Create a new repository', '创建一个新的存储库');
replace_dom($('.subhead-description'), 0, 'innerHTML', 'A repository contains all the files for your project, including the revision history.', '一个存储库包含您的项目的所有文件,包括修改历史记录。');
replace_dom($('.owner-reponame label'), 0, 'innerHTML', 'Owner', '所有者');
replace_dom($('.owner-reponame label'), 1, 'innerHTML', 'Repository name', '仓库名称');
replace_dom($('.with-permission-fields .my-3'), 0, 'innerHTML', 'Great repository names are short and memorable. Need inspiration? How about', '一个存储库包含您的项目的所有文件,包括修改历史记录。');
replace_dom($('.select-menu-title'), 0, 'innerHTML', 'Choose another owner', '选择其他所有者');
replace_dom($('[for=repository_description]'), 0, 'innerHTML', 'Description', '描述');
// replace_dom($('.with-permission-fields .form-checkbox label :nth-child(3)'), 0, 'textContent', 'Public', '公开');
replace_dom($('.with-permission-fields .form-checkbox .note'), 0, 'innerHTML', 'Anyone can see this repository. You choose who can commit.', '公开: 任何人都可以看到这个库。你可以选择谁能提交。');
// replace_dom($('.with-permission-fields .form-checkbox label :nth-child(3)'), 0, 'textContent', 'Private', '私有');
replace_dom($('.with-permission-fields .form-checkbox .note'), 1, 'innerHTML', 'You choose who can see and commit to this repository.', '私有: 您选择谁可以看到并提交到这个存储库。');
// 版本库首页
replace_dom($('.header-search-scope'), 0, 'innerHTML', [
['This repository', '搜索当前仓库'],
['This organization', '搜索当前组织']
]);
replace_dom($('.numbers-summary li:nth-child(1) a'), 0, 'innerHTML', 'commits', '次提交');
replace_dom($('.numbers-summary li:nth-child(2) a'), 0, 'innerHTML', 'branch', '个分支');
replace_dom($('.numbers-summary li:nth-child(3) a'), 0, 'innerHTML', 'releases', '个版本');
replace_dom($('.numbers-summary li:nth-child(4) a'), 0, 'innerHTML', 'contributors', '个贡献者');
replace_dom('#context-commitish-filter-field', 0, 'placeholder', [
['Filter branches/tags', '搜索分支标签'],
['Find a tag', '搜索标签']
]);
replace_dom($('h3'), 'each', 'innerHTML', [
['Watched repositories', '监控的版本库'],
]);
replace_dom($('button,a,span,i'), 'each', 'innerHTML', [
['New pull request', '新拉取请求'],
[' Projects', ' 项目'],
[' Pulse', ' 脉冲'],
[' branch', ' 分支'],
['Graphs', '图表'],
['Settings', '设置'],
['Pull requests', '拉取请求'],
['Change notification settings', '更改通知设置'],
['Unread', '未读'],
['Unwatch all', '取消全部监控'],
['Unwatch', '取消监控'],
['Not watching', '不监控'],
['Participating', '参与'],
['Mark all as read', '标记全部为已读'],
['All notifications', '所有通知'],
['Notifications', '通知'],
['Watching', '监控'],
['Learn more', '加载更多'],
['New repository', '新建仓库'],
['New team', '新建团队'],
['My teams', '我的团队'],
['Repositories', '仓库'],
['People', '成员'],
['Teams', '团队'],
['Use SSH', '使用SSH协议'],
['Use HTTPS', '使用HTTPS协议'],
['Create new file', '创建新文件'],
['Upload files', '上传文件'],
['Find file', '搜索文件'],
['Issues', '问题'],
['Code', '代码'],
['Wiki', '维基'],
['Contact GitHub', '联系GitHub'],
['Training', '培养'],
['Blog', '博客'],
['Shop', '商店'],
['About', '关于'],
['Labels', '标签'],
['Milestones', '里程碑'],
['Filters', '搜索'],
['Clone or download', '克隆或下载'],
['Branches', '分支'],
['Branch:', '分支:'],
['Tags', '标签'],
['Download ZIP', '下载ZIP压缩包'],
['Switch branches/tags', '切换分支或标签']
]);
})();