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 / 1 - Instructions
Last active November 15, 2016 23:33
Basic real-time article suggest functionality within your Desk.com support center contact form
Steps:
1) Edit your support center theme
2) Go to 'Advanced Themes' tab at the top
3) Go to "Email (New)" sub-theme on the left side
4) Insert the JavaScript below at the very bottom
5) Insert the HTML below beneath the contact form HTML
@DeskWOW
DeskWOW / 1. Desk.com gmail style email reply template.html
Last active October 25, 2016 11:10
You can copy and paste the following code into the Email Reply Theme to make your emails look like they are sent from gmail.
{% assign emails = case.emails %}
{% assign threadlength = emails.size|minus:1 %}
{% for email in emails reversed %}
{% if forloop.first %}
{{email.new_html}}
{% if email.agent %}
{% if email.agent.signature %}
@DeskWOW
DeskWOW / gist:7218265
Last active December 26, 2015 21:49
Using Sessvars (JavaScript session variables) to send data to your support center and store it within the browser session (so it's still accessible as the user browses your support center) without the use of cookies or multipass.
// Include the sessvars library
<script src="https://desk-customers.s3.amazonaws.com/shared/sessvars.js" type="text/javascript"></script>
// This function allows you to read a GET parameter from the URL
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
@DeskWOW
DeskWOW / gist:7338514
Last active December 27, 2015 14:09
Below is the JavaScript code for real-time article suggest in your Desk.com support center contact form. This is to be placed within your theme's "Email (New)" section of Advanced Themes within Desk.com Admin.
<div id="autosuggest" style="display: none;"></div>
<div id="common">
<h4>Common Questions</h4>
<p>This will show on page-load and if no results are found based on what the user is typing. You can optionally put links to common articles here.</p>
</div>
<script>
var as_count = 0;
$(function() {
@DeskWOW
DeskWOW / gist:7361694
Created November 7, 2013 20:53
To limit My Portal cases per brand, record which brand each case is regarding as a case custom field. Then, within "My Cases (List)" you'd use this code.
<table class='mycases'>
<thead>
<tr>
<th></th>
<th>{{desk.system.snippets.case_id}}</th>
<th>{{desk.system.snippets.subject}}</th>
<th>{{desk.system.snippets.from}}</th>
<th>{{desk.system.snippets.created}}</th>
<th>{{desk.system.snippets.status}}</th>
</tr>
@DeskWOW
DeskWOW / gist:8183108
Created December 30, 2013 15:04
How to feature articles by article ID for support centers with its content segmented by topic description.
{% capture featured_force_article %}1227039,1227386{% endcapture %}
{% for topic in site.topics %}
{% if topic.desc == "force" or topic.desc == "all" %}
{% for article in topic.articles %}
{% capture current_article_id %}{{ article.id }}{% endcapture %}
{% if featured_force_article contains current_article_id %}
<li><a href="{{ article.public_url }}">{{ article.subject_plain }}</a></li>
{% endif %}
{% endfor %}
@DeskWOW
DeskWOW / gist:8198042
Last active January 1, 2016 20:39
How to add "previous article" and "next article" to your Desk.com support center article pages.
{% for current_article in topic.articles %}
{% if current_processed == true %}
{% assign next_article = current_article %}
{% assign current_processed = false %}
{% endif %}
{% if current_article.subject_plain == article.subject_plain %}
{% assign current_processed = true %}
{% assign previous_article = last_processed %}
{% endif %}
{% assign last_processed = current_article %}
@DeskWOW
DeskWOW / gist:8393310
Created January 13, 2014 01:39
Code snippet to demonstrate multi-brand liquid variables
List of all brands:
<ul>
{% for current_brand in desk.brands %}
<li><a href="{{current_brand.public_url}}">{{current_brand.name}}</a></li>
{% endfor %}
</ul>
<hr>
Current brand variables:
@DeskWOW
DeskWOW / dynamic_height.js
Created January 16, 2014 05:31
when you need to have the same height for 2 divs and one div has dynamic content, just add a simultaneously class to each div and the shorter div increases in height to match the larger div.
<script type="text/javascript">
$(document).ready(function(){
var maxHeight = 0;
$('div.simultaneously').each(function(index){
if ($(this).height() > maxHeight)
{
maxHeight = $(this).height();
@DeskWOW
DeskWOW / gist:8587383
Created January 23, 2014 21:42
List links to other articles in the same topic and bold the current article.
<style>
.active { font-weight: bold; }
.inactive { opacity: 0.5; }
</style>
<ul>
{% for cur in topic.articles %}
<li>
<a class="{% if article.id == cur.id %}active{% else %}inactive{% endif %}" href='{{ cur.public_url }}'>{{ cur.subject_plain | clip:40 }}</a>
</li>