Skip to content

Instantly share code, notes, and snippets.

@skipjac
skipjac / gist:5393261
Created April 16, 2013 04:05
watch for changes on DOMtree
$j('#topic_search').bind('DOMSubtreeModified', function(e) {console.log(e); console.log($j('#topic_search_result .item').length);})
@skipjac
skipjac / sortarrayofobjects.js
Created April 11, 2013 22:49
This will sort a bunch of objects in a array by a object property
sortJsonArrayByProperty: function(objArray, prop, direction){
if (arguments.length<2) throw new Error("sortJsonArrayByProp requires 2 arguments");
var direct = arguments.length>2 ? arguments[2] : 1; //Default to ascending
if (objArray && objArray.constructor===Array){
var propPath = (prop.constructor===Array) ? prop : prop.split(".");
objArray.sort(function(a,b){
for (var p in propPath){
if (a[propPath[p]] && b[propPath[p]]){
a = a[propPath[p]];
b = b[propPath[p]];
@skipjac
skipjac / hide_request.css
Created March 20, 2013 19:01
hide submit a request based on user tags in zendesk
.tab_new {
display: none;
}
@skipjac
skipjac / getAssigneeValue.js
Created March 18, 2013 17:17
Get the assignee change from a autocomplete dropdown fields
Event.observe(window, 'load', function() {
jQuery('.assignee').parent().find('input.ui-widget').blur(function(){
jQuery("#ticket_fields_22399063").val(jQuery('.assignee').find('option:selected').text());
});
});
@skipjac
skipjac / redirect-forums.js
Created March 15, 2013 17:03
redirect from bad article to good article
if (!currentUser.isAgent) {
if (window.location.pathname == '/bad/entry'){
window.location.href = '/good/entry';
}
}
@skipjac
skipjac / gist:5165313
Created March 14, 2013 21:11
create a ticket in a zendesk spoke from a widget in classic
<div id='createtheticket'>
<ol>
<li>
<div class="select" style>
<label for="zendeskSelect">Select Spoke Account</label>
<select id="zendeskSelect" name="zendeskSelect" onchange style="width: auto;">
<option value="-">-</option>
<option value="sutoka.techassistant.net">Germany</option>
</select>
</li>
var UrbanDictionaryWidget = Class.create({
getRandomTerm: function() {
var url = '/proxy/direct?url=http://www.urbandictionary.com/random.php'
new Ajax.Request(url, {
method:'post',
postBody: '',
onSuccess: function(transport) {
this.getDocument(transport.responseText);
@skipjac
skipjac / gist:4512657
Created January 11, 2013 17:52
Change the color of the last element in the Zendesk forum breadcrumb
$j('h2.forums a:last-child').css('color', 'red')
@skipjac
skipjac / autocompleteFromSelect.js
Created December 19, 2012 17:07
add search autocomplete for non nested dropdown fields
$j('#ticket_fields_104609').autocompleteFromSelect();
$j('#ticket_fields_109943').autocompleteFromSelect();
@skipjac
skipjac / attachment.html
Created November 16, 2012 23:18
Zendesk attachment links in Classic sidebar
<div id="attachmentList">
<div id="attachmentItem">
</div>
</div>
<script type="application/javascript">
(function () {
var processComments = function (data) {
data.forEach(function (i) {