gremmie@1
|
1 var gcalTzInfo = {
|
gremmie@1
|
2 areas: ['Africa', 'America', 'Antarctica', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'US'],
|
gremmie@1
|
3 locations: [['Abidjan', 'Accra', 'Addis Ababa', 'Algiers', 'Asmara', 'Bamako', 'Bangui', 'Banjul', 'Bissau', 'Blantyre', 'Brazzaville', 'Bujumbura', 'Cairo', 'Casablanca', 'Ceuta', 'Conakry', 'Dakar', 'Dar es Salaam', 'Djibouti', 'Douala', 'El Aaiun', 'Freetown', 'Gaborone', 'Harare', 'Johannesburg', 'Kampala', 'Khartoum', 'Kigali', 'Kinshasa', 'Lagos', 'Libreville', 'Lome', 'Luanda', 'Lubumbashi', 'Lusaka', 'Malabo', 'Maputo', 'Maseru', 'Mbabane', 'Mogadishu', 'Monrovia', 'Nairobi', 'Ndjamena', 'Niamey', 'Nouakchott', 'Ouagadougou', 'Porto-Novo', 'Sao Tome', 'Tripoli', 'Tunis', 'Windhoek'],
|
gremmie@1
|
4 ['Adak', 'Anchorage', 'Anguilla', 'Antigua', 'Araguaina', 'Argentina/Buenos Aires', 'Argentina/Catamarca', 'Argentina/Cordoba', 'Argentina/Jujuy', 'Argentina/La Rioja', 'Argentina/Mendoza', 'Argentina/Rio Gallegos', 'Argentina/Salta', 'Argentina/San Juan', 'Argentina/San Luis', 'Argentina/Tucuman', 'Argentina/Ushuaia', 'Aruba', 'Asuncion', 'Atikokan', 'Bahia', 'Barbados', 'Belem', 'Belize', 'Blanc-Sablon', 'Boa Vista', 'Bogota', 'Boise', 'Cambridge Bay', 'Campo Grande', 'Cancun', 'Caracas', 'Cayenne', 'Cayman', 'Chicago', 'Chihuahua', 'Costa Rica', 'Cuiaba', 'Curacao', 'Danmarkshavn', 'Dawson', 'Dawson Creek', 'Denver', 'Detroit', 'Dominica', 'Edmonton', 'Eirunepe', 'El Salvador', 'Fortaleza', 'Glace Bay', 'Godthab', 'Goose Bay', 'Grand Turk', 'Grenada', 'Guadeloupe', 'Guatemala', 'Guayaquil', 'Guyana', 'Halifax', 'Havana', 'Hermosillo', 'Indiana/Indianapolis', 'Indiana/Knox', 'Indiana/Marengo', 'Indiana/Petersburg', 'Indiana/Tell City', 'Indiana/Vevay', 'Indiana/Vincennes', 'Indiana/Winamac', 'Inuvik', 'Iqaluit', 'Jamaica', 'Juneau', 'Kentucky/Louisville', 'Kentucky/Monticello', 'La Paz', 'Lima', 'Los Angeles', 'Maceio', 'Managua', 'Manaus', 'Martinique', 'Mazatlan', 'Menominee', 'Merida', 'Mexico City', 'Miquelon', 'Moncton', 'Monterrey', 'Montevideo', 'Montreal', 'Montserrat', 'Nassau', 'New York', 'Nipigon', 'Nome', 'Noronha', 'North Dakota/Center', 'North Dakota/New Salem', 'Panama', 'Pangnirtung', 'Paramaribo', 'Phoenix', 'Port of Spain', 'Port-au-Prince', 'Porto Velho', 'Puerto Rico', 'Rainy River', 'Rankin Inlet', 'Recife', 'Regina', 'Resolute', 'Rio Branco', 'Santarem', 'Santiago', 'Santo Domingo', 'Sao Paulo', 'Scoresbysund', 'St Johns', 'St Kitts', 'St Lucia', 'St Thomas', 'St Vincent', 'Swift Current', 'Tegucigalpa', 'Thule', 'Thunder Bay', 'Tijuana', 'Toronto', 'Tortola', 'Vancouver', 'Whitehorse', 'Winnipeg', 'Yakutat', 'Yellowknife'],
|
gremmie@1
|
5 ['Casey', 'Davis', 'DumontDUrville', 'Mawson', 'McMurdo', 'Palmer', 'Rothera', 'Syowa', 'Vostok'],
|
gremmie@1
|
6 ['Aden', 'Almaty', 'Amman', 'Anadyr', 'Aqtau', 'Aqtobe', 'Ashgabat', 'Baghdad', 'Bahrain', 'Baku', 'Bangkok', 'Beirut', 'Bishkek', 'Brunei', 'Choibalsan', 'Chongqing', 'Colombo', 'Damascus', 'Dhaka', 'Dili', 'Dubai', 'Dushanbe', 'Gaza', 'Harbin', 'Ho Chi Minh', 'Hong Kong', 'Hovd', 'Irkutsk', 'Jakarta', 'Jayapura', 'Jerusalem', 'Kabul', 'Kamchatka', 'Karachi', 'Kashgar', 'Kathmandu', 'Kolkata', 'Krasnoyarsk', 'Kuala Lumpur', 'Kuching', 'Kuwait', 'Macau', 'Magadan', 'Makassar', 'Manila', 'Muscat', 'Nicosia', 'Novosibirsk', 'Omsk', 'Oral', 'Phnom Penh', 'Pontianak', 'Pyongyang', 'Qatar', 'Qyzylorda', 'Rangoon', 'Riyadh', 'Sakhalin', 'Samarkand', 'Seoul', 'Shanghai', 'Singapore', 'Taipei', 'Tashkent', 'Tbilisi', 'Tehran', 'Thimphu', 'Tokyo', 'Ulaanbaatar', 'Urumqi', 'Vientiane', 'Vladivostok', 'Yakutsk', 'Yekaterinburg', 'Yerevan'],
|
gremmie@1
|
7 ['Azores', 'Bermuda', 'Canary', 'Cape Verde', 'Faroe', 'Madeira', 'Reykjavik', 'South Georgia', 'St Helena', 'Stanley'],
|
gremmie@1
|
8 ['Adelaide', 'Brisbane', 'Broken Hill', 'Currie', 'Darwin', 'Eucla', 'Hobart', 'Lindeman', 'Lord Howe', 'Melbourne', 'Perth', 'Sydney'],
|
gremmie@1
|
9 ['Amsterdam', 'Andorra', 'Athens', 'Belgrade', 'Berlin', 'Brussels', 'Bucharest', 'Budapest', 'Chisinau', 'Copenhagen', 'Dublin', 'Gibraltar', 'Helsinki', 'Istanbul', 'Kaliningrad', 'Kiev', 'Lisbon', 'London', 'Luxembourg', 'Madrid', 'Malta', 'Minsk', 'Monaco', 'Moscow', 'Oslo', 'Paris', 'Prague', 'Riga', 'Rome', 'Samara', 'Simferopol', 'Sofia', 'Stockholm', 'Tallinn', 'Tirane', 'Uzhgorod', 'Vaduz', 'Vienna', 'Vilnius', 'Volgograd', 'Warsaw', 'Zaporozhye', 'Zurich'],
|
gremmie@1
|
10 ['Antananarivo', 'Chagos', 'Christmas', 'Cocos', 'Comoro', 'Kerguelen', 'Mahe', 'Maldives', 'Mauritius', 'Mayotte', 'Reunion'],
|
gremmie@1
|
11 ['Apia', 'Auckland', 'Chatham', 'Easter', 'Efate', 'Enderbury', 'Fakaofo', 'Fiji', 'Funafuti', 'Galapagos', 'Gambier', 'Guadalcanal', 'Guam', 'Honolulu', 'Johnston', 'Kiritimati', 'Kosrae', 'Kwajalein', 'Majuro', 'Marquesas', 'Midway', 'Nauru', 'Niue', 'Norfolk', 'Noumea', 'Pago Pago', 'Palau', 'Pitcairn', 'Ponape', 'Port Moresby', 'Rarotonga', 'Saipan', 'Tahiti', 'Tarawa', 'Tongatapu', 'Truk', 'Wake', 'Wallis'],
|
gremmie@1
|
12 ['Alaska', 'Arizona', 'Central', 'Eastern', 'Hawaii', 'Mountain', 'Pacific']],
|
gremmie@1
|
13 default_area: 9,
|
gremmie@1
|
14 default_location: 6
|
gremmie@1
|
15 };
|
gremmie@1
|
16
|
gremmie@1
|
17 $(document).ready(function() {
|
gremmie@1
|
18 $('#id_description').markItUp(mySettings);
|
gremmie@1
|
19 $('#id_start_date').datepicker({constrainInput: true,
|
gremmie@1
|
20 onClose: function () {
|
gremmie@1
|
21 var end = $('#id_end_date');
|
gremmie@1
|
22 if (this.value > end.val())
|
gremmie@1
|
23 {
|
gremmie@1
|
24 end.val(this.value);
|
gremmie@1
|
25 }
|
gremmie@1
|
26 }
|
gremmie@1
|
27 });
|
gremmie@1
|
28 $('#id_end_date').datepicker({constrainInput: true,
|
gremmie@1
|
29 onClose: function () {
|
gremmie@1
|
30 var start = $('#id_start_date');
|
gremmie@1
|
31 if (this.value < start.val())
|
gremmie@1
|
32 {
|
gremmie@1
|
33 start.val(this.value);
|
gremmie@1
|
34 }
|
gremmie@1
|
35 }
|
gremmie@1
|
36 });
|
gremmie@1
|
37 if ($('#id_all_day:checked').length)
|
gremmie@1
|
38 {
|
gremmie@1
|
39 $('#id_start_time').hide();
|
gremmie@1
|
40 $('#id_end_time').hide();
|
gremmie@1
|
41 $('#id_tz_stuff').hide();
|
gremmie@1
|
42 }
|
gremmie@1
|
43 $('#id_all_day').click(function () {
|
gremmie@1
|
44 $('#id_start_time').toggle();
|
gremmie@1
|
45 $('#id_end_time').toggle();
|
gremmie@1
|
46 $('#id_tz_stuff').toggle();
|
gremmie@1
|
47 });
|
gremmie@1
|
48
|
gremmie@1
|
49 var tz_area = $('#id_tz_area')[0];
|
gremmie@1
|
50 var tz_loc = $('#id_tz_location')[0];
|
gremmie@1
|
51 tz_area.options.length = 0;
|
gremmie@1
|
52 for (var i = 0; i < gcalTzInfo.areas.length; ++i)
|
gremmie@1
|
53 {
|
gremmie@1
|
54 tz_area.options[i] = new Option(gcalTzInfo.areas[i]);
|
gremmie@1
|
55 }
|
gremmie@1
|
56
|
gremmie@1
|
57 var event_tz = $('#id_time_zone').val();
|
gremmie@1
|
58 if (event_tz == '')
|
gremmie@1
|
59 {
|
gremmie@1
|
60 tz_area.options.selectedIndex = gcalTzInfo.default_area;
|
gremmie@1
|
61 }
|
gremmie@1
|
62 else
|
gremmie@1
|
63 {
|
gremmie@1
|
64 var area_match = event_tz.match(/^(\w+)\/.*$/);
|
gremmie@1
|
65 if (area_match != null)
|
gremmie@1
|
66 {
|
gremmie@1
|
67 var i = gcalTzInfo.areas.indexOf(area_match[1]);
|
gremmie@1
|
68 tz_area.options.selectedIndex = (i != -1) ? i : gcalTzInfo.default_area;
|
gremmie@1
|
69 }
|
gremmie@1
|
70 else
|
gremmie@1
|
71 {
|
gremmie@1
|
72 tz_area.options.selectedIndex = gcalTzInfo.default_area;
|
gremmie@1
|
73 }
|
gremmie@1
|
74 }
|
gremmie@1
|
75
|
gremmie@1
|
76 $('#id_tz_area').change(function () {
|
gremmie@1
|
77 tz_loc.options.length = 0;
|
gremmie@1
|
78 var area = tz_area.options.selectedIndex;
|
gremmie@1
|
79 for (var i = 0; i < gcalTzInfo.locations[area].length; ++i)
|
gremmie@1
|
80 {
|
gremmie@1
|
81 tz_loc.options[i] = new Option(gcalTzInfo.locations[area][i]);
|
gremmie@1
|
82 }
|
gremmie@1
|
83 }).change();
|
gremmie@1
|
84
|
gremmie@1
|
85 if (event_tz == '')
|
gremmie@1
|
86 {
|
gremmie@1
|
87 tz_loc.options.selectedIndex = gcalTzInfo.default_location;
|
gremmie@1
|
88 }
|
gremmie@1
|
89 else
|
gremmie@1
|
90 {
|
gremmie@1
|
91 var loc_match = event_tz.match(/^[^\/]+\/(.*)$/);
|
gremmie@1
|
92 if (loc_match != null)
|
gremmie@1
|
93 {
|
gremmie@1
|
94 var loc = loc_match[1].replace(/_/g, ' ');
|
gremmie@1
|
95 var i = gcalTzInfo.locations[tz_area.options.selectedIndex].indexOf(loc);
|
gremmie@1
|
96 tz_loc.options.selectedIndex = (i != -1) ? i : gcalTzInfo.default_location;
|
gremmie@1
|
97 }
|
gremmie@1
|
98 else
|
gremmie@1
|
99 {
|
gremmie@1
|
100 tz_loc.options.selectedIndex = gcalTzInfo.default_location;
|
gremmie@1
|
101 }
|
gremmie@1
|
102 }
|
gremmie@1
|
103
|
gremmie@1
|
104 $('#id_gcal_event_form').submit(function () {
|
gremmie@1
|
105 var area = $('#id_tz_area').val();
|
gremmie@1
|
106 var loc = $('#id_tz_location').val();
|
gremmie@1
|
107 var tz = area + '/' + loc.replace(/ /g, '_');
|
gremmie@1
|
108 $('#id_time_zone').val(tz);
|
gremmie@1
|
109 return true;
|
gremmie@1
|
110 });
|
gremmie@1
|
111 });
|