/*
Geekinit
Jeff Vogelpohl
August 7, 2012
*/
function jFrame() {
this.memberName = null;
this.googleInit = function(i) {
/*
Parameters:
(i) Google Analytics ID
*/
//var _gaq = _gaq || [];
//_gaq.push(['_setAccount', i]); _gaq.push(['_trackPageview']);
//(function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();
var _gaq = _gaq || [];
_gaq.push(["_setAccount", i]);
_gaq.push(["_trackPageview"]);
(function() {
var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
})();
}
this.googleSet = function(n, d, v) {
/*
Parameters:
(n) Event Name
(d) Description
(v) Value
*/
//_gaq.push(["_trackEvent", "Event_Name_Here", "Event_Description_Here", "Event_Value_Here"]);
_gaq.push(["_trackEvent", n, d, v]);
}
this.title = function() {
/*
Parameters:
(none)
*/
e = document.getElementsByTagName("title")[0];
return e.innerHTML;
}
this.boxHide = function() {
/*
Parameters:
(none)
*/
e = document.body;
c1 = document.getElementById("jBoxOverlay");
c2 = document.getElementById("jBox");
e.removeChild(c1);
e.removeChild(c2);
}
this.boxShow = function(v, w, h, c) {
/*
Parameters:
(v) Value
(w) Width
(h) Height
(c) Background Color
*/
e = document.body;
c1 = document.createElement("div");
c2 = document.createElement("div");
c1.setAttribute("id", "jBoxOverlay");
c1.setAttribute("style", "z-index:16777270;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto;width:" + (parseInt(w) + 100) + "px;height:" + (parseInt(h) + 100) + "px;background:" + c + ";color:#fefefe;filter:alpha(opacity=90);opacity: 0.90;-moz-opacity:0.90;");
c2.setAttribute("id", "jBox");
c2.setAttribute("style", "z-index:16777271;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto;padding:10px;width:" + w + "px;height:" + h + "px;color:#111111;background:#fefefe;border:4px solid #cccccc;");
c2.innerHTML = v;
e.appendChild(c1);
e.appendChild(c2);
}
this.boxPopup = function(v, w, h, c) {
/*
Parameters:
(v) Value
(w) Width
(h) Height
(c) Background Color
*/
e = document.body;
c1 = document.createElement("div");
c2 = document.createElement("div");
c1.setAttribute("id", "jBoxOverlay");
//c1.setAttribute("onclick", "this.parentNode.removeChild(nextSibling);this.parentNode.removeChild(this);");
c1.setAttribute("style", "z-index:16777270;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto;width:100%;height:100%;background:" + c + ";color:#fefefe;filter:alpha(opacity=90);opacity: 0.90;-moz-opacity:0.90;");
c2.setAttribute("id", "jBox");
//c2.setAttribute("style", "z-index:16777271;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto;padding:10px;width:" + w + "px;height:" + h + "px;color:#111111;background:#fefefe;border:4px solid #cccccc;");
c2.setAttribute("style", "z-index:16777271;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto;padding:10px;width:" + w + ";height:" + h + ";color:#111111;background:#fefefe;border:4px solid #cccccc;");
c2.innerHTML = v;
e.appendChild(c1);
e.appendChild(c2);
}
this.boxShow2 = function(v, w, h, c, p) {
/*
Parameters:
(v) Value
(w) Width
(h) Height
(c) Background Color
(p) Parent Object
*/
e = document.body;
c1 = document.createElement("div");
c2 = document.createElement("div");
pH = this.objectGet(p).clientHeight;
c1.setAttribute("id", "jBoxOverlay");
c1.setAttribute("onclick", "this.parentNode.removeChild(nextSibling);this.parentNode.removeChild(this);");
c1.setAttribute("style", "z-index:16777270;position:absolute;top:0;bottom:0;left:0;right:0;margin:0px auto;width:auto;height:" + pH + ";background:" + c + ";color:#fefefe;filter:alpha(opacity=90);opacity: 0.90;-moz-opacity:0.90;");
c2.setAttribute("id", "jBox");
c2.setAttribute("style", "z-index:16777271;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto;padding:10px;width:" + w + "px;height:" + h + "px;color:#111111;background:#fefefe;border:4px solid #cccccc;");
c2.innerHTML = v;
e.appendChild(c1);
e.appendChild(c2);
}
this.boxShow3 = function(v, w, h, c, p) {
/*
Parameters:
(v) Value
(w) Width
(h) Height
(c) Background Color
(p) Parent Object
(mT) Margin-Top (Readonly)
(mL) Margin-Left (Readonly)
*/
var mT = Math.round((h / 2));
var mL = Math.round((w / 2));
e = document.body;
c1 = document.createElement("div");
c2 = document.createElement("div");
pH = this.objectGet(p).clientHeight;
//c1.setAttribute("id", "jBoxOverlay");
//c1.setAttribute("onclick", "this.parentNode.removeChild(nextSibling);this.parentNode.removeChild(this);");
//c1.setAttribute("style", "z-index:16777270;position:absolute;top:0;bottom:0;left:0;right:0;margin:0px auto;width:auto;height:" + pH + ";background:" + c + ";color:#fefefe;filter:alpha(opacity=90);opacity: 0.90;-moz-opacity:0.90;");
c2.setAttribute("id", "jBox");
c2.setAttribute("style", "z-index:16777271;position:fixed;top:50%;left:50%;margin-top:-" + mT + "px;margin-left:-" + mL + "px;padding:10px;width:" + w + "px;height:" + h + "px;color:#111111;background:#fefefe;border:4px solid #cccccc;");
c2.innerHTML = v;
//e.appendChild(c1);
e.appendChild(c2);
}
this.boxVideo = function(i, w, h, u, p, t) {
/*
Parameters:
(i) Element ID Value
(w) Width
(h) Height
(u) Video URL
(p) Poster URL
(t) Video Type
*/
u = "content/media/video.ogv";
p = "poster.jpg";
t = "video/ogg";
v = "";
return v;
}
this.htmlGet = function (i) {
/*
Parameters:
(i) Element ID Value
*/
e = document.getElementById(i);
return e.innerHTML;
}
this.htmlSet = function (i, v, a) {
/*
Parameters:
(i) Element ID Value
(v) Value
(a) Append
*/
e = document.getElementById(i);
x = e.innerHTML;
if (x.length > 0) {
if (a == true) {
e.innerHTML = x + v;
} else if (a == false) {
e.innerHTML = v;
} else {
e.innerHTML = v;
}
} else {
e.innerHTML = v;
}
}
this.valueGet = function (i) {
/*
Parameters:
(i) Element ID Value
*/
x = document.getElementById(i).getAttribute("value");
return x;
}
this.valueSet = function (i, v, a) {
/*
Parameters:
(i) Element ID Value
(v) Value
(a) Append
*/
e = document.getElementById(i);
x = e.value;
if (x.length > 0) {
if (a == true) {
e.value = x + v;
} else if (a == false) {
e.value = v;
} else {
e.value = v;
}
} else {
e.value = v;
}
}
this.attrSet = function (i, a, v) {
/*
Parameters:
(i) Element ID Value
(a) Attribute
(v) Attribute Value
*/
e = document.getElementById(i);
e.setAttribute(a, v);
}
this.toggleDim = function (i, o) {
/*
Parameters:
(i) Element ID Value
(o) Option
*/
e = document.getElementById(i);
switch (o) {
case false:
e.setAttribute("style", "filter:alpha(opacity=15);opacity:0.15;-moz-opacity:0.15;");
break;
case true:
e.setAttribute("style", "filter:alpha(opacity=100);opacity:1;-moz-opacity:1;");
break;
}
}
this.toggleView = function (i, o) {
/*
Parameters:
(i) Element ID Value
(o) Option
*/
e = document.getElementById(i);
switch (o) {
case false:
e.setAttribute("style", "visibility:hidden;");
break;
case true:
e.setAttribute("style", "visibility:visible");
break;
}
}
this.cssSet = function (i, p, v) {
/*
Parameters:
(i) Element ID Value
(p) Property
(v) Value
*/
e = document.getElementById(i);
x = e.style.cssText;
if (x.length > 0) {
e.setAttribute("style", x + p + ":" + v + ";");
} else {
e.setAttribute("style", p + ":" + v + ";");
}
}
this.styleSet = function (i, v) {
/*
Parameters:
(i) Element ID Value
(v) Style Value
*/
e = document.getElementById(i);
x = e.style.cssText;
if (x.length > 0) {
e.setAttribute("style", x + v);
} else {
e.setAttribute("style", v);
}
}
this.objectGet = function (i) {
/*
Parameters:
(i) Element ID Value
*/
e = document.getElementById(i);
return e;
}
this.object_cssSet = function (o, p, v) {
/*
Parameters:
(o) Object
(p) Property
(v) Value
*/
e = o;
x = e.style.cssText;
if (x.length > 0) {
e.setAttribute("style", x + p + ":" + v + ";");
} else {
e.setAttribute("style", p + ":" + v + ";");
}
}
this.insertCode = function (v) {
/*
Parameters:
(v) Value
*/
/*
Sources:
http://stackoverflow.com/questions/6690752/insert-html-at-cursor-in-a-contenteditable-div
http://jsfiddle.net/jwvha/1/
*/
var s, r;
if (window.getSelection) {
s = window.getSelection();
if (s.getRangeAt && s.rangeCount) {
r = s.getRangeAt(0); r.deleteContents();
var e = document.createElement("div"); e.innerHTML = html; var f = document.createDocumentFragment(), n, ln;
while ( (n = e.firstChild) ) { ln = f.appendChild(n); }
r.insertNode(f);
if (ln) { r = r.cloneRange(); r.setStartAfter(ln); r.collapse(true); s.removeAllRanges(); s.addRange(r); }
}
} else if (document.selection && document.selection.type != "Control") {
document.selection.createRange().pasteHTML(html);
}
}
this.boxHelp = function (f, t, m) {
/*
Parameters:
(f) Function
(t) Title
(m) Message
*/
this.boxShow("![]()
" + m + "
", "500", "250", "#003366"); } this.boxResponse = function (f, t, m, nf, yf, nm, ym) { /* Parameters: (f) Function (t) Title (m) Message (nf) "No" Button Function (yf) "Yes" Button Function (nm) "No" Button Message (ym) "Yes" Button Message */ this.boxShow("" + m + "
\n\n", "500", "250", "#266a2e"); } this.boxValidate = function (f, t, m) { /* Parameters: (f) Function (t) Title (m) Message */ this.boxShow("" + m + "
", "500", "250", "#ee1111"); } this.boxInformation = function (f, t, m) { /* Parameters: (f) Function (t) Title (m) Message */ this.boxShow("Data:
" + st + ":
" + st + ":
" + st + ":