allpy
changeset 47:d4296357acc1
fixes
author | boris <bnagaev@gmail.com> |
---|---|
date | Wed, 15 Sep 2010 22:17:10 +0400 |
parents | bf7095e67d38 |
children | e9cd32f12f87 |
files | blocks3d-wt-widget.C blocks3d-wt-widget.h files/js/.ajax.js files/js/.dollar.js files/js/countdown.js files/js/jquery.countdown.pack.js work-time.C work-time.h |
diffstat | 8 files changed, 56 insertions(+), 488 deletions(-) [+] |
line diff
1.1 --- a/blocks3d-wt-widget.C Wed Sep 15 22:05:12 2010 +0400 1.2 +++ b/blocks3d-wt-widget.C Wed Sep 15 22:17:10 2010 +0400 1.3 @@ -134,12 +134,14 @@ 1.4 1.5 void Blocks3DWidget::alignment_uploaded() 1.6 { 1.7 - textarea_from_file(alignment_textarea, alignment_upload->spoolFileName().c_str()); 1.8 + textarea_from_file(alignment_textarea, 1.9 + alignment_upload->spoolFileName().c_str()); 1.10 } 1.11 1.12 void Blocks3DWidget::conformity_uploaded() 1.13 { 1.14 - textarea_from_file(conformity_textarea, conformity_upload->spoolFileName().c_str()); 1.15 + textarea_from_file(conformity_textarea, 1.16 + conformity_upload->spoolFileName().c_str()); 1.17 } 1.18 1.19 void Blocks3DWidget::try_to_run() 1.20 @@ -210,7 +212,9 @@ 1.21 } 1.22 1.23 std::string cmd = str( 1.24 - boost::format("cd %s ; %s %s -i %s %s -H %s -d %s -m %s -t %s -T %s; echo 'f' > %s;") 1.25 + boost::format("cd %s ; " 1.26 + "%s %s -i %s %s -H %s -d %s -m %s -t %s -T %s; " 1.27 + "echo 'f' > %s;") 1.28 % Malakite::temp_path 1.29 % Malakite::python_path % Malakite::blocks3d_path 1.30 % tempfile_alignment 1.31 @@ -233,12 +237,17 @@ 1.32 new Wt::WBreak(results_panel); 1.33 new Wt::WText("Task start", results_panel); 1.34 1.35 + new Wt::WBreak(results_panel); 1.36 + new Wt::WText("Time elapsed: ", results_panel); 1.37 + worktime = new Worktime(results_panel); 1.38 + 1.39 timer->start(); 1.40 1.41 } 1.42 1.43 void Blocks3DWidget::timeout() 1.44 { 1.45 + worktime->render(); 1.46 // FIXME: check status of task 1.47 std::ifstream check_file; 1.48 check_file.open(tempfile_check.c_str()); 1.49 @@ -249,6 +258,7 @@ 1.50 check_file.close(); 1.51 1.52 timer->stop(); 1.53 + worktime->stop(); 1.54 1.55 std::ifstream tempfile_html_file; 1.56 tempfile_html_file.open(tempfile_html.c_str()); 1.57 @@ -271,7 +281,7 @@ 1.58 a_view->setTarget(Wt::TargetNewWindow); 1.59 1.60 Wt::WFileResource* html_download = 1.61 - new Wt::WFileResource("application/html; filename=\"123.html\"", tempfile_html, this); 1.62 + new Wt::WFileResource("application/html", tempfile_html, this); 1.63 new Wt::WBreak(results_panel); 1.64 Wt::WAnchor* a = new Wt::WAnchor(html_download, "Download", results_panel); 1.65
2.1 --- a/blocks3d-wt-widget.h Wed Sep 15 22:05:12 2010 +0400 2.2 +++ b/blocks3d-wt-widget.h Wed Sep 15 22:17:10 2010 +0400 2.3 @@ -2,6 +2,7 @@ 2.4 #define MALAKITE_BLOCKS3D_WIDGET_H_ 2.5 2.6 #include "config.h" 2.7 +#include "work-time.h" 2.8 2.9 #include <Wt/WPanel> 2.10 #include <Wt/WString> 2.11 @@ -38,6 +39,7 @@ 2.12 2.13 Wt::WContainerWidget* results_panel; 2.14 Wt::WTimer* timer; 2.15 + Worktime* worktime; 2.16 2.17 std::string tempfile_alignment; 2.18 std::string tempfile_conformity;
3.1 --- a/files/js/.ajax.js Wed Sep 15 22:05:12 2010 +0400 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,393 +0,0 @@ 3.4 - 3.5 - 3.6 - ////////////////////////////////////////////// 3.7 - ////////////////////////////////////////////// 3.8 - //// AJAX functions 3.9 - ////////////////////////////////////////////// 3.10 - ////////////////////////////////////////////// 3.11 - 3.12 - 3.13 - 3.14 -/* 3.15 - 3.16 -usage: 3.17 - 3.18 -1. Execute this JavaScript file 3.19 - 3.20 -2. Main function is 3.21 - bajax(sURL, post_array, action, then) 3.22 - 3.23 -Arguments: 3.24 - 3.25 - sURL - path to downloading file 3.26 - GET parameters should be written here 3.27 - example: "/php/info1.php?fu=123" 3.28 - 3.29 - post_array - array with POST parameters and their values 3.30 - 3.31 - variant 1: 3.32 - example: ['fu','ttt', 'eee','rrr'] 3.33 - variant 2: 3.34 - example: {'fu':'ttt', 'eee':'rrr'} 3.35 - 3.36 - In this example two parameters wiil be sent: 3.37 - fu = ttt, eee = rrr 3.38 - 3.39 - action - a string with rules how to use downloaded text 3.40 - 'return': function will be runned in not 3.41 - asynchronous type and return this text (not Asynchronous) 3.42 - 3.43 - 'eval': downloaded text will 3.44 - be runned as JavaScript code (Asynchronous) 3.45 - 3.46 - 'eval_sync': same, but not Asynchronous 3.47 - 3.48 - 3.49 - Other: 3.50 - downloaded text will be inserted in HTML element with id = action 3.51 - 3.52 - 3.53 - 3.54 - then - this JavaScript code will be runned after using 3.55 - downloaded text. It can be zero string. 3.56 - It will not executed, if action = 'return' 3.57 - 3.58 - 3.59 -------------- 3.60 - 3.61 -Other functions to work: 3.62 - 3.63 -setHTML(sURL, then, kuda) 3.64 - Set downloadedtext to element with id kuda and runns then 3.65 - 3.66 -myeval_post(sURL, then, what, value) 3.67 - Analog of myeval, but it adds POST parameter what with value value :) 3.68 - 3.69 -loadHTML(sURL) 3.70 - returns downloaded text 3.71 - 3.72 - 3.73 -myeval(sURL, then) 3.74 - runns downloaded text and execute code from argument then 3.75 -*/ 3.76 - 3.77 -// Возвращает document.getElementById 3.78 -function $(str) 3.79 -{ 3.80 - return document.getElementById(str); 3.81 -} 3.82 - 3.83 - 3.84 - 3.85 - 3.86 - 3.87 -// показать надпись, что идет загрузка 3.88 -function ajax_loading_show() 3.89 -{ 3.90 - if ($('ajax_loading')) 3.91 - { 3.92 - $('ajax_loading').style.visibility = ''; 3.93 - } 3.94 -} 3.95 - 3.96 -// спрятать надпись, что идет загрузка 3.97 -function ajax_loading_hide() 3.98 -{ 3.99 - if ($('ajax_loading')) 3.100 - { 3.101 - $('ajax_loading').style.visibility = 'hidden'; 3.102 - } 3.103 -} 3.104 - 3.105 -ajax_loading_hide(); 3.106 - 3.107 - 3.108 -var bajax_killed = 0; // убит ли bajax 3.109 - 3.110 -// после выполнения этой функции bajax перестает работать 3.111 -function bajax_kill() 3.112 -{ 3.113 - bajax_killed = 1; 3.114 - 3.115 - try 3.116 - { 3.117 - make_request_object = function(){return false;}; 3.118 - bajax = function(){return false;}; 3.119 - } 3.120 - catch(e) 3.121 - { 3.122 - } 3.123 -} 3.124 - 3.125 -//////////////////////////////////////////////////////////// 3.126 -// функция возвращает объект request 3.127 -//////////////////////////////////////////////////////////// 3.128 - 3.129 -function make_request_object() 3.130 -{ 3.131 - var i; 3.132 - var request = null; 3.133 - 3.134 - var msxmlhttp = 3.135 - [ 3.136 - //'Msxml2.XMLHTTP.5.0', 3.137 - //'Msxml2.XMLHTTP.4.0', 3.138 - //'Msxml2.XMLHTTP.3.0', 3.139 - 'Msxml2.XMLHTTP', 3.140 - 'Microsoft.XMLHTTP' 3.141 - ]; 3.142 - 3.143 - for (i = 0; i < msxmlhttp.length; i++) 3.144 - { 3.145 - try 3.146 - { 3.147 - request = new ActiveXObject(msxmlhttp[i]); 3.148 - } 3.149 - catch (e) 3.150 - { 3.151 - request = null; 3.152 - } 3.153 - 3.154 - if (request) 3.155 - { 3.156 - break; 3.157 - } 3.158 - } 3.159 - 3.160 - if (request) 3.161 - { 3.162 - return request; 3.163 - } 3.164 - 3.165 - try 3.166 - { 3.167 - request = new XMLHttpRequest(); 3.168 - } 3.169 - catch (e) 3.170 - { 3.171 - } 3.172 - 3.173 - return request; 3.174 -} 3.175 - 3.176 - 3.177 - 3.178 -//////////////////////////////////////////////////////////// 3.179 -// универсальная AJAX-функция 3.180 -//////////////////////////////////////////////////////////// 3.181 - 3.182 -function bajax(sURL, post_array, action, then) 3.183 -{ 3.184 - 3.185 - if (bajax_killed) 3.186 - { 3.187 - return ''; 3.188 - } 3.189 - 3.190 - var i; 3.191 - var post = ''; 3.192 - var request_type = 'GET'; 3.193 - var sURL1 = sURL; 3.194 - 3.195 - var request = make_request_object(); 3.196 - var asynchronous = false; 3.197 - 3.198 - if (!request) 3.199 - { 3.200 - return; 3.201 - } 3.202 - 3.203 - if (sURL.split('?').length==1) 3.204 - { 3.205 - sURL1 += '?'; 3.206 - } 3.207 - else 3.208 - { 3.209 - if (sURL[sURL.length - 1] != '&') 3.210 - { 3.211 - sURL1 += '&'; 3.212 - } 3.213 - } 3.214 - 3.215 - sURL1 += 'ran='+Math.floor(Math.random() * 9999999); 3.216 - 3.217 - if (action != 'return' && action != 'eval_sync') 3.218 - { 3.219 - asynchronous = true; 3.220 - 3.221 - request.onreadystatechange = function() 3.222 - { 3.223 - if (request.readyState == 4) 3.224 - { 3.225 - //alert(sURL + "\n\n" + request.responseText); 3.226 - 3.227 - // hide 'loading...' 3.228 - ajax_loading_hide(); 3.229 - 3.230 - try 3.231 - { 3.232 - if (action == 'eval') 3.233 - { 3.234 - eval(request.responseText); 3.235 - } 3.236 - else 3.237 - { 3.238 - $(action).innerHTML = request.responseText; 3.239 - } 3.240 - } 3.241 - catch (e) 3.242 - { 3.243 - } 3.244 - 3.245 - if (then) 3.246 - { 3.247 - try 3.248 - { 3.249 - eval(then); 3.250 - } 3.251 - catch(e) 3.252 - { 3.253 - } 3.254 - } 3.255 - } 3.256 - }; 3.257 - } 3.258 - 3.259 - 3.260 - 3.261 - // если есть POST-данные, присобачим их 3.262 - if (post_array) 3.263 - { 3.264 - var p, v; 3.265 - request_type = 'POST'; 3.266 - if (post_array.length) 3.267 - { 3.268 - for (i = 0; i < post_array.length / 2; i++) 3.269 - { 3.270 - p = post_array[2 * i]; 3.271 - v = post_array[2 * i + 1]; 3.272 - if (!v) 3.273 - { 3.274 - continue; 3.275 - } 3.276 - post += p + "=" + encodeURIComponent(v + '') + '&'; 3.277 - } 3.278 - } 3.279 - else 3.280 - { 3.281 - for (p in post_array) 3.282 - { 3.283 - v = post_array[p]; 3.284 - if (!v) 3.285 - { 3.286 - continue; 3.287 - } 3.288 - post += p + "=" + encodeURIComponent(v + '') + '&'; 3.289 - } 3.290 - } 3.291 - } 3.292 - 3.293 - // loading... 3.294 - ajax_loading_show(); 3.295 - 3.296 - // делаем запрос 3.297 - request.open(request_type, sURL1, asynchronous); 3.298 - 3.299 - if (post_array) 3.300 - { 3.301 - //alert(post); 3.302 - 3.303 - request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 3.304 - request.setRequestHeader("Content-Length", post.length); 3.305 - request.send(post); 3.306 - } 3.307 - else 3.308 - { 3.309 - request.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); 3.310 - request.send(null); 3.311 - } 3.312 - 3.313 - if (action == 'return') 3.314 - { 3.315 - // hide 'loading...' 3.316 - ajax_loading_hide(); 3.317 - return request.responseText; 3.318 - } 3.319 - 3.320 - if (action == 'eval_sync') 3.321 - { 3.322 - // hide 'loading...' 3.323 - ajax_loading_hide(); 3.324 - 3.325 - try 3.326 - { 3.327 - eval(request.responseText); 3.328 - } 3.329 - catch (e) 3.330 - { 3.331 - } 3.332 - 3.333 - if (then) 3.334 - { 3.335 - try 3.336 - { 3.337 - eval(then); 3.338 - } 3.339 - catch(e) 3.340 - { 3.341 - } 3.342 - } 3.343 - } 3.344 -} 3.345 - 3.346 - 3.347 -function gbajax(sURL, GET, POST, action, then) 3.348 -{ 3.349 - if (sURL.split('?').length==1) 3.350 - { 3.351 - sURL += '?'; 3.352 - } 3.353 - else 3.354 - { 3.355 - sURL += '&'; 3.356 - } 3.357 - 3.358 - for (k in GET) 3.359 - { 3.360 - sURL += encodeURIComponent(k + '') + '=' + encodeURIComponent(GET[k] + '') + '&'; 3.361 - } 3.362 - return bajax(sURL, POST, action, then); 3.363 -} 3.364 - 3.365 - 3.366 -//////////////////////////////////////////////////////////// 3.367 -// функция для выполнения содержимого файла из Интернет 3.368 -//////////////////////////////////////////////////////////// 3.369 -function myeval(sURL, then) 3.370 -{ 3.371 - bajax(sURL, false, 'eval', then); 3.372 -} 3.373 - 3.374 -//////////////////////////////////////////////////////////////// 3.375 -// функция присваивает элементу kuda значение файла из Интернет 3.376 -//////////////////////////////////////////////////////////////// 3.377 -function setHTML(sURL, then, kuda) 3.378 -{ 3.379 - bajax(sURL, false, kuda, then); 3.380 -} 3.381 - 3.382 -//////////////////////////////////////////////////////////////// 3.383 -// функция присваивает элементу kuda значение файла из Интернет 3.384 -//////////////////////////////////////////////////////////////// 3.385 - 3.386 -function loadHTML(sURL) 3.387 -{ 3.388 - return bajax(sURL, false, 'return', false); 3.389 -} 3.390 - 3.391 -// функция для получения содержимого файла из Интернет 3.392 -function myeval_post(sURL, then, what, value) 3.393 -{ 3.394 - bajax(sURL, [what, value], 'eval', then); 3.395 -} 3.396 -
4.1 --- a/files/js/.dollar.js Wed Sep 15 22:05:12 2010 +0400 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,11 +0,0 @@ 4.4 -function dollar(str) 4.5 -{ 4.6 - if (document.getElementById(str)) 4.7 - { 4.8 - return document.getElementById(str); 4.9 - } 4.10 - else 4.11 - { 4.12 - return {}; 4.13 - } 4.14 -}
5.1 --- a/files/js/countdown.js Wed Sep 15 22:05:12 2010 +0400 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,73 +0,0 @@ 5.4 - 5.5 -function timer_div_id(id) 5.6 -{ 5.7 - return '#timer_' + id; 5.8 -} 5.9 -function timer_div(id) 5.10 -{ 5.11 - return $(timer_div_id(id)); 5.12 -} 5.13 - 5.14 -//~ var started = realnow(); 5.15 - 5.16 -var limits = {}; // index: product id 5.17 -function countdown_show(id) 5.18 -{ 5.19 - try 5.20 - { 5.21 - var delta = realnow() - limits[id][1]; 5.22 - var limit = limits[id][0] - delta; 5.23 - if (limit < 0) 5.24 - { 5.25 - timer_div(id).html('...'); 5.26 - } 5.27 - else 5.28 - { 5.29 - timer_div(id).html(cool_time(limit)); 5.30 - } 5.31 - } 5.32 - catch(e) 5.33 - { 5.34 - } 5.35 -} 5.36 - 5.37 -function countdown_show_all() 5.38 -{ 5.39 - var id; 5.40 - for (id in limits) 5.41 - { 5.42 - countdown_show(id); 5.43 - } 5.44 -} 5.45 - 5.46 -var timers = {}; 5.47 -var prices_end = {}; 5.48 -function set_countdown(product_id, now_left, price_end) 5.49 -{ 5.50 - 5.51 - if (prices_end[product_id] && prices_end[product_id] < price_end) { 5.52 - $(timer_div_id(product_id)).css({opacity: 0}).animate({ opacity: 1}, 1000, "linear") 5.53 - } 5.54 - prices_end[product_id] = price_end; 5.55 - 5.56 - limits[product_id] = [now_left, realnow()]; 5.57 - 5.58 - if (now_left && now_left + 5 > 0) 5.59 - { 5.60 - try 5.61 - { 5.62 - if (timers[product_id]) 5.63 - { 5.64 - clearTimeout(timers[product_id]); 5.65 - } 5.66 - timers[product_id] = setTimeout('ajax_refresh(false)', (now_left + 0.1) * 1000); 5.67 - } 5.68 - catch(e) 5.69 - { 5.70 - } 5.71 - } 5.72 -} 5.73 - 5.74 - 5.75 -setInterval('countdown_show_all()', 100); 5.76 -
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/files/js/jquery.countdown.pack.js Wed Sep 15 22:17:10 2010 +0400 6.3 @@ -0,0 +1,7 @@ 6.4 +/* http://keith-wood.name/countdown.html 6.5 + Countdown for jQuery v1.5.8. 6.6 + Written by Keith Wood (kbwood{at}iinet.com.au) January 2008. 6.7 + Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 6.8 + MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. 6.9 + Please attribute the author if you use it. */ 6.10 +eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(B($){B 1i(){8.1D=[];8.1D[\'\']={1j:[\'2C\',\'2D\',\'2E\',\'2F\',\'2G\',\'2H\',\'2I\'],2J:[\'2K\',\'2L\',\'2M\',\'2N\',\'2O\',\'2P\',\'2Q\'],1k:[\'y\',\'m\',\'w\',\'d\'],1u:E,1E:\':\',1V:Q};8.1g={1W:E,1X:E,1Y:E,1Z:E,20:\'2R\',1l:\'\',21:Q,1v:0,1F:\'\',22:\'\',23:\'\',25:Q,26:E,27:E,28:1};$.1m(8.1g,8.1D[\'\']);8.1n=[]}x w=\'G\';x Y=0;x O=1;x W=2;x D=3;x H=4;x M=5;x S=6;$.1m(1i.29,{1o:\'2S\',2T:2U(B(){$.G.2a()},2V),19:[],2W:B(a){8.1G(8.1g,a);1H(8.1g,a||{})},1I:B(a,b,c,e,f,g,h,i){A(1p b==\'2X\'&&b.2Y==P){i=b.1J();h=b.1K();g=b.1L();f=b.1M();e=b.T();c=b.17();b=b.18()}x d=K P();d.2Z(b);d.2b(1);d.31(c||0);d.2b(e||1);d.33(f||0);d.34((g||0)-(U.35(a)<30?a*1a:a));d.36(h||0);d.37(i||0);F d},2c:B(a){F a[0]*38+a[1]*39+a[2]*2d+a[3]*2e+a[4]*2f+a[5]*1a+a[6]},3a:B(a,b){A(!b){F $.G.1g}x c=$.X(a,w);F(b==\'3b\'?c.Z:c.Z[b])},2g:B(a,b){x c=$(a);A(c.2h(8.1o)){F}c.3c(8.1o);x d={Z:$.1m({},b),z:[0,0,0,0,0,0,0]};$.X(a,w,d);8.2i(a)},1N:B(a){A(!8.1O(a)){8.19.2j(a)}},1O:B(a){F($.3d(a,8.19)>-1)},1w:B(b){8.19=$.3e(8.19,B(a){F(a==b?E:a)})},2a:B(){V(x i=8.19.1x-1;i>=0;i--){8.1q(8.19[i])}},1q:B(a,b){x c=$(a);b=b||$.X(a,w);A(!b){F}c.3f(8.2k(b));c[(8.C(b,\'1V\')?\'3g\':\'3h\')+\'3i\'](\'3j\');x d=8.C(b,\'27\');A(d){x e=b.R!=\'2l\'?b.z:8.1y(b,b.11,8.C(b,\'1v\'),K P());x f=8.C(b,\'28\');A(f==1||8.2c(e)%f==0){d.1r(a,[e])}}x g=b.R!=\'1s\'&&(b.I?b.1b.L()<b.I.L():b.1b.L()>=b.13.L());A(g&&!b.1P){b.1P=1Q;A(8.1O(a)||8.C(b,\'25\')){8.1w(a);x h=8.C(b,\'26\');A(h){h.1r(a,[])}x i=8.C(b,\'23\');A(i){x j=8.C(b,\'1l\');b.Z.1l=i;8.1q(a,b);b.Z.1l=j}x k=8.C(b,\'22\');A(k){3k.3l=k}}b.1P=Q}1c A(b.R==\'1s\'){8.1w(a)}$.X(a,w,b)},2i:B(a,b,c){b=b||{};A(1p b==\'1R\'){x d=b;b={};b[d]=c}x e=$.X(a,w);A(e){8.1G(e.Z,b);1H(e.Z,b);8.2m(a,e);$.X(a,w,e);x f=K P();A((e.I&&e.I<f)||(e.13&&e.13>f)){8.1N(a)}8.1q(a,e)}},1G:B(a,b){x c=Q;V(x n 1S b){A(n!=\'1u\'&&n.N(/[2n]2o/)){c=1Q;14}}A(c){V(x n 1S a){A(n.N(/[2n]2o[0-9]/)){a[n]=E}}}},2m:B(a,b){x c;x d=8.C(b,\'1Z\');x e=0;x f=E;V(x i=0;i<8.1n.1x;i++){A(8.1n[i][0]==d){f=8.1n[i][1];14}}A(f!=E){e=(d?f:0);c=K P()}1c{x g=(d?d.1r(a,[]):E);c=K P();e=(g?c.L()-g.L():0);8.1n.2j([d,e])}x h=8.C(b,\'1Y\');h=(h==E?-c.3m():h);b.I=8.C(b,\'1X\');A(b.I!=E){b.I=8.1I(h,8.1z(b.I,E));A(b.I&&e){b.I.1A(b.I.1J()+e)}}b.13=8.1I(h,8.1z(8.C(b,\'1W\'),c));A(e){b.13.1A(b.13.1J()+e)}b.11=8.2p(b)},3n:B(a){x b=$(a);A(!b.2h(8.1o)){F}8.1w(a);b.3o(8.1o).3p();$.3q(a,w)},3r:B(a){8.R(a,\'1s\')},3s:B(a){8.R(a,\'2l\')},3t:B(a){8.R(a,E)},R:B(a,b){x c=$.X(a,w);A(c){A(c.R==\'1s\'&&!b){c.z=c.2q;x d=(c.I?\'-\':\'+\');c[c.I?\'I\':\'13\']=8.1z(d+c.z[0]+\'y\'+d+c.z[1]+\'o\'+d+c.z[2]+\'w\'+d+c.z[3]+\'d\'+d+c.z[4]+\'h\'+d+c.z[5]+\'m\'+d+c.z[6]+\'s\');8.1N(a)}c.R=b;c.2q=(b==\'1s\'?c.z:E);$.X(a,w,c);8.1q(a,c)}},3u:B(a){x b=$.X(a,w);F(!b?E:(!b.R?b.z:8.1y(b,b.11,8.C(b,\'1v\'),K P())))},C:B(a,b){F(a.Z[b]!=E?a.Z[b]:$.G.1g[b])},1z:B(k,l){x m=B(a){x b=K P();b.2r(b.L()+a*15);F b};x n=B(a){a=a.3v();x b=K P();x c=b.18();x d=b.17();x e=b.T();x f=b.1M();x g=b.1L();x h=b.1K();x i=/([+-]?[0-9]+)\\s*(s|m|h|d|w|o|y)?/g;x j=i.2s(a);3w(j){3x(j[2]||\'s\'){1d\'s\':h+=1e(j[1],10);14;1d\'m\':g+=1e(j[1],10);14;1d\'h\':f+=1e(j[1],10);14;1d\'d\':e+=1e(j[1],10);14;1d\'w\':e+=1e(j[1],10)*7;14;1d\'o\':d+=1e(j[1],10);e=U.1B(e,$.G.1h(c,d));14;1d\'y\':c+=1e(j[1],10);e=U.1B(e,$.G.1h(c,d));14}j=i.2s(a)}F K P(c,d,e,f,g,h,0)};x o=(k==E?l:(1p k==\'1R\'?n(k):(1p k==\'3y\'?m(k):k)));A(o)o.1A(0);F o},1h:B(a,b){F 32-K P(a,b,32).T()},1T:B(a){F a},2k:B(c){x d=8.C(c,\'1v\');c.z=(c.R?c.z:8.1y(c,c.11,d,K P()));x e=Q;x f=0;x g=d;x h=$.1m({},c.11);V(x i=Y;i<=S;i++){e|=(c.11[i]==\'?\'&&c.z[i]>0);h[i]=(c.11[i]==\'?\'&&!e?E:c.11[i]);f+=(h[i]?1:0);g-=(c.z[i]>0?1:0)}x j=[Q,Q,Q,Q,Q,Q,Q];V(x i=S;i>=Y;i--){A(c.11[i]){A(c.z[i]){j[i]=1Q}1c{j[i]=g>0;g--}}}x k=8.C(c,\'21\');x l=8.C(c,\'1l\');x m=(k?8.C(c,\'1k\'):8.C(c,\'1j\'));x n=8.C(c,\'1u\')||8.1T;x o=8.C(c,\'1E\');x p=8.C(c,\'1F\')||\'\';x q=B(a){x b=$.G.C(c,\'1k\'+n(c.z[a]));F(h[a]?c.z[a]+(b?b[a]:m[a])+\' \':\'\')};x r=B(a){x b=$.G.C(c,\'1j\'+n(c.z[a]));F((!d&&h[a])||(d&&j[a])?\'<16 1t="3z"><16 1t="2t">\'+c.z[a]+\'</16><3A/>\'+(b?b[a]:m[a])+\'</16>\':\'\')};F(l?8.2u(c,h,l,k,d,j):((k?\'<16 1t="1U 2t\'+(c.R?\' 2v\':\'\')+\'">\'+q(Y)+q(O)+q(W)+q(D)+(h[H]?8.J(c.z[H],2):\'\')+(h[M]?(h[H]?o:\'\')+8.J(c.z[M],2):\'\')+(h[S]?(h[H]||h[M]?o:\'\')+8.J(c.z[S],2):\'\'):\'<16 1t="1U 3B\'+(d||f)+(c.R?\' 2v\':\'\')+\'">\'+r(Y)+r(O)+r(W)+r(D)+r(H)+r(M)+r(S))+\'</16>\'+(p?\'<16 1t="1U 3C">\'+p+\'</16>\':\'\')))},2u:B(c,d,e,f,g,h){x j=8.C(c,(f?\'1k\':\'1j\'));x k=8.C(c,\'1u\')||8.1T;x l=B(a){F($.G.C(c,(f?\'1k\':\'1j\')+k(c.z[a]))||j)[a]};x m=B(a,b){F U.1C(a/b)%10};x o={3D:8.C(c,\'1F\'),3E:8.C(c,\'1E\'),3F:l(Y),3G:c.z[Y],3H:8.J(c.z[Y],2),3I:8.J(c.z[Y],3),3J:m(c.z[Y],1),3K:m(c.z[Y],10),3L:m(c.z[Y],1f),3M:m(c.z[Y],15),3N:l(O),3O:c.z[O],3P:8.J(c.z[O],2),3Q:8.J(c.z[O],3),3R:m(c.z[O],1),3S:m(c.z[O],10),3T:m(c.z[O],1f),3U:m(c.z[O],15),3V:l(W),3W:c.z[W],3X:8.J(c.z[W],2),3Y:8.J(c.z[W],3),3Z:m(c.z[W],1),40:m(c.z[W],10),41:m(c.z[W],1f),42:m(c.z[W],15),43:l(D),44:c.z[D],45:8.J(c.z[D],2),46:8.J(c.z[D],3),47:m(c.z[D],1),48:m(c.z[D],10),49:m(c.z[D],1f),4a:m(c.z[D],15),4b:l(H),4c:c.z[H],4d:8.J(c.z[H],2),4e:8.J(c.z[H],3),4f:m(c.z[H],1),4g:m(c.z[H],10),4h:m(c.z[H],1f),4i:m(c.z[H],15),4j:l(M),4k:c.z[M],4l:8.J(c.z[M],2),4m:8.J(c.z[M],3),4n:m(c.z[M],1),4o:m(c.z[M],10),4p:m(c.z[M],1f),4q:m(c.z[M],15),4r:l(S),4s:c.z[S],4t:8.J(c.z[S],2),4u:8.J(c.z[S],3),4v:m(c.z[S],1),4w:m(c.z[S],10),4x:m(c.z[S],1f),4y:m(c.z[S],15)};x p=e;V(x i=Y;i<=S;i++){x q=\'4z\'.4A(i);x r=K 2w(\'\\\\{\'+q+\'<\\\\}(.*)\\\\{\'+q+\'>\\\\}\',\'g\');p=p.2x(r,((!g&&d[i])||(g&&h[i])?\'$1\':\'\'))}$.2y(o,B(n,v){x a=K 2w(\'\\\\{\'+n+\'\\\\}\',\'g\');p=p.2x(a,v)});F p},J:B(a,b){a=\'\'+a;A(a.1x>=b){F a}a=\'4B\'+a;F a.4C(a.1x-b)},2p:B(a){x b=8.C(a,\'20\');x c=[];c[Y]=(b.N(\'y\')?\'?\':(b.N(\'Y\')?\'!\':E));c[O]=(b.N(\'o\')?\'?\':(b.N(\'O\')?\'!\':E));c[W]=(b.N(\'w\')?\'?\':(b.N(\'W\')?\'!\':E));c[D]=(b.N(\'d\')?\'?\':(b.N(\'D\')?\'!\':E));c[H]=(b.N(\'h\')?\'?\':(b.N(\'H\')?\'!\':E));c[M]=(b.N(\'m\')?\'?\':(b.N(\'M\')?\'!\':E));c[S]=(b.N(\'s\')?\'?\':(b.N(\'S\')?\'!\':E));F c},1y:B(c,d,e,f){c.1b=f;c.1b.1A(0);x g=K P(c.1b.L());A(c.I){A(f.L()<c.I.L()){c.1b=f=g}1c{f=c.I}}1c{g.2r(c.13.L());A(f.L()>c.13.L()){c.1b=f=g}}x h=[0,0,0,0,0,0,0];A(d[Y]||d[O]){x i=$.G.1h(f.18(),f.17());x j=$.G.1h(g.18(),g.17());x k=(g.T()==f.T()||(g.T()>=U.1B(i,j)&&f.T()>=U.1B(i,j)));x l=B(a){F(a.1M()*1a+a.1L())*1a+a.1K()};x m=U.4D(0,(g.18()-f.18())*12+g.17()-f.17()+((g.T()<f.T()&&!k)||(k&&l(g)<l(f))?-1:0));h[Y]=(d[Y]?U.1C(m/12):0);h[O]=(d[O]?m-h[Y]*12:0);f=K P(f.L());x n=(f.T()==i);x o=$.G.1h(f.18()+h[Y],f.17()+h[O]);A(f.T()>o){f.2z(o)}f.4E(f.18()+h[Y]);f.4F(f.17()+h[O]);A(n){f.2z(o)}}x p=U.1C((g.L()-f.L())/15);x q=B(a,b){h[a]=(d[a]?U.1C(p/b):0);p-=h[a]*b};q(W,2d);q(D,2e);q(H,2f);q(M,1a);q(S,1);A(p>0&&!c.I){x r=[1,12,4.4G,7,24,1a,1a];x s=S;x t=1;V(x u=S;u>=Y;u--){A(d[u]){A(h[s]>=t){h[s]=0;p=1}A(p>0){h[u]++;p=0;s=u;t=1}}t*=r[u]}}A(e){V(x u=Y;u<=S;u++){A(e&&h[u]){e--}1c A(!e){h[u]=0}}}F h}});B 1H(a,b){$.1m(a,b);V(x c 1S b){A(b[c]==E){a[c]=E}}F a}$.4H.G=B(a){x b=4I.29.4J.4K(4L,1);A(a==\'4M\'||a==\'4N\'){F $.G[\'2A\'+a+\'1i\'].1r($.G,[8[0]].2B(b))}F 8.2y(B(){A(1p a==\'1R\'){$.G[\'2A\'+a+\'1i\'].1r($.G,[8].2B(b))}1c{$.G.2g(8,a)}})};$.G=K 1i()})(4O);',62,299,'||||||||this|||||||||||||||||||||||||var||_periods|if|function|_get||null|return|countdown||_since|_minDigits|new|getTime||match||Date|false|_hold||getDate|Math|for||data||options||_show||_until|break|1000|span|getMonth|getFullYear|_timerTargets|60|_now|else|case|parseInt|100|_defaults|_getDaysInMonth|Countdown|labels|compactLabels|layout|extend|_serverSyncs|markerClassName|typeof|_updateCountdown|apply|pause|class|whichLabels|significant|_removeTarget|length|_calculatePeriods|_determineTime|setMilliseconds|min|floor|regional|timeSeparator|description|_resetExtraLabels|extendRemove|UTCDate|getMilliseconds|getSeconds|getMinutes|getHours|_addTarget|_hasTarget|_expiring|true|string|in|_normalLabels|countdown_row|isRTL|until|since|timezone|serverSync|format|compact|expiryUrl|expiryText||alwaysExpire|onExpiry|onTick|tickInterval|prototype|_updateTargets|setUTCDate|periodsToSeconds|604800|86400|3600|_attachCountdown|hasClass|_changeCountdown|push|_generateHTML|lap|_adjustSettings|Ll|abels|_determineShow|_savePeriods|setTime|exec|countdown_amount|_buildLayout|countdown_holding|RegExp|replace|each|setDate|_|concat|Years|Months|Weeks|Days|Hours|Minutes|Seconds|labels1|Year|Month|Week|Day|Hour|Minute|Second|dHMS|hasCountdown|_timer|setInterval|980|setDefaults|object|constructor|setUTCFullYear||setUTCMonth||setUTCHours|setUTCMinutes|abs|setUTCSeconds|setUTCMilliseconds|31557600|2629800|_settingsCountdown|all|addClass|inArray|map|html|add|remove|Class|countdown_rtl|window|location|getTimezoneOffset|_destroyCountdown|removeClass|empty|removeData|_pauseCountdown|_lapCountdown|_resumeCountdown|_getTimesCountdown|toLowerCase|while|switch|number|countdown_section|br|countdown_show|countdown_descr|desc|sep|yl|yn|ynn|ynnn|y1|y10|y100|y1000|ol|on|onn|onnn|o1|o10|o100|o1000|wl|wn|wnn|wnnn|w1|w10|w100|w1000|dl|dn|dnn|dnnn|d1|d10|d100|d1000|hl|hn|hnn|hnnn|h1|h10|h100|h1000|ml|mn|mnn|mnnn|m1|m10|m100|m1000|sl|sn|snn|snnn|s1|s10|s100|s1000|yowdhms|charAt|0000000000|substr|max|setFullYear|setMonth|3482|fn|Array|slice|call|arguments|getTimes|settings|jQuery'.split('|'),0,{})) 6.11 \ No newline at end of file
7.1 --- a/work-time.C Wed Sep 15 22:05:12 2010 +0400 7.2 +++ b/work-time.C Wed Sep 15 22:17:10 2010 +0400 7.3 @@ -5,10 +5,11 @@ 7.4 7.5 7.6 Worktime::Worktime(Wt::WContainerWidget *parent) : 7.7 - WText(parent) 7.8 + WText(parent), stoped(false) 7.9 { 7.10 wApp->require("/files/js/jquery.countdown.pack.js"); 7.11 start_at = now(); 7.12 + stop_at = now(); // ?? 7.13 render(); 7.14 } 7.15 7.16 @@ -18,13 +19,35 @@ 7.17 return to_simple_string(secs1); 7.18 } 7.19 7.20 +void Worktime::stop() 7.21 +{ 7.22 + stoped = true; 7.23 + stop_at = now(); 7.24 + render(); 7.25 +} 7.26 + 7.27 void Worktime::render() 7.28 { 7.29 setText(int2time(spent())); 7.30 7.31 - doJavaScript("$('#" + id() + "').countdown({" 7.32 - "since: -" + boost::lexical_cast<std::string>( 7.33 - spent().total_milliseconds()) + " / 1000," 7.34 - "compact: true" 7.35 - "});"); 7.36 + if (!stoped) 7.37 + { 7.38 + doJavaScript("$('#" + id() + "').countdown({" 7.39 + "since: -" + boost::lexical_cast<std::string>( 7.40 + spent().total_milliseconds()) + " / 1000," 7.41 + "compact: true" 7.42 + "});"); 7.43 + } 7.44 }; 7.45 + 7.46 +posix::time_duration Worktime::spent() 7.47 +{ 7.48 + if (stoped) 7.49 + { 7.50 + return stop_at - start_at; 7.51 + } 7.52 + else 7.53 + { 7.54 + return now() - start_at; 7.55 + } 7.56 +}
8.1 --- a/work-time.h Wed Sep 15 22:05:12 2010 +0400 8.2 +++ b/work-time.h Wed Sep 15 22:17:10 2010 +0400 8.3 @@ -13,10 +13,13 @@ 8.4 public: 8.5 Worktime(Wt::WContainerWidget *parent=0); 8.6 void render(); 8.7 + void stop(); 8.8 inline posix::ptime now() { return posix::microsec_clock::universal_time(); } 8.9 - inline posix::time_duration spent() { return now() - start_at; } 8.10 + inline posix::time_duration spent(); 8.11 private: 8.12 posix::ptime start_at; 8.13 + posix::ptime stop_at; 8.14 + bool stoped; 8.15 std::string int2time(posix::time_duration secs); 8.16 }; 8.17