Skip to content

Instantly share code, notes, and snippets.

@sTiLL-iLL
sTiLL-iLL / GTRX.js
Last active August 29, 2015 14:03
geo locator module
// GTRX geolocator
(function GTRX(window) {
var wndw = window,
var startG = function() {
if (wndw.navigator.geolocation) {
var trxLST = [], pID = "", cnt = 0, ipAddrs = "";
// caching script fetcher //
var futrs = {};
var ajaxFetch = function( url, cBak ) {
if ( !futrs[ url ] ) {
futrs[ url ] = $.Deferred(function( defer ) {
$.getScript( url )
.then( defer.resolve, defer.reject );
@sTiLL-iLL
sTiLL-iLL / KND_Index.js
Last active August 29, 2015 14:03
HTTP STREAMING SERVER... KNDsrvr.js... javascript for Node.js
// programatic entry point for the server //
var router = require('./router.js'),
requestHandlers = require('./requestHandlers.js'),
webServer = require('./server.js'),
handle = {};
// Unary referencing... each function maps -to- a specific request/params/method etc... //
handle['/'] = handle['/home'] = handle['/Home'] = handle['/index.html'] = handle['/Index.html'] = requestHandlers.startRoot;
@sTiLL-iLL
sTiLL-iLL / index.html
Last active August 29, 2015 14:04
Simple position tracker
<!Doctype html>
<meta name="viewport" content="width=620" />
<title>KnD-MApPA</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<article>
<p>Finding You...: <span id="status">Checking...</span>
</p>
</article>
<script>
var map = "",
@sTiLL-iLL
sTiLL-iLL / blobStorage.js
Last active August 29, 2015 14:04
blobs in the IndexDB
// make a blob
var blob = new Blob(['blobyJo'], {
type: 'text/plain'
});
try {
var store = db.transaction(['buckets'], 'readwrite')
.objectStore('buckets');
var fngr = store.put(blob, 'blob');
@sTiLL-iLL
sTiLL-iLL / OP_NS.js
Last active August 29, 2015 14:05
Object Pool microframework
(function (context) {
var createKontxt = function (nameStr, baseLine) {
var x, j, r, baseKnTxt, name;
var wdgts = nameStr.split('.');
j = baseKnTxt = baseLine ? baseLine : (Function('return this')());
var events = (function(){
var topics = {};
return {
subscribe: function(topic, listener) {
if(!topics[topic]) topics[topic] = {
queue: []
};
@sTiLL-iLL
sTiLL-iLL / addClass.js
Created August 19, 2014 01:56
addClass function similar to Jquery
function addClass(node, class) {
if (!node.length) node = [node];
for (var n = 0, m = node.length; n < m; n++) {
if ((" " + node[n].className + " ").indexOf(" "+class+" ") >= 0) {
node.className += " " + class;
}
}
}
// apply myclass to all nodes
addClass(document.getElementById("myelement"), "myclass");
@sTiLL-iLL
sTiLL-iLL / ajaxRequest.js
Created August 19, 2014 01:59
ajax request
var r = new XMLHttpRequest();
r.open("POST", "webservice", true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;
console.log(r.responseText);
};
r.send("a=1&b=2&c=3");
@sTiLL-iLL
sTiLL-iLL / EventEmitterPattern.js
Last active August 29, 2015 14:05
An example of inheriting from event emitter
// Require our emitter
var Emitter = require('events').EventEmitter;
// Our main constructor
var myEmitter = function (config) {
// extend with emitter
Emitter.call(this);
};