Skip to content

Instantly share code, notes, and snippets.

View JumboLove's full-sized avatar

David Witt JumboLove

View GitHub Profile
@JumboLove
JumboLove / multiselect-server.js
Created May 6, 2021 16:36
SFCC Page Designer Multi-select
'use strict';
module.exports.init = function (editor) {
// Add in localization or server side processing here if you need it
};
import Vue from 'vue'
import GraphEdge from '../data/graph/GraphEdge'
import GraphVertex from '../data/graph/GraphVertex'
export default {
namespaced: true,
state: {
vertices: {},
edges: {},
@JumboLove
JumboLove / GraphDataStructure.vue
Created June 26, 2019 03:55
Vuex Graph Data store using Adjacency List
<template>
<div>
<h1>Data Structure Vuex in Vue</h1>
<br/>
<br/>
<button @click="runMacro">Run Macro</button>
<br/>
<br/>
<br/>
@JumboLove
JumboLove / Replace -9999px hack
Created October 16, 2014 20:20
Image Replacement Instead of hiding the text off screen using the -9999px hack (and creating a huge invisible box in the process), his technique hides the text while leaving it accessible to screen readers.
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@JumboLove
JumboLove / social-buttons.html
Created October 16, 2014 20:20
Social Buttons Facebook, Twitter, Pinterest, and Google Plus
<iscomment>
Social Media Buttons
All dependent libary files to make these buttons work are included once per page
as socialmedia.js. This template may be included multiple times per page
so long as the following exist in the pdict :
--Required--
SitePreference FacebookAppID
pdict.Product
</iscomment>
@JumboLove
JumboLove / native-jquery-scroll.js
Created October 16, 2014 20:20
smoothly scroll to an element without a fancy library
$('html, body').animate({
scrollTop: $("#elementID").offset().top
}, 2000);
@JumboLove
JumboLove / get-sale-price.js
Created October 16, 2013 13:36
Get Sale Price
// returns a formatted string of the sale price in USD or an empty string if there is no sale price
function getSalePrice(product : Product) {
var priceTable : ProductPriceModel = product.getPriceModel();
var currentPrice : Money = priceTable.getPrice();
var standardPrice : Money = priceTable.getPriceBookPrice(dw.system.Site.getCurrent().getCustomPreferenceValue('listPriceDefault'));
if(standardPrice.available && currentPrice.available && standardPrice.compareTo(currentPrice) == 1){
// Product is on sale
return currentPrice.toNumberString() === "N/A" ? "" : currentPrice.toNumberString();
} else {
// Product is not on sale
@JumboLove
JumboLove / image-exists
Created September 19, 2013 20:42
Check if Image Exists
var imgFile : dw.io.File = dw.io.File('/Catalogs/'+catalogId+'/default/' +imagelocation);
var imgFileExists : Boolean = imgFile.exists();
//OR
var img = File('/LIBRARIES/Sitename/default/images/'+mycustomobject.custom.name);
if (!img.exists()) // replace this image url with a default one;
@JumboLove
JumboLove / iterate-up-categories
Created September 5, 2013 18:10
Iterate Upward Through Categories
var sizeChartID = null;
var category = pdict.Product.primaryCategory;
while (category !== null && sizeChartID === null) {
if (('sizeChartID' in category.custom) && !empty(category.custom.sizeChartID)) {
sizeChartID = category.custom.sizeChartID;
}
else {
category = category.parent;
}
@JumboLove
JumboLove / get-url-param
Created August 28, 2013 18:31
Get URL param from key
//Returns the value of the URL parameter input key
urlParam: function(key){
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
return result && result[1] || "";
},