cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="container">
  <h1>Live edits<!-- or other events! --> to all Wikimedia wikis </h1>
  <em><a href="https://wikitech.wikimedia.org/wiki/RCStream">Documentation</a></em>
  <hr>
  <span hidden>Messages in the last second: <span id="rate-min">..</span> (average so far: <span id="rate-avg">..</span>/s)</span>
  <div class="alert alert-warning">The stream/v1 API ("RCStream") has been deprecated in favor of stream/v2 ("EventStreams"), also available at <a href="https://wikitech.wikimedia.org/wiki/EventStreams">https://stream.wikimedia.org</a>.</div>
  <div class="alert alert-danger">The stream/v1 API was shutdown in July 2017. See <a href="https://wikitech.wikimedia.org/wiki/EventStreams">https://wikitech.wikimedia.org/wiki/EventStreams</a> for an updated CodePen demo.</div>
  <pre id="feed" class="mw-feed" hidden></pre>
</div>
<footer class="mw-footer" role="contentinfo">
	<div class="container">
		<p>Created by <a href="https://github.com/Krinkle">@Krinkle</a>.</p>
	</div>
</footer>
            
          
!
            
              
.mw-footer {
	padding-top: 40px;
	padding-bottom: 40px;
	margin-top: 100px;
	background: #f9f9f9;
	color: #777;
	text-align: center;
	border-top: 1px solid #e5e5e5
}
            
          
!
            
              (function() {
  // See http://socket.io/
  var socket = io.connect('https://stream.wikimedia.org/rc');
  
  var feedNode = document.getElementById('feed');
  var rateMinNode = document.getElementById('rate-min');
  var rateAvgNode = document.getElementById('rate-avg');
  var errorNode = document.createElement('div');
  errorNode.className = 'alert alert-danger';
  var infoNode = document.createElement('div');
  infoNode.className = 'alert alert-info';
  var updateBuffer = makeDisplayBuffer(10);
  var freq;
  printEvent({
    type: 'info',
    message: 'Connecting...'
  });
  socket.on('connect', function() {
    printEvent({
      type: 'info',
      message: 'Connected! Listening for events...'
    });
    freq = new Frequency(1000, function (count, average) {
      rateMinNode.textContent = count;
      rateAvgNode.textContent = average;
    });

    // Subscribe to one or more wikis
    // See https://wikitech.wikimedia.org/wiki/RCStream
    socket.emit('subscribe', '*');
  });

  socket.on('change', function(rc) {
    if (freq) { freq.add(1); }

    // See https://www.mediawiki.org/wiki/Manual:RCFeed#Properties
    if (rc.type == 'edit') {
      printEvent({
        type: 'rc',
        data: rc
      });
    }

  });

  socket.on('error', function(data) {
    printEvent({
     type: 'error',
     data: data || /* Hardcoded as of 2017-07-10 */ '[error] Server unavailable'
    });
  });

  function printEvent(event) {
    var node;
    if (event.type === 'rc') {
      var node = document.createTextNode(JSON.stringify(event.data) + '\n\n');
      $(feedNode).prepend(node);
      updateBuffer(node);
    } else if (event.type === 'error') {
      $(errorNode).empty().text(JSON.stringify(event.data));
      if (!errorNode.parentNode) {
        $(feedNode).before(errorNode);
      }
    } else if (event.type === 'info') {
      $(infoNode).text(event.message);
      if (!infoNode.parentNode) {
        $(feedNode).prepend(infoNode);
        updateBuffer(infoNode);
      }
    }
  }

  function makeDisplayBuffer(size) {
    var buffer = [];
    return function (element) {
      buffer.push(element);
      if (buffer.length > size) {
        var popped = buffer.shift();
        popped.parentNode.removeChild(popped);
      }
    }
  }
}());

function Frequency(interval, callback) {
  var freq = this;
  var rAF = window.requestAnimationFrame || setTimeout;

  this.interval = interval;
  this.callback = callback;
  this.count = 0;
  this.total = 0;
  this.since = this.start = this.now();
  function checker() {
    freq.check();
    rAF(checker);
  }
  rAF(checker);
}
Frequency.prototype.now = ( function () {
  var perf = window.performance;
  return perf.now ?
    function () { return perf.now(); } :
    function () { return +new Date(); };
}() );
Frequency.prototype.add = function (count) {
  this.count += count;
  this.total += count;
  this.check();
};
Frequency.prototype.check = function () {
  var count, avg, ellapsedTotal;
  var ellapsed = this.now() - this.since;
  if (ellapsed >= this.interval) {
    ellapsedTotal = this.now() - this.start;
    count = this.count;
    // One optional digit
    avg = (this.total / (ellapsedTotal / this.interval)).toFixed(1).replace('.0', '');
    this.since = this.now();
    this.count = 0;
    this.callback(count, avg);
  }
};
            
          
!
999px
Loading ..................

Console