| 1 | {combine_script id="jquery.ui" path="themes/default/js/ui/minified/jquery.ui.core.min.js"} |
|---|
| 2 | {combine_script id="jquery.ui.dialog" path="themes/default/js/ui/minified/jquery.ui.dialog.min.js"} |
|---|
| 3 | |
|---|
| 4 | {literal} |
|---|
| 5 | <script type="text/javascript"> |
|---|
| 6 | var processAnalyze = { |
|---|
| 7 | step:0, |
|---|
| 8 | lists:new Array(), |
|---|
| 9 | timeStart:0, |
|---|
| 10 | timeEnd:0 |
|---|
| 11 | } |
|---|
| 12 | |
|---|
| 13 | function init() |
|---|
| 14 | { |
|---|
| 15 | getStatus(); |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | function getStatus() |
|---|
| 19 | { |
|---|
| 20 | data=$.ajax( |
|---|
| 21 | { |
|---|
| 22 | type: "POST", |
|---|
| 23 | url: "{/literal}{$datas.urlRequest}{literal}", |
|---|
| 24 | async: false, |
|---|
| 25 | data: { ajaxfct:"updateDatabaseGetStatus" } |
|---|
| 26 | } |
|---|
| 27 | ).responseText; |
|---|
| 28 | |
|---|
| 29 | list=data.split(";"); |
|---|
| 30 | $("#ianalyzestatus").html("<ul><li>"+list[0]+"</li><li>"+list[1]+"</li><li>"+list[2]+"</li></ul>"); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | function doAnalyze() |
|---|
| 35 | { |
|---|
| 36 | mode="all"; |
|---|
| 37 | modeLabel=""; |
|---|
| 38 | |
|---|
| 39 | if($("#ianalyze_action0").get(0).checked) |
|---|
| 40 | { |
|---|
| 41 | mode="notAnalyzed"; |
|---|
| 42 | modeLabel="{/literal}{'cstat_analyze_not_analyzed_pictures'|@translate}{literal}"; |
|---|
| 43 | } |
|---|
| 44 | else if($("#ianalyze_action1").get(0).checked) |
|---|
| 45 | { |
|---|
| 46 | mode="all"; |
|---|
| 47 | modeLabel="{/literal}{'cstat_analyze_all_pictures'|@translate}{literal}"; |
|---|
| 48 | } |
|---|
| 49 | else if($("#ianalyze_action2").get(0).checked) |
|---|
| 50 | { |
|---|
| 51 | mode="caddieAdd"; |
|---|
| 52 | modeLabel="{/literal}{'cstat_analyze_caddie_add_pictures'|@translate}{literal}"; |
|---|
| 53 | } |
|---|
| 54 | else if($("#ianalyze_action3").get(0).checked) |
|---|
| 55 | { |
|---|
| 56 | mode="caddieReplace"; |
|---|
| 57 | modeLabel="{/literal}{'cstat_analyze_caddie_replace_pictures'|@translate}{literal}"; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | doAnalyzeDialog="<br><form id='iDialogProgress' class='formtable'>"+ |
|---|
| 62 | "<div id='iprogressbar_contener' class='gcBorderInput'>"+ |
|---|
| 63 | "<span id='iprogressbar_bg' class='gcBgInput' style='width:0%;'> </span>"+ |
|---|
| 64 | "<span id='iprogressbar_fg' class='gcLink'>0%</span>"+ |
|---|
| 65 | "</div><p>{/literal}{'cstat_analyze_in_progress'|@translate}{literal}"+ |
|---|
| 66 | "<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>" |
|---|
| 67 | "</p></form>"; |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | $("#dialog") |
|---|
| 71 | .html("") |
|---|
| 72 | .dialog( |
|---|
| 73 | { |
|---|
| 74 | resizable: false, |
|---|
| 75 | width:480, |
|---|
| 76 | height:120, |
|---|
| 77 | modal: true, |
|---|
| 78 | draggable:true, |
|---|
| 79 | dialogClass: 'gcBgTabSheet gcBorder', |
|---|
| 80 | title: '{/literal}{"cstat_updating_database"|@translate}{literal} ('+modeLabel+')', |
|---|
| 81 | } |
|---|
| 82 | ).html(doAnalyzeDialog); |
|---|
| 83 | |
|---|
| 84 | NumberOfItemsPerRequest=$("#iNumberOfItemsPerRequest").val(); |
|---|
| 85 | |
|---|
| 86 | $.ajax( |
|---|
| 87 | { |
|---|
| 88 | type: "POST", |
|---|
| 89 | url: "{/literal}{$datas.urlRequest}{literal}", |
|---|
| 90 | async: true, |
|---|
| 91 | data: { ajaxfct:"updateDatabaseGetList", selectMode:mode, numOfItems:NumberOfItemsPerRequest }, |
|---|
| 92 | success: function(msg) |
|---|
| 93 | { |
|---|
| 94 | processAnalyze.step=0; |
|---|
| 95 | processAnalyze.lists=msg.split(";"); |
|---|
| 96 | processAnalyze.timeStart=new Date(); |
|---|
| 97 | doStep_processList(); |
|---|
| 98 | }, |
|---|
| 99 | error: function() |
|---|
| 100 | { |
|---|
| 101 | alert('error'); |
|---|
| 102 | } |
|---|
| 103 | } |
|---|
| 104 | ); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | function displayTime(eTime) |
|---|
| 109 | { |
|---|
| 110 | seconds=(eTime%60).toFixed(2); |
|---|
| 111 | minutes=((eTime-seconds)/60).toFixed(0); |
|---|
| 112 | returned=seconds+"s"; |
|---|
| 113 | if(minutes>0) returned=minutes+"m"+returned; |
|---|
| 114 | return(returned); |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | function doStep_processList() |
|---|
| 118 | { |
|---|
| 119 | if(processAnalyze.step < processAnalyze.lists.length) |
|---|
| 120 | { |
|---|
| 121 | $.ajax( |
|---|
| 122 | { |
|---|
| 123 | type: "POST", |
|---|
| 124 | url: "{/literal}{$datas.urlRequest}{literal}", |
|---|
| 125 | async: true, |
|---|
| 126 | data: { ajaxfct:"updateDatabaseDoAnalyze", imagesList:processAnalyze.lists[processAnalyze.step] }, |
|---|
| 127 | success: function(msg) |
|---|
| 128 | { |
|---|
| 129 | processAnalyze.step++; |
|---|
| 130 | doStep_processList(); |
|---|
| 131 | }, |
|---|
| 132 | }); |
|---|
| 133 | |
|---|
| 134 | pct=100*(processAnalyze.step+1)/processAnalyze.lists.length; |
|---|
| 135 | $("#iprogressbar_bg").css("width", pct+"%"); |
|---|
| 136 | $("#iprogressbar_fg").html(Math.round(pct)+"%"); |
|---|
| 137 | } |
|---|
| 138 | else |
|---|
| 139 | { |
|---|
| 140 | // list completely processed |
|---|
| 141 | tmp = $.ajax({ |
|---|
| 142 | type: "POST", |
|---|
| 143 | url: "{/literal}{$datas.urlRequest}{literal}", |
|---|
| 144 | async: false, |
|---|
| 145 | data: { ajaxfct:"updateDatabaseConsolidation" } |
|---|
| 146 | }).responseText; |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | processAnalyze.timeEnd = new Date(); |
|---|
| 150 | timeElapsed=processAnalyze.timeEnd.getTime()-processAnalyze.timeStart.getTime(); |
|---|
| 151 | |
|---|
| 152 | $("#dialog") |
|---|
| 153 | .dialog("destroy") |
|---|
| 154 | .html("") |
|---|
| 155 | .get(0).removeAttribute('style'); |
|---|
| 156 | |
|---|
| 157 | $("#dialog") |
|---|
| 158 | .dialog( |
|---|
| 159 | { |
|---|
| 160 | resizable: false, |
|---|
| 161 | width:480, |
|---|
| 162 | height:120, |
|---|
| 163 | modal: true, |
|---|
| 164 | draggable:true, |
|---|
| 165 | dialogClass: 'gcBgTabSheet gcBorder', |
|---|
| 166 | title: '{/literal}{"cstat_updating_database"|@translate}{literal}', |
|---|
| 167 | dialogClass: 'gcBgTabSheet gcBorder', |
|---|
| 168 | open: function(event, ui) |
|---|
| 169 | { |
|---|
| 170 | bH=$("div.ui-dialog-buttonpane").get(0).clientHeight; |
|---|
| 171 | $("#dialog").css('height', (this.clientHeight-bH)+"px"); |
|---|
| 172 | }, |
|---|
| 173 | buttons: |
|---|
| 174 | { |
|---|
| 175 | '{/literal}{"cstat_ok"|@translate}{literal}': |
|---|
| 176 | function() |
|---|
| 177 | { |
|---|
| 178 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
|---|
| 179 | } |
|---|
| 180 | } |
|---|
| 181 | } |
|---|
| 182 | ) |
|---|
| 183 | .html("<br>{/literal}{'cstat_analyze_is_finished'|@translate}{literal} ("+displayTime(timeElapsed/1000)+")"); |
|---|
| 184 | |
|---|
| 185 | getStatus(); |
|---|
| 186 | } |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | </script> |
|---|
| 192 | {/literal} |
|---|
| 193 | |
|---|
| 194 | <h2>{'cstat_status_of_database'|@translate}</h2> |
|---|
| 195 | |
|---|
| 196 | <div id="dialog"></div> |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | <div id="ianalyzestatus"> |
|---|
| 200 | <ul> |
|---|
| 201 | <li>{'cstat_loading'|@translate}</li> |
|---|
| 202 | <li>{'cstat_loading'|@translate}</li> |
|---|
| 203 | <li>{'cstat_loading'|@translate}</li> |
|---|
| 204 | </ul> |
|---|
| 205 | </div> |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | <div id='ianalyzearea'> |
|---|
| 209 | <fieldset> |
|---|
| 210 | <legend>{'cstat_update_color_database'|@translate}</legend> |
|---|
| 211 | <form class="formtable"> |
|---|
| 212 | <div class="nfo"> |
|---|
| 213 | <p>{'cstat_need_to_analyze'|@translate}</p> |
|---|
| 214 | </div> |
|---|
| 215 | |
|---|
| 216 | <label> |
|---|
| 217 | <input type="radio" value="caddieAdd" name="fAMD_analyze_action" id="ianalyze_action2" checked> |
|---|
| 218 | {'cstat_analyze_caddie_add_pictures'|@translate} |
|---|
| 219 | </label><br> |
|---|
| 220 | |
|---|
| 221 | <label> |
|---|
| 222 | <input type="radio" value="caddieReplace" name="fAMD_analyze_action" id="ianalyze_action3"> |
|---|
| 223 | {'cstat_analyze_caddie_replace_pictures'|@translate} |
|---|
| 224 | </label><br> |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | <label> |
|---|
| 228 | <input type="radio" value="notAnalayzed" name="fAMD_analyze_action" id="ianalyze_action0"> |
|---|
| 229 | {'cstat_analyze_not_analyzed_pictures'|@translate} |
|---|
| 230 | </label><br> |
|---|
| 231 | |
|---|
| 232 | <label> |
|---|
| 233 | <input type="radio" value="all" name="fAMD_analyze_action" id="ianalyze_action1"> |
|---|
| 234 | {'cstat_analyze_all_pictures'|@translate} |
|---|
| 235 | </label><br> |
|---|
| 236 | |
|---|
| 237 | <div class="warning"> |
|---|
| 238 | <p style="font-weight:bold; font-size:+2;">{'cstat_warning_on_analyze_0'|@translate}</p> |
|---|
| 239 | <p>{'cstat_warning_on_analyze_1'|@translate}</p> |
|---|
| 240 | <p style="font-weight:bold;">{'cstat_warning_on_analyze_2'|@translate}</p> |
|---|
| 241 | </div> |
|---|
| 242 | |
|---|
| 243 | |
|---|
| 244 | <br> |
|---|
| 245 | <input type="hidden" id="iNumberOfItemsPerRequest" value="{$datas.numberOfItemsPerRequest}"> |
|---|
| 246 | <!-- |
|---|
| 247 | {'cstat_setting_nb_items_per_request'|@translate} |
|---|
| 248 | <div id="iamd_nb_item_per_request_slider"></div> |
|---|
| 249 | <div id="iamd_nb_item_per_request_display"></div> |
|---|
| 250 | <br><br> |
|---|
| 251 | --> |
|---|
| 252 | |
|---|
| 253 | <input type="button" value="{'cstat_analyze'|@translate}" onclick="doAnalyze();"> |
|---|
| 254 | |
|---|
| 255 | </form> |
|---|
| 256 | </fieldset> |
|---|
| 257 | |
|---|
| 258 | </div> |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | <script type="text/javascript"> |
|---|
| 264 | init(); |
|---|
| 265 | </script> |
|---|