Skip to content

Instantly share code, notes, and snippets.

public Dictionary<string,Object> getChildrenRecursive()
{
Dictionary<string,Object> categoryDictionary = new Dictionary<string, Object>();
Dictionary<string, Object>[] children;
if (this.hasChildren())
{
// Get child nodes
Duke.CategoryDataTable ChildTable = this.CategoryAdapter.GetAllByParentCategory(categoryCode);
children = new Dictionary<string, Object>[ChildTable.Rows.Count];
for (int i = 0; i < ChildTable.Rows.Count; i++)
<%
Action<System.Data.DataTable, int> printCategoriesRecursively = null;
printCategoriesRecursively = (System.Data.DataTable categoryRows, int depth) => {
if (categoryRows==null || categoryRows.Rows.Count==0) return;
%>
<ul class="node-list depth-<%=depth%>">
<%
foreach (System.Data.DataRow CategoryRow in categoryRows.Rows) {
%>
<li>
@thinkt4nk
thinkt4nk / dynamic_image_loading.js
Created May 10, 2011 15:45
Dynamic Image Loading with jquery
// load an image - with a callback on load
function loadImageDynamic(image_url,callback,container) {
if( container != 'undefined' ) {
container = 'body';
}
var image_load = 0;
$('<img/>')
.attr('src',image_url)
.load( function(e) {
if( image_load < 1 ) { // webkit hack to protect from multiple loads on cached images
@thinkt4nk
thinkt4nk / reverse-geocoding.js
Created May 10, 2011 15:46
Reverse Geocoding with Google js API
function ReverseGeocodeLatLng(latlng)
{
var geocoder = new google.maps.Geocoder();
if (latlng !== undefined) {
latlng = latlng.split(',');
var LatLng = new google.maps.LatLng(latlng[0],latlng[1]);
geocoder.geocode({location:LatLng},function(result,status) {
if( status == 'success' ) {
var locationString = "";
$(result).each(function() {
@thinkt4nk
thinkt4nk / jquery.character-counter.js
Created May 12, 2011 18:37
Maximum Character Counter
(function($) {
/**
* Maximum Character Counter
* Author: Ryan Bales, Creative Anvil 2011
*
* This plugin allows one to specify a container for a character counter element, set the maximum characters, and add an 'error' class to
* counter elements of offending text inputs
*/
$.fn.jsCharacterCounter = function(options) {
// Set default values
@thinkt4nk
thinkt4nk / array.each.js
Created May 17, 2011 13:58
array.each.js
Array.prototype.each = function(callback) {
for( i=0; i<this.length; i++ ) {
callback(this[i]);
}
}
@thinkt4nk
thinkt4nk / jquery.log.js
Created May 26, 2011 21:40
jquery.log.js
$.fn.log = function(options) {
this.each(function() {
console.log(this);
});
return this;
}
@thinkt4nk
thinkt4nk / iframe_file_uploader.js
Created July 12, 2011 22:28
File uploader with hidden IFrame
/* FILE UPLOADER */
var CLASS_UPLOADING = 'file-uploading';
var CLASS_UPLOADING_COMPLETE = 'file-uploading-complete';
var CLASS_LOADER_WIDGET = 'file-upload-loader';
var CLASS_LOADER_LABEL = 'file-upload-loader-label';
var CLASS_LOADER_CONTAINER = 'file-upload-container';
var FILE_UPLOAD_URL = '/path/to/handler';
var updateFileContainerState = function(file_input)
{
// hide input
@thinkt4nk
thinkt4nk / addNumberSuffix.js
Created July 28, 2011 18:50
Given a day of the month, return a stringified representation of it
Array.prototype.contains = function(elem)
{
return (this.indexOf(elem) === -1) ? false : true;
}
function addNumberSuffix(n)
{
var suffix = '';
n = parseInt(n);
var number_last_digit = parseInt((''+n).substr(-1,1));
if( [4,5,6,7,8,9,0].contains(number_last_digit) || (n > 10 && n < 14) )
@thinkt4nk
thinkt4nk / reverseGeocode.js
Created August 1, 2011 20:55
Reverse Geocode using google.maps
var inArray = function(needle,haystack) {
for(i=0;i<haystack.length;i++) {
if( needle === haystack[i] ) {
return true;
}
}
}
var reverseGeocode = function(options)
{
if( typeof(options.lat) !== 'undefined' && typeof(options.lng) !== 'undefined' && typeof(options.onReverseGeocode) === 'function' )