1 var currentSideBar = 'div#title_side_bar';
2 function changeSideBar(enabled_bar) {
3 $(currentSideBar).hide();
4 currentSideBar = enabled_bar;
5 $(currentSideBar).fadeIn('slow');
9 $('div#editor_side_bar').hide();
10 $('div#tags_side_bar').hide();
12 $('#id_title').focus(function(){changeSideBar('div#title_side_bar')});
13 $('#editor').focus(function(){changeSideBar('div#editor_side_bar')});
14 $('#id_tags').focus(function(){changeSideBar('div#tags_side_bar')});
18 var $input = $('#id_title');
19 var $box = $('#ask-related-questions');
20 var template = $('#question-summary-template').html();
22 var results_cache = {};
24 function reload_suggestions_box(e) {
25 var q = $input.val().replace(/^\s+|\s+$/g,"");
28 $('#ask-related-questions').html('');
32 if (results_cache[q] && results_cache[q] != '') {
33 $('#ask-related-questions').html(results_cache[q]);
37 $.post(related_questions_url, {title: q}, function(data) {
39 var c = $input.val().replace(/^\s+|\s+$/g,"");
46 for (var i = 0; i < data.length; i++) {
47 var item = template.replace(new RegExp('%URL%', 'g'), data[i].url)
48 .replace(new RegExp('%SCORE%', 'g'), data[i].score)
49 .replace(new RegExp('%TITLE%', 'g'), data[i].title)
50 .replace(new RegExp('%SUMMARY%', 'g'), data[i].summary);
56 results_cache[q] = html;
58 $('#ask-related-questions').html(html);
65 $input.keyup(reload_suggestions_box);