Skip to content

Instantly share code, notes, and snippets.

View DeskWOW's full-sized avatar

Desk.com Customer WOW Team DeskWOW

View GitHub Profile
@DeskWOW
DeskWOW / gist:14497626d952bd41d527
Created September 4, 2014 14:44
Only show chat during business hours
<script>
(function(a){function E(a,b,c,d){var e=c.lang();return e[a].call?e[a](c,d):e[a][b]}function F(a,b){return function(c){return K(a.call(this,c),b)}}function G(a){return function(b){var c=a.call(this,b);return c+this.lang().ordinal(c)}}function H(a,b,c){this._d=a,this._isUTC=!!b,this._a=a._a||null,this._lang=c||!1}function I(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=J(j/1e3),b.seconds=i%60,h+=J(i/60),b.minutes=h%60,g+=J(h/60),b.hours=g%24,f+=J(g/24),f+=e*7,b.days=f%30,d+=J(f/30),b.months=d%12,c+=J(d/12),b.years=c,this._lang=!1}function J(a){return a<0?Math.ceil(a):Math.floor(a)}function K(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function L(a,b,c){var d=b._milliseconds,e=b._days,f=b._months,g;d&&a._d.setTime(+a+d*c),e&&a.date(a.date()+e*c),f&&(g=a.date(),a.date
@DeskWOW
DeskWOW / gist:4855216ccb650602c060
Created September 18, 2014 15:31
Hide topic link on Article page's breadcrumbs for specific topics (useful to prevent 404 error for topics that are hidden)
<div id='breadcrumbs'>
<a href='{{desk.system.links.home}}'>{{system.snippets.home}}</a>
{% unless article.id == 192318 or article.id == 192318 or article.id == 214892 or article.id == 214892 or article.id == 592064 or article.id == 532027 or article.id == 592065 or article.id == 443527 %}
&rsaquo; <a href='{{ topic.public_articles_url }}'>{{ topic.name | clip:30 }}</a>
{% endunless %}
&rsaquo; {{ article.subject_plain | clip:30 }}
</div>
#a-content-select {
display: none;
}
@DeskWOW
DeskWOW / gist:a986c46fcf3a91abcf4e
Last active August 29, 2015 14:07
Page (Index) modified to list brand links if the current brand is titled "Home"
<div id="desk-external-variables-page_index" class="desk-external-variables">
<div id="system-snippets-just_moderated">{{just_moderated}}</div>
</div>
{{ search_form_begin }}
<div class='outer'>
<div class='inner'>
<input type='text' id='q' name='q' maxlength='100' value='' />
{{template_form_params}}
<div id='question-mask' class='question-big'>{{system.snippets.have_a_question}}</div>
@DeskWOW
DeskWOW / gist:7eb6681c00d67155f351
Created October 7, 2014 13:31
Basic conditional logic for Home brand
{% if desk.current_brand.name == "Home" %}
<ul>
{% for cur_brand in desk.brands %}
<li><a href="{{ cur_brand.public_url }}">{{ cur_brand.name }}</a></li>
{% endfor %}
</ul>
{% else %}
<!-- Normal code -->
{% endif %}
@DeskWOW
DeskWOW / gist:af28c295783e1f81b2a7
Last active August 29, 2015 14:08
An example of adding list case custom fields to your contact form and making them required.
<!-- HTML -->
<div class="form-group div-category">
<label for="ticket_custom_category" class="control-label">Category ({{system.snippets.required}}):</label>
{{ ticket_custom_category }}
</div>
<div class="form-group div-favorite-color">
<label for="customer_custom_favorite_color" class="control-label">Favorite Color ({{system.snippets.required}}):</label>
{{ customer_custom_favorite_color }}
</div>
@DeskWOW
DeskWOW / javascript.html
Created November 4, 2014 14:06
Editing rate_block
<script>
$(function() {
$(".rate_link").click(function() {
$("#rate_article").hide();
$("#rate_article_container").html("Custom message");
});
});
</script>
@DeskWOW
DeskWOW / gist:9bb8a41fa35a3a0a1328
Created November 4, 2014 17:29
Add an email confirmation field
<input name="confirm_email" id="confirm_email">
<script>
$(function() {
$("#confirm_email").rules("add", { required:true, equalTo: "#interaction_email" });
});
</script>
@DeskWOW
DeskWOW / gist:e865affa12576fb67540
Created November 5, 2014 16:11
Adding a custom field to My Cases (Detail)
...
<ul class='case-data'>
<li>
<strong>{{desk.system.snippets.case_id}}:</strong>
<span>{{case.id}}</span>
</li>
<li>
<strong>{{desk.system.snippets.assigned_agent}}:</strong>
<span>{{case.user.name_public | show_something: desk.system.snippets.unassigned}}</span>
@DeskWOW
DeskWOW / gist:675137249c5eae2d088e
Created November 6, 2014 15:35
Require a field and set a minimum lengths of characters required
<script>
$(function() {
$("#id_of_field").rules("add", {
required: true,
minlength: 9
});
});
</script>