// Copyright (C) 2014 Jacob Barkdull
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see
', '');
var website = (document.getElementById('opt-website-' + e) != undefined) ? document.getElementById('opt-website-' + e).href : 'Website';
document.getElementById('cmtopts-' + e).style.display = 'none';
document.getElementById('cmtforms-' + e).innerHTML = '\n\n\
Edit Comment\n\
\n\
\n\
\n\
\n\
\n\
\n';
return false
}
// Function to cancel reply and edit forms
function cancelform(f) {
document.getElementById('cmtopts-' + f).style.display = '';
document.getElementById('cmtforms-' + f).innerHTML = '';
return false;
}
// Function to like a comment
function like(c, f) {
// Load "like.php"
var like = new XMLHttpRequest();
like.open('GET', '/hashover/scripts/like.php?like=image-Wkz/' + f);
like.send();
// Get number of likes
if (document.getElementById('likes-' + c).innerHTML != '') {
var likes = parseInt(document.getElementById('likes-' + c).innerHTML.replace(/[^0-9]/g, ''));
} else {
var likes = parseInt(0);
}
// Change "Like" button title and class; Increase likes
if (document.getElementById('like-' + c).className == 'like') {
document.getElementById('like-' + c).className = 'liked';
document.getElementById('like-' + c).title = 'You \'Liked\' This Comment';
likes++;
} else {
document.getElementById('like-' + c).className = 'like';
document.getElementById('like-' + c).title = '\'Like\' This Comment';
likes--;
}
// Change number of likes
var like_count = (likes != 1) ? likes + ' Likes' : likes + ' Like';
document.getElementById('likes-' + c).innerHTML = (likes > 0) ? '' + like_count + '' : '';
}
// Displays options
function options(r) {
if (name_on == 'yes' || email_on == 'yes' || passwd_on == 'yes' || sites_on == 'yes') {
if (document.getElementById('options-' + r).style.maxHeight != '200px') {
document.getElementById('options-' + r).style.maxHeight = '200px';
} else {
document.getElementById('options-' + r).style.maxHeight = '0px';
}
}
return false;
}
// Displays a "blank email address" warning
// function noemail() {
// if (email_on == 'yes' && (document.comment_form.email.value == '' || document.comment_form.email.value == 'E-mail Address')) {
// var answer = confirm('You will not receive notification of replies to your comment without supplying an e-mail.');
//
// if (answer == false) {
// document.comment_form.email.focus();
// return false;
// }
// }
// }
// Displays a "blank email address" warning when replying
// function noemailreply(f) {
// if (email_on == 'yes' && (document.getElementById('reply_form-' + f).email.value == '' || document.getElementById('reply_form-' + f).email.value == 'E-mail Address')) {
// var answer = confirm('You will not receive notification of replies to your comment without supplying an e-mail.');
//
// if (answer == false) {
// document.getElementById('options-' + f).style.display = '';
// document.getElementById('reply_form-' + f).email.focus();
// return false;
// }
// }
// }
// Displays confirmation dialog for deletion
function delwarn() {
var answer = confirm('Are you sure you want to delete this comment?');
if (answer == false) {
return false;
}
}
// Get page title
if (document.title != '') {
var pagetitle = ' on "'+document.title+'"';
} else {
var pagetitle = '';
}
var show_cmt = '';
function parse_template(object, sort, method) {
var indent = (sort == false || method == 'ascending') ? object['indent'] : '16px 0px 12px 0px';
if (!object['deletion_notice']) {
var
permalink = object['permalink'],
cmtclass = (sort == false || method == 'ascending') ? object['cmtclass'] : 'cmtdiv',
avatar = object['avatar'],
name = object['name'],
thread = (object['thread']) ? object['thread'] : '',
date = object['date'],
likes = (object['likes']) ? object['likes'] : '',
like_link = (object['like_link']) ? object['like_link'] : '',
edit_link = (object['edit_link']) ? object['edit_link'] : '',
reply_link = object['reply_link'],
comment = object['comment'],
form = '',
cmtopts_style = ''
;
show_cmt += '\n';
show_cmt += '\n';
show_cmt += ' ' + avatar + '\n';
show_cmt += ' \n';
show_cmt += ' ' + name + ' ' + thread + '\n';
show_cmt += ' ' + comment + '
\n';
show_cmt += ' \n';
show_cmt += '\n';
show_cmt += ' \n';
show_cmt += ' ' + date + ' ' + likes + '\n';
show_cmt += ' \n';
show_cmt += ' \n';
show_cmt += ' \n';
show_cmt += '\n';
} else {
show_cmt += '\n';
show_cmt += '\n';
show_cmt += object['deletion_notice'] + '\n';
show_cmt += '\n';
}
}
function sort_comments(method) {
var methods = {
ascending: function() {
for (var comment in comments) {
parse_template(comments[comment], true, method);
}
},
descending: function() {
for (var comment = (comments.length - 1); comment >= 0; comment--) {
parse_template(comments[comment], true, method);
}
},
byname: function() {
var tmpSortArray = comments.slice(0).sort(function(a, b) {
if(a.sort_name < b.sort_name) return -1;
if(a.sort_name > b.sort_name) return 1;
})
for (var comment in tmpSortArray) {
parse_template(tmpSortArray[comment], true, method);
}
},
bydate: function() {
var tmpSortArray = comments.slice(0).sort(function(a, b) {
return b.sort_date - a.sort_date;
})
for (var comment in tmpSortArray) {
parse_template(tmpSortArray[comment], true, method);
}
},
bylikes: function() {
var tmpSortArray = comments.slice(0).sort(function(a, b) {
return b.sort_likes - a.sort_likes;
})
for (var comment in tmpSortArray) {
parse_template(tmpSortArray[comment], true, method);
}
}
}
show_cmt = '';
document.getElementById('sort_div').innerHTML = 'Loading...' + '\n';
methods[method]();
document.getElementById('sort_div').innerHTML = show_cmt + '\n';
}
// Place "hashover" DIV
if (document.getElementById("hashover") == null) {
document.write("\n");
}
show_cmt += '
Post a Comment'+pagetitle+':';
show_cmt += '
\n';
show_cmt += '
\n';
show_cmt += '
Showing 0 Comments:\n';
show_cmt += '\n';
show_cmt += '
\n';
show_cmt += '\n';
show_cmt += 'Be the first to comment!\n';
show_cmt += '
\n';
show_cmt += '\n';
show_cmt += 'HashOver Comments ·\n';
show_cmt += 'Source Code ·\n';
show_cmt += 'JavaScript ·\n';
show_cmt += 'ChangeLog ·\n';
show_cmt += 'Archives
\n';
show_cmt += ' \n';
// Place all content on page
document.getElementById("hashover").innerHTML = show_cmt;
// Script Execution Time: 0.08963 Seconds