MyBB Community Forums

Full Version: [B] rating.js - minor really minor problem :P
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok so, go to a thread and rate it. You will see that you can still "rollover" the stars if you don't refresh.

In rating.js

After:
			if(!$('success_rating_' + element_id))
			{
				var success = document.createElement('span');
				var element = $('rating_thread_' + element_id);
				element.parentNode.insertBefore(success, element.nextSibling);
				element.removeClassName('star_rating_notrated');
			}
			else
			{
				var success = $('success_rating_' + element_id);
			}

Add:
			$('rating_thread_' + element_id).removeClassName('star_rating_notrated');
			var elements = Element.getElementsBySelector($('rating_thread_' + element_id), 'li a');
			if(Element.hasClassName($('rating_thread_' + element_id), 'star_rating_notrated'))
			{
				elements.each(function(element) {
					element.onclick = function() {
						var parameterString = this.href.replace(/.*\?(.*)/, "$1");
						return Rating.add_rating(parameterString);
					};
				});
			}
			else
			{
				elements.each(function(element) {
					element.onclick = function() { return false; };
					element.style.cursor = 'default';
					var element_id = element.href.replace(/.*\?(.*)/, "$1").match(/tid=(.*)&(.*)&/)[1];
					element.title = $('current_rating_'+element_id).innerHTML;
				});
			}

This is not really a bug but in my opinion, it would be better like this Toungue
I am not really good with javascript but I undestand it so if something's wrong, tell me. I used part of the rating.js's init function code. Maybe it could be done with less code but I don't know how Toungue