summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Noorenberghe <github@matthew.noorenberghe.com>2014-02-23 00:52:37 -0800
committerMatthew Noorenberghe <github@matthew.noorenberghe.com>2014-02-23 00:53:48 -0800
commit95a243753614b21a165966c589780706a31ed53f (patch)
tree2bd4b65e04a6c254ecc60ce939fc2327927489bf
parent7348059e9ab05dcecb9f4dcffc9fbd3c28fae364 (diff)
downloadwebtrees-95a243753614b21a165966c589780706a31ed53f.tar.gz
webtrees-95a243753614b21a165966c589780706a31ed53f.tar.bz2
webtrees-95a243753614b21a165966c589780706a31ed53f.zip
Switch from browser detection using document.all to feature detection
-rw-r--r--find.php21
-rw-r--r--lifespan.php6
-rw-r--r--modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php37
3 files changed, 29 insertions, 35 deletions
diff --git a/find.php b/find.php
index 287f66476c..f931f2c320 100644
--- a/find.php
+++ b/find.php
@@ -334,23 +334,12 @@ if ($type == "facts") {
DefaultTag.prototype= {
_newCounter:0
,view:function() {
- var row=document.createElement("tr"),cell,o;
+ var row=document.createElement("tr"),cell;
row.appendChild(cell=document.createElement("td"));
- o=null;
- if (document.all) {
- //Old IEs handle the creation of a checkbox already checked, as far as I know, only in this way
- try {
- o=document.createElement("<input type='checkbox' id='tag"+this._counter+"' "+(this.selected?"checked='checked'":"")+">");
- } catch(e) {
- o=null;
- }
- }
- if (!o) {
- o=document.createElement("input");
- o.setAttribute("id","tag"+this._counter);
- o.setAttribute("type","checkbox");
- if (this.selected) o.setAttribute("checked", "checked");
- }
+ var o = document.createElement("input");
+ o.id = "tag"+this._counter;
+ o.type = "checkbox";
+ o.checked = this.selected;
o.DefaultTag=this;
o.ParentRow=row;
o.onclick=function() {
diff --git a/lifespan.php b/lifespan.php
index cd775c4d7d..1524ac47a4 100644
--- a/lifespan.php
+++ b/lifespan.php
@@ -98,10 +98,11 @@ $controller
}
// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
- if (IE) { // grab the x-y pos.s if browser is IE
+ var event = e || window.event;
+ if (typeof event.pageX === "undefined" || typeof event.pageY === "undefined") {
msX = event.clientX + document.documentElement.scrollLeft;
msY = event.clientY + document.documentElement.scrollTop;
- } else { // grab the x-y pos.s if browser is NS
+ } else {
msX = e.pageX;
msY = e.pageY;
}
@@ -124,7 +125,6 @@ $controller
}
}
- var IE = document.all?true:false;
document.onmousemove = getMouseXY;
document.onmouseup = releaseimage;
');
diff --git a/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php b/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php
index ec04709d2d..a6bf55a1b1 100644
--- a/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php
+++ b/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php
@@ -270,10 +270,10 @@ function insertRowToTable(pid, nam, head)
var numrows = links.rows.length;
var strRow = '';
for (var i=1; i<numrows; i++) {
- if (document.all) { // If Internet Explorer
- strRow += (strRow==''?'':', ') + links.rows[i].cells[1].innerText;
- } else {
+ if (typeof links.rows[i].cells[1].textContent !== "undefined") {
strRow += (strRow==''?'':', ') + links.rows[i].cells[1].textContent;
+ } else {
+ strRow += (strRow==''?'':', ') + links.rows[i].cells[1].innerText;
}
}
strRow += (strRow==''?'':', ');
@@ -287,8 +287,14 @@ function insertRowToTable(pid, nam, head)
// Check if id exists in "Add links" list ==========================
for (var i=0; i<tbl.tBodies[0].rows.length; i++) {
- if (tbl.tBodies[0].rows[i].myRow.one.textContent==pid) {
- rowToInsertAt = 'EXIST' ;
+ var cellText;
+ if (typeof tbl.tBodies[0].rows[i].myRow.one.textContent !== "undefined") {
+ cellText = tbl.tBodies[0].rows[i].myRow.one.textContent;
+ } else {
+ cellText = tbl.tBodies[0].rows[i].myRow.one.innerText;
+ }
+ if (cellText==pid) {
+ rowToInsertAt = 'EXIST';
} else
if (tbl.tBodies[0].rows[i].myRow && tbl.tBodies[0].rows[i].myRow.ra.getAttribute('type') == 'radio' && tbl.tBodies[0].rows[i].myRow.ra.checked) {
rowToInsertAt = i;
@@ -311,14 +317,10 @@ function removeHTMLTags(htmlString)
if (htmlString) {
var mydiv = document.createElement("div");
mydiv.innerHTML = htmlString;
- if (document.all) // IE Stuff
- {
- return mydiv.innerText;
- }
- else // Mozilla does not work with innerText
- {
+ if (typeof mydiv.textContent !== "undefined") {
return mydiv.textContent;
}
+ return mydiv.innerText;
}
}
@@ -367,8 +369,11 @@ function addRowToTable(num, pid, nam, head)
} else {
var txtInp1 = document.createElement('div');
txtInp1.setAttribute('type', 'text');
- txtInp1.innerHTML = pid; // Required for IE
- txtInp1.textContent = pid;
+ if (typeof txtInp1.textContent !== "undefined") {
+ txtInp1.textContent = pid;
+ } else {
+ txtInp1.innerText = pid;
+ }
}
txtInp1.setAttribute('id', INPUT_NAME_PREFIX + iteration + '_1');
txtInp1.style.background='transparent';
@@ -532,10 +537,10 @@ function parseAddLinks() {
var tbl = document.getElementById('addlinkQueue');
for (var i=1; i<tbl.rows.length; i++) { // start at i=1 because we need to avoid header
var tr = tbl.rows[i];
- if (document.all) { // If internet explorer
- str += (str==''?'':',') + tr.cells[1].childNodes[0].innerHTML;
- } else {
+ if (typeof tr.cells[1].childNodes[0].textContent !== "undefined") {
str += (str==''?'':',') + tr.cells[1].childNodes[0].textContent;
+ } else {
+ str += (str==''?'':',') + tr.cells[1].childNodes[0].innerHTML;
}
}
document.link.more_links.value = str;