done_text ‘) html (t),.} $ (‘ # done click ‘)’) trigger (. ‘ ,} function managesubscription (op, id) {$ ajax ({url: ‘/ stream / assinar.html’, data: {id: id, remove: op == ‘un’ 1: 0}, type: ‘.? post ‘, dataType:’ json ‘, success: function (a, b, c) {if (a.result == 200) {if (op ==.’ un ‘) {$ (‘ # subscribe ‘) removeClass ( .. ‘on’) addClass (‘off’) attr (‘title’, ‘. subscription Click to subscribe removed again’);} else {$ (‘# subscribe’) removeClass (‘off’) addClass (‘.. on ‘) attr (.’ title ‘,’ Notification of new messages will be sent to your e-mail Click to remove the signature. ‘);}}}, error: function (a, b) {alert (‘ Error removing signature .., please try again later ‘);}, complete: function () {}});} function vote (d, id) {if (loggedin) {$ (!’ # login click ‘);’) trigger (. ‘ return;} $ ajax ({url: ‘/ stream / vote.html’, data: {id: id, d: d}, type: ‘post’, dataType: ‘json’, success: function (a, b. , c) {$ (‘# voteup_’ + a.id) find (‘span’) text (a.voteup)..; $ (‘# Votedown_’ + a.id) find (‘span’) text (a.votedown)..; if (a.result == 302) done (‘You have already voted for this post’); else if (a.result == 304) done (‘You can not vote for their own posts’); }, Error: function (a, b) {}, complete: function () {}}); Report} function (id) {if (! Loggedin) {alert (‘You must be logged in to report posts’); . $ (‘# Login’) trigger (‘click’); return; Reason} = $ (‘input [name = "reason"]: checked’, ‘# report_form’); if (reason.length> 0) reason.attr (‘checked’, false); / / Checks if the post is moderated Modred var = false; m = $ (‘# post_’ + id); if (! m.hasClass (‘moderated’)) {$ (‘label [for = "action_3"]‘) hide ().; $ (‘# Action_3′) hide ().; } / / Checks if the post is deleted d = $ (‘# deleted_’ + id); if (d.length> 0) {$ (‘label [for = "action_0"]‘) text (‘Restore post.’); $ (‘Label [for = "action_1"]‘) hide ().; $ (‘# Action_1′) hide ().; $ (‘Label [for = "action_1_1"]‘) hide ().; $ (‘# Action_1_1′) hide ().; } Else {$ (‘label [for = "action_0"]‘) text (‘Delete post’).; $ (‘Label [for = "action_1"]‘) show ().; $ (‘# Action_1′) show ().; } $ (‘# Action_1′) live (‘click’, function () {var t = $ (this) is (… ‘: Checked’) if (t) {$ (‘# action_1_1′) show ( ); $ (‘label [for = "action_1_1"]‘) show ();.} else {$ (‘# action_1_1′) hide ();.. $ (‘label [for = "action_1_1"]‘) hide ();}}); $ (‘# Reason_other’) hide ().; . $ (‘# Report_id’) val (id); . $ (‘# Reason_text’) val (”); . $ (‘# Report_error’) html (”); $ (‘Input: radio’, ‘# report_form’) removeAttr (‘checked’);. $ (‘Input: checkbox’, ‘# report_form’) removeAttr (‘checked’);. $ (‘# None’) attr (‘checked’, ‘checked’).; . $ (‘# Reporting’) trigger (‘click’); Reply} function (id) {if (loggedin) {$ (‘# login’) trigger (‘click’).; return; } Username = $ (‘# username_’ + id [2]) text ().; quote = ‘[quote =' + username + ';' + Id [1] + ‘]’ + br2nl ($ (‘# text_’ + id [1]) val ().) + ‘[/Quote] r n’; text = $ (‘# comment_text’) val ().; if (text.length> 0) text + = ‘ r n’; $ (‘# Comment_text’) val (text + quote) focus ()..; IsModerator} function () {var mod = array (1, 1, 0, 0, 0, 0, 0, 0, 0, 0); return (loggedin | | typeof (groupid) == ‘undefined’ | | groupid ‘!); Br2nl} function (s) {return s.replace (‘ n’, ‘ r n’); ZeroesLeft} function (s, p) {s = ’00000 ‘+ s; return s.substr (s.length – p); MakeTimeString} function (stime, literal) {d = new Date (); time = parseInt (d.getTime () / 1000) – stime; / / If (typeof literal == ‘undefined’) literal = false; literal = false; if (time> 86400 | | literal) {d.setTime (stime * 1000); zeroesLeft return (d.getDate (), 2) + “/” + zeroesLeft (d.getMonth () + 1 2) + “/” + zeroesLeft (d.getFullYear () 4) + ” + zeroesLeft (d . getHours () 2) + ‘:’ + zeroesLeft (d.getMinutes () 2) + ‘:’ + zeroesLeft (d.getSeconds () 2); Units} = new Array (‘year’, ‘month’, ‘week’, ‘day’, ‘hour’, ‘minute’, ‘second’); tokens = new Array (31536000, 2592000, 604800, 86400, 3600, 60, 1); for (u = 0, u 1)? ‘S’,”); $ Fn.extend}} ({insertAtCaret:. Function (myValue) {if (document.selection) {this.focus (); document.selection.createRange sel = (); sel.text = myValue; this.focus () ;} else if (this.selectionStart | | this.selectionStart == ’0 ‘) {var startPos = this.selectionStart; var endpos = this.selectionEnd; var scrollTop = this.scrollTop; this.value = this.value.substring (0, startPos) + myValue + this.value.substring (endpos, this.value.length); this.focus (); this.selectionStart = startPos + myValue.length; this.selectionEnd = startPos + myValue.length; this . scrollTop = scrollTop;} else {this.value + = myValue; this.focus ();}}}); / ** Plugin jQuery.BBCode * Version 0.2 ** Based on jQuery.BBCode plugin (http://www.kamaikinproject.ru) * / (function ($ ) {$ . Fn.bbcode = function (options) {/ / default settings var options = $ extend ({tag_bold: true, tag_italic: true, tag_underline: true, tag_link: true, tag_image: false, button_image: true, image_url: ‘bbimage /’}, options | | {});. / / panel var text =”; $ (this) wrap (”).;
$ (“# Bbcode_container”) prepend (text).;
$ (“# Bbcode_bb_bar img”) css (“border”, “none”).;
var id = ‘#’ + $ (this) attr (“id”).;
and var = $ (id) get (0).;
$ (‘. Editor_smilie’.) Live (‘click’, function (ev) {
ev.preventDefault ();
start = $ (this) attr (‘rel’).;
end =”;
insert (start, end, e);
$ (‘Smilies_close.’) Hide ().;
$ (‘# Smilies_container’) slideUp (‘fast’).;
return false;
});
$ (‘# Bbcode_bb_bar a’). Click (function (event) {
event.preventDefault ();
button_id var = $ (this) attr (“id”).;
if (button_id == ‘smilies’) {
if ($ (‘# smilies_container’) is (. ‘: visible’)) {
$ (‘Smilies_close.’) Hide ().;
$ (‘# Smilies_container’) slideUp (‘fast’).;
}
else {
$ (‘# Smilies_container’). SlideDown (‘fast’, function () {
$ (‘Smilies_close.’) Show ().;
});
}
return;
}
var start = ‘[' + button_id + ']‘;
var end = ‘[/' + button_id + ']‘;
var param = “”;
if (button_id == ‘img’)
{
param = prompt (“Enter image URL”, “http://”);
if (param)
start + = param;
}
else if (button_id == ‘url’)
{
param = prompt (“Enter URL”, “http://”);
if (param)
start = ‘[url href =' + param + ']‘;
}
insert (start, end, e);
return false;
});
}
function insert (start, end, element) {
if (document.selection) {
/ / Element.focus ();
sel = document.selection.createRange ();
sel.text = start + end + sel.text;
} Else if (element.selectionStart | | element.selectionStart == ’0 ‘) {
/ / Element.focus ();
var startPos = element.selectionStart;
var endpos = element.selectionEnd;
element.value element.value.substring = (0, startPos) + start + element.value.substring (startPos, endpos) + end + element.value.substring (endpos, element.value.length);
element.selectionStart = startPos;
element.selectionEnd = endpos + + start.length end.length;
Else {}
element.value + = start + end;
}
. $ (‘. Comment_text’) trigger (‘keyup’);
}
/ / Hotkeys
/ *
$ (Document). Keyup (function (e)
{If (e.which == 17) isCtrl = false; }). Keydown (function (e)
{If (e.which == 17) isCtrl = true;
if (e.which == 66 && isCtrl == true) / / CTRL + B Bold
{
$ (“# B”) click ().;
return false;
}
else if (e.which == 73 && isCtrl == true) / / Ctrl + I italic
{
$ (“# I”) click ().;
return false;
}
else if (e.which == 85 && isCtrl == true) / / Ctrl + U, underline
{
$ (“# U”) click ().;
return false;
}
});
* /
}) (JQuery);