Skip to content

Instantly share code, notes, and snippets.

@skipjac
skipjac / gist:2f82078f0cc5f84044dd
Created October 8, 2014 22:35
playing with the date in Zendesk placeholders
{{ticket.created_at}} old {{ticket.created_at_with_time | date: "%B %d %H:%M %Z" }}
{% capture day %}{{ticket.updated_at | date: "%d" }}{% endcapture %}
{% capture month %}{{ticket.updated_at | date: "%B" }}{% endcapture %}
new {{ticket.updated_at | date: "%B"}} {{day | plus:2}}</br>
{% capture dayCheck %}{{day | plus:2}}{% endcapture %}
{{dayCheck}}</br>
{% if month == 'January' %}
{% if dayCheck > '31' %}
{% assign month = 'February' %}
@skipjac
skipjac / more.js
Last active August 29, 2015 14:08
This changes the not selected label in zendesk helpcenter
//this function will walk all the way down the JSON object into all the arrays and create flat JSON object.
function flattenObject(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object' && ob[i] !== null) {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
toReturn[i + '.' + x] = flatObject[x];
@skipjac
skipjac / submit.js
Last active August 29, 2015 14:10
change submit a request to contact us and point to a zendesk form
$('a.submit-a-request').text('Contact Us').attr('href', function(){return this +'?ticket_form_id=18434';}).addClass('contact-info');
@skipjac
skipjac / gist:c58125b768e686b8e2b9
Created February 17, 2015 18:59
hide ticket forms in Zendesk
<script>
$(document).ready(function() {
$('#request_issue_type_select option[value="631"]').wrap('<span class="hide-option"></span>');
});
</script>
@skipjac
skipjac / gist:8af6bca6b036c891e1e0
Created February 18, 2015 06:51
Remove a option from zendesk ticket form options in Help Center
//remove the options from the select
$('#request_issue_type_select option[value="43517"]').remove();
//remove the option from the nesty-input after it's been created.
$('div').one('DOMNodeInserted', function(e){
$('.nesty-panel').one('DOMNodeInserted', function(e){
$(this).children('ul').children().remove('#43517');
});
});
@skipjac
skipjac / gist:cc9242432bbb8fc0e006
Created March 9, 2015 21:55
Place this in your new request template Zendesk
<script>
$(document).ready(function() {
jQuery.extend({
getQueryParameters : function(str) {
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
}
});
var queryParameters = $.getQueryParameters();
HC.api('user',function(x){console.log(x);})
Object { identifier: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
role: "anonymous",
avatar_url: "https://assets.zendesk.com/images/frame_user.png",
email: null,
name: null,
orgainizations: []
}
@skipjac
skipjac / amy.js
Last active August 29, 2015 14:20
build to functions to run in a loop with the options you want to show and hide
//make a function to hide options as they are passed into it.
var skip1 = function(k){
$('.nesty-panel').on('DOMNodeInserted', function(e){
$(this).children('ul').children(k).hide();
});
}
// call the function with the option value with a # in front
skip1('#sss_a_1')
//make a function to show the option
@skipjac
skipjac / setOrg.js
Last active August 29, 2015 14:21
Set the default org zendesk
$(document).ready(function(){
function setDefaultValue(field, setDefault){
$('.'+field).one('DOMNodeInserted', function(d){
var inputTar = $(d.currentTarget).children('select')
var inputNest = $(d.currentTarget).children('a.nesty-input');
var TestObj = inputTar[0];
var TestNest = inputNest[0];
$('#'+TestObj.id).append('<option value="-">-</option>');
$('#'+TestObj.id+' option').removeAttr('selected').filter('[value='+setDefault+']').attr('selected', true);
$(TestNest).text(setDefault);
@skipjac
skipjac / hideSubmitRequest
Created June 26, 2015 18:04
hide submit request for anonymous users
var userRole = HelpCenter.user.role;
if (userRole === "anonymous") {
$(".banners").hide();
}