')
- .css({
- width: window.innerWidth,
- height: window.innerHeight,
- overflowY: 'scroll'
- })
- .appendTo(Ox.UI.$body);
- Ox.test(Ox.PATH + 'Ox.js', function(tests) {
- var total = tests.length,
- succeeded = tests.filter(function(test) {
- return test.success;
- }).length,
- failed = total - succeeded,
- names = Ox.unique(tests.map(function(test) {
- return test.name;
- })).sort();
- testsByName = {};
- tests.forEach(function(test) {
- if (!(test.name in testsByName)) {
- testsByName[test.name] = [];
- }
- testsByName[test.name].push(test);
+ Ox.load('Geo', function() {
+ var $div = $('
')
+ .css({
+ width: window.innerWidth,
+ height: window.innerHeight,
+ overflowY: 'scroll'
+ })
+ .appendTo(Ox.UI.$body),
+ colors = [
+ [[255, 64, 64], [224, 32, 32]],
+ [[64, 192, 64], [32, 160, 32]]
+ ],
+ counter = 0,
+ files = [
+ Ox.PATH + 'Ox.js',
+ Ox.PATH + 'Ox.Geo/Ox.Geo.js'
+ ],
+ tests = [];
+ files.forEach(function(file) {
+ Ox.test(file, function(fileTests) {
+ tests = Ox.merge(tests, fileTests);
+ if (++counter == files.length) {
+ renderTests();
+ }
+ });
});
- getBar(total == succeeded)
- .html(
- '
' + total + ' tests, ' +
- succeeded + ' succeeded, ' + failed + ' failed'
- )
- .appendTo($foo);
- names.forEach(function(name) {
- var tests = testsByName[name],
- total = tests.length,
+ function renderTests() {
+ var total = tests.length,
succeeded = tests.filter(function(test) {
return test.success;
}).length,
failed = total - succeeded,
- classname = name.replace('.', '');
+ names = Ox.unique(tests.map(function(test) {
+ return test.name;
+ })).sort();
+ testsByName = {};
+ tests.forEach(function(test) {
+ if (!(test.name in testsByName)) {
+ testsByName[test.name] = [];
+ }
+ testsByName[test.name].push(test);
+ });
getBar(total == succeeded)
.html(
- '
' + name + ' — ' + total +
- ' test' + (total == 1 ? '' : 's') + ', ' +
+ '
' + total + ' tests, ' +
succeeded + ' succeeded, ' + failed + ' failed'
)
- .click(function() {
- $('.' + classname).toggle();
- })
- .appendTo($foo);
- tests.forEach(function(test) {
- getBar(test.success, true)
- .addClass(classname)
+ .appendTo($div);
+ names.forEach(function(name) {
+ var tests = testsByName[name],
+ total = tests.length,
+ succeeded = tests.filter(function(test) {
+ return test.success;
+ }).length,
+ failed = total - succeeded,
+ classname = name.replace('.', '');
+ getBar(total == succeeded)
.html(
- Ox.repeat(' ', 4) +
- '
> ' + Ox.encodeHTML(test.statement) + ' ==> ' +
- (test.success ? '' : Ox.encodeHTML(test.actual) + ' !=> ') +
- Ox.encodeHTML(test.expected)
+ '
' + name + ' — ' + total +
+ ' test' + (total == 1 ? '' : 's') + ', ' +
+ succeeded + ' succeeded, ' + failed + ' failed'
)
- .hide()
- .appendTo($foo);
+ .click(function() {
+ $('.' + classname).toggle();
+ })
+ .appendTo($div);
+ tests.forEach(function(test) {
+ getBar(test.success, true)
+ .addClass(classname)
+ .html(
+ Ox.repeat(' ', 4) +
+ '
> ' + Ox.encodeHTML(test.statement) + ' ==> ' +
+ (test.success ? '' : Ox.encodeHTML(test.actual) + ' !=> ') +
+ Ox.encodeHTML(test.expected)
+ )
+ .hide()
+ .appendTo($div);
+ });
});
- });
- });
- function getBar(success, darker) {
- var $div = $('
')
- .css({
- width: window.innerWidth - Ox.UI.SCROLLBAR_SIZE,
- height: '15px',
- padding: '4px 8px 4px 8px',
- fontFamily: 'Menlo, Monaco, Courier',
- fontSize: '12px',
- whiteSpace: 'nowrap',
- MozUserSelect: 'text',
- WebkitUserSelect: 'text'
- });
- gradients.forEach(function(gradient) {
- $div.css({
- background: gradient + 'left top, left bottom, from(rgb(' +
- getColor(success, 0) + ')), to(rgb(' +
- getColor(success, 1) + ')))'
- });
- });
- function getColor(success, i) {
- return colors[+success][i].map(function(color) {
- return color - (darker || 0) * 32;
- }).join(', ')
}
- return $div;
- }
-});
\ No newline at end of file
+ function getBar(success, darker) {
+ var $div = $('
')
+ .css({
+ width: window.innerWidth - Ox.UI.SCROLLBAR_SIZE,
+ height: '15px',
+ padding: '4px 8px 4px 8px',
+ fontFamily: 'Menlo, Monaco, Courier',
+ fontSize: '12px',
+ whiteSpace: 'nowrap',
+ MozUserSelect: 'text',
+ WebkitUserSelect: 'text'
+ });
+ ['moz', 'webkit'].forEach(function(browser) {
+ Ox.print('-' + browser + '-linear-gradient(left top, left bottom, rgb(' +
+ getColor(success, 0) + '), rgb(' +
+ getColor(success, 1) + '))')
+ $div.css({
+ background: '-' + browser + '-linear-gradient(top, rgb(' +
+ getColor(success, 0) + '), rgb(' +
+ getColor(success, 1) + '))'
+ });
+ });
+ function getColor(success, i) {
+ return colors[+success][i].map(function(color) {
+ return color - (darker || 0) * 32;
+ }).join(', ')
+ }
+ return $div;
+ }
+ });
+});
diff --git a/source/Ox.Geo/Ox.Geo.js b/source/Ox.Geo/Ox.Geo.js
index 77deef5f..d79d5b2c 100644
--- a/source/Ox.Geo/Ox.Geo.js
+++ b/source/Ox.Geo/Ox.Geo.js
@@ -2,8 +2,79 @@ Ox.load.Geo = function(options, callback) {
Ox.getJSON(Ox.PATH + 'Ox.Geo/json/Ox.Geo.json', function(data) {
+ //@ Constants ----------------------------------------------------------
+
+ /*@
+ Ox.COUNTRIES <[o]> Array of countries
+ area Area of the country in square meters
+ code ISO 3166 country code
+ dependencies <[s]> Array of dependencies of the country (country codes)
+ dependency <[s]> Array of countries the country is a dependency of (country codes)
+ east Longitude of eastern boundary in deg
+ former True if the country is a former country
+ imageURLs Collection of dataURLs
+ marker Map marker
+ imdbCode IMDb country code
+ imdbName IMDb country name
+ lat Latitude of the center in deg
+ lng Longitude of the center in deg
+ name Name
+ north Latitude of northern boundary in deg
+ other True if the country is an "other entity" (EU, FX, UK)
+ south Latitude of southern boundary in deg
+ wikipediaURL URL of the wikipedia article for the country
+ west Longitude of western boundary in deg
+
+ > Ox.COUNTRIES.length
+ 311
+ > Ox.sum(Ox.test.array)
+ 311
+ > Ox.test.array
+ [15, 189, 74, 1, 16, 13, 3]
+ @*/
Ox.COUNTRIES = data;
+ //@ Functions ----------------------------------------------------------
+
+ /*@
+ Ox.getCountryByCode Returns a country object for a given country code
+ (code) -> Country object
+ code ISO 3166 country code
+ > Ox.getCountryByCode('US').name
+ 'United States'
+ @*/
+
Ox.getCountryByCode = function(code) {
var country;
Ox.forEach(Ox.COUNTRIES, function(c) {
@@ -15,6 +86,14 @@ Ox.load.Geo = function(options, callback) {
return country;
};
+ /*@
+ Ox.getCountryByName Returns a country object for a given country name
+ (name) -> Country object
+ name Country name
+ > Ox.getCountryByName('United States').code
+ 'US'
+ @*/
+
Ox.getCountryByName = function(name) {
var country;
Ox.forEach(Ox.COUNTRIES, function(c) {
diff --git a/source/Ox.UI/js/Video/Ox.BlockTimeline.js b/source/Ox.UI/js/Video/Ox.BlockTimeline.js
index efab3707..b88b6dbd 100644
--- a/source/Ox.UI/js/Video/Ox.BlockTimeline.js
+++ b/source/Ox.UI/js/Video/Ox.BlockTimeline.js
@@ -274,7 +274,8 @@ Ox.BlockTimeline = function(options, self) {
self.$tooltip.options({
title: subtitle ?
'' +
- Ox.highlight(subtitle.value, self.options.find).replace(/\n/g, '
') + '
' +
+ Ox.highlight(subtitle.value, self.options.find, 'OxHighlight').replace(/\n/g, '
') +
+ '
' +
Ox.formatDuration(subtitle['in'], 3) + ' - ' + Ox.formatDuration(subtitle['out'], 3) :
Ox.formatDuration(position, 3)
})
diff --git a/source/Ox.UI/js/Video/Ox.LargeTimeline.js b/source/Ox.UI/js/Video/Ox.LargeTimeline.js
index 2ffb600d..04a7e56c 100644
--- a/source/Ox.UI/js/Video/Ox.LargeTimeline.js
+++ b/source/Ox.UI/js/Video/Ox.LargeTimeline.js
@@ -54,7 +54,7 @@ Ox.LargeTimeline = function(options, self) {
left: (v['in'] * self.fps) + 'px',
width: (((v['out'] - v['in']) * self.fps) - 2) + 'px'
})
- .html(Ox.highlight(v.value, self.options.find))
+ .html(Ox.highlight(v.value, self.options.find, 'OxHighlight'))
.appendTo(self.$timeline)
});
diff --git a/source/Ox.UI/js/Video/Ox.SmallTimeline.js b/source/Ox.UI/js/Video/Ox.SmallTimeline.js
index 083ae5b3..c5bf0369 100644
--- a/source/Ox.UI/js/Video/Ox.SmallTimeline.js
+++ b/source/Ox.UI/js/Video/Ox.SmallTimeline.js
@@ -130,7 +130,8 @@ Ox.SmallTimeline = function(options, self) {
self.$tooltip.options({
title: subtitle ?
'' +
- Ox.highlight(subtitle.value, self.options.find).replace(/\n/g, '
') + '
' +
+ Ox.highlight(subtitle.value, self.options.find, 'OxHighlight').replace(/\n/g, '
') +
+ '
' +
Ox.formatDuration(subtitle['in'], 3) + ' - ' + Ox.formatDuration(subtitle['out'], 3) :
Ox.formatDuration(position, 3)
})
diff --git a/source/Ox.UI/js/Video/Ox.VideoEditorPlayer.js b/source/Ox.UI/js/Video/Ox.VideoEditorPlayer.js
index 7d27fc8a..aa138cb5 100644
--- a/source/Ox.UI/js/Video/Ox.VideoEditorPlayer.js
+++ b/source/Ox.UI/js/Video/Ox.VideoEditorPlayer.js
@@ -320,7 +320,10 @@ Ox.VideoEditorPlayer = function(options, self) {
var subtitle = getSubtitle();
if (subtitle != self.subtitle) {
self.subtitle = subtitle;
- self.$subtitle.html(Ox.highlight(self.subtitle, self.options.find).replace(/\n/g, '
'));
+ self.$subtitle.html(
+ Ox.highlight(self.subtitle, self.options.find, 'Ox.Highlight')
+ .replace(/\n/g, '
')
+ );
}
}
diff --git a/source/Ox.js b/source/Ox.js
index 305c6435..c982ce01 100644
--- a/source/Ox.js
+++ b/source/Ox.js
@@ -2903,7 +2903,6 @@ Ox.doc = (function() {
}
function parseNode(node) {
var item = parseItem(node.line), subitem;
- Ox.print(node, node.line, 'item', item);
node.nodes && node.nodes.forEach(function(node) {
var key, line = node.line, subitem;
if (!/^#/.test(node.line)) {
@@ -2946,10 +2945,8 @@ Ox.doc = (function() {
}
function parseTest(str) {
var lines = decodeLinebreaks(str).split('\n');
- Ox.print('$$$', str)
return {
statement: lines[0].substr(2),
- // result: JSON.parse(lines[1].trim())
result: lines[1].trim()
};
}
@@ -3144,7 +3141,6 @@ Ox.test = function(file, callback) {
var tests = [];
items.forEach(function(item) {
item.examples && item.examples.forEach(function(example) {
- Ox.print(example)
var actual = eval(example.statement);
if (example.result) {
tests.push({
@@ -3859,12 +3855,16 @@ Ox.endsWith = function(str, sub) {
return str.substr(str.length - sub.length) == sub;
};
-Ox.highlight = function(txt, str) {
- // fixme: move to ox.ui
- return str ? txt.replace(
+/*@
+Ox.highlight Highlight matches in a string
+ > Ox.highlight('foobar', 'foo', 'match')
+ 'foobar'
+@*/
+Ox.highlight = function(txt, str, classname) {
+ return txt.replace(
new RegExp('(' + str + ')', 'ig'),
- '$1'
- ) : txt;
+ '$1'
+ );
};
/*@
@@ -4028,7 +4028,7 @@ Ox.toCamelCase Takes a string with '-', '/' or '_', returns a camelCase stri
@*/
Ox.toCamelCase = function(str) {
- return str.replace(/[\-_\/][a-z]/g, function(str) {
+ return str.replace(/[\-\/_][a-z]/g, function(str) {
return str[1].toUpperCase();
});
};