$('.questionlistbox').each(function() { /* questionlistboxes contain three switches: - gotta know - neutral - don't care */ this.jstr = this.id.replace('questionlistbox:',''); $(this).find('a').not('.selected').hide(); $(this).find('.copy').hide(); $(this).hover( function() { $(this).children('a').not('.selected').slideDown(120); $(this).find('.copy').show(); }, function() { $(this).children('a').not('.selected').slideUp(180); setTimeout("$(document.getElementById('" + this.id + "')).find('.copy').hide()",360); } ); if (CLIENT_ID > 1) { $(this).find('a').click(function() { this.jstr = this.parentNode.jstr; var _s = this.jstr.split('-'); this.idnum = _s[_s.length-1]; $(this.parentNode).find('a').each(function() { $(this).removeClass('selected'); }); $(this).addClass('selected'); if ($(this).hasClass('good')) { $.get('http://' + document.domain + '/qi_questions_service?&function=good&j=' + this.jstr); $('.questionlistbox_copy_' + this.idnum).html('You want to know when your friends answer this'); } else if ($(this).hasClass('bad')) { $.get('http://' + document.domain + '/qi_questions_service?&function=bad&j=' + this.jstr); $('.questionlistbox_copy_' + this.idnum).html('You are not interested in this'); } else if ($(this).hasClass('neutral')) { $.get('http://' + document.domain + '/qi_questions_service?&function=neutral&j=' + this.jstr); $('.questionlistbox_copy_' + this.idnum).html('You are moderately interested in this'); } return false; }); } else { $(this).find('a').click(function() { setTimeout('alert(\'Plese log in first!\')',10); return false; }); } });
}
function prepend_answer(answer_id,question_jstr,format) { if (!format) { var format = 'standard'; } $.get('http://' + document.domain + '/qi_questions_service?&function=answer_html&j=/answer-' + answer_id + '&answer_format=' + format + '&jstr_echo=' + question_jstr, function(data) { var _s = this.url.split('='); var _question_jstr = _s[_s.length-1]; var el = document.getElementById('answers:' + _question_jstr); $(el).prepend(data); $(el).children('div:first').slideDown(180); activate_delete_links(); }); }
function activate_delete_links() { $('.delete_link').click(function() { // each delete link is within a parent container called "otype-idnum"; the delete link itself should be called "delete:otype-idnum". var pElId = this.id.replace('delete:',''); var c = confirm('Really delete? There is no undo.'); if (c == true) { var _s = pElId.split('-'); var otype = _s[0]; var idnum = _s[1]; $.post('http://' + document.domain + '/?&siteformat=xml&elId=' + pElId, {'1_posttype':'delete','1_orb':otype,'1_where':otype + '.id = ' + idnum}, function(data) { var _s = this.url.split('='); var el = document.getElementById(_s[_s.length-1]); var spacer_id = el.id + '-spacer'; $(el).slideUp(360); try { $('##' + spacer_id).hide(); } catch(err) {} // how many records now match? var _n = document.getElementById('num_records'); if (_n !== null) { var num_records = $(_n).html(); var num_records = num_records - 1; if (num_records == 1) { var _txt = "Result"; } else { var _txt = "Results"; } $(_n).html(num_records); $('##records_match').html(_txt); } }); } return false; }); }