<!--- Script Routine Template:
http://joelie.org/j:/routinetype-script --->
<!--- optionally, include js headers --->
<if isdefined("att.headers") AND att.headers EQ 1>
<tag.js_headers expires="90">
</if>
<!--- output javascript statements --->
$(document).ready(function() {
activate_delete_links();
activate_iquestions();
$('.iquestion_hoverable').each(function() {
var _s = this.id.split('-');
this.idnum = _s[_s.length-1];
this.target_user_id = 0;
this.target_user_name = '';
var _targs = $(this).find('.target_user_id');
if (_targs.length > 0) {
this.target_user_id = $(_targs[0]).html();
this.target_user_name = $($(this).find('.target_user_name')[0]).html();
}
$(this).hover(
function() { // Mouse Goes Over
this.mouse_is_over = 1;
$(this).css('background','#GLOBAL.Def.Style.color.back_accent#');
var _cushion = 8;
var _width = 240;
var _height = 240;
var _left = 0;
var _top = 0;
var _offset = $(this).offset();
_offset.left = _offset.left - _width - _cushion - $(window).scrollLeft();
_offset.top = _offset.top - $(window).scrollTop();
if (_offset.top + _height + _cushion < $(window).height()) {
var _top = _offset.top;
}
else {
var _top = $(window).height() - _height - _cushion;
}
if (_offset.left + _width + _cushion < $(window).width()) {
var _left = _offset.left;
}
else {
var _left = $(window).width() - _width - _width - _cushion;
}
$(document.body).append('<div class="hoverer" id="hoverer:' + this.id + '" style="position:fixed; padding-right:' + (_cushion+8) + 'px; left:' + _left + 'px; top:' + _top + 'px; width:' + _width + 'px; min-height:' + _height + 'px; z-index:1001;">\
<div class="hoverer_content" style="display:none; font-size:0.72em; background:#GLOBAL.Def.Style.color.back_accent#; border:1px solid ##555; height:' + (_height-12) + 'px; overflow:auto;">\
<div style="font-size:0.88em; margin:1.7em;"><tag.ajax_loader_gif> hangonnasecond...</div>\
</div>\
</div>');
var _hoverer = document.getElementById('hoverer:' + this.id);
_hoverer.compadre = this;
this.compadre = _hoverer;
$(this.compadre).find('.hoverer_content').slideDown(210);
$(this.compadre).hover(
function() { this.mouse_is_over = 1; },
function() {
this.mouse_is_over = 0;
setTimeout("try{if (document.getElementById('" + this.id + "').compadre.mouse_is_over !== 1) {\
$(document.getElementById('" + this.compadre.id + "')).css('background','none');\
$(document.getElementById('" + this.id + "')).remove();\
}}catch(err){}",500);
}
);
_idnum = this.idnum;
$(this.compadre).find('.hoverer_content').load('http://' + document.domain + '/qi_questions_service?&j=/question-' + _idnum + '&function=question_facts&target_user_id=' + encodeURIComponent(this.target_user_id) + '&target_user_name=' + encodeURIComponent(this.target_user_name), function(data) {
activate_iquestions();
});
},
function() { // Mouse Goes Out
this.mouse_is_over = 0;
setTimeout("try{if (document.getElementById('" + this.id + "').compadre.mouse_is_over !== 1) {\
$(document.getElementById('" + this.compadre.id + "')).remove();\
$(document.getElementById('" + this.id + "')).css('background','none');\
}}catch(err){}",500);
}
);
});
});
function activate_iquestions() {
$('.answer_question').each( function() {
/*
Note that .answer_question anchors are followed by hidden spans that contain
the question text (ex. "What did you eat for breakfast?")
*/
var _s = this.href.split('=');
var _jstr = _s[_s.length-1];
var _title = $(this).next('span').text();
var _answer_format = 'standard';
if ($(this).hasClass('answerformat_short')) {
var _answer_format = 'short';
}
$(this).click(function() {
$(document.body).append('<div class="answerer_container" style="position:fixed; left:0px; top:0px; width:100%; height:100%; z-index:1002;">\
<div class="answerer_bg" style="position:absolute; left:0px; top:0px; width:100%; height:100%; background:##69e; opacity:0.4; filter:alpha(opacity=40); z-index:1;"></div>\
<div class="answerer" style="position:absolute; display:none; width:44%; min-height:40%; padding:2%; left:26%; top:10%; background:white; z-index:2;">\
<h3>' + _title + '</h3>\
<div style="margin-bottom:1em;">\
<input class="answerer_input" style="width:99%; font-size:1.64em;">\
</div>\
<div style="margin-bottom:1em;">\
<select class="answerer_key">\
<option value="1">Everyone can see my answer</option>\
<option value="5">Friends and followers can see my answer</option>\
<option value="9">Only my friends can see this</option>\
<option value="0">Only I can see this (private)</option>\
</select>\
</div>\
<div align="right">\
<a onclick="setTimeout("$(\'.answerer_container\').remove()",10); return false;" href="##">Cancel</a>\
| \
<a class="answerer_submit answerformat_' + _answer_format + '" href="http://' + document.domain + '/qi_questions_service?&function=answer&j=' + _jstr + '"><b>Answer</b></a>\
</div>\
</div>\
</div>');
$('.answerer_submit').click(function() {
var _s = this.href.split('=');
var _question_jstr = _s[_s.length-1];
var _txt = $('.answerer_input').val();
var _key = $('.answerer_key').val();
var _answer_format = 'standard';
if ($(this).hasClass('answerformat_short')) {
var _answer_format = 'short';
}
if (jQuery.trim(_txt) == '') {
alert('Type something first!');
return false;
}
$.get(this.href + '&answer=' + encodeURIComponent(_txt) + '&key=' + _key + '&answer_format=' + _answer_format + '&jstr_echo=' + _question_jstr, function(data) {
var _s = this.url.split('=');
var _question_jstr = _s[_s.length-1];
var _answer_format = _s[_s.length-2].split('&')[0];
var _idnum = jQuery.trim(data);
prepend_answer(_idnum,_question_jstr,_answer_format);
$('.answerer_container').remove();
});
return false;
});
$('.answerer_input').keydown(function(e) {
if (e.keyCode == 13) {
$('.answerer_submit').click();
return false;
}
});
setTimeout("$('.answerer').fadeIn(240); $('.answerer_input').focus();",120);
return false;
});
});
$('.ask_question').each( function() {
$(this).click(function() {
$(document.body).append('<div class="asker_container" style="position:fixed; left:0px; top:0px; width:100%; height:100%; z-index:1000;">\
<div class="asker_bg" style="position:absolute; left:0px; top:0px; width:100%; height:100%; background:##280; opacity:0.4; filter:alpha(opacity=40); z-index:1;"></div>\
<div class="asker" style="position:absolute; display:none; width:44%; min-height:40%; padding:2%; left:26%; top:10%; background:white; z-index:2;">\
<h3>Ask a Question:</h3>\
<div style="margin-bottom:1em;">\
<input class="asker_input" style="width:99%; font-size:1.64em;">\
<div style="padding-top:3px; font-size:0.72em; color:##999;">\
Questions you ask will automatically be added to your "Gotta Know!" list.\
<br>Remember - questions can be viewed by the general public.\
</div>\
</div>\
<div align="right">\
<a onclick="setTimeout("$(\'.asker_container\').remove()",10); return false;" href="##">Cancel</a>\
| \
<a class="asker_submit" href="http://' + document.domain + '/qi_questions_service?&function=ask"><b>Ask</b></a>\
</div>\
</div>\
</div>');
$('.asker_submit').click(function() {
var _txt = $('.asker_input').val();
if (jQuery.trim(_txt) == '') {
alert('Type something first!');
return false;
}
$.get(this.href + '&question=' + encodeURIComponent(_txt), function() {
$('.asker_container').remove();
window.location = 'http://' + document.domain + '/Questions/Gotta_Know';
});
return false;
});
$('.asker_input').keydown(function(e) {
if (e.keyCode == 13) {
$('.asker_submit').click();
return false;
}
});
setTimeout("$('.asker').fadeIn(240); $('.asker_input').focus();",120);
return false;
});
});
$('.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;
});
}