use minify in build script; add unicode module
This commit is contained in:
parent
6b2d26e950
commit
66b9d41450
331 changed files with 114865 additions and 147253 deletions
97
source/Ox.Unicode/Ox.Unicode.js
Normal file
97
source/Ox.Unicode/Ox.Unicode.js
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
Ox.load.Unicode = function(options, callback) {
|
||||
|
||||
Ox.getJSON(Ox.PATH + 'Ox.Unicode/json/Ox.Unicode.json', function(chars) {
|
||||
|
||||
//@ Ox.UNICODE_CHARACTERS <o> Unicode characters
|
||||
Ox.UNICODE_CHARACTERS = chars;
|
||||
|
||||
var byASCII = {}, byName = {}, bySection = [], byType = {};
|
||||
|
||||
Ox.forEach(chars, function(data, char) {
|
||||
if (data.ascii) {
|
||||
byASCII[data.ascii] = byASCII[data.ascii] || [];
|
||||
byASCII[data.ascii].push(char);
|
||||
}
|
||||
data.names.forEach(function(name) {
|
||||
byName[name] = char;
|
||||
});
|
||||
bySection[data.section] = bySection[data.section] || [];
|
||||
bySection[data.section].push(char);
|
||||
byType[data.type] = byType[data.type] || [];
|
||||
byType[data.type].push(char);
|
||||
});
|
||||
|
||||
/*@
|
||||
Ox.getCharactersByASCII <f> Returns all unicode equivalents of a given ASCII string
|
||||
(ascii) -> <[s]> Unicode Characters
|
||||
ascii <s> ASCII string
|
||||
> Ox.getCharactersByASCII('A').length
|
||||
36
|
||||
@*/
|
||||
Ox.getCharactersByASCII = function(ascii) {
|
||||
return byASCII[ascii] || '';
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.getCharacterByName <f> Returns a character for a given unicode name
|
||||
(name) -> <s> Character
|
||||
> Ox.getCharacterByName('Skull and Crossbones')
|
||||
'\u2620'
|
||||
@*/
|
||||
Ox.getCharacterByName = function(name) {
|
||||
return byName[name.toUpperCase()] || '';
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.getCharactersBySection <f> Returns all characters in a given section
|
||||
(section) -> <[s]> Characters
|
||||
section <s> Unicode section name
|
||||
> Ox.getCharactersBySection('Arabic').length
|
||||
252
|
||||
@*/
|
||||
Ox.getCharactersBySection = function(section) {
|
||||
return bySection[section.toUpperCase()] || '';
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.getCharactersByType <f> Returns all characters of a given type
|
||||
(type) -> <[s]> Characters
|
||||
type <s> Unicode character type
|
||||
> Ox.getCharactersByType('Uppercase Latin Alphabet').join('')
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
@*/
|
||||
Ox.getCharactersByType = function(type) {
|
||||
return byType[type.toUpperCase()] || '';
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.sortASCII <f> Sorts an array of unicode strings
|
||||
(arr) -> <[s]> Sorted array
|
||||
> Ox.sortASCII(['å', 'b', 'ç', 'd', 'é'])
|
||||
['å', 'b', 'ç', 'd', 'é']
|
||||
@*/
|
||||
Ox.sortASCII = function(arr) {
|
||||
return Ox.sort(arr, function(str) {
|
||||
return Ox.toASCII(str);
|
||||
});
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.toASCII <f> Replaces a unicode string with its ASCII equivalent
|
||||
(unicode) -> <s> ASCII string
|
||||
> Ox.toASCII('Åbçdé')
|
||||
'Abcde'
|
||||
> Ox.toASCII('\u2162 \u33a6')
|
||||
'3 km3'
|
||||
@*/
|
||||
Ox.toASCII = function(str) {
|
||||
return Ox.map(str, function(chr) {
|
||||
return chars[chr].ascii || chr;
|
||||
}).join('');
|
||||
};
|
||||
|
||||
callback(true);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
114626
source/Ox.Unicode/json/Ox.Unicode.json
Normal file
114626
source/Ox.Unicode/json/Ox.Unicode.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue