source: Dev/branches/rest-dojo-ui/client/util/buildscripts/cldr/cldrUtil.js @ 257

Last change on this file since 257 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.5 KB
Line 
1// monkey-patch dojo.xhrGet, as there is no Rhino support there
2dojo.xhrGet = function(args){
3    args.load(readFile(args.url, "utf-8"));
4};
5
6(function(){
7        // monkey patch fromJson to avoid Rhino bug in eval: https://bugzilla.mozilla.org/show_bug.cgi?id=471005
8        var fromJson = dojo.fromJson;
9        dojo.fromJson = function(json){
10                json = json.replace(/[\u200E\u200F\u202A-\u202E]/g, function(match){
11                        return "\\u" + match.charCodeAt(0).toString(16);
12                })
13                return json ? fromJson(json) : ""; //TODO: json value passed in shouldn't be empty
14        }
15})();
16
17function isLocaleAliasSrc(prop, bundle){
18        if(!bundle){ return false; }
19        var isAlias = false;
20        var LOCALE_ALIAS_MARK = '@localeAlias';
21
22        for(x in bundle){
23                if(x.indexOf(LOCALE_ALIAS_MARK) > 0){
24                        var prefix = x.substring(0,x.indexOf(LOCALE_ALIAS_MARK));
25                        if(prop.indexOf(prefix) == 0){
26                                isAlias = true;
27                        }
28                }
29        }
30        return isAlias;
31}
32
33function getNativeBundle(filePath){
34        //summary: get native bundle content with utf-8 encoding
35        //      native means the content of this bundle is not flattened with parent
36        //      returns empty object if file not found
37        try{
38                var content = readFile(filePath, "utf-8");
39                return (!content || !content.length) ? {} : dojo.fromJson(content);
40        }catch(e){
41                return {};
42        }
43}
44
45function compare(a/*String or Array*/, b/*String or Array*/){
46        //summary: simple comparison
47        if(dojo.isArray(a) && dojo.isArray(b)){
48                for(var i = 0; i < a.length; i++){
49                        if(a[i] != b[i]){ return false; }
50                }
51                return true;
52        }
53        return a==b;
54}
Note: See TracBrowser for help on using the repository browser.