/usr/share/mizuho/templates/juvia.js is in ruby-mizuho 0.9.20+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | var disqus_identifier;
var disqus_title;
var disqus_url;
var disqus_developer = 1;
Mizuho.initializeCommenting = $.proxy(function() {
var self = this;
this.commentBalloons = $('.comments');
this.commentBalloons.click(function() {
self.showCommentsPopup(this);
});
this.reloadCommentCount();
}, Mizuho);
Mizuho.showLightbox = $.proxy(function(creationCallback, closeCallback) {
var lightbox = $(
'<div id="comments_lightbox">' +
' <div id="comments_lightbox_shadow"></div>' +
' <div id="comments_lightbox_contents"><div class="shell"></div></div>' +
'</div>');
var shadow = $('#comments_lightbox_shadow', lightbox);
var contents = $('#comments_lightbox_contents > .shell', lightbox);
function close() {
if (lightbox) {
lightbox.remove();
lightbox = undefined;
if (closeCallback) {
closeCallback();
}
}
}
shadow.click(close);
lightbox.bind('lightbox:close', close);
lightbox.appendTo(document.body);
creationCallback(contents);
}, Mizuho);
Mizuho.getCommentThreadInfo = $.proxy(function(balloon) {
var info = {};
if ($(balloon).closest('#toc').length > 0) {
info.id = 'toctitle';
info.topic = 'toctitle';
info.title = $('#header h1').text() + " - " + $('#toctitle').text();
} else {
var header = $(balloon).next('h2, h3, h4');
if (header.length > 0) {
info.id = header.attr('id');
info.topic = header.data('comment-topic');
info.title = $('#header h1').text() + " - " + header.text();
} else {
info = undefined;
}
}
return info;
}, Mizuho);
Mizuho.callJuviaApi = function(action, options) {
function makeQueryString(options) {
var key, params = [];
for (key in options) {
params.push(
encodeURIComponent(key) +
'=' +
encodeURIComponent(options[key]));
}
return params.join('&');
}
// Makes sure that each call generates a unique URL, otherwise
// the browser may not actually perform the request.
if (!('_juviaRequestCounter' in window)) {
window._juviaRequestCounter = 0;
}
var url =
JUVIA_URL + '/api/' + action +
'?_c=' + window._juviaRequestCounter +
'&' + makeQueryString(options);
window._juviaRequestCounter++;
var s = document.createElement('script');
s.async = true;
s.type = 'text/javascript';
s.className = 'juvia';
s.src = url;
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(s);
}
Mizuho.showCommentsPopup = $.proxy(function(balloon) {
var info = this.getCommentThreadInfo(balloon);
if (!info) {
return;
}
var self = this;
this.showLightbox(function(element) {
// We install a 'Close' button in the Juvia comment form after it has loaded.
function installCloseButton() {
if ($('#comments .juvia-form-actions').size() > 0) {
// The Juvia form is now loaded. Install the button.
var div = $('<div class="juvia-action" style="margin-left: 0.5em"></div>');
var button = $('<input type="button" value="Cancel"></div>').appendTo(div);
div.insertBefore('#comments .juvia-form-actions .juvia-error');
button.click(function() {
$(element).trigger('lightbox:close');
});
} else {
// Continue polling.
setTimeout(installCloseButton, 50);
}
}
setTimeout(installCloseButton, 50);
// Now load the Juvia comments form.
element.html('<div id="comments">Loading comments...</div>');
self.changingHash = true;
location.hash = '#!/' + info.id;
self.callJuviaApi('show_topic.js', {
container : '#comments',
site_key : JUVIA_SITE_KEY,
topic_key : info.topic,
topic_url : location.href,
topic_title : info.topic,
include_base: !window.Juvia,
include_css : !window.Juvia
});
}, function() {
self.reloadCommentCount();
});
}, Mizuho);
Mizuho.reloadCommentCount = $.proxy(function() {
this.callJuviaApi('list_topics.jsonp', {
site_key: JUVIA_SITE_KEY,
jsonp : 'Mizuho.topicListReceived'
});
}, Mizuho);
Mizuho.topicListReceived = $.proxy(function(result) {
var self = this;
var i, topic, map = {};
for (i = 0; i < result.topics.length; i++) {
topic = result.topics[i];
map[topic.key] = topic;
}
this.commentBalloons.each(function() {
var info = self.getCommentThreadInfo(this);
if (info) {
topic = map[info.topic];
if (topic) {
var balloon = $(this);
$('.count', balloon).text(topic.comment_count);
balloon.removeClass('empty');
balloon.addClass('nonempty');
balloon.attr('title', null);
}
}
});
}, Mizuho);
$(document).ready(Mizuho.initializeCommenting);
|