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
/** | |
* API扩展 | |
* | |
* Class ApiTrait | |
*/ | |
trait ApiTrait | |
{ | |
/** | |
* 设置允许跨域访问的域名白名单 | |
*/ |
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
/** | |
* 把从HTML源码中获取的相对路径转换成绝对路径 | |
* @param string $url HTML中获取的网址 | |
* @param string $URI 用来参考判断的原始地址 | |
* @return 返回修改过的网址,如果网址有误则返回FALSE | |
*/ | |
function filter_relative_url($url, $URI){ | |
//STEP1: 先去判断URL中是否包含协议,如果包含说明是绝对地址则可以原样返回 | |
if(strpos($url, '://') !== FALSE){ | |
return $url; |
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
Show hidden characters
{ | |
"presets": [ | |
"react", | |
"es2015" | |
], | |
"plugins": [ | |
"transform-class-properties" | |
] | |
} |
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 getQueryString (name) { | |
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); | |
var r = window.location.search.substr(1).match(reg); | |
if (r != null) return unescape(r[2]); return null; | |
} |
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
/** | |
* contenteditable 支持, 代码来自 http://stackoverflow.com/questions/23047093/contenteditable-in-angular-js | |
* 对于添加了 contenteditable 属性的元素, 可以直接用 `ng-model` 双向绑定 | |
*/ | |
app.directive('contenteditable', function() { | |
return { | |
restrict: 'A', // only activate on element attribute | |
require: '?ngModel', // get a hold of NgModelController | |
link: function(scope, element, attrs, ngModel) { | |
if(!ngModel) return; // do nothing if no ng-model |
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
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title></title> | |
</head> | |
<body> | |
<div> | |
<audio controls autoplay></audio> | |
<input onclick="startRecording()" type="button" value="录音" /> |
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
/** | |
* Get browser infomation for MixPamel (node) | |
* | |
* Usage: | |
* var detectBrowser = require('./mixPanelDetectBrowser.js') | |
* mixpanel.track('some events', Object.assign({}, detectBrowser(theUserAgentYouGet), { | |
* // your properties | |
* })); | |
* | |
* @param userAgent |
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
/** | |
* Get parameter from URL query(search) string | |
* | |
* Example: | |
* ``` | |
* var id = getQueryString('id') | |
* ``` | |
* | |
* @param {string} name | |
* @returns {string} |
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 { | |
overflow : hidden; | |
text-overflow: ellipsis; | |
display: -webkit-box; | |
-webkit-line-clamp: 2; /* should be the line count limited */ | |
-webkit-box-orient: vertical; | |
} |
OlderNewer