Gazelle/static/functions/staffpm.js

123 lines
3.8 KiB
JavaScript
Raw Normal View History

2011-03-28 14:21:28 +00:00
function SetMessage() {
var id = document.getElementById('common_answers_select').value;
ajax.get("?action=get_response&plain=1&id=" + id, function (data) {
$('#quickpost').raw().value = data;
2013-06-17 08:01:02 +00:00
$('#common_answers').ghide();
2011-03-28 14:21:28 +00:00
});
}
function UpdateMessage() {
var id = document.getElementById('common_answers_select').value;
ajax.get("?action=get_response&plain=0&id=" + id, function (data) {
$('#common_answers_body').raw().innerHTML = data;
$('#first_common_response').remove()
});
}
function SaveMessage(id) {
var ajax_message = 'ajax_message_' + id;
var ToPost = [];
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
ToPost['id'] = id;
ToPost['name'] = document.getElementById('response_name_' + id).value;
ToPost['message'] = document.getElementById('response_message_' + id).value;
ajax.post("?action=edit_response", ToPost, function (data) {
if (data == '1') {
document.getElementById(ajax_message).textContent = 'Response successfully created.';
} else if (data == '2') {
document.getElementById(ajax_message).textContent = 'Response successfully edited.';
} else {
document.getElementById(ajax_message).textContent = 'Something went wrong.';
}
2013-06-17 08:01:02 +00:00
$('#' + ajax_message).gshow();
var t = setTimeout("$('#" + ajax_message + "').ghide()", 2000);
2011-03-28 14:21:28 +00:00
}
);
}
function DeleteMessage(id) {
var div = '#response_' + id;
var ajax_message = 'ajax_message_' + id;
var ToPost = [];
ToPost['id'] = id;
ajax.post("?action=delete_response", ToPost, function (data) {
2013-06-17 08:01:02 +00:00
$(div).ghide();
2011-03-28 14:21:28 +00:00
if (data == '1') {
document.getElementById(ajax_message).textContent = 'Response successfully deleted.';
} else {
document.getElementById(ajax_message).textContent = 'Something went wrong.';
}
2013-06-17 08:01:02 +00:00
$('#'+ajax_message).gshow();
var t = setTimeout("$('#" + ajax_message + "').ghide()", 2000);
2011-03-28 14:21:28 +00:00
});
}
function Assign() {
var ToPost = [];
ToPost['assign'] = document.getElementById('assign_to').value;
ToPost['convid'] = document.getElementById('convid').value;
ajax.post("?action=assign", ToPost, function (data) {
if (data == '1') {
document.getElementById('ajax_message').textContent = 'Conversation successfully assigned.';
} else {
document.getElementById('ajax_message').textContent = 'Something went wrong.';
}
2013-06-17 08:01:02 +00:00
$('#ajax_message').gshow();
var t = setTimeout("$('#ajax_message').ghide()", 2000);
2011-03-28 14:21:28 +00:00
});
}
function PreviewResponse(id) {
var div = '#response_div_'+id;
if ($(div).has_class('hidden')) {
var ToPost = [];
ToPost['message'] = document.getElementById('response_message_'+id).value;
ajax.post('?action=preview', ToPost, function (data) {
document.getElementById('response_div_'+id).innerHTML = data;
2013-06-17 08:01:02 +00:00
$(div).gtoggle();
$('#response_message_'+id).gtoggle();
2011-03-28 14:21:28 +00:00
});
} else {
2013-06-17 08:01:02 +00:00
$(div).gtoggle();
$('#response_message_'+id).gtoggle();
2011-03-28 14:21:28 +00:00
}
}
function PreviewMessage() {
if ($('#preview').has_class('hidden')) {
var ToPost = [];
ToPost['message'] = document.getElementById('quickpost').value;
ajax.post('?action=preview', ToPost, function (data) {
document.getElementById('preview').innerHTML = data;
2013-06-17 08:01:02 +00:00
$('#preview').gtoggle();
$('#quickpost').gtoggle();
2012-02-06 08:00:21 +00:00
$('#previewbtn').raw().value = "Edit";
2011-03-28 14:21:28 +00:00
});
} else {
2013-06-17 08:01:02 +00:00
$('#preview').gtoggle();
$('#quickpost').gtoggle();
2012-02-06 08:00:21 +00:00
$('#previewbtn').raw().value = "Preview";
2011-03-28 14:21:28 +00:00
}
}
2012-03-04 08:00:21 +00:00
function Quote(post, user) {
username = user;
postid = post;
2013-05-04 08:00:48 +00:00
ajax.get("?action=get_post&post=" + postid, function(response) {
2012-03-04 08:00:21 +00:00
if ($('#quickpost').raw().value !== '') {
$('#quickpost').raw().value = $('#quickpost').raw().value + "\n\n";
}
2013-05-04 08:00:48 +00:00
$('#quickpost').raw().value = $('#quickpost').raw().value + "[quote=" + username + "]" +
2012-03-04 08:00:21 +00:00
//response.replace(/(img|aud)(\]|=)/ig,'url$2').replace(/\[url\=(https?:\/\/[^\s\[\]<>"\'()]+?)\]\[url\](.+?)\[\/url\]\[\/url\]/gi, "[url]$1[/url]")
html_entity_decode(response)
+ "[/quote]";
resize('quickpost');
});
2013-05-04 08:00:48 +00:00
}