
load('path/to/all_localizations.json');
32 | *
33 | * This can also load a localization file for a locale
34 | * load( 'path/to/de-messages.json', 'de' );
35 | *
36 | * A data object containing message key- message translation mappings
37 | * can also be passed Eg:
38 | *
39 | * load( { 'hello' : 'Hello' }, optionalLocale );
40 | * If the data argument is
41 | * null/undefined/false,
42 | * all cached messages for the i18n instance will get reset.
43 | *
44 | * @param {string|Object} source
45 | * @param {string} locale Language tag
46 | * @return {jQuery.Promise}
47 | */
48 | load: function ( source, locale ) {
49 | var key = null,
50 | deferred = null,
51 | deferreds = [],
52 | messageStore = this;
53 |
54 | if ( typeof source === 'string' ) {
55 | // This is a URL to the messages file.
56 | $.i18n.log( 'Loading messages from: ' + source );
57 | deferred = jsonMessageLoader( source )
58 | .done( function ( localization ) {
59 | messageStore.set( locale, localization );
60 | } );
61 |
62 | return deferred.promise();
63 | }
64 |
65 | if ( locale ) {
66 | // source is an key-value pair of messages for given locale
67 | messageStore.set( locale, source );
68 |
69 | return $.Deferred().resolve();
70 | } else {
71 | // source is a key-value pair of locales and their source
72 | for ( key in source ) {
73 | if ( Object.prototype.hasOwnProperty.call( source, key ) ) {
74 | locale = key;
75 | // No {locale} given, assume data is a group of languages,
76 | // call this function again for each language.
77 | deferreds.push( messageStore.load( source[ key ], locale ) );
78 | }
79 | }
80 | return $.when.apply( $, deferreds );
81 | }
82 |
83 | },
84 |
85 | /**
86 | * Set messages to the given locale.
87 | * If locale exists, add messages to the locale.
88 | *
89 | * @param {string} locale
90 | * @param {Object} messages
91 | */
92 | set: function ( locale, messages ) {
93 | if ( !this.messages[ locale ] ) {
94 | this.messages[ locale ] = messages;
95 | } else {
96 | this.messages[ locale ] = $.extend( this.messages[ locale ], messages );
97 | }
98 | },
99 |
100 | /**
101 | *
102 | * @param {string} locale
103 | * @param {string} messageKey
104 | * @return {boolean}
105 | */
106 | get: function ( locale, messageKey ) {
107 | return this.messages[ locale ] && this.messages[ locale ][ messageKey ];
108 | }
109 | };
110 |
111 | function jsonMessageLoader( url ) {
112 | var deferred = $.Deferred();
113 |
114 | $.getJSON( url )
115 | .done( deferred.resolve )
116 | .fail( function ( jqxhr, settings, exception ) {
117 | $.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
118 | // Ignore 404 exception, because we are handling fallabacks explicitly
119 | deferred.resolve();
120 | } );
121 |
122 | return deferred.promise();
123 | }
124 |
125 | $.extend( $.i18n.messageStore, new MessageStore() );
126 | }( jQuery, window ) );
127 |
--------------------------------------------------------------------------------
/src/de/michaelkuerbis/presenter/rest/CronREST.java:
--------------------------------------------------------------------------------
1 | package de.michaelkuerbis.presenter.rest;
2 |
3 | import java.text.ParseException;
4 | import java.util.Vector;
5 |
6 | import javax.servlet.http.HttpServletRequest;
7 | import javax.ws.rs.Consumes;
8 | import javax.ws.rs.DELETE;
9 | import javax.ws.rs.FormParam;
10 | import javax.ws.rs.GET;
11 | import javax.ws.rs.POST;
12 | import javax.ws.rs.Path;
13 | import javax.ws.rs.PathParam;
14 | import javax.ws.rs.core.Context;
15 | import javax.ws.rs.core.MediaType;
16 | import javax.ws.rs.core.Response;
17 |
18 | import net.redhogs.cronparser.CronExpressionDescriptor;
19 | import net.redhogs.cronparser.Options;
20 |
21 | import org.json.simple.JSONArray;
22 | import org.json.simple.JSONObject;
23 |
24 | import de.michaelkuerbis.presenter.servlets.CronServlet;
25 | import de.michaelkuerbis.presenter.utils.CronJob;
26 |
27 | @Path("/cron")
28 | public class CronREST {
29 |
30 | @Context
31 | private HttpServletRequest webRequest;
32 |
33 | @POST
34 | @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
35 | @Path("/add/{target}")
36 | public Response addChromecast(@PathParam("target") String target,
37 | @FormParam("name") String name, @FormParam("url") String url,
38 | @FormParam("pattern") String pattern, @FormParam("reload") int reload) {
39 | JSONObject obj = new JSONObject();
40 | if (target != null && !target.isEmpty() && name != null
41 | && !name.isEmpty()) {
42 | boolean alreadyDefined = false;
43 | for (CronJob con : CronServlet.getCronJobs()) {
44 | if (con.getTarget().equals(target) && con.getName().equals(name)) {
45 | alreadyDefined = true;
46 | obj.put("error", "cronjob already defined with name: "
47 | + con.getName());
48 | break;
49 | }
50 | }
51 | if (!alreadyDefined) {
52 | CronJob con = new CronJob(target, url, pattern, name, reload);
53 | Vectorload('path/to/all_localizations.json');
101 | *
102 | * To load a localization file for a locale:
103 | *
104 | * load('path/to/de-messages.json', 'de' );
105 | *
106 | *
107 | * To load a localization file from a directory:
108 | *
109 | * load('path/to/i18n/directory', 'de' );
110 | *
111 | * The above method has the advantage of fallback resolution.
112 | * ie, it will automatically load the fallback locales for de.
113 | * For most usecases, this is the recommended method.
114 | * It is optional to have trailing slash at end.
115 | *
116 | * A data object containing message key- message translation mappings
117 | * can also be passed. Example:
118 | *
119 | * load( { 'hello' : 'Hello' }, optionalLocale );
120 | *
121 | *
122 | * A source map containing key-value pair of languagename and locations
123 | * can also be passed. Example:
124 | *
125 | * load( {
126 | * bn: 'i18n/bn.json',
127 | * he: 'i18n/he.json',
128 | * en: 'i18n/en.json'
129 | * } )
130 | *
131 | *
132 | * If the data argument is null/undefined/false,
133 | * all cached messages for the i18n instance will get reset.
134 | *
135 | * @param {string|Object} source
136 | * @param {string} locale Language tag
137 | * @return {jQuery.Promise}
138 | */
139 | load: function ( source, locale ) {
140 | var fallbackLocales, locIndex, fallbackLocale, sourceMap = {};
141 | if ( !source && !locale ) {
142 | source = 'i18n/' + $.i18n().locale + '.json';
143 | locale = $.i18n().locale;
144 | }
145 | if ( typeof source === 'string' &&
146 | source.split( '.' ).pop() !== 'json'
147 | ) {
148 | // Load specified locale then check for fallbacks when directory is specified in load()
149 | sourceMap[ locale ] = source + '/' + locale + '.json';
150 | fallbackLocales = ( $.i18n.fallbacks[ locale ] || [] )
151 | .concat( this.options.fallbackLocale );
152 | for ( locIndex in fallbackLocales ) {
153 | fallbackLocale = fallbackLocales[ locIndex ];
154 | sourceMap[ fallbackLocale ] = source + '/' + fallbackLocale + '.json';
155 | }
156 | return this.load( sourceMap );
157 | } else {
158 | return this.messageStore.load( source, locale );
159 | }
160 |
161 | },
162 |
163 | /**
164 | * Does parameter and magic word substitution.
165 | *
166 | * @param {string} key Message key
167 | * @param {Array} parameters Message parameters
168 | * @return {string}
169 | */
170 | parse: function ( key, parameters ) {
171 | var message = key.toLocaleString();
172 | // FIXME: This changes the state of the I18N object,
173 | // should probably not change the 'this.parser' but just
174 | // pass it to the parser.
175 | this.parser.language = $.i18n.languages[ $.i18n().locale ] || $.i18n.languages[ 'default' ];
176 | if ( message === '' ) {
177 | message = key;
178 | }
179 | return this.parser.parse( message, parameters );
180 | }
181 | };
182 |
183 | /**
184 | * Process a message from the $.I18N instance
185 | * for the current document, stored in jQuery.data(document).
186 | *
187 | * @param {string} key Key of the message.
188 | * @param {string} param1 [param...] Variadic list of parameters for {key}.
189 | * @return {string|$.I18N} Parsed message, or if no key was given
190 | * the instance of $.I18N is returned.
191 | */
192 | $.i18n = function ( key, param1 ) {
193 | var parameters,
194 | i18n = $.data( document, 'i18n' ),
195 | options = typeof key === 'object' && key;
196 |
197 | // If the locale option for this call is different then the setup so far,
198 | // update it automatically. This doesn't just change the context for this
199 | // call but for all future call as well.
200 | // If there is no i18n setup yet, don't do this. It will be taken care of
201 | // by the `new I18N` construction below.
202 | // NOTE: It should only change language for this one call.
203 | // Then cache instances of I18N somewhere.
204 | if ( options && options.locale && i18n && i18n.locale !== options.locale ) {
205 | String.locale = i18n.locale = options.locale;
206 | }
207 |
208 | if ( !i18n ) {
209 | i18n = new I18N( options );
210 | $.data( document, 'i18n', i18n );
211 | }
212 |
213 | if ( typeof key === 'string' ) {
214 | if ( param1 !== undefined ) {
215 | parameters = slice.call( arguments, 1 );
216 | } else {
217 | parameters = [];
218 | }
219 |
220 | return i18n.parse( key, parameters );
221 | } else {
222 | // FIXME: remove this feature/bug.
223 | return i18n;
224 | }
225 | };
226 |
227 | $.fn.i18n = function () {
228 | var i18n = $.data( document, 'i18n' );
229 |
230 | if ( !i18n ) {
231 | i18n = new I18N();
232 | $.data( document, 'i18n', i18n );
233 | }
234 | String.locale = i18n.locale;
235 | return this.each( function () {
236 | var $this = $( this ),
237 | messageKey = $this.data( 'i18n' ),
238 | lBracket, rBracket, type, key;
239 |
240 | if ( messageKey ) {
241 | lBracket = messageKey.indexOf( '[' );
242 | rBracket = messageKey.indexOf( ']' );
243 | if ( lBracket !== -1 && rBracket !== -1 && lBracket < rBracket ) {
244 | type = messageKey.slice( lBracket + 1, rBracket );
245 | key = messageKey.slice( rBracket + 1 );
246 | if ( type === 'html' ) {
247 | $this.html( i18n.parse( key ) );
248 | } else {
249 | $this.attr( type, i18n.parse( key ) );
250 | }
251 | } else {
252 | $this.text( i18n.parse( messageKey ) );
253 | }
254 | } else {
255 | $this.find( '[data-i18n]' ).i18n();
256 | }
257 | } );
258 | };
259 |
260 | String.locale = String.locale || $( 'html' ).attr( 'lang' );
261 |
262 | if ( !String.locale ) {
263 | if ( typeof window.navigator !== undefined ) {
264 | nav = window.navigator;
265 | String.locale = nav.language || nav.userLanguage || '';
266 | } else {
267 | String.locale = '';
268 | }
269 | }
270 |
271 | $.i18n.languages = {};
272 | $.i18n.messageStore = $.i18n.messageStore || {};
273 | $.i18n.parser = {
274 | // The default parser only handles variable substitution
275 | parse: function ( message, parameters ) {
276 | return message.replace( /\$(\d+)/g, function ( str, match ) {
277 | var index = parseInt( match, 10 ) - 1;
278 | return parameters[ index ] !== undefined ? parameters[ index ] : '$' + match;
279 | } );
280 | },
281 | emitter: {}
282 | };
283 | $.i18n.fallbacks = {};
284 | $.i18n.debug = false;
285 | $.i18n.log = function ( /* arguments */ ) {
286 | if ( window.console && $.i18n.debug ) {
287 | window.console.log.apply( window.console, arguments );
288 | }
289 | };
290 | /* Static members */
291 | I18N.defaults = {
292 | locale: String.locale,
293 | fallbackLocale: 'en',
294 | parser: $.i18n.parser,
295 | messageStore: $.i18n.messageStore
296 | };
297 |
298 | // Expose constructor
299 | $.i18n.constructor = I18N;
300 | }( jQuery ) );
301 |
--------------------------------------------------------------------------------
/WebContent/assets/js/jquery.i18n.emitter.bidi.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * BIDI embedding support for jQuery.i18n
3 | *
4 | * Copyright (C) 2015, David Chan
5 | *
6 | * This code is dual licensed GPLv2 or later and MIT. You don't have to do
7 | * anything special to choose one license or the other and you don't have to
8 | * notify anyone which license you are using. You are free to use this code
9 | * in commercial projects as long as the copyright header is left intact.
10 | * See files GPL-LICENSE and MIT-LICENSE for details.
11 | *
12 | * @licence GNU General Public Licence 2.0 or later
13 | * @licence MIT License
14 | */
15 |
16 | ( function ( $ ) {
17 | 'use strict';
18 | var strongDirRegExp;
19 |
20 | /**
21 | * Matches the first strong directionality codepoint:
22 | * - in group 1 if it is LTR
23 | * - in group 2 if it is RTL
24 | * Does not match if there is no strong directionality codepoint.
25 | *
26 | * Generated by UnicodeJS (see tools/strongDir) from the UCD; see
27 | * https://phabricator.wikimedia.org/diffusion/GUJS/ .
28 | */
29 | strongDirRegExp = new RegExp(
30 | '(?:' +
31 | '(' +
32 | '[\u0041-\u005a\u0061-\u007a\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u02bb-\u02c1\u02d0\u02d1\u02e0-\u02e4\u02ee\u0370-\u0373\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0482\u048a-\u052f\u0531-\u0556\u0559-\u055f\u0561-\u0587\u0589\u0903-\u0939\u093b\u093d-\u0940\u0949-\u094c\u094e-\u0950\u0958-\u0961\u0964-\u0980\u0982\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd-\u09c0\u09c7\u09c8\u09cb\u09cc\u09ce\u09d7\u09dc\u09dd\u09df-\u09e1\u09e6-\u09f1\u09f4-\u09fa\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3e-\u0a40\u0a59-\u0a5c\u0a5e\u0a66-\u0a6f\u0a72-\u0a74\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd-\u0ac0\u0ac9\u0acb\u0acc\u0ad0\u0ae0\u0ae1\u0ae6-\u0af0\u0af9\u0b02\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b3e\u0b40\u0b47\u0b48\u0b4b\u0b4c\u0b57\u0b5c\u0b5d\u0b5f-\u0b61\u0b66-\u0b77\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe\u0bbf\u0bc1\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcc\u0bd0\u0bd7\u0be6-\u0bf2\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c41-\u0c44\u0c58-\u0c5a\u0c60\u0c61\u0c66-\u0c6f\u0c7f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd-\u0cc4\u0cc6-\u0cc8\u0cca\u0ccb\u0cd5\u0cd6\u0cde\u0ce0\u0ce1\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d40\u0d46-\u0d48\u0d4a-\u0d4c\u0d4e\u0d57\u0d5f-\u0d61\u0d66-\u0d75\u0d79-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dcf-\u0dd1\u0dd8-\u0ddf\u0de6-\u0def\u0df2-\u0df4\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e4f-\u0e5b\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0ed0-\u0ed9\u0edc-\u0edf\u0f00-\u0f17\u0f1a-\u0f34\u0f36\u0f38\u0f3e-\u0f47\u0f49-\u0f6c\u0f7f\u0f85\u0f88-\u0f8c\u0fbe-\u0fc5\u0fc7-\u0fcc\u0fce-\u0fda\u1000-\u102c\u1031\u1038\u103b\u103c\u103f-\u1057\u105a-\u105d\u1061-\u1070\u1075-\u1081\u1083\u1084\u1087-\u108c\u108e-\u109c\u109e-\u10c5\u10c7\u10cd\u10d0-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1360-\u137c\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u167f\u1681-\u169a\u16a0-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1735\u1736\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17b6\u17be-\u17c5\u17c7\u17c8\u17d4-\u17da\u17dc\u17e0-\u17e9\u1810-\u1819\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1923-\u1926\u1929-\u192b\u1930\u1931\u1933-\u1938\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19da\u1a00-\u1a16\u1a19\u1a1a\u1a1e-\u1a55\u1a57\u1a61\u1a63\u1a64\u1a6d-\u1a72\u1a80-\u1a89\u1a90-\u1a99\u1aa0-\u1aad\u1b04-\u1b33\u1b35\u1b3b\u1b3d-\u1b41\u1b43-\u1b4b\u1b50-\u1b6a\u1b74-\u1b7c\u1b82-\u1ba1\u1ba6\u1ba7\u1baa\u1bae-\u1be5\u1be7\u1bea-\u1bec\u1bee\u1bf2\u1bf3\u1bfc-\u1c2b\u1c34\u1c35\u1c3b-\u1c49\u1c4d-\u1c7f\u1cc0-\u1cc7\u1cd3\u1ce1\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200e\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u214f\u2160-\u2188\u2336-\u237a\u2395\u249c-\u24e9\u26ac\u2800-\u28ff\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d70\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u302e\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u3190-\u31ba\u31f0-\u321c\u3220-\u324f\u3260-\u327b\u327f-\u32b0\u32c0-\u32cb\u32d0-\u32fe\u3300-\u3376\u337b-\u33dd\u33e0-\u33fe\u3400-\u4db5\u4e00-\u9fd5\ua000-\ua48c\ua4d0-\ua60c\ua610-\ua62b\ua640-\ua66e\ua680-\ua69d\ua6a0-\ua6ef\ua6f2-\ua6f7\ua722-\ua787\ua789-\ua7ad\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua824\ua827\ua830-\ua837\ua840-\ua873\ua880-\ua8c3\ua8ce-\ua8d9\ua8f2-\ua8fd\ua900-\ua925\ua92e-\ua946\ua952\ua953\ua95f-\ua97c\ua983-\ua9b2\ua9b4\ua9b5\ua9ba\ua9bb\ua9bd-\ua9cd\ua9cf-\ua9d9\ua9de-\ua9e4\ua9e6-\ua9fe\uaa00-\uaa28\uaa2f\uaa30\uaa33\uaa34\uaa40-\uaa42\uaa44-\uaa4b\uaa4d\uaa50-\uaa59\uaa5c-\uaa7b\uaa7d-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaaeb\uaaee-\uaaf5\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab65\uab70-\uabe4\uabe6\uabe7\uabe9-\uabec\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\ue000-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]|\ud800[\udc00-\udc0b]|\ud800[\udc0d-\udc26]|\ud800[\udc28-\udc3a]|\ud800\udc3c|\ud800\udc3d|\ud800[\udc3f-\udc4d]|\ud800[\udc50-\udc5d]|\ud800[\udc80-\udcfa]|\ud800\udd00|\ud800\udd02|\ud800[\udd07-\udd33]|\ud800[\udd37-\udd3f]|\ud800[\uddd0-\uddfc]|\ud800[\ude80-\ude9c]|\ud800[\udea0-\uded0]|\ud800[\udf00-\udf23]|\ud800[\udf30-\udf4a]|\ud800[\udf50-\udf75]|\ud800[\udf80-\udf9d]|\ud800[\udf9f-\udfc3]|\ud800[\udfc8-\udfd5]|\ud801[\udc00-\udc9d]|\ud801[\udca0-\udca9]|\ud801[\udd00-\udd27]|\ud801[\udd30-\udd63]|\ud801\udd6f|\ud801[\ude00-\udf36]|\ud801[\udf40-\udf55]|\ud801[\udf60-\udf67]|\ud804\udc00|\ud804[\udc02-\udc37]|\ud804[\udc47-\udc4d]|\ud804[\udc66-\udc6f]|\ud804[\udc82-\udcb2]|\ud804\udcb7|\ud804\udcb8|\ud804[\udcbb-\udcc1]|\ud804[\udcd0-\udce8]|\ud804[\udcf0-\udcf9]|\ud804[\udd03-\udd26]|\ud804\udd2c|\ud804[\udd36-\udd43]|\ud804[\udd50-\udd72]|\ud804[\udd74-\udd76]|\ud804[\udd82-\uddb5]|\ud804[\uddbf-\uddc9]|\ud804\uddcd|\ud804[\uddd0-\udddf]|\ud804[\udde1-\uddf4]|\ud804[\ude00-\ude11]|\ud804[\ude13-\ude2e]|\ud804\ude32|\ud804\ude33|\ud804\ude35|\ud804[\ude38-\ude3d]|\ud804[\ude80-\ude86]|\ud804\ude88|\ud804[\ude8a-\ude8d]|\ud804[\ude8f-\ude9d]|\ud804[\ude9f-\udea9]|\ud804[\udeb0-\udede]|\ud804[\udee0-\udee2]|\ud804[\udef0-\udef9]|\ud804\udf02|\ud804\udf03|\ud804[\udf05-\udf0c]|\ud804\udf0f|\ud804\udf10|\ud804[\udf13-\udf28]|\ud804[\udf2a-\udf30]|\ud804\udf32|\ud804\udf33|\ud804[\udf35-\udf39]|\ud804[\udf3d-\udf3f]|\ud804[\udf41-\udf44]|\ud804\udf47|\ud804\udf48|\ud804[\udf4b-\udf4d]|\ud804\udf50|\ud804\udf57|\ud804[\udf5d-\udf63]|\ud805[\udc80-\udcb2]|\ud805\udcb9|\ud805[\udcbb-\udcbe]|\ud805\udcc1|\ud805[\udcc4-\udcc7]|\ud805[\udcd0-\udcd9]|\ud805[\udd80-\uddb1]|\ud805[\uddb8-\uddbb]|\ud805\uddbe|\ud805[\uddc1-\udddb]|\ud805[\ude00-\ude32]|\ud805\ude3b|\ud805\ude3c|\ud805\ude3e|\ud805[\ude41-\ude44]|\ud805[\ude50-\ude59]|\ud805[\ude80-\udeaa]|\ud805\udeac|\ud805\udeae|\ud805\udeaf|\ud805\udeb6|\ud805[\udec0-\udec9]|\ud805[\udf00-\udf19]|\ud805\udf20|\ud805\udf21|\ud805\udf26|\ud805[\udf30-\udf3f]|\ud806[\udca0-\udcf2]|\ud806\udcff|\ud806[\udec0-\udef8]|\ud808[\udc00-\udf99]|\ud809[\udc00-\udc6e]|\ud809[\udc70-\udc74]|\ud809[\udc80-\udd43]|\ud80c[\udc00-\udfff]|\ud80d[\udc00-\udc2e]|\ud811[\udc00-\ude46]|\ud81a[\udc00-\ude38]|\ud81a[\ude40-\ude5e]|\ud81a[\ude60-\ude69]|\ud81a\ude6e|\ud81a\ude6f|\ud81a[\uded0-\udeed]|\ud81a\udef5|\ud81a[\udf00-\udf2f]|\ud81a[\udf37-\udf45]|\ud81a[\udf50-\udf59]|\ud81a[\udf5b-\udf61]|\ud81a[\udf63-\udf77]|\ud81a[\udf7d-\udf8f]|\ud81b[\udf00-\udf44]|\ud81b[\udf50-\udf7e]|\ud81b[\udf93-\udf9f]|\ud82c\udc00|\ud82c\udc01|\ud82f[\udc00-\udc6a]|\ud82f[\udc70-\udc7c]|\ud82f[\udc80-\udc88]|\ud82f[\udc90-\udc99]|\ud82f\udc9c|\ud82f\udc9f|\ud834[\udc00-\udcf5]|\ud834[\udd00-\udd26]|\ud834[\udd29-\udd66]|\ud834[\udd6a-\udd72]|\ud834\udd83|\ud834\udd84|\ud834[\udd8c-\udda9]|\ud834[\uddae-\udde8]|\ud834[\udf60-\udf71]|\ud835[\udc00-\udc54]|\ud835[\udc56-\udc9c]|\ud835\udc9e|\ud835\udc9f|\ud835\udca2|\ud835\udca5|\ud835\udca6|\ud835[\udca9-\udcac]|\ud835[\udcae-\udcb9]|\ud835\udcbb|\ud835[\udcbd-\udcc3]|\ud835[\udcc5-\udd05]|\ud835[\udd07-\udd0a]|\ud835[\udd0d-\udd14]|\ud835[\udd16-\udd1c]|\ud835[\udd1e-\udd39]|\ud835[\udd3b-\udd3e]|\ud835[\udd40-\udd44]|\ud835\udd46|\ud835[\udd4a-\udd50]|\ud835[\udd52-\udea5]|\ud835[\udea8-\udeda]|\ud835[\udedc-\udf14]|\ud835[\udf16-\udf4e]|\ud835[\udf50-\udf88]|\ud835[\udf8a-\udfc2]|\ud835[\udfc4-\udfcb]|\ud836[\udc00-\uddff]|\ud836[\ude37-\ude3a]|\ud836[\ude6d-\ude74]|\ud836[\ude76-\ude83]|\ud836[\ude85-\ude8b]|\ud83c[\udd10-\udd2e]|\ud83c[\udd30-\udd69]|\ud83c[\udd70-\udd9a]|\ud83c[\udde6-\ude02]|\ud83c[\ude10-\ude3a]|\ud83c[\ude40-\ude48]|\ud83c\ude50|\ud83c\ude51|[\ud840-\ud868][\udc00-\udfff]|\ud869[\udc00-\uded6]|\ud869[\udf00-\udfff]|[\ud86a-\ud86c][\udc00-\udfff]|\ud86d[\udc00-\udf34]|\ud86d[\udf40-\udfff]|\ud86e[\udc00-\udc1d]|\ud86e[\udc20-\udfff]|[\ud86f-\ud872][\udc00-\udfff]|\ud873[\udc00-\udea1]|\ud87e[\udc00-\ude1d]|[\udb80-\udbbe][\udc00-\udfff]|\udbbf[\udc00-\udffd]|[\udbc0-\udbfe][\udc00-\udfff]|\udbff[\udc00-\udffd]' +
33 | ')|(' +
34 | '[\u0590\u05be\u05c0\u05c3\u05c6\u05c8-\u05ff\u07c0-\u07ea\u07f4\u07f5\u07fa-\u0815\u081a\u0824\u0828\u082e-\u0858\u085c-\u089f\u200f\ufb1d\ufb1f-\ufb28\ufb2a-\ufb4f\u0608\u060b\u060d\u061b-\u064a\u066d-\u066f\u0671-\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u0710\u0712-\u072f\u074b-\u07a5\u07b1-\u07bf\u08a0-\u08e2\ufb50-\ufd3d\ufd40-\ufdcf\ufdf0-\ufdfc\ufdfe\ufdff\ufe70-\ufefe]|\ud802[\udc00-\udd1e]|\ud802[\udd20-\ude00]|\ud802\ude04|\ud802[\ude07-\ude0b]|\ud802[\ude10-\ude37]|\ud802[\ude3b-\ude3e]|\ud802[\ude40-\udee4]|\ud802[\udee7-\udf38]|\ud802[\udf40-\udfff]|\ud803[\udc00-\ude5f]|\ud803[\ude7f-\udfff]|\ud83a[\udc00-\udccf]|\ud83a[\udcd7-\udfff]|\ud83b[\udc00-\uddff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\ude00-\udeef]|\ud83b[\udef2-\udeff]' +
35 | ')' +
36 | ')'
37 | );
38 |
39 | /**
40 | * Gets directionality of the first strongly directional codepoint
41 | *
42 | * This is the rule the BIDI algorithm uses to determine the directionality of
43 | * paragraphs ( http://unicode.org/reports/tr9/#The_Paragraph_Level ) and
44 | * FSI isolates ( http://unicode.org/reports/tr9/#Explicit_Directional_Isolates ).
45 | *
46 | * TODO: Does not handle BIDI control characters inside the text.
47 | * TODO: Does not handle unallocated characters.
48 | */
49 | function strongDirFromContent( text ) {
50 | var m = text.match( strongDirRegExp );
51 | if ( !m ) {
52 | return null;
53 | }
54 | if ( m[ 2 ] === undefined ) {
55 | return 'ltr';
56 | }
57 | return 'rtl';
58 | }
59 |
60 | $.extend( $.i18n.parser.emitter, {
61 | /**
62 | * Wraps argument with unicode control characters for directionality safety
63 | *
64 | * This solves the problem where directionality-neutral characters at the edge of
65 | * the argument string get interpreted with the wrong directionality from the
66 | * enclosing context, giving renderings that look corrupted like "(Ben_(WMF".
67 | *
68 | * The wrapping is LRE...PDF or RLE...PDF, depending on the detected
69 | * directionality of the argument string, using the BIDI algorithm's own "First
70 | * strong directional codepoint" rule. Essentially, this works round the fact that
71 | * there is no embedding equivalent of U+2068 FSI (isolation with heuristic
72 | * direction inference). The latter is cleaner but still not widely supported.
73 | */
74 | bidi: function ( nodes ) {
75 | var dir = strongDirFromContent( nodes[ 0 ] );
76 | if ( dir === 'ltr' ) {
77 | // Wrap in LEFT-TO-RIGHT EMBEDDING ... POP DIRECTIONAL FORMATTING
78 | return '\u202A' + nodes[ 0 ] + '\u202C';
79 | }
80 | if ( dir === 'rtl' ) {
81 | // Wrap in RIGHT-TO-LEFT EMBEDDING ... POP DIRECTIONAL FORMATTING
82 | return '\u202B' + nodes[ 0 ] + '\u202C';
83 | }
84 | // No strong directionality: do not wrap
85 | return nodes[ 0 ];
86 | }
87 | } );
88 | }( jQuery ) );
89 |
--------------------------------------------------------------------------------
/WebContent/assets/js/jquery.i18n.language.js:
--------------------------------------------------------------------------------
1 | /*global pluralRuleParser */
2 | ( function ( $ ) {
3 | 'use strict';
4 |
5 | var language = {
6 | // CLDR plural rules generated using
7 | // libs/CLDRPluralRuleParser/tools/PluralXML2JSON.html
8 | pluralRules: {
9 | ak: {
10 | one: 'n = 0..1'
11 | },
12 | am: {
13 | one: 'i = 0 or n = 1'
14 | },
15 | ar: {
16 | zero: 'n = 0',
17 | one: 'n = 1',
18 | two: 'n = 2',
19 | few: 'n % 100 = 3..10',
20 | many: 'n % 100 = 11..99'
21 | },
22 | be: {
23 | one: 'n % 10 = 1 and n % 100 != 11',
24 | few: 'n % 10 = 2..4 and n % 100 != 12..14',
25 | many: 'n % 10 = 0 or n % 10 = 5..9 or n % 100 = 11..14'
26 | },
27 | bh: {
28 | one: 'n = 0..1'
29 | },
30 | bn: {
31 | one: 'i = 0 or n = 1'
32 | },
33 | br: {
34 | one: 'n % 10 = 1 and n % 100 != 11,71,91',
35 | two: 'n % 10 = 2 and n % 100 != 12,72,92',
36 | few: 'n % 10 = 3..4,9 and n % 100 != 10..19,70..79,90..99',
37 | many: 'n != 0 and n % 1000000 = 0'
38 | },
39 | bs: {
40 | one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
41 | few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
42 | },
43 | cs: {
44 | one: 'i = 1 and v = 0',
45 | few: 'i = 2..4 and v = 0',
46 | many: 'v != 0'
47 | },
48 | cy: {
49 | zero: 'n = 0',
50 | one: 'n = 1',
51 | two: 'n = 2',
52 | few: 'n = 3',
53 | many: 'n = 6'
54 | },
55 | da: {
56 | one: 'n = 1 or t != 0 and i = 0,1'
57 | },
58 | fa: {
59 | one: 'i = 0 or n = 1'
60 | },
61 | ff: {
62 | one: 'i = 0,1'
63 | },
64 | fil: {
65 | one: 'i = 0..1 and v = 0'
66 | },
67 | fr: {
68 | one: 'i = 0,1'
69 | },
70 | ga: {
71 | one: 'n = 1',
72 | two: 'n = 2',
73 | few: 'n = 3..6',
74 | many: 'n = 7..10'
75 | },
76 | gd: {
77 | one: 'n = 1,11',
78 | two: 'n = 2,12',
79 | few: 'n = 3..10,13..19'
80 | },
81 | gu: {
82 | one: 'i = 0 or n = 1'
83 | },
84 | guw: {
85 | one: 'n = 0..1'
86 | },
87 | gv: {
88 | one: 'n % 10 = 1',
89 | two: 'n % 10 = 2',
90 | few: 'n % 100 = 0,20,40,60'
91 | },
92 | he: {
93 | one: 'i = 1 and v = 0',
94 | two: 'i = 2 and v = 0',
95 | many: 'v = 0 and n != 0..10 and n % 10 = 0'
96 | },
97 | hi: {
98 | one: 'i = 0 or n = 1'
99 | },
100 | hr: {
101 | one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
102 | few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
103 | },
104 | hy: {
105 | one: 'i = 0,1'
106 | },
107 | is: {
108 | one: 't = 0 and i % 10 = 1 and i % 100 != 11 or t != 0'
109 | },
110 | iu: {
111 | one: 'n = 1',
112 | two: 'n = 2'
113 | },
114 | iw: {
115 | one: 'i = 1 and v = 0',
116 | two: 'i = 2 and v = 0',
117 | many: 'v = 0 and n != 0..10 and n % 10 = 0'
118 | },
119 | kab: {
120 | one: 'i = 0,1'
121 | },
122 | kn: {
123 | one: 'i = 0 or n = 1'
124 | },
125 | kw: {
126 | one: 'n = 1',
127 | two: 'n = 2'
128 | },
129 | lag: {
130 | zero: 'n = 0',
131 | one: 'i = 0,1 and n != 0'
132 | },
133 | ln: {
134 | one: 'n = 0..1'
135 | },
136 | lt: {
137 | one: 'n % 10 = 1 and n % 100 != 11..19',
138 | few: 'n % 10 = 2..9 and n % 100 != 11..19',
139 | many: 'f != 0'
140 | },
141 | lv: {
142 | zero: 'n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19',
143 | one: 'n % 10 = 1 and n % 100 != 11 or v = 2 and f % 10 = 1 and f % 100 != 11 or v != 2 and f % 10 = 1'
144 | },
145 | mg: {
146 | one: 'n = 0..1'
147 | },
148 | mk: {
149 | one: 'v = 0 and i % 10 = 1 or f % 10 = 1'
150 | },
151 | mo: {
152 | one: 'i = 1 and v = 0',
153 | few: 'v != 0 or n = 0 or n != 1 and n % 100 = 1..19'
154 | },
155 | mr: {
156 | one: 'i = 0 or n = 1'
157 | },
158 | mt: {
159 | one: 'n = 1',
160 | few: 'n = 0 or n % 100 = 2..10',
161 | many: 'n % 100 = 11..19'
162 | },
163 | naq: {
164 | one: 'n = 1',
165 | two: 'n = 2'
166 | },
167 | nso: {
168 | one: 'n = 0..1'
169 | },
170 | pa: {
171 | one: 'n = 0..1'
172 | },
173 | pl: {
174 | one: 'i = 1 and v = 0',
175 | few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14',
176 | many: 'v = 0 and i != 1 and i % 10 = 0..1 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 12..14'
177 | },
178 | pt: {
179 | one: 'i = 1 and v = 0 or i = 0 and t = 1'
180 | },
181 | // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
182 | pt_PT: {
183 | one: 'n = 1 and v = 0'
184 | },
185 | // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
186 | ro: {
187 | one: 'i = 1 and v = 0',
188 | few: 'v != 0 or n = 0 or n != 1 and n % 100 = 1..19'
189 | },
190 | ru: {
191 | one: 'v = 0 and i % 10 = 1 and i % 100 != 11',
192 | many: 'v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14'
193 | },
194 | se: {
195 | one: 'n = 1',
196 | two: 'n = 2'
197 | },
198 | sh: {
199 | one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
200 | few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
201 | },
202 | shi: {
203 | one: 'i = 0 or n = 1',
204 | few: 'n = 2..10'
205 | },
206 | si: {
207 | one: 'n = 0,1 or i = 0 and f = 1'
208 | },
209 | sk: {
210 | one: 'i = 1 and v = 0',
211 | few: 'i = 2..4 and v = 0',
212 | many: 'v != 0'
213 | },
214 | sl: {
215 | one: 'v = 0 and i % 100 = 1',
216 | two: 'v = 0 and i % 100 = 2',
217 | few: 'v = 0 and i % 100 = 3..4 or v != 0'
218 | },
219 | sma: {
220 | one: 'n = 1',
221 | two: 'n = 2'
222 | },
223 | smi: {
224 | one: 'n = 1',
225 | two: 'n = 2'
226 | },
227 | smj: {
228 | one: 'n = 1',
229 | two: 'n = 2'
230 | },
231 | smn: {
232 | one: 'n = 1',
233 | two: 'n = 2'
234 | },
235 | sms: {
236 | one: 'n = 1',
237 | two: 'n = 2'
238 | },
239 | sr: {
240 | one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
241 | few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
242 | },
243 | ti: {
244 | one: 'n = 0..1'
245 | },
246 | tl: {
247 | one: 'i = 0..1 and v = 0'
248 | },
249 | tzm: {
250 | one: 'n = 0..1 or n = 11..99'
251 | },
252 | uk: {
253 | one: 'v = 0 and i % 10 = 1 and i % 100 != 11',
254 | few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14',
255 | many: 'v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14'
256 | },
257 | wa: {
258 | one: 'n = 0..1'
259 | },
260 | zu: {
261 | one: 'i = 0 or n = 1'
262 | }
263 | },
264 |
265 | /**
266 | * Plural form transformations, needed for some languages.
267 | *
268 | * @param {integer} count
269 | * Non-localized quantifier
270 | * @param {Array} forms
271 | * List of plural forms
272 | * @return {string} Correct form for quantifier in this language
273 | */
274 | convertPlural: function ( count, forms ) {
275 | var pluralRules,
276 | pluralFormIndex,
277 | index,
278 | explicitPluralPattern = new RegExp( '\\d+=', 'i' ),
279 | formCount,
280 | form;
281 |
282 | if ( !forms || forms.length === 0 ) {
283 | return '';
284 | }
285 |
286 | // Handle for Explicit 0= & 1= values
287 | for ( index = 0; index < forms.length; index++ ) {
288 | form = forms[ index ];
289 | if ( explicitPluralPattern.test( form ) ) {
290 | formCount = parseInt( form.slice( 0, form.indexOf( '=' ) ), 10 );
291 | if ( formCount === count ) {
292 | return ( form.slice( form.indexOf( '=' ) + 1 ) );
293 | }
294 | forms[ index ] = undefined;
295 | }
296 | }
297 |
298 | forms = $.map( forms, function ( form ) {
299 | if ( form !== undefined ) {
300 | return form;
301 | }
302 | } );
303 |
304 | pluralRules = this.pluralRules[ $.i18n().locale ];
305 |
306 | if ( !pluralRules ) {
307 | // default fallback.
308 | return ( count === 1 ) ? forms[ 0 ] : forms[ 1 ];
309 | }
310 |
311 | pluralFormIndex = this.getPluralForm( count, pluralRules );
312 | pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 );
313 |
314 | return forms[ pluralFormIndex ];
315 | },
316 |
317 | /**
318 | * For the number, get the plural for index
319 | *
320 | * @param {integer} number
321 | * @param {Object} pluralRules
322 | * @return {integer} plural form index
323 | */
324 | getPluralForm: function ( number, pluralRules ) {
325 | var i,
326 | pluralForms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ],
327 | pluralFormIndex = 0;
328 |
329 | for ( i = 0; i < pluralForms.length; i++ ) {
330 | if ( pluralRules[ pluralForms[ i ] ] ) {
331 | if ( pluralRuleParser( pluralRules[ pluralForms[ i ] ], number ) ) {
332 | return pluralFormIndex;
333 | }
334 |
335 | pluralFormIndex++;
336 | }
337 | }
338 |
339 | return pluralFormIndex;
340 | },
341 |
342 | /**
343 | * Converts a number using digitTransformTable.
344 | *
345 | * @param {number} num Value to be converted
346 | * @param {boolean} integer Convert the return value to an integer
347 | */
348 | convertNumber: function ( num, integer ) {
349 | var tmp, item, i,
350 | transformTable, numberString, convertedNumber;
351 |
352 | // Set the target Transform table:
353 | transformTable = this.digitTransformTable( $.i18n().locale );
354 | numberString = String( num );
355 | convertedNumber = '';
356 |
357 | if ( !transformTable ) {
358 | return num;
359 | }
360 |
361 | // Check if the restore to Latin number flag is set:
362 | if ( integer ) {
363 | if ( parseFloat( num, 10 ) === num ) {
364 | return num;
365 | }
366 |
367 | tmp = [];
368 |
369 | for ( item in transformTable ) {
370 | tmp[ transformTable[ item ] ] = item;
371 | }
372 |
373 | transformTable = tmp;
374 | }
375 |
376 | for ( i = 0; i < numberString.length; i++ ) {
377 | if ( transformTable[ numberString[ i ] ] ) {
378 | convertedNumber += transformTable[ numberString[ i ] ];
379 | } else {
380 | convertedNumber += numberString[ i ];
381 | }
382 | }
383 |
384 | return integer ? parseFloat( convertedNumber, 10 ) : convertedNumber;
385 | },
386 |
387 | /**
388 | * Grammatical transformations, needed for inflected languages.
389 | * Invoked by putting {{grammar:form|word}} in a message.
390 | * Override this method for languages that need special grammar rules
391 | * applied dynamically.
392 | *
393 | * @param {string} word
394 | * @param {string} form
395 | * @return {string}
396 | */
397 | convertGrammar: function ( word, form ) { /*jshint unused: false */
398 | return word;
399 | },
400 |
401 | /**
402 | * Provides an alternative text depending on specified gender. Usage
403 | * {{gender:[gender|user object]|masculine|feminine|neutral}}. If second
404 | * or third parameter are not specified, masculine is used.
405 | *
406 | * These details may be overriden per language.
407 | *
408 | * @param {string} gender
409 | * male, female, or anything else for neutral.
410 | * @param {Array} forms
411 | * List of gender forms
412 | *
413 | * @return {string}
414 | */
415 | gender: function ( gender, forms ) {
416 | if ( !forms || forms.length === 0 ) {
417 | return '';
418 | }
419 |
420 | while ( forms.length < 2 ) {
421 | forms.push( forms[ forms.length - 1 ] );
422 | }
423 |
424 | if ( gender === 'male' ) {
425 | return forms[ 0 ];
426 | }
427 |
428 | if ( gender === 'female' ) {
429 | return forms[ 1 ];
430 | }
431 |
432 | return ( forms.length === 3 ) ? forms[ 2 ] : forms[ 0 ];
433 | },
434 |
435 | /**
436 | * Get the digit transform table for the given language
437 | * See http://cldr.unicode.org/translation/numbering-systems
438 | *
439 | * @param {string} language
440 | * @return {Array|boolean} List of digits in the passed language or false
441 | * representation, or boolean false if there is no information.
442 | */
443 | digitTransformTable: function ( language ) {
444 | var tables = {
445 | ar: '٠١٢٣٤٥٦٧٨٩',
446 | fa: '۰۱۲۳۴۵۶۷۸۹',
447 | ml: '൦൧൨൩൪൫൬൭൮൯',
448 | kn: '೦೧೨೩೪೫೬೭೮೯',
449 | lo: '໐໑໒໓໔໕໖໗໘໙',
450 | or: '୦୧୨୩୪୫୬୭୮୯',
451 | kh: '០១២៣៤៥៦៧៨៩',
452 | pa: '੦੧੨੩੪੫੬੭੮੯',
453 | gu: '૦૧૨૩૪૫૬૭૮૯',
454 | hi: '०१२३४५६७८९',
455 | my: '၀၁၂၃၄၅၆၇၈၉',
456 | ta: '௦௧௨௩௪௫௬௭௮௯',
457 | te: '౦౧౨౩౪౫౬౭౮౯',
458 | th: '๐๑๒๓๔๕๖๗๘๙', // FIXME use iso 639 codes
459 | bo: '༠༡༢༣༤༥༦༧༨༩' // FIXME use iso 639 codes
460 | };
461 |
462 | if ( !tables[ language ] ) {
463 | return false;
464 | }
465 |
466 | return tables[ language ].split( '' );
467 | }
468 | };
469 |
470 | $.extend( $.i18n.languages, {
471 | 'default': language
472 | } );
473 | }( jQuery ) );
474 |
--------------------------------------------------------------------------------
/WebContent/assets/js/main.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var spinner_opts = {
3 | lines: 10 // The number of lines to draw
4 | ,
5 | length: 0 // The length of each line
6 | ,
7 | width: 6 // The line thickness
8 | ,
9 | radius: 10 // The radius of the inner circle
10 | ,
11 | scale: 1 // Scales overall size of the spinner
12 | ,
13 | corners: 1 // Corner roundness (0..1)
14 | ,
15 | color: '#fff' // #rgb or #rrggbb or array of colors
16 | ,
17 | opacity: 0 // Opacity of the lines
18 | ,
19 | rotate: 0 // The rotation offset
20 | ,
21 | direction: 1 // 1: clockwise, -1: counterclockwise
22 | ,
23 | speed: 2 // Rounds per second
24 | ,
25 | trail: 100 // Afterglow percentage
26 | ,
27 | fps: 20 // Frames per second when using setTimeout() as a fallback for
28 | // CSS
29 | ,
30 | zIndex: 2e9 // The z-index (defaults to 2000000000)
31 | ,
32 | className: 'spinner' // The CSS class to assign to the spinner
33 | ,
34 | top: '50%' // Top position relative to parent
35 | ,
36 | left: '50%' // Left position relative to parent
37 | ,
38 | shadow: true // Whether to render a shadow
39 | ,
40 | hwaccel: true // Whether to use hardware acceleration
41 | ,
42 | position: 'absolute' // Element positioning
43 | }
44 |
45 | function requestStatus(container) {
46 | var spinner = new Spinner(spinner_opts).spin();
47 | var status = container.find('p.status');
48 | var application = container.find('p.application');
49 |
50 | status.removeClass("alert alert-success");
51 | status.removeClass("alert alert-danger");
52 |
53 | application.removeClass("alert alert-success");
54 | application.removeClass("alert alert-warning");
55 | application.removeClass("alert alert-danger");
56 |
57 | status.after(spinner.el);
58 | status.html("");
59 | application.html("");
60 | $.ajax({
61 | type: "GET",
62 | url: "rest/status/get/" + container.data('ip'),
63 | beforeSend: function() {
64 | container.find(".panelrefresh").attr("disabled", "disabled");
65 | }
66 | }).done(function(data, textStatus, jqXHR) {
67 | var obj = JSON.parse(data);
68 | status.html(obj['status']);
69 | if (obj['status'] === "online") {
70 | status.addClass("alert alert-success");
71 | application.addClass("alert alert-success");
72 | // the Backdrop shall not be default ...
73 | if (obj['application'] === "Backdrop")
74 | application.addClass("alert alert-warning");
75 | application.html(obj['application']);
76 | if (obj['application'] == "chromecast-kiosk-web" && obj['application']) {
77 | application.html('' + obj['application'] + '');
78 | }
79 | } else {
80 | status.addClass("alert alert-danger");
81 | application.addClass("alert alert-danger");
82 | application.html("-");
83 | }
84 | }).fail(function(jqXHR, textStatus, errorThrown) {
85 | // TODO error
86 | console.log("error");
87 | }).always(function() {
88 | spinner.stop();
89 | container.find(".panelrefresh").removeAttr("disabled", "disabled");
90 | });
91 | }
92 |
93 | function requestEach() {
94 | $('.chromecastpanel').each(function() {
95 | var attr = $(this).find(".panelrefresh").attr('disabled');
96 | if (typeof attr !== typeof undefined && attr !== false) {
97 | // if its disabled do nothing
98 | } else {
99 | requestStatus($(this));
100 | }
101 | });
102 | }
103 |
104 | function addCast(ip, name) {
105 | $.ajax({
106 | type: "POST",
107 | url: "rest/settings/add/" + ip + "/" + name
108 | }).done(function(data, textStatus, jqXHR) {
109 | var obj = JSON.parse(data);
110 | if (obj['error']) {
111 | toastr['warning'](obj['error']);
112 | console.log("error:" + obj['error']);
113 | } else {
114 | location.reload();
115 | }
116 | }).fail(function(jqXHR, textStatus, errorThrown) {
117 | console.log("error");
118 | }).always(function() {
119 |
120 | });
121 | }
122 |
123 | $(document).ready(function() {
124 | requestEach();
125 |
126 | $('#addcastbutton').click(function(ev) {
127 | ev.preventDefault();
128 | var ip = $('#addip').val();
129 | var name = $('#addname').val();
130 | if (ip && name) {
131 | $('#addip').val("");
132 | $('#addname').val("");
133 | addCast(ip, name);
134 | }
135 | });
136 |
137 | $('.paneltrash').click(
138 | function(ev) {
139 | ev.preventDefault();
140 | $(this).parent().parent().parent().find(
141 | '.trashmsg').slideToggle();
142 | });
143 |
144 | $('a.option-info').click(function(ev) {
145 | ev.preventDefault();
146 | var ip = $(this).data("ip");
147 | if (ip) {
148 | $.ajax({
149 | type: "POST",
150 | url: "rest/settings/update/" + ip + "/false"
151 | }).done(function(data, textStatus, jqXHR) {
152 | var obj = JSON.parse(data);
153 | if (obj['error']) {
154 | toastr['warning'](obj['error']);
155 | } else {
156 | toastr['info']("change done");
157 | }
158 | }).fail(function(jqXHR, textStatus, errorThrown) {
159 | console.log("error");
160 | }).always(function() {
161 |
162 | });
163 | }
164 | });
165 |
166 | $('a.option-default').click(function(ev) {
167 | console.log("grrr");
168 | ev.preventDefault();
169 | var ip = $(this).data("ip");
170 | if (ip) {
171 | $.ajax({
172 | type: "POST",
173 | url: "rest/settings/update/" + ip + "/true"
174 | }).done(function(data, textStatus, jqXHR) {
175 | var obj = JSON.parse(data);
176 | if (obj['error']) {
177 | toastr['warning'](obj['error']);
178 | } else {
179 | //location.reload();
180 | toastr['info']("change done");
181 | }
182 | }).fail(function(jqXHR, textStatus, errorThrown) {
183 | console.log("error");
184 | }).always(function() {
185 |
186 | });
187 | }
188 | });
189 |
190 | $('.notrash').click(function(ev) {
191 | ev.preventDefault();
192 | $(this).parent().parent().slideToggle();
193 | });
194 |
195 | $('.yestrash').click(function(ev) {
196 | ev.preventDefault();
197 | var ip = $(this).data("ip");
198 | if (ip) {
199 | $.ajax({
200 | type: "DELETE",
201 | url: "rest/settings/remove/" + ip
202 | }).done(function(data, textStatus, jqXHR) {
203 | var obj = JSON.parse(data);
204 | if (obj['error']) {
205 | toastr['warning'](obj['error']);
206 | } else {
207 | location.reload();
208 | }
209 | }).fail(function(jqXHR, textStatus, errorThrown) {
210 | console.log("error");
211 | }).always(function() {
212 |
213 | });
214 | }
215 | });
216 |
217 | $('.panelrefresh').click(
218 | function(ev) {
219 | ev.preventDefault();
220 | requestStatus($(this).parent().parent()
221 | .parent().parent());
222 | });
223 |
224 | $('#refreshall').click(function(ev) {
225 | ev.preventDefault();
226 | requestEach();
227 | });
228 |
229 | $('#searchcasts').click(function(ev) {
230 | // ev.preventDefault();
231 |
232 | $.ajax({
233 | type: "GET",
234 | url: "rest/discovered/get",
235 | beforeSend: function() {
236 | $('#discoverchromecast').find('.modal-body').html("");
237 | }
238 | }).done(function(data, textStatus, jqXHR) {
239 | var obj = JSON.parse(data);
240 | $.each(obj, function(i, elem) {
241 | console.log(elem);
242 | var row = '