Thread: [Picfinity-commit] SF.net SVN: picfinity: [60] trunk/.themes/db/db.js
Status: Beta
Brought to you by:
espadav8
From: <esp...@us...> - 2007-08-26 11:16:56
|
Revision: 60 http://picfinity.svn.sourceforge.net/picfinity/?rev=60&view=rev Author: espadav8 Date: 2007-08-26 04:16:59 -0700 (Sun, 26 Aug 2007) Log Message: ----------- Use setAttribute for the buttons type, fixes a bug in Opera Remove a few unneeded vars When closing an image, only try and remove the comments if they exist Don't give focus to the first input on the form since it's a hidden input Modified Paths: -------------- trunk/.themes/db/db.js Modified: trunk/.themes/db/db.js =================================================================== --- trunk/.themes/db/db.js 2007-08-25 15:31:09 UTC (rev 59) +++ trunk/.themes/db/db.js 2007-08-26 11:16:59 UTC (rev 60) @@ -415,6 +415,7 @@ expandedImage.src = imageThumbPath; return expandedImageDiv; + } function createCommentForm(imageID) @@ -506,7 +507,7 @@ { var tmpButton = document.createElement("button"); tmpButton.appendChild(document.createTextNode(buttonText)); - tmpButton.type = buttonType; + tmpButton.setAttribute("type", buttonType); return tmpButton; } @@ -684,12 +685,8 @@ function showImage(imageID) { - var siblingNodes = getChildNodesByTagName(getLayoutNode(imageID).parentNode, "image"); - var expandedImage = createExpandedImage(getLayoutNode(imageID)); - // var imageComments = createComments(siblingNodes[i]); - if (document.getElementById("expandedimage")) { document.getElementById("expandedimage").parentNode.replaceChild(expandedImage, document.getElementById("expandedimage")); @@ -701,7 +698,9 @@ // remove the old comments if (document.getElementById("comments")) + { document.getElementById("comments").parentNode.removeChild(document.getElementById("comments")); + } getCommentsXML(imageID); @@ -717,13 +716,21 @@ function closeImage() { - document.getElementById("expandedimage").parentNode.removeChild(document.getElementById("expandedimage")); - document.getElementById("comments").parentNode.removeChild(document.getElementById("comments")); + if (document.getElementById("expandedimage")) + { + document.getElementById("expandedimage").parentNode.removeChild(document.getElementById("expandedimage")); + } + if (document.getElementById("comments")) + { + document.getElementById("comments").parentNode.removeChild(document.getElementById("comments")); + } var lastSelectedImage = getElementsByClassName("selected", "div", document); if (lastSelectedImage) + { lastSelectedImage[0].className = "thumbnail"; + } } function getCommentsXML(imageID) @@ -731,7 +738,7 @@ if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); - xmlHttp.onprogress = commentsProgress; + // xmlHttp.onprogress = commentsProgress; xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { @@ -842,7 +849,6 @@ else { commentForm.style.display = ""; - commentForm.getElementsByTagName("input")[0].focus(); } } @@ -940,4 +946,4 @@ ((path) ? ';path=' + path : '') + ((domain) ? ';domain=' + domain : '') + ';expires=Thu, 01-Jan-1970 00:00:01 GMT'; -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-09-01 16:16:32
|
Revision: 61 http://picfinity.svn.sourceforge.net/picfinity/?rev=61&view=rev Author: espadav8 Date: 2007-09-01 09:16:32 -0700 (Sat, 01 Sep 2007) Log Message: ----------- Set the correct action for the comments form Only set up the comments div if there are comments returned Use .firstChild.nodeValue instead if .textContent since IE doesn't support that If the comments div already exists then replace it (used to reload the comments when a new one has been posted) Modified Paths: -------------- trunk/.themes/db/db.js Modified: trunk/.themes/db/db.js =================================================================== --- trunk/.themes/db/db.js 2007-08-26 11:16:59 UTC (rev 60) +++ trunk/.themes/db/db.js 2007-09-01 16:16:32 UTC (rev 61) @@ -434,7 +434,7 @@ var commentForm = document.createElement("form"); commentForm.onsubmit = addNewComment; - commentForm.action = ".themes/db/postComment.php"; + commentForm.action = ".themes/db/addComment.php"; commentForm.style.display = "none"; var commentFormFieldset = document.createElement("fieldset"); @@ -746,7 +746,7 @@ } } xmlHttp.open("GET", ".themes/db/getcomments.php?md5=" + imageID, true); - xmlHttp.send(null) + xmlHttp.send(null); } } @@ -759,85 +759,88 @@ { var comments = xmlHttp.responseXML.documentElement; - var commentsDiv = document.createElement("div"); - commentsDiv.setAttribute("id", "comments"); - - for (var i = 0; i < comments.childNodes.length; i++) + if (comments.childNodes.length > 0) { - var currentComment = comments.childNodes[i]; + var commentsDiv = document.createElement("div"); + commentsDiv.setAttribute("id", "comments"); - var comment = document.createElement("div"); - comment.className = "comment"; - if (i % 2) comment.className += " odd"; + for (var i = 0; i < comments.childNodes.length; i++) + { + var currentComment = comments.childNodes[i]; - var commentOwner = document.createElement("span"); - commentOwner.className = "name"; - var commentOwnerAnchor = document.createElement("a"); - commentOwner.appendChild(commentOwnerAnchor); + var comment = document.createElement("div"); + comment.className = "comment"; + if (i % 2) comment.className += " odd"; - var commentOwnerWeb = document.createElement("span"); - commentOwnerWeb.className = "web"; - var commentOwnerWebAnchor = document.createElement("a"); - commentOwnerWeb.appendChild(commentOwnerWebAnchor); + var commentOwner = document.createElement("span"); + commentOwner.className = "name"; + var commentOwnerAnchor = document.createElement("a"); + commentOwner.appendChild(commentOwnerAnchor); - var commentRating = document.createElement("span"); - commentRating.className = "rating"; + var commentOwnerWeb = document.createElement("span"); + commentOwnerWeb.className = "web"; + var commentOwnerWebAnchor = document.createElement("a"); + commentOwnerWeb.appendChild(commentOwnerWebAnchor); - var commentContents = document.createElement("span"); - commentContents.className = "commenttext"; + var commentRating = document.createElement("span"); + commentRating.className = "rating"; - var commentDate = document.createElement("span"); - commentDate.className = "date"; + var commentContents = document.createElement("span"); + commentContents.className = "commenttext"; - for (var j = 0; j < currentComment.childNodes.length; j++) - { - var currentNodeName = currentComment.childNodes[j].nodeName; - var currentNodeValue = currentComment.childNodes[j].textContent; + var commentDate = document.createElement("span"); + commentDate.className = "date"; - if (currentNodeName == "name") + for (var j = 0; j < currentComment.childNodes.length; j++) { - commentOwnerAnchor.appendChild(document.createTextNode(currentNodeValue)); + var currentNodeName = currentComment.childNodes[j].nodeName; + var currentNodeValue = currentComment.childNodes[j].firstChild.nodeValue; + + if (currentNodeName == "name") + { + commentOwnerAnchor.appendChild(document.createTextNode(currentNodeValue)); + } + else if (currentNodeName == "www") + { + commentOwnerWebAnchor.appendChild(document.createTextNode(currentNodeValue)); + commentOwnerWebAnchor.setAttribute("href", "http://" + currentNodeValue); + } + else if (currentNodeName == "email") + { + commentOwnerAnchor.setAttribute("href", "mailto:" + currentNodeValue); + } + else if (currentNodeName == "rating") + { + commentRating.appendChild(document.createTextNode(currentNodeValue)); + } + else if (currentNodeName == "comment_text") + { + commentContents.appendChild(document.createTextNode(currentNodeValue)); + } + else if (currentNodeName == "added") + { + commentDate.appendChild(document.createTextNode(currentNodeValue)); + } } - else if (currentNodeName == "www") - { - commentOwnerWebAnchor.appendChild(document.createTextNode(currentNodeValue)); - commentOwnerWebAnchor.setAttribute("href", "http://" + currentNodeValue); - } - else if (currentNodeName == "email") - { - commentOwnerAnchor.setAttribute("href", "mailto:" + currentNodeValue); - } - else if (currentNodeName == "rating") - { - commentRating.appendChild(document.createTextNode(currentNodeValue)); - } - else if (currentNodeName == "comment_text") - { - commentContents.appendChild(document.createTextNode(currentNodeValue)); - } - else if (currentNodeName == "added") - { - commentDate.appendChild(document.createTextNode(currentNodeValue)); - } - } - comment.appendChild(commentDate); - comment.appendChild(commentOwner); - comment.appendChild(commentOwnerWeb); - comment.appendChild(commentContents); - comment.appendChild(commentRating); + comment.appendChild(commentDate); + comment.appendChild(commentOwner); + comment.appendChild(commentOwnerWeb); + comment.appendChild(commentContents); + comment.appendChild(commentRating); - commentsDiv.appendChild(comment); - } + commentsDiv.appendChild(comment); + } - if (document.getElementById("comments")) - { - document.getElementById("comments").parentNode.replaceChild(commentsDiv, document.getElementById("comments")); + if (document.getElementById("comments")) + { + document.getElementById("comments").parentNode.replaceChild(commentsDiv, document.getElementById("comments")); + } + else + { + document.getElementById("expandedimage").parentNode.insertBefore(commentsDiv, document.getElementById("expandedimage").nextSibling); + } } - else - { - document.getElementById("expandedimage").parentNode.insertBefore(commentsDiv, document.getElementById("expandedimage").nextSibling); - } } function toggleCommentsForm() @@ -860,6 +863,7 @@ function addNewComment() { + alert("Adding a comment"); if (window.XMLHttpRequest) { var commentForm = document.getElementById("commentform").getElementsByTagName("form")[0]; @@ -875,7 +879,6 @@ xmlHttp.open("POST", ".themes/db/addComment.php", true); xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - xmlHttp.setRequestHeader("Content-length", postData.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.onreadystatechange = function() { @@ -887,10 +890,7 @@ xmlHttp.send(postData); return false; } - else - { - return true; - } + return true; } function checkAddedCommentReply(imageID) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-09-01 17:59:42
|
Revision: 62 http://picfinity.svn.sourceforge.net/picfinity/?rev=62&view=rev Author: espadav8 Date: 2007-09-01 10:59:43 -0700 (Sat, 01 Sep 2007) Log Message: ----------- Allow createFormInput to create other input types by passing in the type required In IE use the IE-only way to set the name of the form inputs Since IE doesn't allow buttons to set the type in JS, the button now has an onclick instead which runs the addNewComment function Remove the form action and onsubmit from the JS since it's not needed now Modified Paths: -------------- trunk/.themes/db/db.js Modified: trunk/.themes/db/db.js =================================================================== --- trunk/.themes/db/db.js 2007-09-01 16:16:32 UTC (rev 61) +++ trunk/.themes/db/db.js 2007-09-01 17:59:43 UTC (rev 62) @@ -433,27 +433,19 @@ addCommentSpan.appendChild(addCommentAnchor); var commentForm = document.createElement("form"); - commentForm.onsubmit = addNewComment; - commentForm.action = ".themes/db/addComment.php"; commentForm.style.display = "none"; var commentFormFieldset = document.createElement("fieldset"); - var ajaxInput = document.createElement("input"); - ajaxInput.type = "hidden"; - ajaxInput.value = "0"; - ajaxInput.name = "ajax"; + var ajaxInput = createFormInput("hidden", "ajax", "0"); + var imageIDInput = createFormInput("hidden", "image_id", imageID); - var imageIDInput = document.createElement("input"); - imageIDInput.type = "hidden"; - imageIDInput.value = imageID; - imageIDInput.name = "image_id"; - - var nameLabel = createFormInput("user_name", "Name:"); - var emailLabel = createFormInput("user_email", "Email:"); - var webLabel = createFormInput("user_web", "Web:"); + var nameLabel = createFormInput("text", "user_name", "Name:"); + var emailLabel = createFormInput("text", "user_email", "Email:"); + var webLabel = createFormInput("text", "user_web", "Web:"); var commentLabel = createFormTextarea("user_comment", "Comment:"); var submitButton = createFormButton("submit", "Submit"); + submitButton.onclick = addNewComment; commentFormFieldset.appendChild(ajaxInput); commentFormFieldset.appendChild(imageIDInput); @@ -471,20 +463,45 @@ return commentFormDiv; } -function createFormInput(inputName, spanText) +function createFormInput(inputType, inputName, spanText) { - var tmpLabel = document.createElement("label"); - var tmpSpan = document.createElement("span"); - tmpSpan.appendChild(document.createTextNode(spanText)); - var tmpInput = document.createElement("input"); - tmpInput.type = "text"; - tmpInput.value = ""; - tmpInput.name = inputName; + if (inputType == "hidden") + { + if (document.all) + { + var tmpInput = document.createElement("<input name=\"" + inputName + "\">"); + } + else + { + var tmpInput = document.createElement("input"); + tmpInput.name = inputName; + } + tmpInput.type = inputType; + tmpInput.value = spanText; - tmpLabel.appendChild(tmpSpan); - tmpLabel.appendChild(tmpInput); + return tmpInput; + } + else + { + var tmpLabel = document.createElement("label"); + var tmpSpan = document.createElement("span"); + tmpSpan.appendChild(document.createTextNode(spanText)); + if (document.all) + { + var tmpInput = document.createElement("<input name=\"" + inputName + "\">"); + } + else + { + var tmpInput = document.createElement("input"); + tmpInput.name = inputName; + } + tmpInput.type = inputType; + tmpInput.value = ""; - return tmpLabel; + tmpLabel.appendChild(tmpSpan); + tmpLabel.appendChild(tmpInput); + return tmpLabel; + } } function createFormTextarea(textareaName, spanText) @@ -492,8 +509,15 @@ var tmpLabel = document.createElement("label"); var tmpSpan = document.createElement("span"); tmpSpan.appendChild(document.createTextNode(spanText)); - var tmpTextarea = document.createElement("textarea"); - tmpTextarea.name = textareaName; + if (document.all) + { + var tmpTextarea = document.createElement("<textarea name=\"" + textareaName + "\">"); + } + else + { + var tmpTextarea = document.createElement("textarea"); + tmpTextarea.name = textareaName; + } tmpTextarea.rows = 3; tmpTextarea.cols = 50; @@ -863,7 +887,6 @@ function addNewComment() { - alert("Adding a comment"); if (window.XMLHttpRequest) { var commentForm = document.getElementById("commentform").getElementsByTagName("form")[0]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-09-01 18:00:45
|
Revision: 63 http://picfinity.svn.sourceforge.net/picfinity/?rev=63&view=rev Author: espadav8 Date: 2007-09-01 11:00:46 -0700 (Sat, 01 Sep 2007) Log Message: ----------- Forgot to set the button type to 'button' for browsers that support it Modified Paths: -------------- trunk/.themes/db/db.js Modified: trunk/.themes/db/db.js =================================================================== --- trunk/.themes/db/db.js 2007-09-01 17:59:43 UTC (rev 62) +++ trunk/.themes/db/db.js 2007-09-01 18:00:46 UTC (rev 63) @@ -444,7 +444,7 @@ var emailLabel = createFormInput("text", "user_email", "Email:"); var webLabel = createFormInput("text", "user_web", "Web:"); var commentLabel = createFormTextarea("user_comment", "Comment:"); - var submitButton = createFormButton("submit", "Submit"); + var submitButton = createFormButton("button", "Submit"); submitButton.onclick = addNewComment; commentFormFieldset.appendChild(ajaxInput); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <esp...@us...> - 2007-09-02 17:51:24
|
Revision: 66 http://picfinity.svn.sourceforge.net/picfinity/?rev=66&view=rev Author: espadav8 Date: 2007-09-02 10:51:23 -0700 (Sun, 02 Sep 2007) Log Message: ----------- Remove the alerts when creating xmlHttp's Don't use document.all to check for IE, now using window.ActiveXObject Make createFormInput a bit nicer to read Modified Paths: -------------- trunk/.themes/db/db.js Modified: trunk/.themes/db/db.js =================================================================== --- trunk/.themes/db/db.js 2007-09-02 17:30:38 UTC (rev 65) +++ trunk/.themes/db/db.js 2007-09-02 17:51:23 UTC (rev 66) @@ -43,22 +43,15 @@ { if (window.XMLHttpRequest) { - alert("returning window.XMLHttpRequest"); return new XMLHttpRequest(); } else if (document.implementation && document.implementation.createDocument) { - alert("returning document.implementation.createDocument"); return document.implementation.createDocument("", "layout", null); } else if (window.ActiveXObject) { - alert("returning ActiveXObject(\"Microsoft.XMLHTTP\")"); - var tmpHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); - // tmpHttpReq.validateOnParse = false; - // tmpHttpReq.resolveExternals = false; - - return tmpHttpReq; + return new ActiveXObject("Microsoft.XMLHTTP"); } else { @@ -476,20 +469,20 @@ function createFormInput(inputType, inputName, spanText) { + if (window.ActiveXObject) + { + var tmpInput = document.createElement("<input name=\"" + inputName + "\">"); + } + else + { + var tmpInput = document.createElement("input"); + tmpInput.name = inputName; + } + if (inputType == "hidden") { - if (document.all) - { - var tmpInput = document.createElement("<input name=\"" + inputName + "\">"); - } - else - { - var tmpInput = document.createElement("input"); - tmpInput.name = inputName; - } tmpInput.type = inputType; tmpInput.value = spanText; - return tmpInput; } else @@ -497,15 +490,7 @@ var tmpLabel = document.createElement("label"); var tmpSpan = document.createElement("span"); tmpSpan.appendChild(document.createTextNode(spanText)); - if (document.all) - { - var tmpInput = document.createElement("<input name=\"" + inputName + "\">"); - } - else - { - var tmpInput = document.createElement("input"); - tmpInput.name = inputName; - } + tmpInput.type = inputType; tmpInput.value = ""; @@ -520,7 +505,7 @@ var tmpLabel = document.createElement("label"); var tmpSpan = document.createElement("span"); tmpSpan.appendChild(document.createTextNode(spanText)); - if (document.all) + if (window.ActiveXObject) { var tmpTextarea = document.createElement("<textarea name=\"" + textareaName + "\">"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2008-03-13 14:57:44
|
Revision: 72 http://picfinity.svn.sourceforge.net/picfinity/?rev=72&view=rev Author: espadav8 Date: 2008-03-13 07:56:20 -0700 (Thu, 13 Mar 2008) Log Message: ----------- Check if the firstChild is null before trying to get it's value (if it is null, use an empty string) If the email/web address are empty don't set the attributes Modified Paths: -------------- trunk/.themes/db/db.js Modified: trunk/.themes/db/db.js =================================================================== --- trunk/.themes/db/db.js 2007-09-11 12:24:58 UTC (rev 71) +++ trunk/.themes/db/db.js 2008-03-13 14:56:20 UTC (rev 72) @@ -815,18 +815,18 @@ for (var j = 0; j < currentComment.childNodes.length; j++) { var currentNodeName = currentComment.childNodes[j].nodeName; - var currentNodeValue = currentComment.childNodes[j].firstChild.nodeValue; + var currentNodeValue = ( currentComment.childNodes[j].firstChild != null ) ? currentComment.childNodes[j].firstChild.nodeValue : ''; if (currentNodeName == "name") { commentOwnerAnchor.appendChild(document.createTextNode(currentNodeValue)); } - else if (currentNodeName == "www") + else if ( (currentNodeName == "www") && ( currentNodeValue != '') ) { commentOwnerWebAnchor.appendChild(document.createTextNode(currentNodeValue)); commentOwnerWebAnchor.setAttribute("href", "http://" + currentNodeValue); } - else if (currentNodeName == "email") + else if ( (currentNodeName == "email") && ( currentNodeValue != '') ) { commentOwnerAnchor.setAttribute("href", "mailto:" + currentNodeValue); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |