20 function showTheMessage(message) {
21 $(
"html, body").animate({ scrollTop: 0 },
"slow");
22 $(
"#messageSpace").html(message +
"<hr />").fadeIn(500).delay(5000).fadeOut(500);
25 $(document).ready(
function() {
27 var form = $(
'form#adminLicenseCommentForm');
29 var t = $(
"#adminLicenseCommentTable").DataTable({
31 "paginationType":
"listbox",
32 "order": [[ 1,
'asc' ]],
35 "createdCell":
function (cell) {
36 $(cell).attr(
"style",
"text-align:center");
49 t.on(
'order.dt search.dt',
function () {
50 t.column(0, {
search:
'applied', order:
'applied'}).nodes().each(
function (cell, i) {
55 form.find(
"input[type=text],textarea").on(
"change",
function(){
56 $(
this).addClass(
"inputChanged");
59 form.submit(
function(event) {
60 var updatedFields = form.find(
".inputChanged").serializeArray();
61 var insertedFields = form.find(
".newCommentInputs").serializeArray();
62 if (updatedFields.length > 0 || insertedFields.length > 0) {
63 var itemsToSend = $.merge(updatedFields, insertedFields);
64 itemsToSend.push({
"name":
"formUpdated",
"value": 1});
66 url :
'?mod=admin_license_std_comments',
70 success :
function(data) {
72 if (data.updated == -1) {
73 message =
"No comments updated";
74 }
else if (data.updated > 0) {
75 form.find(
".inputChanged").removeClass(
"inputChanged");
76 message =
"Comments updated succesfully";
78 message = data.updated;
81 if (data.inserted.status != 0) {
82 if (data.inserted.status & 1) {
83 form.find(
".newCommentInputs").each(
function(){
84 if ($(
this).val().
trim()) {
85 $(
this).removeClass(
"newCommentInputs");
88 messageIns.push(
"Comments inserted successfully");
90 if (data.inserted.status & 1<<1) {
91 messageIns.push(
"errors during insertion");
93 if (data.inserted.status & 1<<2) {
94 messageIns.push(
"exceptions during insertion");
97 showTheMessage(message +
".<br />" + messageIns.join(
" with some ") +
".");
99 error :
function(data) {
100 showTheMessage(data);
104 event.preventDefault();
107 $(
"#addStdLicComment").on(
'click',
function(){
110 '<input type="text" name="insertStdLicNames[]" ' +
111 'placeholder="Please enter a name for the comment" ' +
112 'class="newCommentInputs" />',
113 '<textarea rows="7" cols="80" name="insertStdLicComments[]" ' +
114 'placeholder="Please enter a comment statement" ' +
115 'class="newCommentInputs"></textarea>',
116 '<input type="checkbox" checked disabled />' 120 $(
".licStdCommentToggle").change(
function(){
121 var changedBox = $(
this);
122 var boxName = changedBox.attr(
"name");
123 var idRegex = /stdLicCommentEnabled\[(\d+)\]/g;
124 var commId = idRegex.exec(boxName);
127 url :
'?mod=ajax_license_std_comments',
130 data : {
"toggle": commId},
131 success :
function(data) {
132 if (data.status !=
true) {
134 var current = changedBox.prop(
"checked");
135 changedBox.prop(
"checked", !current);
char * trim(char *ptext)
Trimming whitespace.