[Picfinity-commit] SF.net SVN: picfinity: [65] trunk/.themes/db/db.js
Status: Beta
Brought to you by:
espadav8
From: <esp...@us...> - 2007-09-02 17:31:09
|
Revision: 65 http://picfinity.svn.sourceforge.net/picfinity/?rev=65&view=rev Author: espadav8 Date: 2007-09-02 10:30:38 -0700 (Sun, 02 Sep 2007) Log Message: ----------- Move the creation of xmlHttp's to a function This now allows the commenting system to work in IE6/7 Modified Paths: -------------- trunk/.themes/db/db.js Modified: trunk/.themes/db/db.js =================================================================== --- trunk/.themes/db/db.js 2007-09-02 17:29:00 UTC (rev 64) +++ trunk/.themes/db/db.js 2007-09-02 17:30:38 UTC (rev 65) @@ -25,9 +25,9 @@ function importLayout() { - if (window.XMLHttpRequest) + var xmlHttp = createHttpRequest(); + if (xmlHttp) { - var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { @@ -35,24 +35,35 @@ } } xmlHttp.open("GET", "gallery.xml", true); - xmlHttp.send(null) + xmlHttp.send(null); } +} + +function createHttpRequest() +{ + if (window.XMLHttpRequest) + { + alert("returning window.XMLHttpRequest"); + return new XMLHttpRequest(); + } else if (document.implementation && document.implementation.createDocument) { - xmlDoc = document.implementation.createDocument("", "layout", null); - xmlDoc.load("gallery.xml"); + alert("returning document.implementation.createDocument"); + return document.implementation.createDocument("", "layout", null); } else if (window.ActiveXObject) { - xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); - xmlDoc.validateOnParse = false; - xmlDoc.resolveExternals = false; - xmlDoc.load("gallery.xml"); + alert("returning ActiveXObject(\"Microsoft.XMLHTTP\")"); + var tmpHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); + // tmpHttpReq.validateOnParse = false; + // tmpHttpReq.resolveExternals = false; + + return tmpHttpReq; } else { alert('Your browser can\'t handle this script'); - return; + return null; } } @@ -759,11 +770,12 @@ function getCommentsXML(imageID) { - if (window.XMLHttpRequest) + xmlHttp = createHttpRequest(); + + if (xmlHttp) { - xmlHttp = new XMLHttpRequest(); - // xmlHttp.onprogress = commentsProgress; - xmlHttp.onreadystatechange = function() { + xmlHttp.onreadystatechange = function() + { if (xmlHttp.readyState == 4) { createCommentsSection(); @@ -887,8 +899,10 @@ function addNewComment() { - if (window.XMLHttpRequest) - { + xmlHttp = createHttpRequest(); + + if(xmlHttp) + { var commentForm = document.getElementById("commentform").getElementsByTagName("form")[0]; var postData = "image_id=" + commentForm.image_id.value + "&" @@ -897,8 +911,6 @@ + "email=" + commentForm.user_email.value + "&" + "web=" + commentForm.user_web.value + "&" + "comment=" + encodeURIComponent(commentForm.user_comment.value); - - xmlHttp = new XMLHttpRequest(); xmlHttp.open("POST", ".themes/db/addComment.php", true); xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); @@ -911,9 +923,8 @@ } } xmlHttp.send(postData); - return false; } - return true; + return false; } function checkAddedCommentReply(imageID) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |