Pārlūkot izejas kodu

HUE-1910 [oozie] Added Moment.js timezone and tzdetect

Enrico Berti 10 gadi atpakaļ
vecāks
revīzija
46feb96

+ 2 - 0
apps/oozie/src/oozie/templates/editor2/coordinator_editor.mako

@@ -515,6 +515,8 @@ ${ layout.menubar(section='coordinators', is_editor=True, pullright=buttons) }
 <script src="${ static('desktop/js/jqCron.js') }" type="text/javascript"></script>
 
 <script src="${ static('desktop/ext/js/moment-with-locales.min.js') }" type="text/javascript" charset="utf-8"></script>
+<script src="${ static('desktop/ext/js/moment-timezone-with-data.min.js') }" type="text/javascript" charset="utf-8"></script>
+<script src="${ static('desktop/ext/js/tzdetect.js') }" type="text/javascript" charset="utf-8"></script>
 
 <link rel="stylesheet" href="${ static('desktop/ext/select2/select2.css') }">
 <script src="${ static('desktop/ext/select2/select2.min.js') }" type="text/javascript" charset="utf-8"></script>

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 5 - 0
desktop/core/src/desktop/static/desktop/ext/js/moment-timezone-with-data.min.js


+ 21 - 0
desktop/core/src/desktop/static/desktop/ext/js/tzdetect.js

@@ -0,0 +1,21 @@
+// A small public domain library detecting the user's timezone using moment.js
+// Repository : https://github.com/Canop/tzdetect.js
+// Usage :
+//   tzdetect.matches()     : array of all timezones matching the user's one
+//   tzdetect.matches(base) : array of all timezones matching the supplied one
+var tzdetect = {
+	names: moment.tz.names(),
+	matches: function(base){
+		var results = [], now = Date.now(), makekey = function(id){
+			return [0, 4, 8, -5*12, 4-5*12, 8-5*12, 4-2*12, 8-2*12].map(function(months){
+				var m = moment(now + months*30*24*60*60*1000);
+				if (id) m.tz(id);
+				return m.format("DDHHmm");
+			}).join(' ');
+		}, lockey = makekey(base);
+		tzdetect.names.forEach(function(id){
+			if (makekey(id)===lockey) results.push(id);
+		});
+		return results;
+	}
+};

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels