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
// 1st given: the .get call on line 5 should fire only when .sidebar is present | |
// 2nd given: the current page does NOT have any element with a .sidebar attribute | |
if ($('.sidebar')) { | |
$.get( "ajax/fundraising.html", function( data ) { | |
$( '.sidebar' ).html( data ); | |
}); | |
} |
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
javascript: (function () {/*retrieves pageID of CommonSpot pages quickly*/ if(typeof jsPageID!=="undefined"){console.log("Page ID is: " + jsPageID);}else{console.log("No Page ID found here.")}}()); |
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 comicPanels(rows, columns, width, height, border, spacing, padding) { | |
// our properties | |
this.rows = rows || 3; | |
this.columns = columns || 2; | |
this.width = width || 800; | |
this.height = height || 600; | |
this.border = border || 1; | |
this.spacing = spacing || 0; | |
this.padding = padding || 0; |
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 isPalindrome(phrase) { | |
"use strict"; | |
var letters, x; | |
// turn our phrase into only ALPHA CAPS | |
phrase = phrase.match(/[a-zA-Z]/g); | |
phrase = phrase.toString(); | |
phrase = phrase.replace(/[,]/g, ""); |
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 isPalindrome(phrase) { | |
"use strict"; | |
var forwards, backwards; | |
forwards = phrase | |
.toUpperCase() // convert to upper case | |
.match(/[A-Z0-9]/g) // an array of only alphanumerics | |
.toString() // convert back to CSV string |
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
/** | |
* isPalindrome - tests phrase for alphanumeric symmetry | |
* @param {String} phrase to be tested | |
* @returns {Bool} true if a palindrome, false if not | |
*/ | |
class MyString extends String { | |
isPalindrome() { | |
"use strict"; |
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
/** | |
* findDuplicateIDs - scan array of structs for duplicate values in unique id field | |
* @param {Array} - the array to be scanned | |
* @param {String} - name of unique id field in array | |
* @return {Object} - object with lists of unique and duplicated ids | |
* | |
* Examples: | |
* findDuplicateIDs( alerts, "unique_id" ); | |
* findDuplicateIDs( people, "SSN" ); | |
*/ |
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
/** | |
* deDuplicate - remove duplicates from Array of Objects/Structures by value of a Unique ID | |
* @param {Array} - the Array of Objects/Structures | |
* @param {String} - the field to use as a Unique ID | |
* @returns {Array} - an Array of Objects/Structures, filtered by the Unique ID property specified | |
* Example: | |
* deDuplicate( people, "SSN" ); // filter people array by unique values in people[x].SSN property | |
*/ | |
function deDuplicate(myArray, myUniqueID) { | |
"use strict"; |
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 wordFreq(myText) { | |
"use strict"; | |
var results = []; | |
myText.split(" ").forEach(function(element) { | |
var foundIt = results.findIndex( x => x.word === 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
function charFreq(myText) { | |
"use strict"; | |
var results = []; | |
myText.split("").forEach(function(element) { | |
var foundIt = results.findIndex( x => x.char === element); |