widget.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var circle;
  2. function widget_clock_init(){
  3. circle = new ProgressBar.Circle('#clock', {
  4. color: '#50C8FB',
  5. duration: 3000,
  6. easing: 'easeInOut',
  7. text: {
  8. style : { fontSize : '38px'},
  9. value : '00:00:00'
  10. }
  11. });
  12. refresh_clock();
  13. setInterval(function(){
  14. refresh_clock();
  15. },1000);
  16. }
  17. function refresh_clock(){
  18. var d = new Date();
  19. var hour = d.getHours();
  20. var minut = ("00" + d.getMinutes()).slice(-2) ;
  21. var second = ("00" + d.getSeconds()).slice(-2) ;
  22. var year = d.getFullYear() ;
  23. var month = ("00" + (d.getMonth()+1)).slice(-2) ;
  24. var day = ("00" + d.getDate()).slice(-2) ;
  25. var days = ["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"];
  26. var monthName = ["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Décembre"];
  27. var dayName = days[d.getDay()];
  28. circle.setText(hour+':'+minut+':'+second+'<div class="dayName">'+dayName+'</div><div class="dayDate">'+day+' '+monthName[d.getMonth()]+' '+year+'</div>');
  29. circle.set(second/60);
  30. }