1 /** @fileoverview SVG Clock widget.
  2 	@version 1.0
  3 	@author Matheus Martins Teixeira <a href="mailto:mteixeira@grad.icmc.usp.br"><mteixeira@grad.icmc.usp.br></a>
  4  */ 
  5 /* ***** BEGIN LICENSE BLOCK *****
  6  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  7  *
  8  * The contents of this file are subject to the Mozilla Public License Version
  9  * 1.1 (the "License"); you may not use this file except in compliance with
 10  * the License. You may obtain a copy of the License at
 11  * http://www.mozilla.org/MPL/
 12  *
 13  * Software distributed under the License is distributed on an "AS IS" basis,
 14  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 15  * for the specific language governing rights and limitations under the
 16  * License.
 17  *
 18  * The Original Code is TelaSocial
 19  *
 20  * The Initial Developer of the Original Code is Taboca TelaSocial.
 21  * Portions created by the Initial Developer are Copyright (C) 2010 
 22  * the Initial Developer. All Rights Reserved.
 23  *
 24  * Contributor(s):
 25  *      Marcio Galli   <mgalli@taboca.com>
 26  *      Matheus Teixeira <teixeira.mdk@gmail.com>
 27  *
 28  * Alternatively, the contents of this file may be used under the terms of
 29  * either the GNU General Public License Version 2 or later (the "GPL"), or
 30  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 31  * in which case the provisions of the GPL or the LGPL are applicable instead
 32  * of those above. If you wish to allow use of your version of this file only
 33  * under the terms of either the GPL or the LGPL, and not to allow others to
 34  * use your version of this file under the terms of the MPL, indicate your
 35  * decision by deleting the provisions above and replace them with the notice
 36  * and other provisions required by the GPL or the LGPL. If you do not delete
 37  * the provisions above, a recipient may use your version of this file under
 38  * the terms of any one of the MPL, the GPL or the LGPL.
 39  *
 40  * ***** END LICENSE BLOCK ***** */
 41  
 42  
 43 /**
 44 	Armazena os segundos do horario atual
 45 	@type Number
 46 */
 47 var seconds = null;
 48 /**
 49 	Armazena os minutos do horario atual
 50 	@type Number
 51 */
 52 var minutes = null;
 53 /**
 54 	Armazena as horas do horario atual
 55 	@type Number
 56 */
 57 var hour    = null;
 58 /**
 59 	Armazena o dia da data atual
 60 	@type Number
 61 */
 62 var day     = null;
 63 /**
 64 	Armazena a data atual
 65 	@type Date
 66 */
 67 var date    = null;
 68 
 69 
 70 /**
 71 	Inicia o relógio
 72 	@public
 73 	@function
 74 */
 75 function start() { 
 76     seconds =document.getElementById("seconds");
 77     minutes =document.getElementById("minutes");
 78     hour = document.getElementById("hour");
 79     day = document.getElementById("day");
 80     date = document.getElementById("date");
 81     tick();
 82 };
 83 /**
 84 	Função que gera o tick do relógio (1 tick per second)
 85 	@Private
 86 	@function
 87 */
 88 function tick() {
 89 	data = new Date();
 90 	var days = new Array();
 91 	days[0] = "domingo";
 92 	days[1] = "segunda-feira";
 93 	days[2] = "ter\u00e7a-feira";
 94 	days[3] = "quarta-feira";
 95 	days[4] = "quinta-feira";
 96 	days[5] = "sexta-feira";
 97 	days[6] = "s\u00e1bado";
 98 	
 99 	var months = new Array();
100 	months[0] = "janeiro";
101 	months[1] = "fevereiro";
102 	months[2] = "mar\u00e7o";
103 	months[3] = "abril";
104 	months[4] = "maio";
105 	months[5] = "junho";
106 	months[6] = "julho";
107 	months[7] = "agosto";
108 	months[8] = "setembro";
109 	months[9] = "outubro";
110 	months[10] = "novembro";
111 	months[11] = "dezembro";
112 	
113 	var hours = data.getHours();
114 	var min = data.getMinutes();
115 	var secs = data.getSeconds();
116 	var wday = data.getDay();
117 	var month = data.getMonth();
118 	var dt = data.getDate();
119 	
120 	var psecs = "";
121 	var pmin = "";
122 	var phour = "";
123 	if(secs<=9) {
124 		psecs = "0";
125 	} 
126 	if(min<=9) { 
127 		pmin = "0";
128 	}
129 	if(hours<=9) { 
130 		phour = "0";
131 	} 
132     
133     hour.textContent = phour+hours;
134     minutes.textContent = pmin+min;
135     seconds.textContent = psecs+secs;
136     date.textContent = dt + " de "+months[month];
137     day.textContent = days[wday];
138 	setTimeout( function () { tick() }, 1000);
139 };
140 
141 start();
142