MediaWiki:Common.js

From Openresearch
Revision as of 12:46, 30 October 2016 by Liy1 (talk | contribs)
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */

/**
 * Additional linked icon for the searchlabel of result format "feed"
 * @author mwjames
 */
 
$( '.smw-feed-furtherresults > a' ).addClass( 'feedlink' );

<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//openresearch.org/analysis/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', 1]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<noscript><p><img src="//openresearch.org/analysis/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->

<!-- twitter position -->
html, body {
    height: 100%;
    overflow:auto;
}
body #fixbox {
    position:fixed !important;
    position: absolute; /*ie6 */
    bottom: 0;
}
<!-- end twitter setting -->

<!-- get twitter feeds -->
var tds = document.getElementById("mw-content-text").getElementsByTagName("td");
window.alert(tds);
var twitter = "";
for(var i = 0; i < tds.length; i++){
    if (tds[i].innerText = "Twitter account:"){ // we find the twitter account on this page
        twitter = tds[i+1].innerText;
        break;
    }
}
if(twitter != ""){ // if twitter exist, create feeds box on current page
   twitter = twitter.replace (/@/g, "");
   var twitterUrl = "https://twitter.com/".concat(twitter);
   var by = "Tweets by ".concat(twitter);
   html = "<a class="twitter-timeline" height="500" width="200" href=".concat(twitterUrl).concat(">").concat(by).concat(</a> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></html>);
   document.getElementById("globalWrapper").appendChild(html);
}
<!-- end get twitter feeds -->