minor cleanup

This commit is contained in:
rolux 2012-05-25 13:42:33 +02:00
parent b1ff236b3f
commit e47f826329
4 changed files with 15 additions and 18 deletions

View file

@ -1,4 +1,5 @@
'use strict';
/*@
Ox.cache <f> Memoize a function
<script>

View file

@ -145,12 +145,12 @@
{lat: 0, lng: 0}
@*/
Ox.getLatLngByXY = function(xy) {
function getVal(val) {
return (val - 0.5) * 2 * Math.PI;
function getValue(value) {
return (value - 0.5) * 2 * Math.PI;
}
return {
lat: -Ox.deg(Math.atan(Ox.sinh(getVal(xy.y)))),
lng: Ox.deg(getVal(xy.x))
lat: -Ox.deg(Math.atan(Ox.sinh(getValue(xy.y)))),
lng: Ox.deg(getValue(xy.x))
};
};
@ -213,12 +213,12 @@
{x: 0.5, y: 0.5}
@*/
Ox.getXYByLatLng = function(latlng) {
function getVal(val) {
return (val / (2 * Math.PI) + 0.5)
function getValue(value) {
return (value / (2 * Math.PI) + 0.5);
}
return {
x: getVal(Ox.rad(latlng.lng)),
y: getVal(Ox.asinh(Math.tan(Ox.rad(-latlng.lat))))
x: getValue(Ox.rad(latlng.lng)),
y: getValue(Ox.asinh(Math.tan(Ox.rad(-latlng.lat))))
};
};

View file

@ -45,7 +45,6 @@ Ox.parseHTML <f> Takes HTML from an untrusted source and returns something sane
> Ox.parseHTML('<b>foo</b></b>')
'<b>foo</b>'
@*/
Ox.parseHTML = (function() {
var defaultTags = [
// inline formatting
@ -141,9 +140,9 @@ Ox.parseURL = (function() {
var a = document.createElement('a'),
keys = ['hash', 'host', 'hostname', 'origin',
'pathname', 'port', 'protocol', 'search'];
return function(str) {
return function(string) {
var ret = {};
a.href = str;
a.href = string;
keys.forEach(function(key) {
ret[key] = a[key];
});
@ -167,14 +166,10 @@ Ox.parseURLs <f> Takes HTML and turns URLs into links
Ox.parseURLs = function(html) {
return html.replace(
/\b((https?:\/\/|www\.).+?)([\.,:;!\?\)\]]*?(\s|$))/gi,
function(str, url, pre, end) {
url = (pre == 'www.' ? 'http://' : '' ) + url;
function(string, url, prefix, end) {
url = (prefix == 'www.' ? 'http://' : '') + url;
return Ox.formatString(
'<a href="{url}">{url}</a>{end}',
{
end: end,
url: url
}
'<a href="{url}">{url}</a>{end}', {end: end, url: url}
);
}
);

View file

@ -94,4 +94,5 @@ Ox.oshash = function(file, callback) {
}
reader.readAsBinaryString(blob);
}
};