summaryrefslogtreecommitdiff
path: root/js/webtrees-1.5.0.js
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2013-10-05 20:49:25 +0100
committerGreg Roach <fisharebest@gmail.com>2013-10-05 20:49:25 +0100
commit1daf13e46df1fd903ab9a808585db166ec8e9fa6 (patch)
tree7c5113fe26ce75e8bd005ec87ed0b50cfab49b84 /js/webtrees-1.5.0.js
parentc3415972b7e001c67f34a4df4c792cd7b93c1d48 (diff)
downloadwebtrees-1daf13e46df1fd903ab9a808585db166ec8e9fa6.tar.gz
webtrees-1daf13e46df1fd903ab9a808585db166ec8e9fa6.tar.bz2
webtrees-1daf13e46df1fd903ab9a808585db166ec8e9fa6.zip
HTML validation
Diffstat (limited to 'js/webtrees-1.5.0.js')
-rw-r--r--js/webtrees-1.5.0.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/js/webtrees-1.5.0.js b/js/webtrees-1.5.0.js
index 16e6924898..0dae4fc883 100644
--- a/js/webtrees-1.5.0.js
+++ b/js/webtrees-1.5.0.js
@@ -1231,6 +1231,31 @@ function message(username, method, url) {
return false;
}
+function valid_lati_long(field, pos, neg) {
+ // valid LATI or LONG according to Gedcom standard
+ // pos (+) : N or E
+ // neg (-) : S or W
+ txt=field.value.toUpperCase();
+ txt=txt.replace(/(^\s*)|(\s*$)/g, ''); // trim
+ txt=txt.replace(/ /g, ':'); // N12 34 ==> N12.34
+ txt=txt.replace(/\+/g, ''); // +17.1234 ==> 17.1234
+ txt=txt.replace(/-/g, neg); // -0.5698 ==> W0.5698
+ txt=txt.replace(/,/g, '.'); // 0,5698 ==> 0.5698
+ // 0°34'11 ==> 0:34:11
+ txt=txt.replace(/\uB0/g, ':'); // °
+ txt=txt.replace(/\u27/g, ':'); // '
+ // 0:34:11.2W ==> W0.5698
+ txt=txt.replace(/^([0-9]+):([0-9]+):([0-9.]+)(.*)/g, function($0, $1, $2, $3, $4) { var n=parseFloat($1); n+=($2/60); n+=($3/3600); n=Math.round(n*1E4)/1E4; return $4+n; });
+ // 0:34W ==> W0.5667
+ txt=txt.replace(/^([0-9]+):([0-9]+)(.*)/g, function($0, $1, $2, $3) { var n=parseFloat($1); n+=($2/60); n=Math.round(n*1E4)/1E4; return $3+n; });
+ // 0.5698W ==> W0.5698
+ txt=txt.replace(/(.*)([N|S|E|W]+)$/g, '$2$1');
+ // 17.1234 ==> N17.1234
+ if (txt!='' && txt.charAt(0)!=neg && txt.charAt(0)!=pos) txt=pos+txt;
+ field.value = txt;
+}
+
+
// This is the default way for webtrees to show image galleries.
// Custom themes may use a different viewer.
function activate_colorbox(config) {