Skip to content

Instantly share code, notes, and snippets.

@anthonyringoet
Created May 27, 2014 14:49
Show Gist options
  • Save anthonyringoet/b359e7ceca1dadcd9a13 to your computer and use it in GitHub Desktop.
Save anthonyringoet/b359e7ceca1dadcd9a13 to your computer and use it in GitHub Desktop.
requirebin sketch
var N = require('notification-count');
var n = new N();
setInterval(function(){
n.add();
},500)
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({sc370P:[function(require,module,exports){module.exports=Notifier;function Notifier(count,el,left,right){if(!(this instanceof Notifier)){return new Notifier(count,left,right)}this.separatorLeft=left||"(";this.separatorRight=right||")";this.initial=count||0;this.count=count||0;this.el=el||document.getElementsByTagName("title")[0];if(this.initial){this.update()}}Notifier.prototype.update=function(){var output=this.separatorLeft+this.count+this.separatorRight;var regexString="^(\\"+this.separatorLeft+")\\w+(\\"+this.separatorRight+") ";var reg=new RegExp(regexString,"g");var oldTitle=this.el.textContent.replace(reg,"");if(this.count){this.el.textContent=output+" "+oldTitle}else{this.el.textContent=oldTitle}return this};Notifier.prototype.set=function(input){if(typeof input==="undefined"){this.count=1}else{this.count=parseFloat(input)}if(this.count<0||isNaN(this.count)){this.count=0}this.update();return this};Notifier.prototype.default=function(){this.count=this.initial;this.update();return this};Notifier.prototype.add=function(input){if(typeof input==="undefined"){input=1}this.count+=parseFloat(input);this.update();return this};Notifier.prototype.subtract=function(input){if(typeof input==="undefined"){input=1}this.count-=parseFloat(input);if(this.count<0||isNaN(this.count)){this.count=0}this.update();return this}},{}],"notification-count":[function(require,module,exports){module.exports=require("sc370P")},{}]},{},[]);var N=require("notification-count");var n=new N;setInterval(function(){n.add()},500);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"notification-count": "0.0.1"
}
}
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment