[3157] | 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 | |
---|
| 42 | cExecute ("expressoMail1_2.imap_functions.get_quota_folders", handler_buildQuota); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | emInfoQuota.prototype.showWindow = function (div) |
---|
| 46 | { |
---|
[5426] | 47 | |
---|
| 48 | var newWidth = ((parseInt(document.body.clientWidth,10)*0.7)^0); |
---|
[3157] | 49 | if(! this.win) { |
---|
| 50 | div.style.height = "350px"; |
---|
[5426] | 51 | div.style.width = newWidth + "px"; |
---|
[3157] | 52 | var title = get_lang("View Quota Usage in Folders"); |
---|
| 53 | var wHeight = div.offsetHeight + "px"; |
---|
| 54 | var wWidth = div.offsetWidth + "px"; |
---|
| 55 | |
---|
| 56 | this.win = new dJSWin({ |
---|
| 57 | id: 'win_'+div.id, |
---|
| 58 | content_id: div.id, |
---|
| 59 | width: wWidth, |
---|
| 60 | height: wHeight, |
---|
| 61 | title_color: '#3978d6', |
---|
| 62 | title_align: 'center', |
---|
| 63 | bg_color: '#eee', |
---|
| 64 | title: title, |
---|
| 65 | title_text_color: 'white', |
---|
| 66 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
| 67 | border: true }); |
---|
| 68 | |
---|
| 69 | this.win.draw(); |
---|
| 70 | this.win.title.align = "center"; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | this.win.open(); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | emInfoQuota.prototype.close_window = function() { |
---|
| 77 | this.win.close(); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | emInfoQuota.prototype.buildQuota = function (data){ |
---|
| 81 | if(Element("window_InfoQuota")){ |
---|
| 82 | Element("window_InfoQuota").innerHTML = ''; |
---|
| 83 | } |
---|
| 84 | var content = ''; |
---|
[3854] | 85 | var q_limit = borkb(data.quota_root.quota_limit*1024); |
---|
[3157] | 86 | |
---|
| 87 | var value = ''; |
---|
| 88 | var q_used = ''; |
---|
| 89 | var table = document.createElement("TABLE"); |
---|
| 90 | table.id = "table_quota"; |
---|
| 91 | table.style.border="1px solid #CCC"; |
---|
| 92 | table.style.marginTop = "10px"; |
---|
| 93 | table.style.width="100%"; |
---|
[4561] | 94 | if (navigator.userAgent.toLowerCase().indexOf('chrome') == -1)// chrome == > -1 |
---|
[3157] | 95 | table.style.height="80%"; |
---|
| 96 | table.style.background = "#FFF"; |
---|
| 97 | table.cellSpacing = 5; |
---|
[5430] | 98 | table.cellPadding = 0; |
---|
| 99 | if (is_ie) |
---|
| 100 | table.setAttribute('class','table-info-quota'); |
---|
| 101 | |
---|
[3157] | 102 | var thead = document.createElement("THEAD"); |
---|
| 103 | var tbody = document.createElement("TBODY"); |
---|
| 104 | var tfoot = document.createElement("TFOOT"); |
---|
| 105 | table.appendChild(thead); |
---|
| 106 | table.appendChild(tbody); |
---|
| 107 | table.appendChild(tfoot); |
---|
| 108 | thead.style.background = "#FFF"; |
---|
| 109 | var tr_thead = document.createElement("TR"); |
---|
| 110 | tr_thead.style.fontSize = "10pt"; |
---|
[5430] | 111 | tr_thead.style.height = '15px'; |
---|
[3157] | 112 | tr_thead.style.background = "#3978d6"; |
---|
| 113 | tr_thead.style.color = "white"; |
---|
| 114 | tr_thead.style.fontWeight = "bold"; |
---|
| 115 | thead.appendChild(tr_thead); |
---|
| 116 | var th_thead = document.createElement("TH"); |
---|
| 117 | th_thead.style.paddingRight = '5px'; |
---|
| 118 | th_thead.style.paddingLeft = '5px'; |
---|
| 119 | th_thead.innerHTML = get_lang('Folder'); |
---|
| 120 | tr_thead.appendChild(th_thead); |
---|
| 121 | th_thead = document.createElement("TH"); |
---|
| 122 | th_thead.style.paddingRight = '5px'; |
---|
| 123 | th_thead.style.paddingLeft = '5px'; |
---|
| 124 | th_thead.style.align = "center"; |
---|
| 125 | th_thead.colSpan = "2"; |
---|
| 126 | th_thead.noWrap = "true"; |
---|
| 127 | th_thead.innerHTML = get_lang('% used'); |
---|
| 128 | tr_thead.appendChild(th_thead); |
---|
| 129 | th_thead = document.createElement("TH"); |
---|
| 130 | th_thead.style.paddingRight = '5px'; |
---|
| 131 | th_thead.style.paddingLeft = '5px'; |
---|
| 132 | th_thead.noWrap = "true"; |
---|
| 133 | th_thead.innerHTML = get_lang("Size")+" (bytes)"; |
---|
| 134 | tr_thead.appendChild(th_thead); |
---|
| 135 | tbody.style.overflowY = "auto"; |
---|
| 136 | tbody.style.overflowX = "hidden"; |
---|
| 137 | tbody.style.width = "50%"; |
---|
| 138 | var last_folder = 'null'; |
---|
| 139 | for(var x in data) { |
---|
| 140 | if(x == 'quota_root') continue; |
---|
[3854] | 141 | q_used = borkb(data[x]['quota_used']); |
---|
[3157] | 142 | value = data[x]['quota_percent']; |
---|
| 143 | td01 = document.createElement("TD"); |
---|
| 144 | td01.align="left"; |
---|
| 145 | if(x.indexOf(last_folder+"/") == -1){ |
---|
| 146 | last_folder = x; |
---|
| 147 | td01.innerHTML = " "+x; |
---|
[5426] | 148 | td01.setAttribute('title',x); |
---|
[3157] | 149 | } |
---|
| 150 | else { |
---|
| 151 | var a_folder = x.split('/'); |
---|
| 152 | for (var i =0; i< a_folder.length;i++) |
---|
| 153 | td01.innerHTML += " "; |
---|
| 154 | td01.innerHTML += a_folder[a_folder.length-1]; |
---|
[5426] | 155 | td01.setAttribute('title',a_folder[a_folder.length - 1]); |
---|
[3157] | 156 | } |
---|
| 157 | |
---|
[5426] | 158 | var user_max_width = ((parseInt(document.body.clientWidth,10)*0.7)^0); |
---|
| 159 | var max_len_permited = ((user_max_width*(1/6)*(0.5))^0);//tamanho maximo do nome de pasta |
---|
| 160 | |
---|
[3157] | 161 | td01.width="40%"; |
---|
[5426] | 162 | td01.style.maxWidth = max_len_permited + "px"; |
---|
[5430] | 163 | td01.style.borderBottom = "1px dashed #DDD"; |
---|
| 164 | td01.setAttribute('class','td-info-quota'); |
---|
[3157] | 165 | td02 = document.createElement("TD"); |
---|
| 166 | td02.align="center"; |
---|
| 167 | td02.width="5%"; |
---|
| 168 | td02.setAttribute("noWrap","true"); |
---|
| 169 | td02.innerHTML = value+"%"; |
---|
| 170 | td11 = document.createElement("TD"); |
---|
| 171 | td11.width="10%"; |
---|
| 172 | td11.align="center"; |
---|
| 173 | td11.setAttribute("noWrap","true"); |
---|
| 174 | td11.style.borderBottom = "1px dashed #DDD"; |
---|
| 175 | td11.innerHTML += ' <span class="boxHeaderText">'+q_used+"</span>"; |
---|
| 176 | tr2 = document.createElement("TR"); |
---|
| 177 | td21 = document.createElement("TD"); |
---|
| 178 | td21.setAttribute("noWrap","true"); |
---|
| 179 | td21.height="15px"; |
---|
| 180 | td22 = document.createElement("TD"); |
---|
| 181 | td21.setAttribute("background","../phpgwapi/templates/"+template+"/images/dsunused.gif"); |
---|
| 182 | table221 = document.createElement("TABLE"); |
---|
| 183 | tbody221 = document.createElement("TBODY"); |
---|
| 184 | table221.appendChild(tbody221); |
---|
| 185 | table221.style.width=value+"%"; |
---|
| 186 | td21.width="30%"; |
---|
| 187 | table221.cellSpacing = 0; |
---|
| 188 | table221.cellPadding = 0; |
---|
| 189 | tr221 = document.createElement("TR"); |
---|
| 190 | td221 = document.createElement("TD"); |
---|
| 191 | td221.height="15px"; |
---|
[4561] | 192 | td221.className = 'dsused'; |
---|
| 193 | td221.style.width = '100%'; |
---|
[3157] | 194 | tr221.appendChild(td221); |
---|
| 195 | tbody221.appendChild(tr221); |
---|
| 196 | td21.appendChild(table221); |
---|
| 197 | tr2.appendChild(td01); |
---|
| 198 | tr2.appendChild(td02); |
---|
| 199 | tr2.appendChild(td21); |
---|
| 200 | tr2.appendChild(td11); |
---|
| 201 | tbody.appendChild(tr2); |
---|
| 202 | } |
---|
| 203 | var tr_tfoot = document.createElement("TR"); |
---|
| 204 | tr_tfoot.style.fontSize = "10pt"; |
---|
| 205 | tr_tfoot.style.color = "#bbb"; |
---|
| 206 | tr_tfoot.style.fontWeight = "bold"; |
---|
| 207 | tfoot.appendChild(tr_tfoot); |
---|
| 208 | var th_tfoot = document.createElement("TH"); |
---|
| 209 | th_tfoot.style.align = "center"; |
---|
| 210 | th_tfoot.colSpan = "4"; |
---|
| 211 | th_tfoot.style.paddingRight = '5px'; |
---|
| 212 | th_tfoot.style.paddingLeft = '5px'; |
---|
[3854] | 213 | th_tfoot.innerHTML = get_lang("You are currently using %1 (%2%).",borkb(data.quota_root.quota_used*1024), data.quota_root.quota_percent); |
---|
[3157] | 214 | tr_tfoot.appendChild(th_tfoot); |
---|
[5430] | 215 | |
---|
[3157] | 216 | return table; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | /* Build the Object */ |
---|
| 220 | var InfoQuota; |
---|
| 221 | InfoQuota = new emInfoQuota(); |
---|
| 222 | |
---|
| 223 | /* Override function :: refresh and auto_refresh */ |
---|
| 224 | var __build_quota = build_quota; |
---|
| 225 | build_quota = function (data) { |
---|
| 226 | __build_quota(data); |
---|
| 227 | if(InfoQuota.win) |
---|
| 228 | InfoQuota.win.close(); |
---|
| 229 | InfoQuota.preLoad(); |
---|
| 230 | }; |
---|