[3632] | 1 | (function() |
---|
| 2 | { |
---|
| 3 | |
---|
| 4 | function notifications(){} |
---|
| 5 | |
---|
| 6 | function AddEmail() |
---|
| 7 | { |
---|
| 8 | var emailFrom = document.getElementById('filemanager_add_email_from'); |
---|
| 9 | var emailTo = document.getElementById('filemanager_add_email_to'); |
---|
| 10 | |
---|
| 11 | var _AddEmail = function( data ) |
---|
| 12 | { |
---|
| 13 | if( data !== "False") |
---|
| 14 | { |
---|
| 15 | var _data = data.split(","); |
---|
| 16 | var _tableElement = document.getElementById("table_email_notifications"); |
---|
| 17 | _tableElement.innerHTML = "<tr class='th'><td width='80%'>"+get_lang("Email")+"</td>" + |
---|
| 18 | "<td width='20%' align='center'>"+get_lang("Delete")+"</td></tr>"; |
---|
| 19 | |
---|
| 20 | for( var i = 0; i < _data.length ; i++ ) |
---|
| 21 | { |
---|
| 22 | var _tr = document.createElement("tr"); |
---|
| 23 | |
---|
| 24 | var _td1 = document.createElement("td"); |
---|
| 25 | _td1.appendChild( document.createTextNode( _data[i] ) ); |
---|
| 26 | _tr.appendChild( _td1 ); |
---|
| 27 | |
---|
| 28 | var _td2 = document.createElement("td"); |
---|
| 29 | _td2.align = "center"; |
---|
| 30 | _td2.innerHTML = '<a href="javascript:void();" onclick="notify.deleteEmail(\'' + _data[i] + '\',this);">' + get_lang("Delete") + '</a>'; |
---|
| 31 | _tr.appendChild( _td2 ); |
---|
| 32 | |
---|
| 33 | _tableElement.appendChild( _tr ); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | emailTo.value = ""; |
---|
| 37 | emailTo.focus(); |
---|
| 38 | } |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | if( ( emailFrom.value = trim(emailFrom.value) ) != "") |
---|
| 42 | { |
---|
| 43 | if( ( emailTo.value = trim(emailTo.value) ) != "" ) |
---|
| 44 | { |
---|
| 45 | cExecute_("./index.php?menuaction=filemanager.notifications.AddEmail&emailFrom="+emailFrom.value+"&emailTo="+emailTo.value, _AddEmail); |
---|
| 46 | } |
---|
| 47 | else |
---|
| 48 | alert( get_lang("It is necessary to inform the user that will receive email notification") + "!"); |
---|
| 49 | } |
---|
| 50 | else |
---|
| 51 | { |
---|
| 52 | alert( get_lang("It is necessary to inform the user that sends mail file") + "!"); |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | function DeleteEmail() |
---|
| 57 | { |
---|
| 58 | if( arguments.length > 0 ) |
---|
| 59 | { |
---|
| 60 | var _emailFrom = trim( document.getElementById('filemanager_add_email_from').value ); |
---|
| 61 | var _emailTo = arguments[0]; |
---|
| 62 | var _tr = arguments[1].parentNode.parentNode; |
---|
| 63 | |
---|
| 64 | var _DeleteEmail = function(data) |
---|
| 65 | { |
---|
| 66 | if( data !== "False" ) |
---|
| 67 | _tr.parentNode.removeChild( _tr ); |
---|
| 68 | }; |
---|
| 69 | |
---|
| 70 | cExecute_("./index.php?menuaction=filemanager.notifications.DeleteEmail&emailFrom="+_emailFrom+"&emailTo="+_emailTo, _DeleteEmail); |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | function DeleteEmailUser() |
---|
| 75 | { |
---|
| 76 | if( arguments.length > 0 ) |
---|
| 77 | { |
---|
| 78 | var _id = trim( arguments[0] ); |
---|
| 79 | var _tr = arguments[1].parentNode.parentNode; |
---|
| 80 | |
---|
| 81 | var _DeleteEmailUser = function(data) |
---|
| 82 | { |
---|
| 83 | if( data !== "False" ) |
---|
| 84 | _tr.parentNode.removeChild( _tr ); |
---|
| 85 | }; |
---|
| 86 | |
---|
| 87 | cExecute_("./index.php?menuaction=filemanager.notifications.DeleteEmailUser&filemanagerId="+_id, _DeleteEmailUser); |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | function trim(inputString) |
---|
| 92 | { |
---|
| 93 | if ( typeof inputString != "string" ) |
---|
| 94 | return inputString; |
---|
| 95 | |
---|
| 96 | var retValue = inputString; |
---|
| 97 | var ch = retValue.substring(0, 1); |
---|
| 98 | |
---|
| 99 | while (ch == " ") |
---|
| 100 | { |
---|
| 101 | retValue = retValue.substring(1, retValue.length); |
---|
| 102 | ch = retValue.substring(0, 1); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
| 106 | |
---|
| 107 | while (ch == " ") |
---|
| 108 | { |
---|
| 109 | retValue = retValue.substring(0, retValue.length-1); |
---|
| 110 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | while (retValue.indexOf(" ") != -1) |
---|
| 114 | { |
---|
| 115 | retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); |
---|
| 116 | } |
---|
| 117 | return retValue; |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | notifications.prototype.addEmail = AddEmail; |
---|
| 121 | notifications.prototype.deleteEmail = DeleteEmail; |
---|
| 122 | notifications.prototype.deleteEmailUser = DeleteEmailUser; |
---|
| 123 | |
---|
| 124 | window.notify = new notifications; |
---|
| 125 | |
---|
| 126 | })(); |
---|