Skip to content

Instantly share code, notes, and snippets.

View leohxj's full-sized avatar
💯
Focusing

Leo Hui leohxj

💯
Focusing
View GitHub Profile
@leohxj
leohxj / requestXMLHttpRequest.js
Created August 5, 2016 07:20
request with XMLHttpRequest, 兼容性为: android 4.4以上, ios 8.0以上
function request(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = callback;
xhr.send();
}
// demo
@leohxj
leohxj / toggleCheckbox.js
Created June 3, 2016 07:44
input checkbox toggle
// Check
$(':checkbox').prop('checked', true);
// Un-check
$(':checkbox').prop('checked', false);
// Toggle
$(':checkbox').prop('checked', function (i, value) {
return !value;
});
@leohxj
leohxj / ps-restore.html
Created April 6, 2016 01:37
视觉稿还原蒙层
<!-- add a perfect pixel layer [[ -->
<div class="perfect-pixel" style="display:none;position: absolute; z-index: 2147483646; width: 100%; height: auto; cursor: all-scroll; pointer-events: none; margin: 0 auto; margin-left: -50%; top: 0; left: 50%; min-width: 1190px; opacity: 0.3; background-color: transparent;">
<img src="temp/index-1190x.jpg" alt="" style="position: relative; margin: 0 auto; padding: 0px; display: block; height: auto;">
</div>
<!-- add a perfect pixel layer ]] -->
@leohxj
leohxj / jank.md
Last active April 6, 2016 09:13
名词解释:jank, 直白一点就是“卡”

Apps whose displays tend to jump raggedly during animations, scrolling, or other user interaction suffer from a performance issue commonly called jank or judder. Jank is an annoying distraction for users; it interrupts the users' flow of thought and it makes the app look less polished and professional.

@leohxj
leohxj / ie-hacks.css
Created April 1, 2016 09:31
IE Hacks
#hack{
color:red; /* All browsers */
color:red !important;/* All browsers but IE6 */
_color:red; /* Only works in IE6 */
*color:red; /* IE6, IE7 */
+color:red;/* Only works in IE7*/
*+color:red; /* Only works in IE7 */
color:red\9; /* IE6, IE7, IE8, IE9 */
color:red\0; /* IE8, IE9 */
color:red\9\0;/*Only works in IE9*/
@leohxj
leohxj / leftpad.js
Created March 24, 2016 06:12
leftpad: 左侧位数不足补字符
function leftpad (str, len, ch) {
str = String(str);
var i = -1;
if (!ch && ch !== 0) ch = ' ';
len = len - str.length;
while (++i < len) {
@leohxj
leohxj / windows查询端口杀死进程
Created March 18, 2016 03:09
[Window 通过cmd查看端口占用、相应进程、杀死进程等的命令](http://blog.csdn.net/jiangwei0910410003/article/details/18967441)
c:>netstat -ano|findstr "8080"
c:>tasklist|findstr 3112
@leohxj
leohxj / 一行文字溢出.css
Created March 18, 2016 03:04
文字超过一行,显示省略号
div {
width: 300px;
overflow: hidden;
white-space: nowrap;
-ms-text-overflow: ellipsis;
text-overflow: ellipsis;
}
@leohxj
leohxj / supportPlaceholder.js
Created January 26, 2016 07:13
supportPlaceholder.js
var supportPlaceHolder = function() {
// first, detect the placeholder attribute
var isPlaceholder = function(){
var input = document.createElement('input');
return 'placeholder' in input;
}
if(!isPlaceholder()){
$('[placeholder]').each(function(){
var defaultValue = $(this).attr("placeholder");
@leohxj
leohxj / uc_control.js
Last active August 29, 2015 14:24
UC浏览器关闭默认手势和长按弹出菜单
// UC-U3内核JavaScript专用API
// (经测试,官方文档给出的API很多也不能使用,下面只列出测试能用的)
// 1. 关闭默认手势
// 用法:
navigator.control.gesture(false);
// 推荐写法:
try {
navigator.control.gesture(false);
} catch (e) {
}