Skip to content

Instantly share code, notes, and snippets.

@teamgroove
Created July 31, 2014 11:56
Show Gist options
  • Save teamgroove/9800723996223a02187a to your computer and use it in GitHub Desktop.
Save teamgroove/9800723996223a02187a to your computer and use it in GitHub Desktop.
requirebin sketch
var p = require('categorizr');
console.log(p)
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}({"CDe3/3":[function(require,module,exports){(function(name,context,definition){if(typeof module!=="undefined")module.exports=definition(name,context);else if(typeof define==="function"&&typeof define.amd==="object")define(definition);else context[name]=definition(name,context)})("categorizr",this,function(name,context){var key,isBrowser=context!=null&&context==context.window,isNode=!isBrowser,is$=isBrowser&&context.$,eventEmitter=function(){var e;if(is$)e=context.$("").trigger;return e}(),docElement=isNode?null:document.documentElement,deviceTypes="Tv Desktop Tablet Mobile".split(" "),test=function(ua){return ua.match(/GoogleTV|SmartTV|Internet.TV|NetCast|NETTV|AppleTV|boxee|Kylo|Roku|DLNADOC|CE\-HTML/i)?"tv":ua.match(/Xbox|PLAYSTATION.3|Wii/i)?"tv":ua.match(/iPad/i)||ua.match(/tablet/i)&&!ua.match(/RX-34/i)||ua.match(/FOLIO/i)?"tablet":ua.match(/Linux/i)&&ua.match(/Android/i)&&!ua.match(/Fennec|mobi|HTC.Magic|HTCX06HT|Nexus.One|SC-02B|fone.945/i)?"tablet":ua.match(/Kindle/i)||ua.match(/Mac.OS/i)&&ua.match(/Silk/i)?"tablet":ua.match(/GT-P10|SC-01C|SHW-M180S|SGH-T849|SCH-I800|SHW-M180L|SPH-P100|SGH-I987|zt180|HTC(.Flyer|\_Flyer)|Sprint.ATP51|ViewPad7|pandigital(sprnova|nova)|Ideos.S7|Dell.Streak.7|Advent.Vega|A101IT|A70BHT|MID7015|Next2|nook/i)||ua.match(/MB511/i)&&ua.match(/RUTEM/i)?"tablet":ua.match(/BOLT|Fennec|Iris|Maemo|Minimo|Mobi|mowser|NetFront|Novarra|Prism|RX-34|Skyfire|Tear|XV6875|XV6975|Google.Wireless.Transcoder/i)?"mobile":ua.match(/Opera/i)&&ua.match(/Windows.NT.5/i)&&ua.match(/HTC|Xda|Mini|Vario|SAMSUNG\-GT\-i8000|SAMSUNG\-SGH\-i9/i)?"mobile":ua.match(/Windows.(NT|XP|ME|9)/)&&!ua.match(/Phone/i)||ua.match(/Win(9|.9|NT)/i)?"desktop":ua.match(/Macintosh|PowerPC/i)&&!ua.match(/Silk/i)?"desktop":ua.match(/Linux/i)&&ua.match(/X11/i)?"desktop":ua.match(/Solaris|SunOS|BSD/i)?"desktop":ua.match(/Bot|Crawler|Spider|Yahoo|ia_archiver|Covario-IDS|findlinks|DataparkSearch|larbin|Mediapartners-Google|NG-Search|Snappy|Teoma|Jeeves|TinEye/i)&&!ua.match(/Mobile/i)?"desktop":"mobile"},device=test(context.navigator?context.navigator.userAgent:context.request?context.request.headers["user-agent"]:"No User-Agent Provided"),is=function(type){return device===type},categorizr=function(){var args=[].slice.call(arguments,0);if(args.length===2&&device===args[0]){device=args[1];_update()}else if(args.length===1&&typeof args[0]==="string"){device=args[0];_update()}return device};categorizr.is=is;categorizr.test=test;function _setDeviceBooleans(){var i=deviceTypes.length;while(i--){categorizr["is"+deviceTypes[i]]=is(deviceTypes[i].toLowerCase());if(is$)context.$["is"+deviceTypes[i]]=is(deviceTypes[i].toLowerCase())}}function _setClassName(){if(isBrowser){docElement.className=docElement.className.replace(/(^|\s)desktop|tablet|tv|mobile(\s|$)/,"$1$2")+(" "+device)}}function _update(){_setDeviceBooleans();_setClassName();if(eventEmitter)context.$(context).trigger("deviceChange",[{type:device}])}_update();if(is$){for(key in categorizr)if(Object.hasOwnProperty.call(categorizr,key))context.$[key=="test"?"testUserAgent":key=="is"?"isDeviceType":key]=categorizr[key];context.$.categorizr=categorizr}return categorizr})},{}],categorizr:[function(require,module,exports){module.exports=require("CDe3/3")},{}]},{},[]);var p=require("categorizr");console.log(p);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"categorizr": "0.3.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