[Picfinity-commit] SF.net SVN: picfinity: [50] trunk/.themes/db
Status: Beta
Brought to you by:
espadav8
From: <esp...@us...> - 2007-08-19 11:35:30
|
Revision: 50 http://picfinity.svn.sourceforge.net/picfinity/?rev=50&view=rev Author: espadav8 Date: 2007-08-19 04:35:33 -0700 (Sun, 19 Aug 2007) Log Message: ----------- Various updates to the new theme First workings of a comment system No way to add new comments yet though Modified Paths: -------------- trunk/.themes/db/db.css trunk/.themes/db/db.js trunk/.themes/db/getcomments.php Modified: trunk/.themes/db/db.css =================================================================== --- trunk/.themes/db/db.css 2007-08-18 20:36:55 UTC (rev 49) +++ trunk/.themes/db/db.css 2007-08-19 11:35:33 UTC (rev 50) @@ -1,3 +1,6 @@ +@import "colours.css"; +@import "borders.css"; + * { padding: 0; @@ -2,3 +5,2 @@ margin: 0; - border: 0; } @@ -25,11 +27,9 @@ { font-size: 1.2em; text-align: center; - color: #d0d0d0; } - /* --- ids --- */ #themes @@ -39,6 +39,13 @@ right: 10px; } + +#comments +{ + float: left; + clear: both; +} + #selectedalbum { margin-top: 5px; @@ -54,7 +61,6 @@ width: 100px; display: block; padding: 14px 25px; - border-bottom: 1px solid #ccc; } .folder, @@ -65,7 +71,6 @@ display: block; float: left; margin: 0 5px 5px 0; - border: 1px solid #ccc; position: relative; } @@ -86,7 +91,6 @@ #loadingspan, #linktospan a { - color: #f0f0f0; font-weight: bold; padding: 3px 0; text-align: center; @@ -112,7 +116,6 @@ #expandedimage { - border: 1px solid #ccc; float: left; clear: both; margin-top: 5px; @@ -120,15 +123,12 @@ #expandedimagespan { - border-top: 1px solid #ccc; - border-bottom: 1px solid #ccc; padding: 5px; } #loadingspan { padding: 3px 5px; - border-bottom: 1px solid #ccc; } /* --- hover actions --- */ @@ -139,40 +139,6 @@ cursor: pointer; } - -/*** BACKGROUND ***/ - -html, -.selected a, -#linktospan a:hover, -#breadcrumbtrail ul li a:hover, -#breadcrumbtrail ul li ul li.selected -{ - background-color: #303030; -} - -.folder, -.thumbnail, -#expandedimage, -#breadcrumbtrail ul li -{ - background-color: #505050; -} - -#linktospan a, -.image a:hover, -#breadcrumbtrail ul li ul li a:hover -{ - background-color: #707070; -} - - -#loadingspan -{ - background-color: #cc0022; -} - - /*** BREADCRUMB TRAIL ***/ #breadcrumbtrail ul @@ -196,26 +162,68 @@ margin-right: 5px; float: left; width: 150px; - border: 1px solid #ccc; } + #breadcrumbtrail ul li ul { - border: 1px solid #ccc; left: -999em; position: absolute; width: 150px; z-index: 10; } +#breadcrumbtrail ul li.over ul, +#breadcrumbtrail ul li:hover ul +{ + left: auto; + margin-left: -1px; +} -#breadcrumbtrail ul li ul li + +/*** COMMENTS ***/ + +.comment { - border: none; + padding: 5px; + margin-top: 5px; + clear: both; } -#breadcrumbtrail ul li.over ul, -#breadcrumbtrail ul li:hover ul + + +.comment .date, +.comment .name, +.comment .web { - left: auto; - margin-left: -1px; + font-size: 0.8em; + float: left; + text-align: right; + font-weight: normal; + padding: 0; +} + +.comment .date +{ + float: right; +} + +.comment .web +{ + margin-left: 10px; +} + +.comment .rating +{ + display: block; + text-align: right; + float: right; + clear: both; +} + + +.comment .commenttext +{ + clear: both; + float: left; + margin: 5px 0; } \ No newline at end of file Modified: trunk/.themes/db/db.js =================================================================== --- trunk/.themes/db/db.js 2007-08-18 20:36:55 UTC (rev 49) +++ trunk/.themes/db/db.js 2007-08-19 11:35:33 UTC (rev 50) @@ -2,6 +2,7 @@ addEvent(window, 'load', IE6navhover, false); var xmlDoc; +var xmlHttp; function IE6navhover() { @@ -601,6 +602,12 @@ document.getElementById("selectedalbum").parentNode.insertBefore(expandedImage, document.getElementById("selectedalbum")); } + // remove the old comments + if (document.getElementById("comments")) + document.getElementById("comments").parentNode.removeChild(document.getElementById("comments")); + + getCommentsXML(imageID); + var lastSelectedImage = getElementsByClassName("selected", "div", document); if (lastSelectedImage) @@ -614,6 +621,7 @@ function closeImage() { document.getElementById("expandedimage").parentNode.removeChild(document.getElementById("expandedimage")); + document.getElementById("comments").parentNode.removeChild(document.getElementById("comments")); var lastSelectedImage = getElementsByClassName("selected", "div", document); @@ -621,10 +629,108 @@ lastSelectedImage[0].className = "thumbnail"; } +function getCommentsXML(imageID) +{ + if (window.XMLHttpRequest) + { + xmlHttp = new XMLHttpRequest(); + xmlHttp.onprogress = commentsProgress; + xmlHttp.onreadystatechange = function() { + if (xmlHttp.readyState == 4) + { + createCommentsSection(); + } + } + xmlHttp.open("GET", ".themes/db/getcomments.php?md5=" + imageID, true); + xmlHttp.send(null) + } +} +function commentsProgress(e) +{ +} +function createCommentsSection() +{ + var comments = xmlHttp.responseXML.documentElement; + var commentsDiv = document.createElement("div"); + commentsDiv.setAttribute("id", "comments"); + + for (var i = 0; i < comments.childNodes.length; i++) + { + var currentComment = comments.childNodes[i]; + + var comment = document.createElement("div"); + comment.className = "comment"; + if (i % 2) comment.className += " odd"; + + var commentOwner = document.createElement("span"); + commentOwner.className = "name"; + var commentOwnerAnchor = document.createElement("a"); + commentOwner.appendChild(commentOwnerAnchor); + + var commentOwnerWeb = document.createElement("span"); + commentOwnerWeb.className = "web"; + var commentOwnerWebAnchor = document.createElement("a"); + commentOwnerWeb.appendChild(commentOwnerWebAnchor); + + var commentRating = document.createElement("span"); + commentRating.className = "rating"; + + var commentContents = document.createElement("span"); + commentContents.className = "commenttext"; + + var commentDate = document.createElement("span"); + commentDate.className = "date"; + + for (var j = 0; j < currentComment.childNodes.length; j++) + { + var currentNodeName = currentComment.childNodes[j].nodeName; + var currentNodeValue = currentComment.childNodes[j].textContent; + + 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)); + } + } + + comment.appendChild(commentDate); + comment.appendChild(commentOwner); + comment.appendChild(commentOwnerWeb); + comment.appendChild(commentContents); + comment.appendChild(commentRating); + + commentsDiv.appendChild(comment); + } + + document.getElementById("expandedimage").parentNode.insertBefore(commentsDiv, document.getElementById("expandedimage").nextSibling); +} + + + function getCookie(name) { var start = document.cookie.indexOf( name + "=" ); var len = start + name.length + 1; Modified: trunk/.themes/db/getcomments.php =================================================================== --- trunk/.themes/db/getcomments.php 2007-08-18 20:36:55 UTC (rev 49) +++ trunk/.themes/db/getcomments.php 2007-08-19 11:35:33 UTC (rev 50) @@ -12,29 +12,35 @@ , date_added FROM comments INNER JOIN images - ON images.image_id - WHERE image_md5 = '$image_md5'"; + WHERE images.image_id = comments.image_id + AND images.image_md5 = '$image_md5' + ORDER BY date_added DESC"; $result = mysql_query($query); if ($result) { - $comments_xml = "<?xml version=\"1.0\"?>\n" + header('Content-Type: text/xml'); + $comments_xml = "<?xml version=\"1.0\"?>" . "<comments>"; while ($row = mysql_fetch_assoc($result)) { - $comments_xml .= " - <comment> - <name>$row[user_name]</name> - <www>$row[user_www]</www> - <email>$row[user_email]</email> - <comment_text>$row[user_comment]</comment_text> - <rating>$row[comment_rating]</rating> - <added>$row[date_added]</added> - </comment>"; + $comments_xml .= "<comment>" + . "<name>$row[user_name]</name>" + . "<www>$row[user_www]</www>" + . "<email>$row[user_email]</email>" + . "<comment_text>$row[user_comment]</comment_text>" + . "<rating>$row[comment_rating]</rating>" + . "<added>$row[date_added]</added>" + . "</comment>"; } - $comments_xml .= "\n</comments>\n"; + $comments_xml .= "</comments>"; echo $comments_xml; } + else + { + header('Content-Type: text/xml'); + echo "<error><message>Error in getting the results</message></error>"; + } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |