Novelas
Advertisement
Forums: Index > Development > Article rating



Hello,

I'm the founder of the game cloud and I have a feature that may interest you. I have coded a page rating on each article like at the end of this page. The game cloud is a wiki to create original games and this wiki is to create original stories so you might have the same need. This is how to add this:

  1. Duplicate MediaWiki:WikiaRating.js
  2. Add this code to MediaWiki:Common.css:
#p-rating div { text-align: center }
#ratingStars a { color: #e3e3e3; font-size: 16px; font-weight: normal; cursor: pointer }
#ratingStars a:hover { color: gold; text-decoration: none }
#ratingStars li {
   background-image:url(http://images.wikia.com/uncyclopedia/images/8/81/Star-rating.png);
   background-repeat: no-repeat;
   background-color: transparent;
   list-style: none;
   width: 17px;
   height: 17px;
   float: left;
   text-indent: -9000px;
   padding: 0 1px;
   cursor: pointer;
}
#ratingStars { height: 20px }
.ratingUser { background-position: 0 -34px }
.ratingAvg { background-position: 0 -17px }
  1. Add this code to MediaWiki:Common.js:
importedScripts = {}; // object keeping track of included scripts, so a script ain't included twice
 function importScript( page ) {
     if( importedScripts[page] ) {
         return;
     }
     importedScripts[page] = true;
     var url = wgScriptPath
             + '/index.php?title='
             + encodeURIComponent( page.replace( / /g, '_' ) )
             + '&action=raw&ctype=text/javascript';
     var scriptElem = document.createElement( 'script' );
     scriptElem.setAttribute( 'src' , url );
     scriptElem.setAttribute( 'type' , 'text/javascript' );
     document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );
 }

importScript("MediaWiki:WikiaRating.js");

If you want, you can put all the javascript code in MediaWiki:Common.js instead of importing it. You can change the stars by replacing this image by another one: Star-rating.png

You can ask me questions here. Ftiercel (Game Cloud) 19:24, November 19, 2012 (UTC)

Advertisement