[2517] | 1 | function emInfoQuota () |
---|
| 2 | { |
---|
| 3 | this.win; |
---|
| 4 | this.el; |
---|
| 5 | this.preLoad(); |
---|
| 6 | } |
---|
| 7 | |
---|
| 8 | emInfoQuota.prototype.preLoad = function(){ |
---|
| 9 | if(Element("table_quota")) { |
---|
| 10 | Element("table_quota").style.cursor = "pointer"; |
---|
| 11 | Element("table_quota").title = get_lang("View Quota Usage in Folders"); |
---|
| 12 | Element("table_quota").onclick = function (){ |
---|
| 13 | InfoQuota.showList(); |
---|
| 14 | } |
---|
| 15 | } |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | emInfoQuota.prototype.showList = function() |
---|
| 19 | { |
---|
| 20 | var _this = this; |
---|
| 21 | var el = Element("window_InfoQuota"); |
---|
| 22 | if(!el) { |
---|
| 23 | el = document.createElement("DIV"); |
---|
| 24 | el.style.visibility = "hidden"; |
---|
| 25 | el.style.position = "absolute"; |
---|
| 26 | el.style.left = "0px"; |
---|
| 27 | el.style.top = "0px"; |
---|
| 28 | el.style.overflowY = "auto"; |
---|
| 29 | el.align = "center"; |
---|
| 30 | div.style.height = "400px"; |
---|
| 31 | el.id = 'window_InfoQuota'; |
---|
| 32 | document.body.appendChild(el); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | var handler_buildQuota = function(data){ |
---|
| 36 | el.appendChild(InfoQuota.buildQuota(data)); |
---|
| 37 | el.innerHTML += '<br><input style="margin-bottom:10px" type="button" value=' + get_lang("Close")+ |
---|
| 38 | ' id="InfoQuota_button_close" onClick="InfoQuota.close_window();">'; |
---|
| 39 | _this.showWindow(el); |
---|
| 40 | } |
---|
| 41 | |
---|
[2519] | 42 | cExecute ("expressoMail1_2.imap_functions.get_quota_folders", handler_buildQuota); |
---|
[2517] | 43 | } |
---|
| 44 | |
---|
| 45 | emInfoQuota.prototype.showWindow = function (div) |
---|
| 46 | { |
---|
| 47 | if(! this.win) { |
---|
| 48 | div.style.height = "350px"; |
---|
| 49 | div.style.width = "450px"; |
---|
| 50 | var title = get_lang("View Quota Usage in Folders"); |
---|
| 51 | var wHeight = div.offsetHeight + "px"; |
---|
| 52 | var wWidth = div.offsetWidth + "px"; |
---|
| 53 | |
---|
| 54 | this.win = new dJSWin({ |
---|
| 55 | id: 'win_'+div.id, |
---|
| 56 | content_id: div.id, |
---|
| 57 | width: wWidth, |
---|
| 58 | height: wHeight, |
---|
| 59 | title_color: '#3978d6', |
---|
| 60 | title_align: 'center', |
---|
| 61 | bg_color: '#eee', |
---|
| 62 | title: title, |
---|
| 63 | title_text_color: 'white', |
---|
| 64 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
| 65 | border: true }); |
---|
| 66 | |
---|
| 67 | this.win.draw(); |
---|
| 68 | this.win.title.align = "center"; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | this.win.open(); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | emInfoQuota.prototype.close_window = function() { |
---|
| 75 | this.win.close(); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | emInfoQuota.prototype.buildQuota = function (data){ |
---|
| 79 | if(Element("window_InfoQuota")){ |
---|
| 80 | Element("window_InfoQuota").innerHTML = ''; |
---|
| 81 | } |
---|
| 82 | var content = ''; |
---|
| 83 | var q_limit = data.quota_root.quota_limit; |
---|
| 84 | |
---|
| 85 | var value = ''; |
---|
| 86 | var q_used = ''; |
---|
| 87 | var table = document.createElement("TABLE"); |
---|
| 88 | table.id = "table_quota"; |
---|
| 89 | table.style.border="1px solid #CCC"; |
---|
| 90 | table.style.marginTop = "10px"; |
---|
| 91 | table.style.width="100%"; |
---|
| 92 | table.style.height="80%"; |
---|
| 93 | table.style.background = "#FFF"; |
---|
| 94 | table.cellSpacing = 5; |
---|
| 95 | table.cellPadding = 0; |
---|
| 96 | var thead = document.createElement("THEAD"); |
---|
| 97 | var tbody = document.createElement("TBODY"); |
---|
| 98 | var tfoot = document.createElement("TFOOT"); |
---|
| 99 | table.appendChild(thead); |
---|
| 100 | table.appendChild(tbody); |
---|
| 101 | table.appendChild(tfoot); |
---|
| 102 | thead.style.background = "#FFF"; |
---|
| 103 | var tr_thead = document.createElement("TR"); |
---|
| 104 | tr_thead.style.fontSize = "10pt"; |
---|
| 105 | tr_thead.style.height = '10px'; |
---|
| 106 | tr_thead.style.background = "#3978d6"; |
---|
| 107 | tr_thead.style.color = "white"; |
---|
| 108 | tr_thead.style.fontWeight = "bold"; |
---|
| 109 | tr_thead.outerHTML = tr_thead.outerHTML; |
---|
| 110 | thead.appendChild(tr_thead); |
---|
| 111 | var th_thead = document.createElement("TH"); |
---|
| 112 | th_thead.style.paddingRight = '5px'; |
---|
| 113 | th_thead.style.paddingLeft = '5px'; |
---|
| 114 | th_thead.innerHTML = get_lang('Folder'); |
---|
| 115 | tr_thead.appendChild(th_thead); |
---|
| 116 | th_thead = document.createElement("TH"); |
---|
| 117 | th_thead.style.paddingRight = '5px'; |
---|
| 118 | th_thead.style.paddingLeft = '5px'; |
---|
| 119 | th_thead.style.align = "center"; |
---|
| 120 | th_thead.colSpan = "2"; |
---|
| 121 | th_thead.noWrap = "true"; |
---|
| 122 | th_thead.innerHTML = get_lang('% used'); |
---|
| 123 | tr_thead.appendChild(th_thead); |
---|
| 124 | th_thead = document.createElement("TH"); |
---|
| 125 | th_thead.style.paddingRight = '5px'; |
---|
| 126 | th_thead.style.paddingLeft = '5px'; |
---|
| 127 | th_thead.noWrap = "true"; |
---|
| 128 | th_thead.innerHTML = get_lang("Size")+" (bytes)"; |
---|
| 129 | tr_thead.appendChild(th_thead); |
---|
| 130 | tbody.style.overflowY = "auto"; |
---|
| 131 | tbody.style.overflowX = "hidden"; |
---|
| 132 | tbody.style.width = "50%"; |
---|
| 133 | var last_folder = 'null'; |
---|
| 134 | for(var x in data) { |
---|
| 135 | if(x == 'quota_root') continue; |
---|
| 136 | q_used = data[x]['quota_used']; |
---|
| 137 | value = data[x]['quota_percent']; |
---|
| 138 | td01 = document.createElement("TD"); |
---|
| 139 | td01.align="left"; |
---|
| 140 | if(x.indexOf(last_folder+"/") == -1){ |
---|
| 141 | last_folder = x; |
---|
| 142 | td01.innerHTML = " "+x; |
---|
| 143 | } |
---|
| 144 | else { |
---|
| 145 | var a_folder = x.split('/'); |
---|
| 146 | for (var i =0; i< a_folder.length;i++) |
---|
| 147 | td01.innerHTML += " "; |
---|
| 148 | td01.innerHTML += a_folder[a_folder.length-1]; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | td01.style.borderBottom = "1px dashed #DDD"; |
---|
| 152 | td01.width="40%"; |
---|
| 153 | td01.setAttribute("noWrap","true"); |
---|
| 154 | td02 = document.createElement("TD"); |
---|
| 155 | td02.align="center"; |
---|
| 156 | td02.width="5%"; |
---|
| 157 | td02.setAttribute("noWrap","true"); |
---|
| 158 | td02.innerHTML = value+"%"; |
---|
| 159 | td11 = document.createElement("TD"); |
---|
| 160 | td11.width="10%"; |
---|
| 161 | td11.align="center"; |
---|
| 162 | td11.setAttribute("noWrap","true"); |
---|
| 163 | td11.style.borderBottom = "1px dashed #DDD"; |
---|
| 164 | td11.innerHTML += ' <span class="boxHeaderText">'+q_used+"</span>"; |
---|
| 165 | tr2 = document.createElement("TR"); |
---|
| 166 | td21 = document.createElement("TD"); |
---|
| 167 | td21.setAttribute("noWrap","true"); |
---|
| 168 | td21.height="15px"; |
---|
| 169 | td22 = document.createElement("TD"); |
---|
| 170 | td21.setAttribute("background","../phpgwapi/templates/"+template+"/images/dsunused.gif"); |
---|
| 171 | table221 = document.createElement("TABLE"); |
---|
| 172 | tbody221 = document.createElement("TBODY"); |
---|
| 173 | table221.appendChild(tbody221); |
---|
| 174 | table221.style.width=value+"%"; |
---|
| 175 | td21.width="30%"; |
---|
| 176 | table221.cellSpacing = 0; |
---|
| 177 | table221.cellPadding = 0; |
---|
| 178 | tr221 = document.createElement("TR"); |
---|
| 179 | td221 = document.createElement("TD"); |
---|
| 180 | td221.height="15px"; |
---|
| 181 | td221.className = 'dsused'; |
---|
| 182 | tr221.appendChild(td221); |
---|
| 183 | tbody221.appendChild(tr221); |
---|
| 184 | td21.appendChild(table221); |
---|
| 185 | tr2.appendChild(td01); |
---|
| 186 | tr2.appendChild(td02); |
---|
| 187 | tr2.appendChild(td21); |
---|
| 188 | tr2.appendChild(td11); |
---|
| 189 | tbody.appendChild(tr2); |
---|
| 190 | } |
---|
| 191 | var tr_tfoot = document.createElement("TR"); |
---|
| 192 | tr_tfoot.style.fontSize = "10pt"; |
---|
| 193 | tr_tfoot.style.color = "#bbb"; |
---|
| 194 | tr_tfoot.style.fontWeight = "bold"; |
---|
| 195 | tfoot.appendChild(tr_tfoot); |
---|
| 196 | var th_tfoot = document.createElement("TH"); |
---|
| 197 | th_tfoot.style.align = "center"; |
---|
| 198 | th_tfoot.colSpan = "4"; |
---|
| 199 | th_tfoot.style.paddingRight = '5px'; |
---|
| 200 | th_tfoot.style.paddingLeft = '5px'; |
---|
| 201 | th_tfoot.innerHTML = get_lang("You are currently using %1Mb (%2%).",data.quota_root.quota_used, data.quota_root.quota_percent); |
---|
| 202 | tr_tfoot.appendChild(th_tfoot); |
---|
| 203 | return table; |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | /* Build the Object */ |
---|
| 207 | var InfoQuota; |
---|
| 208 | InfoQuota = new emInfoQuota(); |
---|
| 209 | |
---|
| 210 | /* Override function :: refresh and auto_refresh */ |
---|
| 211 | var __build_quota = build_quota; |
---|
| 212 | build_quota = function (data) { |
---|
| 213 | __build_quota(data); |
---|
| 214 | if(InfoQuota.win) |
---|
| 215 | InfoQuota.win.close(); |
---|
| 216 | InfoQuota.preLoad(); |
---|
[2579] | 217 | }; |
---|