* debian/* cleanup and update
[lichviet-widget] / qml / lichvietwidget / main.js
index 1102377..f380b6f 100644 (file)
@@ -1,6 +1,24 @@
+/*
+Copyright (C) 2011  by Cuong Le <metacuong@gmail.com>
+
+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 <http://www.gnu.org/licenses/>
+*/
 
 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 <b>"+lunarCanChi[0]+"</b>, Tháng <b>"+lunarCanChi[1]+"</b><br>Năm <b>"+lunarCanChi[2]+"</b>";
 
-    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;
+    }
 }
 
 /**