Skip to content

Instantly share code, notes, and snippets.

View iworkforthem's full-sized avatar

Wai Mun iworkforthem

View GitHub Profile
@iworkforthem
iworkforthem / gist:89a247f8a792c62ca6c133bb17f2430f
Last active November 23, 2016 13:21
popup fill screen window.
function popup_full_screen_ads(url)
{
params = 'width='+screen.width;
params += ', height='+screen.height;
params += ', top=0, left=0'
params += ', fullscreen=yes';
newwin=window.open(url,'windowname4', params);
if (window.focus) {newwin.focus()}
return false;
@iworkforthem
iworkforthem / gist:feb1c3844b21a98b5a11cd3407784098
Created November 24, 2016 09:24
mongoose query events at specific date.
var today = req.body.today;
var runDate = (today == '' || today == null ? new Date() : new Date(today));
var tommorrow = new Date(runDate);
tommorrow.setDate(tommorrow.getDate() + 1);
console.log();
console.log('start '+dateFormat(runDate, "yyyy-mm-dd"));
console.log('end '+dateFormat(tommorrow, "yyyy-mm-dd"));
Event.find({
@iworkforthem
iworkforthem / gist:756384aad7d6c2acd048601d193efca8
Created November 26, 2016 13:28
blur background when bootstrap modal open.
body.modal-open #wrap {
-webkit-filter: blur(7px);
-moz-filter: blur(15px);
-o-filter: blur(15px);
-ms-filter: blur(15px);
filter: blur(15px);
}
.modal-backdrop {
background: #f7f7f7;
}
@iworkforthem
iworkforthem / gist:f357de3b6f56b861b3cc5b0365f2fd56
Created December 1, 2016 12:25
boostrap modal background black.
.in {
background: rgba(0, 0, 0, 0.8);
}
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
@iworkforthem
iworkforthem / gist:fd6ed60a78149195edda86f44f69032c
Created December 4, 2016 17:52
reusable mongoose schema.
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
mongoose.Promise = Promise;
mongoose.connect('mongodb://127.0.0.1:27017/local');
var clickSchema = new Schema({
ip: { type: String, default: '' },
hostname: { type: String, default: '' },
country: { type: String, default: '' },
@iworkforthem
iworkforthem / gist:392a0fef06a8a0b2e899315b5155e965
Created December 7, 2016 08:50
show navbar when scroll down.
.navbar {
position:fixed;
top:0px;
width:100%;
height:75px;
background-color:#fff;
color: #FFFFFF;
z-index:9999;
display: none;
border: none;
@iworkforthem
iworkforthem / gist:c4421147735524b5677f3207d7316452
Created December 22, 2016 09:23
addEventListener to body specified tag.
document.querySelector("body").addEventListener('click', function(e) {
var a = e.target.closest('a');
if (a !== null) {
console.log(a);
}
}, false);
document.querySelector("body").style.WebkitFilter = 'blur(4px)';
document.querySelector("body").style.filter= 'blur(4px)';
function postAjax(url, data, success) {
var params = typeof data == 'string' ? data : Object.keys(data).map(
function(k){ return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) }
).join('&');
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
xhr.open('POST', url);
xhr.onreadystatechange = function() {
if (xhr.readyState>3 && xhr.status==200) { success(xhr.responseText); }
};