Skip to content

Instantly share code, notes, and snippets.

@skipjac
Created January 14, 2011 22:46
Show Gist options
  • Save skipjac/780437 to your computer and use it in GitHub Desktop.
Save skipjac/780437 to your computer and use it in GitHub Desktop.
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;
}
$j(document).ready(function() {
//check to see if you are on the end users request page
if (window.location.href.indexOf('entries') >= 0){
$j.getJSON(window.location.href+".json", function(data) {
if(data['current_tags'] === 'gist'){
$j('div#widget_189206').show();
}
});
}
});
var V4Attempts = 0;
var V5Attempts = 0;
$j(document).ready(function() {
if(window.location.href.indexOf('entries') >= 0)
{
$j.getJSON(window.location.href+".json", function(data)
{
if(/version4/i.test(data['current_tags']))
showV4();
if(/version5/i.test(data['current_tags']))
showV5();
});
}
});
function showV4()
{
V4Attempts += 1;
if($j('div#widget_253811').length)
{
$j('div#widget_253811').show();
}
else
{
if(V4Attempts < 50)
window.setTimeout(showV4, 100);
}
}
function showV5()
{
V5Attempts += 1;
if($j('div#widget_256933').length)
{
$j('div#widget_256933').show();
}
else
{
if(V5Attempts < 50)
window.setTimeout(showV5, 100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment