Skip to content

Instantly share code, notes, and snippets.

@skipjac
skipjac / email_validate.js
Created July 20, 2015 00:41
Validate email in zendesk Help Center ticket forms.
$('input').keyup(function(e){
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if(e.target.name === 'request[anonymous_requester_email]'){
var match = re.test(e.target.value);
console.log(match);
};
});
@skipjac
skipjac / Ticket time
Created December 10, 2010 19:16
zendesk custom widget
<div id="realTime">
</div>
<script type="javascript">
pausecomp = function(millis)
{
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
@skipjac
skipjac / check-user-name.js
Created December 22, 2010 04:39
This zendesk javascript widget will not allow users to be created with [GM] at the front of their name. Not really useful but it can be changed to force full names
//this widget checks the user name to see if it has a prefix and hide the submit button if it does
$j(document).ready(function() {
//check to see if you are on the registration page
if (window.location.href.indexOf('registration') >= 0) {
//hide the recaptcha and submit button
$j('.action-login').hide();
$j('div#recaptcha_widget').hide();
//check the name when the move to the next field.
$j('input#user_name.text').blur(function() {
//the regex for the expression you are checking for in this case [GM]
@skipjac
skipjac / change-text-on-anonymous-page.js
Created December 22, 2010 22:22
change the message on the anonymous ticket submission page on zendesk
message = 'If you previously signed up with Support';
message += '(to post to the Forum and/or create a Support ticket) please ';
message += '<a href=\"login?return_to=http%3A%2F%2Fsupport.tuneupmedia.com%2Frequests%2Fnew\">login</a>';
message += ' first to submit a request.';
//check to see if you are on the end users anonymous request page
if (window.location.href.indexOf('anonymous_requests') >= 0) {
jQuery('p:contains(If you are a registered user)').html(message);
}
@skipjac
skipjac / embedJavascript.js
Created January 4, 2011 14:48
Embed Javascript in a Zendesk forum
<script type="text/javascript">// <![CDATA[
$j('div.user_formatted').append("<iframe src =\"http://skipjack.zendesk.com\/account/dropboxes/43\" width=\"100%\" height=\"300\"><p>test</p></iframe>");
// ]]></script>
@skipjac
skipjac / hide-widget.css
Created January 14, 2011 22:46
hide or show a zendesk widget in the side bar based on a tag in the forum topic
/* you can get the widget ID/Number from the widget edit page in the sidebar */
div#widget_189206 {
display: none;
}
@skipjac
skipjac / hipchatRoom.js
Created January 14, 2011 23:27
Shows the users in a hipchat room and the time of the last message
<div id='hipchat_widget'>
</div>
<div id="hipchat_message"></div>
<script type="javascript">
$j(document).ready(function() {
d = new Date();
if(d.getMonth()>9){
month = d.getMonth()+1;
@skipjac
skipjac / ticketview-widget.js
Created January 25, 2011 17:30
Displays a views RSS feed as a sidebar.
<script type="javascript">
/*this is a custom widget for the sidebar of zendesk to display the RSS feed
*of a view. You are limited to 15 items. just copy and paste this code into a custom widget. The one
*bug I couldn't fix is if the 1st 200 charater contain something in the pre tags
*it doesn't wrap and over runs the sidebar.
*/
</script>
<div id="feedContent">
</div>
@skipjac
skipjac / hide-pinned-topic.js
Created January 26, 2011 21:49
This hides a pinned if the user is logged but displays it if it's a Anonymous user
<div id="userNamewidget">
</div>
<script>
$j(document).ready(function() {
if('{{current_user.name}}' == 'Anonymous user'){ $j('div#pinned-entry-57062').show();}
else
{ $j('div#pinned-entry-57062').hide(); }
});
@skipjac
skipjac / urban-custom-widget.js
Created January 27, 2011 04:42
this is the sidebar widget for the urban dictionary
<script type="text/javascript" id="urban_source">Widget.require('http://www.techassistant.net/urban_widget/urban.js', {type: 'text/javascript'});</script>
<div id="urban_content"></div>