Skip to content

Instantly share code, notes, and snippets.

@netsuite
netsuite / dot function with autoCurry.js
Created January 22, 2014 13:21
js: dot function(prop, obj) with autoCurry
var dot = function (prop, obj) {
return obj[prop];
}.autoCurry();
@netsuite
netsuite / include javascript file from chrome console for debuggin.js
Created January 9, 2014 18:18
js: include javascript file from chrome console for debuggin
// Include javascript file in chrome console
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'script.js';
document.head.appendChild(script);
@netsuite
netsuite / load jQuery from chrome console.js
Created January 9, 2014 18:16
jQuery: load jQuery from chrome console
javascript:if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,s){s=d.createElement('script');s.src='https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js';(d.head||d.documentElement).appendChild(s)})(document);
@netsuite
netsuite / SavedSearchExample.js
Created January 8, 2014 20:03
Suitelet: Creates a standard Saved Search on the fly using suitelets
function createSavedSearch()
{
var item = request.getParameter('itemid'); // Get parameter
// Required paremeter for jsonp requests
// var callback = request.getParameter('callback');
// Define search filters
var filters = [];
filters[0] = new nlobjSearchFilter( 'enter search filter id', null, 'anyOf', item );
@netsuite
netsuite / Ajax_CrossDomain_JSONP.js
Created December 13, 2013 23:23
ajax cross domain jsonp call
// Note:
// we have to rap the response like this:
// response.write(callback + "(" +JSON.stringify(searchresults) +")");
jQuery.ajax({
url: 'https://',
dataType: 'jsonp',
crossDomain: true,
success: function(data) {
console.dir(data)
@netsuite
netsuite / jquery_toggle_functionality.js
Created October 29, 2013 19:43
jquery toggle functionality
jQuery.fn.extend({
toggle: function( fn ) {
// Save reference to arguments for access in closure
var args = arguments,
guid = fn.guid || jQuery.guid++,
i = 0,
toggler = function( event ) {
// Figure out which function to execute
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
@netsuite
netsuite / access_form_inside_iframe.js
Created October 8, 2013 12:19
js: access form inside iframe
var ifr = document.getElementById( yourIframeId );
var ifrDoc = ifr.contentDocument || ifr.contentWindow.document;
var theForm = ifrDoc.getElementById( yourFormId );
@netsuite
netsuite / toggleAttr.js
Created September 12, 2013 18:58
jquery: toggle attr
jQuery.fn.toggleAttr = function(a, b) {
var c = (b === undefined);
return this.each(function() {
if((c && !jQuery(this).is("["+a+"]")) || (!c && b)) jQuery(this).attr(a,a);
else jQuery(this).removeAttr(a);
});
};
@netsuite
netsuite / LESS for debuggin.sublime-build
Created August 23, 2013 20:20
build: LESS for debuggin
{
"cmd":
[
"lessc",
//"--line-numbers=all",
"--source-map",
//"--relative-urls",
"--compress",
//"--clean-css",
"--verbose",
@netsuite
netsuite / comments.css
Created May 27, 2013 18:10
css: comments
/* ==========================================================================
Section comment block
========================================================================== */
/* Sub-section comment block
========================================================================== */
/*
* Group comment block.
* Ideal for multi-line explanations and documentation.