function getComments(fkArticleID, page) { new Ajax.Request(document.getElementsByTagName('base')[0].href+'index.html/ajaxgate|articleComments', { method:'post', parameters: {'fkArticleID': fkArticleID, 'pageID': page}, onSuccess: function(transport){ var response = transport.responseXML; // alert(response); writeComments(response); }, onFailure: function(){ } }); } function writeComments(rXML) { $('commentsListing').innerHTML = ''; baseHref = document.getElementsByTagName('base')[0].href; if(document.all) { root = rXML.childNodes[1]; } else { root = rXML.childNodes[0]; } var pagingInfo = root.getElementsByTagName('detalii')[0]; var comments = root.getElementsByTagName('comentarii')[0]; var sysMessage = root.getElementsByTagName('sysMessage')[0]; // alert('mum'); if(comments.hasChildNodes()) { var items = comments.childNodes; for(var i = 0; i < items.length; i++) { var dt = $(document.createElement('dt')); var strong = $(document.createElement('strong')); var br = $(document.createElement('br')); var username = document.createTextNode(items[i].getElementsByTagName('name')[0].firstChild.nodeValue); strong.appendChild(username); dt.appendChild(strong); var span = $(document.createElement('span')); span.innerHTML = '|'; dt.appendChild(span); var em = $(document.createElement('em')); var emInfo = document.createTextNode(items[i].getElementsByTagName('postDate')[0].firstChild.nodeValue); em.appendChild(emInfo); dt.appendChild(em); dt.appendChild(br); pRank = $(document.createElement('div')); pRank.addClassName('note'); var backgroundPosition = 80 - (parseInt(items[i].getElementsByTagName('rank')[0].firstChild.nodeValue) * 16); var rank = new Element('div', {'style':'background-image:url(\''+baseHref+'images/backgrounds/rating.png\');height:20px;background-repeat:no-repeat;width:80px;background-position:-'+backgroundPosition+'px 0px'}); pRank.appendChild(rank); dt.appendChild(pRank); var dd = $(document.createElement('dd')); var message = items[i].getElementsByTagName('message')[0].firstChild.nodeValue; dd.addClassName('text'); dd.innerHTML = message; $('commentsListing').appendChild(dt); $('commentsListing').appendChild(dd); } } if(pagingInfo && pagingInfo.hasChildNodes) { var pageID = pagingInfo.getElementsByTagName('pagina')[0].firstChild.nodeValue; var nPages = pagingInfo.getElementsByTagName('totalpagini')[0].firstChild.nodeValue; var nElements = pagingInfo.getElementsByTagName('totalcomentarii')[0].firstChild.nodeValue; var elementID = pagingInfo.getElementsByTagName('ID')[0].firstChild.nodeValue; if(nPages && nPages > 1) { var cleaner = $(document.createElement('div')); cleaner.addClassName('cleaner'); $('commentsListing').appendChild(cleaner); var ppage = $(document.createElement('p')); ppage.id = 'paginare'; ppage.addClassName('paginare'); var paginare = document.createTextNode('Paginare'); ppage.appendChild(paginare); for(var i = 1; i < nPages; i++) { if(i == pageID) { var pageTag = $(document.createElement('a')); pageTag.addClassName('paginaActiva'); pageTag.href = 'javascript: void(0);'; } else { var pageTag = $(document.createElement('a')); pageTag.addClassName('pagina'); pageTag.href = 'javascript: void(0);'; pageTag.onclick = new Function('getComments(' + elementID + ', ' + i + ')'); } var pageText = document.createTextNode(i); pageTag.appendChild(pageText); ppage.appendChild(pageTag); } $('commentsListing').appendChild(ppage); $('commentsListing').appendChild(cleaner); // alert($('paginare').innerHTML); } } if(sysMessage) { showToolTipFader(sysMessage.firstChild.nodeValue, $('comenteazaSiTuID')); } } function nl2br(str) { if(typeof(str)=="string") return str.replace(/(\r\n)|(\n\r)|\r|\n/g,"
"); else return str; } //COMMENTS function displayCommentForm(formID, userID, fieldToFocus, message) { // if(parseInt(userID)) { Effect.toggle($(formID),'slide'); setTimeout('$(\''+fieldToFocus+'\').focus();', 1000); // } else { // showToolTipFader(message, $('comenteazaSiTuID')); // if(!$('commentGoToLogin')) { // var commentGoToLogin = $(document.createElement('div')); // commentGoToLogin.id = 'commentGoToLogin'; // commentGoToLogin.setStyle({'display':'none'}); // var div = $(document.createElement('div')); // var msg = document.createTextNode(message); // div.appendChild(msg); // var br = document.createElement('br'); // div.appendChild(br); // msg = document.createTextNode('Pentru a intra in contul dumneavoastra, dati click '); // div.appendChild(msg); // var loginLink = $(document.createElement('a')); // loginLink.href = document.getElementsByTagName('base')[0].href + 'index.html/account|login'; // msg = document.createTextNode('aici'); // loginLink.appendChild(msg); // div.appendChild(loginLink); // commentGoToLogin.appendChild(div); // $('comenteazaSiTuID').parentNode.appendChild(commentGoToLogin); // new Effect.SlideDown(commentGoToLogin); // } // } } function validateComment(fieldsToBeValidated) { var ok = true; if(fieldsToBeValidated.length) { for(i = 0; i < fieldsToBeValidated.length; i++) { if(!$(fieldsToBeValidated[i]).value.trim().length) { ok = false; showToolTipFader('Completati...',$(fieldsToBeValidated[i])); } } } return ok; } function postComment(formID, fkArticleID, fieldsToBeValidated) { if(validateComment(fieldsToBeValidated)) { Effect.toggle($(formID),'slide'); new Ajax.Request(document.getElementsByTagName('base')[0].href+'index.html/ajaxgate|articleComments', { method:'post', parameters: {'fkArticleID': fkArticleID, comment: $('comment').value, 'rank':$('rank').value, cname: $('cname').value, 'cemail':$('cemail').value, postComment: '1' }, onSuccess: function(transport){ $('cname').value =''; $('email').value =''; $('comment').value =''; $('rank').value =''; $('ranking').style.backgroundPosition = '-80px 0px'; var response = transport.responseXML; // alert(response); writeComments(response); }, onFailure: function(){ } }); } } function buildRanking() { var ratingSelector = $('ranking'); function mouseOver() { this.parentNode.style.backgroundPosition = -(80 - (this.firstChild.nodeValue * 16)) + "px 0px"; } function mouseOut() { this.parentNode.style.backgroundPosition = -(80 - (this.parentNode.firstChild.value * 16)) + "px 0px"; } function mouseClick() { this.parentNode.firstChild.value = this.firstChild.nodeValue; return false; } for (var i = 1; i <= 5; i++) { var star = document.createElement("a"); star.href = "#"; star.title = i + "/5"; star.appendChild(document.createTextNode(i)); star.onmouseover = mouseOver; star.onmouseout = mouseOut; star.onclick = mouseClick; ratingSelector.appendChild(star); } } String.prototype.trim = function() { var _ret = this.replace(/^\s+|\s+$/g, ''); return _ret.replace(/^(\ \;)+|(\ \;)+$/g, ''); } //end browser user var globalTimeout = ""; function showToolTipFader(texty,obj,doNotCloseAfter) { if($('tooltipX')) { document.body.removeChild($('tooltipX')); window.clearTimeout(globalTimeout); } var newdiv = document.createElement('div'); newdiv.id="tooltipX"; newdiv.style.display = "none"; //generating table inside div if(document.all) { var tbl = document.createElement(''); var tbb = document.createElement("tbody"); } else { var tbl = document.createElement('table'); var tbb = document.createElement("tbody"); tbl.setAttribute('cellpadding','0'); tbl.setAttribute('cellspacing','0'); tbl.setAttribute('border','0'); } // create up arrow td var row = document.createElement('tr'); if(document.all) var cell = document.createElement('
'); else var cell = document.createElement('td'); cell.setAttribute('colspan','3'); //create img var nimg = document.createElement('img'); if(document.all) nimg.src="images/pop-up/sageata_sus.gif"; else nimg.src="images/pop-up/sageata_sus.png"; nimg.className="tooltipUpArrow"; nimg.id = "toolArrowU"; cell.appendChild(nimg); row.appendChild(cell); tbb.appendChild(row); //end create up arrow td //create top tooltip var row = document.createElement('tr'); var cell = document.createElement('td'); cell.className="tooltipCorner_ul"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipBar_u"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipCorner_ur"; row.appendChild(cell); tbb.appendChild(row); //end create top tooltip if(doNotCloseAfter) { var imgClose = "Detaliu utilizator"; //create close tooltip var row = document.createElement('tr'); var cell = document.createElement('td'); cell.className="tooltipBar_l"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipText"; cell.innerHTML=imgClose; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipBar_r"; row.appendChild(cell); tbb.appendChild(row); //end close tooltip } //create middle tooltip var row = document.createElement('tr'); var cell = document.createElement('td'); cell.className="tooltipBar_l"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipText"; cell.innerHTML=texty; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipBar_r"; row.appendChild(cell); tbb.appendChild(row); //end middle tooltip //create bottom tooltip var row = document.createElement('tr'); var cell = document.createElement('td'); cell.className="tooltipCorner_bl"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipBar_b"; row.appendChild(cell); var cell = document.createElement('td'); cell.className="tooltipCorner_br"; row.appendChild(cell); tbb.appendChild(row); //end create bottom tooltip // create down arrow td var row = document.createElement('tr'); if(document.all) var cell = document.createElement(''); else var cell = document.createElement('td'); cell.setAttribute('colspan','3'); //create img var nimg = document.createElement('img'); if(document.all) nimg.src="images/pop-up/sageata_jos.gif"; else nimg.src="images/pop-up/sageata_jos.png"; nimg.className="tooltipDownArrow"; nimg.id = "toolArrowD"; cell.appendChild(nimg); row.appendChild(cell); tbb.appendChild(row); //end create down arrow td tbl.appendChild(tbb); newdiv.appendChild(tbl); newdiv.className ="tooltipDiv"; //add tooltip to document document.body.appendChild(newdiv); //position tooltip setPopupPosition(obj,newdiv); Effect.Appear(newdiv.id,{duration:.2}); //set fade out if(!doNotCloseAfter) globalTimeout = window.setTimeout('Effect.Fade(\'tooltipX\', {duration:.3,from:1.0, to:0.0})',2500); //======================================== } function setPopupPosition(el, x) { var direction = "up"; var position = Position.cumulativeOffset(el); var scrollY = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop; var viewHeight = (navigator.userAgent.toLowerCase().indexOf("safari") != -1 && window.innerHeight) ? window.innerHeight : document.documentElement.clientHeight; x.style.left = position[0]-40 + "px"; var popupTop = position[1] + Element.getHeight(el); if((popupTop + x.offsetHeight > scrollY + viewHeight) && (position[1] - x.offsetHeight > scrollY)) { popupTop = position[1] - x.offsetHeight ; } if(popupTop > (scrollY + Element.getHeight(x) + 40 + Element.getHeight(el))) { direction="down"; $('toolArrowD').style.visibility = "visible"; } else { $('toolArrowU').style.visibility = "visible"; } if(direction == "up") x.style.top = (popupTop+30) + "px"; else x.style.top = (popupTop - Element.getHeight(x) - (document.all ? 15 : 25) - Element.getHeight(el)) + "px"; } function hidePopup() { if($('tooltipX')) { document.body.removeChild($('tooltipX')); window.clearTimeout(globalTimeout); } }