This repository has been archived by the owner on Dec 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
luis.leiva.torres
committed
Nov 1, 2013
1 parent
98c8462
commit e67835c
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* smt2e -- simple mouse tracking | ||
* Copyleft (cc) 2012 Luis Leiva | ||
* http://smt2.googlecode.com & http://smt.speedzinemedia.com | ||
*/ | ||
(function(){var b=document.getElementsByTagName("script");var h=b[b.length-1].src;var e=h.split("/");e.splice(e.length-1,1);var g=e.join("/");var d=e[e.length-1]=="src"?".js":".min.js";var f=["smt-aux","smt-record"];for(var c=0;c<f.length;++c){var a=document.createElement("script");a.src=g+"/"+f[c]+d;document.body.appendChild(a)}})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*! | ||
* smt2e -- simple mouse tracking | ||
* Copyleft (cc) 2012 Luis Leiva | ||
* http://smt2.googlecode.com & http://smt.speedzinemedia.com | ||
*/ | ||
(function(){ | ||
|
||
// Delay recording function until smt2 libs are fully loaded | ||
var smt2cache; | ||
window.smt2 = { | ||
record: function(opts) { | ||
smt2cache = function() { window.smt2.record(opts); } | ||
} | ||
} | ||
|
||
function createScript(filepath) { | ||
var scriptElem = document.createElement('script'); | ||
scriptElem.type = "text/javascript"; | ||
scriptElem.src = filepath; | ||
return scriptElem; | ||
} | ||
|
||
// Grab path of currently executing script | ||
var scripts = document.getElementsByTagName('script'); | ||
var currentScript = scripts[scripts.length - 1]; | ||
// Remove filename | ||
var pathParts = currentScript.src.split("/"); | ||
pathParts.splice(pathParts.length - 1, 1); | ||
// Now we have the full script path | ||
var path = pathParts.join("/"); | ||
// Load smt2 libs accordingly: first aux functions, then record | ||
var ext = pathParts[pathParts.length - 1] == "src" ? ".js" : ".min.js"; | ||
var aux = createScript(path + "/" + "smt-aux" + ext); | ||
currentScript.parentNode.insertBefore(aux, currentScript.nextSibling); | ||
aux.onload = function() { | ||
var record = createScript(path + "/" + "smt-record" + ext); | ||
currentScript.parentNode.insertBefore(record, aux.nextSibling); | ||
record.onload = function() { | ||
smt2cache(); | ||
// DOM is already loaded, so make this explicit fn call | ||
smt2.methods.init(); | ||
} | ||
// Finally remove loader script | ||
currentScript.parentNode.removeChild(currentScript); | ||
} | ||
|
||
})(); |