X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=qml%2Flichvietwidget%2Fmain.js;h=f380b6f7e4c7818de54c8a8108049d163b9f1ace;hb=36869a2326fdc2359a176a21800487e5906b5ea1;hp=1102377b526d4fbaa75cb602b0aa4a636c9ac136;hpb=b8724ff1cc2e63d1ec301edfc647e7883a8a4ddf;p=lichviet-widget diff --git a/qml/lichvietwidget/main.js b/qml/lichvietwidget/main.js index 1102377..f380b6f 100644 --- a/qml/lichvietwidget/main.js +++ b/qml/lichvietwidget/main.js @@ -1,6 +1,24 @@ +/* +Copyright (C) 2011 by Cuong Le + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ var IMGS_RESOURCE_PATH = "/opt/lichvietwidget/qml/lichvietwidget/imgs/"; +var isday=-1; +var ismonth=-1; +var isyear=-1; function refresh(day_center_img, day_left_img, day_right_img, month_left_img, month_right_img, year_1_img, year_2_img,year_3_img,year_4_img, txt_detail) { var date = new Date(); @@ -13,40 +31,48 @@ function refresh(day_center_img, day_left_img, day_right_img, month_left_img, mo txt_detail.text = "Ngày "+lunarCanChi[0]+", Tháng "+lunarCanChi[1]+"
Năm "+lunarCanChi[2]+""; - if (xday <= 9){ - day_center_img.visible = true; - day_center_img.source = IMGS_RESOURCE_PATH + xday + ".png"; - day_left_img.visible = false; - day_right_img.visible = false; - }else{ - var strxday = xday+''; - var firstday = strxday[0]; - var secondday = strxday[1]; - day_center_img.visible = false; - day_left_img.visible = true; - day_left_img.source = IMGS_RESOURCE_PATH + firstday + ".png"; - day_right_img.visible = true; - day_right_img.source = IMGS_RESOURCE_PATH + secondday + ".png"; + if (xday != isday){ + if (xday <= 9){ + day_center_img.visible = true; + day_center_img.source = IMGS_RESOURCE_PATH + xday + ".png"; + day_left_img.visible = false; + day_right_img.visible = false; + }else{ + var strxday = xday+''; + var firstday = strxday[0]; + var secondday = strxday[1]; + day_center_img.visible = false; + day_left_img.visible = true; + day_left_img.source = IMGS_RESOURCE_PATH + firstday + ".png"; + day_right_img.visible = true; + day_right_img.source = IMGS_RESOURCE_PATH + secondday + ".png"; + } + isday = xday; } - if (xmonth <=9){ - month_left_img.source = IMGS_RESOURCE_PATH +"0.png"; - month_right_img.source = IMGS_RESOURCE_PATH + xmonth + ".png"; - }else - { - var strxmonth = xmonth+''; - var firstmonth = strxmonth[0]; - var secondmonth = strxmonth[1]; - month_left_img.source = IMGS_RESOURCE_PATH + firstmonth +".png"; - month_right_img.source = IMGS_RESOURCE_PATH + secondmonth + ".png"; + if (xmonth != ismonth){ + if (xmonth <=9){ + month_left_img.source = IMGS_RESOURCE_PATH +"0.png"; + month_right_img.source = IMGS_RESOURCE_PATH + xmonth + ".png"; + }else + { + var strxmonth = xmonth+''; + var firstmonth = strxmonth[0]; + var secondmonth = strxmonth[1]; + month_left_img.source = IMGS_RESOURCE_PATH + firstmonth +".png"; + month_right_img.source = IMGS_RESOURCE_PATH + secondmonth + ".png"; + } + ismonth=xmonth; } - var strxyear = xyear+''; - year_1_img.source = IMGS_RESOURCE_PATH + strxyear[0] +".png"; - year_2_img.source = IMGS_RESOURCE_PATH + strxyear[1] + ".png"; - year_3_img.source = IMGS_RESOURCE_PATH + strxyear[2] +".png"; - year_4_img.source = IMGS_RESOURCE_PATH + strxyear[3] + ".png"; - + if (xyear != isyear){ + var strxyear = xyear+''; + year_1_img.source = IMGS_RESOURCE_PATH + strxyear[0] +".png"; + year_2_img.source = IMGS_RESOURCE_PATH + strxyear[1] + ".png"; + year_3_img.source = IMGS_RESOURCE_PATH + strxyear[2] +".png"; + year_4_img.source = IMGS_RESOURCE_PATH + strxyear[3] + ".png"; + isyear=xyear; + } } /**