Skip to content

Instantly share code, notes, and snippets.

View ngalluzzo's full-sized avatar

Nic Galluzzo ngalluzzo

  • Mode Analytics
  • Bakersfield, CA
View GitHub Profile
function searchBook(isbn) {
// fetch the book information using Google API's ISBN search:
// https://developers.google.com/books/
return $.get('https://www.googleapis.com/books/v1/volumes?q=isbn:' + isbn);
}
function initSearch($isbn) {
// Focus on the isbn input immediately
$isbn.focus();
@ngalluzzo
ngalluzzo / frigidaire_codes.txt
Created May 1, 2017 19:49
frigidaire ir signals
function, code1, hexcode1, code2, hexcode2
"COOL","sendir,1:1,1,38000,1,69,341,171,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,64,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,21,21,64,21,64,21,64,21,64,21,1555,341,86,21,3653","0000 006C 0022 0002 0155 00AB 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0613 0155 0056 0015 0E45",,
"ENERGY SAVER","sendir,1:1,1,38000,1,69,340,171,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,1555,340,86,21,3653","0000 006C 0022 0002 0154 00AB 0015 0015 0015 0015 0015 0015 0015 0040 0015
$(document).ready(function(){
//this assumes you have a file field in your form with id=image
//when this field is updated, run the function
$('#image').change(function(e){
var file = this.files[0];
var form = new FormData();
form.append('files', file);
$.ajax({
url : "https://api.knack.com/v1/applications/[YOUR APP ID]/assets/image/upload",
headers: {"x-knack-application-id":"YOUR APP ID",
@ngalluzzo
ngalluzzo / Zendesk_TOC.js
Created August 18, 2016 22:51
Zendesk TOC
var $headers = $('.article-body h1');
if ($headers.length > 1) {
var $toc = $('<div class="toc">');
var $firstUl = $('<ul>');
var $currentUl = $firstUl;
var previous_level = 1;
$firstUl.appendTo($toc);
$toc.prependTo('section.article-info');
@ngalluzzo
ngalluzzo / empty_tables.js
Last active April 10, 2017 11:10
hide empty tables in Knack
// target a specific scene / page
$(document).on('knack-scene-render.scene_130', function(event, scene) {
scene.views.map(function(view) { // go through each scene view
if(Knack.models[view.key].data && Knack.models[view.key].data.length < 1) { // if view has row data AND that data is 0...
$('#' + view.key).remove(); // remove this specific view
}
});
});
@ngalluzzo
ngalluzzo / disable_input.js
Created June 10, 2015 17:59
disable an input field
$(document).on('knack-view-render.any', function () {
// add one of these lines per field you want to disabled
$('#field_72').attr("disabled", true)
})
@ngalluzzo
ngalluzzo / signup_href.js
Last active August 29, 2015 14:22
Replace Signup href
$(document).on('knack-view-render.any', function () {
$('a.register').attr("href", "https://yourcustomURLhere")
})
@ngalluzzo
ngalluzzo / gist:85c9472e8a2badc54271
Created December 1, 2014 15:19
reload a page after submit
$(document).on('knack-record-update.view_78', function (event, view, record) {
location.reload();
});
@ngalluzzo
ngalluzzo / data-check.js
Last active September 1, 2022 16:20
insert your own errors
$(document).on('knack-view-render.view_194', function (event, view, data) {
var err_counter = 0;
/* Insert error panel. Hidden by default */
$("<div class='kn-message error' id='app-errors'></div>").insertBefore("#view_194");
$("#app-errors").hide();
/* Conditions to Check */
if (data.field_168 === "Yes") {
@ngalluzzo
ngalluzzo / tentative.js
Last active August 29, 2015 14:07
Highlight 1 Value Based on Other Value
// If Tentative Field = Yes, Highlight Start / End Dates on Table
$(document).on('knack-records-render.view_140', function (event, view, records) {
$("table tr").each(function () {
var tentative = $(this).children("td:nth-child(14)").text().trim();
var startDate = $(this).children("td:nth-child(5)");
var endDate = $(this).children("td:nth-child(6)");
if (tentative === "Yes") {
$(startDate).css('backgroundColor','yellow');
$(endDate).css('backgroundColor','yellow');