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 fixFocus() { | |
if(navigator.userAgent.indexOf('Chrome') !== -1 && window.externalHost) { | |
var el = document.createElement('div'); | |
el.style.width = 0; | |
el.style.height = 0; | |
el.tabIndex = 1; | |
el.setAttribute('id', 'ChromeFrameWorkaroundDiv'); | |
document.body.insertBefore(el, document.body.firstChild); | |
var inpt = document.getElementById('ChromeFrameWorkaroundDiv'); | |
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($) { | |
// settings | |
var hideDelay = 500; // in milliseconds | |
var opacityFadeDelay = 250; // in milliseconds | |
var linkClass = 'edit-table-link'; // class="edit-table-link" | |
var popoutClass = linkClass+'-popout'; // class="edit-table-link-popout" | |
var hideCSSClass = 'hide-edit-link'; // class to hide edit link | |
var hideCSS = { // css to hide element |
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
/*jslint browser: true, indent: 2 */ | |
/*global $, window */ | |
(function () { | |
var weekdays = ["S", "M", "T", "W", "T", "F", "S"], | |
container = $(["<div class=\"calendar-control\"><p class=\"header\">Select Date</p><ul class=\"date-control month\"><li class=\"link previous\"><a href=\"#\">View Previous Month</a></li><li class=\"link next\"><a href=\"#\">View Next Month</a></li></ul><ul class=\"date-control year\"><li class=\"link previous\"><a href=\"#\">View Previous Year</a></li><li class=\"link next\"><a href=\"#\">View Next Year</a></li></ul><table class=\"dates\"><caption class=\"title\"><span class=\"month\"></span> <span class=\"year\"></span></caption><thead><tr class=\"row weekdays\"><th>", weekdays.join("</th><th>"), "</th></tr></thead><tbody></tbody></table></div>"].join("")), | |
monthTitle = $(".title .month", container), | |
yearTitle = $(".title .year", container), | |
body = $("tbody", container), | |
selectedYear, |
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
var Redis = require('redis'); | |
module.exports.configureCache = function(port, host, password) { | |
if(typeof port !== 'undefined' && typeof host !== 'undefined') { | |
console.log('Production Redis: ', port, host); // Production Redis: 6397 10.xxx.xx.xxx | |
Redis.debug_mode = true; | |
cache = Redis.createClient(port, host, null); | |
} else { | |
cache = Redis.createClient(); | |
} |
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
// User Authentication | |
// dumbed down a bit for this gist | |
function authenticateUser(req, res, next) { | |
//req.session.user = { firstName: 'Brooke', lastName: 'Thomas' }; | |
console.log(req); | |
// If there is a session user | |
if (req.session.user) { | |
database.users.get(req.session.user, function(err, user) { | |
req.user = user; | |
res.local('user', user); |
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
updates: { | |
incrDownload: // new lines added for clarity | |
" | |
function(doc, req) { | |
var program = req.form.field; | |
if(!doc.downloads) doc.downloads = {}; | |
if(!doc.downloads[program]) doc.downloads[program] = {}; | |
if(!doc.downloads[program].count) doc.downloads[program].count = 0; | |
doc.downloads[program].count += 1; | |
return [doc, doc.downloads[program].count]; |
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
$(document).delegate(".field-group-head input[name='add'][type='submit'], input[name$='[remove]'][type='submit']", "click", function addSubFormItem(e) { | |
var form = $(this).closest("form") | |
, submit = $(this); |
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
var formSubmitted = false; | |
$(document).on('submit', '.form', function(e) { | |
if(formSubmitted) { | |
e.preventDefault(); | |
} else { | |
formSubmitted = true; | |
} | |
}); |
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
$(document).on('focus', '.message-form .note textarea, .message-form .subject input', function() { | |
var textarea = $(this); // or input subject | |
var tab = $('.content-links').find('.selected'); | |
// make sure none of the inputs are those in the note form | |
var formElements = $(this).parents('form').find('input'); | |
var inputElement = $(this).parents('form').find('input[type=submit]'); | |
var bindings = $('a, input').not(formElements); | |
bindings.bind('click.preventNavigation', function(e) { |
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
var html = ejs.render('scenario/show'); | |
var child = exec('./wkhtmltopdf/wkhtmltopdf-amd64 - -', function(code, stdout, stderr) { | |
console.log('Output: '+stderr); | |
res.send(stdout); | |
}); | |
child.stdin.write(html); | |
child.stdin.end(); |