12 new, 4 updated for 1.3.5
[webos-internals:modifications.git] / clock / clock-alarm-daily-options.patch
1 Name: alarm daily options
2 Version: 1.3.1-1
3 Author: b romano
4 Description: This patch will add the daily values Sunday, Monday, Tuesday, Wednesday, etc. to your alarm options.
5
6 --- .orig/usr/palm/applications/com.palm.app.clock/app/models/alarms.js
7 +++ /usr/palm/applications/com.palm.app.clock/app/models/alarms.js
8 @@ -134,5 +134,12 @@
9         "daily": $L("Daily"),
10         "once": $L("     "), 
11         "weekdays": $L("Weekdays"),
12 -       "weekends": $L("Weekends")
13 +       "weekends": $L("Weekends"),
14 +       "sunday": $L("Sundays"),
15 +       "monday": $L("Mondays"),
16 +       "tuesday": $L("Tuesdays"),
17 +       "wednesday": $L("Wednesdays"),
18 +       "thursday": $L("Thursdays"),
19 +       "friday": $L("Fridays"),
20 +       "saturday": $L("Saturdays")
21  }
22 --- .orig/usr/palm/applications/com.palm.app.clock/app/controllers/alarm-assistant.js
23 +++ /usr/palm/applications/com.palm.app.clock/app/controllers/alarm-assistant.js
24 @@ -5,7 +5,14 @@
25             {label:$L('Ring Once'), value:"once"},
26                 {label:$L('Daily'), value:"daily" },
27                 {label:$L('Weekdays'), value:"weekdays"}, 
28 -               {label:$L('Weekends'), value:"weekends"} 
29 +               {label:$L('Weekends'), value:"weekends"},
30 +               {label:$L('Sundays'), value:"sunday"},
31 +               {label:$L('Mondays'), value:"monday"},
32 +               {label:$L('Tuesdays'), value:"tuesday"},
33 +               {label:$L('Wednesdays'), value:"wednesday"},
34 +               {label:$L('Thursdays'), value:"thursday"},
35 +               {label:$L('Fridays'), value:"friday"},
36 +               {label:$L('Saturdays'), value:"saturday"}
37         ],
38         initialize: function(alarm, deleteSelf) {
39                 this.appControl = Mojo.Controller.getAppController();
40 --- .orig/usr/palm/applications/com.palm.app.clock/app/models/alarm.js
41 +++ /usr/palm/applications/com.palm.app.clock/app/models/alarm.js
42 @@ -232,6 +232,27 @@
43                         case ('weekends'):
44                                 now = this.nextWeekend(d,now);
45                                 break;
46 +                        case ('sunday'):
47 +                               now = this.nextSpecificDay(d,now,Alarm.kSunday);
48 +                               break;
49 +                       case ('monday'):
50 +                               now = this.nextSpecificDay(d,now,Alarm.kMonday);
51 +                               break;
52 +                       case ('tuesday'):
53 +                               now = this.nextSpecificDay(d,now,Alarm.kTuesday);
54 +                               break;
55 +                       case ('wednesday'):
56 +                               now = this.nextSpecificDay(d,now,Alarm.kWednesday);
57 +                               break;
58 +                       case ('thursday'):
59 +                                now = this.nextSpecificDay(d,now,Alarm.kThursday);
60 +                                break;
61 +                       case ('friday'):
62 +                                now = this.nextSpecificDay(d,now,Alarm.kFriday);
63 +                                break;
64 +                        case ('saturday'):
65 +                               now = this.nextSpecificDay(d,now,Alarm.kSaturday);
66 +                               break;
67                         default:
68                                 now = this.nextDay(d,now);
69                                 break;
70 @@ -240,6 +261,31 @@
71                 return now;
72                 
73         },
74 +
75 +       nextSpecificDay: function(d,now,day){
76 +                var timePassed = false;
77 +               if (now.getHours() > d.getHours() || (now.getHours() == d.getHours() && now.getMinutes() >= d.getMinutes())) {
78 +                       timePassed = true;
79 +               }
80 +                       
81 +               var today = now.getDay();
82 +               if (day > today){
83 +                       now.setDate(now.getDate() + (day - today));
84 +               }
85 +               else if (day == today){
86 +                       if(timePassed){
87 +                               now.setDate(now.getDate()+7);
88 +                       }
89 +               }
90 +               else if (day < today){
91 +                       now.setDate(now.getDate() + (7 + day - today));
92 +               }
93 +
94 +               now.setHours(d.getHours());
95 +               now.setMinutes(d.getMinutes());
96 +               now.setSeconds(0);
97 +               return now;
98 +       },
99         
100         nextDay: function(d,now){
101                 if (now.getHours() > d.getHours() || (now.getHours() == d.getHours() && now.getMinutes() >= d.getMinutes())) {
102 @@ -332,6 +378,76 @@
103                                 } else {
104                                         return (today == Alarm.kSunday ? 6 : 1)
105                                 }
106 +                       case 'sunday':
107 +                               if (today == Alarm.kSunday && this.isLaterToday()) {
108 +                                       return 0;
109 +                               }
110 +                               else if (today >= Alarm.kSunday){
111 +                                       return (7 + Alarm.kSunday - today);
112 +                               }
113 +                               else if (today < Alarm.kSunday){
114 +                                       return Alarm.kSunday - today;
115 +                               }
116 +                       case 'monday':
117 +                               if (today == Alarm.kMonday && this.isLaterToday()) {
118 +                                       return 0;
119 +                               }
120 +                               else if (today >= Alarm.kMonday){
121 +                                       return (7 + Alarm.kMonday - today);
122 +                               } 
123 +                               else if (today < Alarm.kMonday){
124 +                                       return Alarm.kMonday - today;
125 +                               }
126 +                       case 'tuesday':
127 +                               if (today == Alarm.kTuesday && this.isLaterToday()) {
128 +                                       return 0;
129 +                               }
130 +                               else if (today >= Alarm.kTuesday){
131 +                                       return (7 + Alarm.kTuesday - today);
132 +                               }
133 +                               else if (today < Alarm.kTuesday){
134 +                                       return Alarm.kTuesday - today;
135 +                               }
136 +                       case 'wednesday':
137 +                               if (today == Alarm.kWednesday && this.isLaterToday()) {
138 +                                       return 0;
139 +                               }
140 +                               else if (today >= Alarm.kWednesday){
141 +                                       return (7 + Alarm.kWednesday - today);
142 +                               }
143 +                               else if (today < Alarm.kWednesday){
144 +                                       return Alarm.kWednesday - today;
145 +                               }
146 +                       case 'thursday':
147 +                               if (today == Alarm.kThursday && this.isLaterToday()) {
148 +                                       return 0;
149 +                               }
150 +                               else if (today >= Alarm.kThursday){
151 +                                       return (7 + Alarm.kThursday - today);
152 +                               }
153 +                               else if (today < Alarm.kThursday){
154 +                                       return Alarm.kThursday - today;
155 +                               }
156 +                       case 'friday':
157 +                               if (today == Alarm.kFriday && this.isLaterToday()) {
158 +                                       return 0;
159 +                               }
160 +                               else if (today >= Alarm.kFriday){
161 +                                       return (7 + Alarm.kFriday - today);
162 +                               }
163 +                               else if (today < Alarm.kFriday){
164 +                                       return Alarm.kFriday - today;
165 +                               }
166 +                       case 'saturday':
167 +                               if (today == Alarm.kSaturday && this.isLaterToday()) {
168 +                                       return 0;
169 +                               }
170 +                               else if (today >= Alarm.kSaturday){
171 +                                       return (7 + Alarm.kSaturday - today);
172 +                               }
173 +                               else if (today < Alarm.kSaturday){
174 +                                       return Alarm.kSaturday - today;
175 +                               }
176                         // if it rings daily or once, then it either rings today or tomorrow
177                         case 'daily':
178                         case 'once':
179 @@ -423,6 +539,76 @@
180                                 } else {
181                                         return "";
182                                 }
183 +                       case 'sunday':
184 +                               if (today == Alarm.kSunday && this.isLaterToday()) {
185 +                                       return "";
186 +                               }
187 +                               else if (today == Alarm.kSaturday){
188 +                                       return $L("tomorrow");
189 +                               }
190 +                               else {
191 +                                       return $L("Sunday");
192 +                               }
193 +                       case 'monday':
194 +                               if (today == Alarm.kMonday && this.isLaterToday()) {
195 +                                       return "";
196 +                               }
197 +                               else if (today == Alarm.kSunday){
198 +                                       return $L("tomorrow");
199 +                               }
200 +                               else {
201 +                                       return $L("Monday");
202 +                               }
203 +                       case 'tuesday':
204 +                               if (today == Alarm.kTuesday && this.isLaterToday()) {
205 +                                       return "";
206 +                               }
207 +                                else if (today == Alarm.kMonday){
208 +                                       return $L("tomorrow");
209 +                                }
210 +                                else {
211 +                                       return $L("Tuesday");
212 +                                }
213 +                       case 'wednesday':
214 +                               if (today == Alarm.kWednesday && this.isLaterToday()) {
215 +                                       return "";
216 +                               }
217 +                               else if (today == Alarm.kTuesday){
218 +                                       return $L("tomorrow");
219 +                               }
220 +                               else {
221 +                                       return $L("Wednesday");
222 +                               }
223 +                       case 'thursday':
224 +                               if (today == Alarm.kThursday && this.isLaterToday()) {
225 +                                       return "";
226 +                               }
227 +                               else if (today == Alarm.kWednesday){
228 +                                       return $L("tomorrow");
229 +                               }
230 +                               else {
231 +                                       return $L("Thursday");
232 +                               }
233 +                       case 'friday':
234 +                               if (today == Alarm.kFriday && this.isLaterToday()) {
235 +                                       return "";
236 +                               }
237 +                               else if (today == Alarm.kThursday){
238 +                                       return $L("tomorrow");
239 +                               }
240 +                               else {
241 +                                       return $L("Friday");
242 +                               }
243 +                       case 'saturday':
244 +                               if (today == Alarm.kSaturday && this.isLaterToday()) {
245 +                                       return "";
246 +                               }
247 +                               else if (today == Alarm.kFriday){
248 +                                       return $L("tomorrow");
249 +                               }
250 +                               else {
251 +                                       return $L("Saturday");
252 +                               }
253                         case 'daily':
254                         case 'once':
255                                 if (this.isLaterToday()) {