<!---------------------------------------------------------------------------------------------------------------------->
<html>
<head>
<title>codeBox</title>
<!----------------------------------------------------------------------------------------------------------------------
>
<script
id="about">
var ututu = {
about : {
title : "codeBox" ,
description : "Put simply, ututu-codeBox is a panic
button."
+
"More specifically,
"
+
"codeBox is
"
+
"a
"
+
"SELF ASSEMBLY MOBILE APPLICATION
"
+
"designed for
"
+
"but not limited to
"
+
"the purpose of enabling multiple text and
email messages to be sent simultaneously " +
"in the event of an emergency
"
+
"at the push of one
button."
,
version : "ututu-1; 2015/09/25; 13:13:13; David Auguste;" , xx:''
} ,
instructions :
"[1] install DroidScript from Google Play Store onto your mobile Android device; " +
"[2] create a new HTML project, then copy and paste all of this code into it;
" +
"[3] hit Run...(tell your
friends...peace)"
,
contacts :
{
davidAuguste : {
name : "David Auguste" ,
address : "London,
England" ,
mobile : "+447449399985" , xx:''
} , xx:''
} ,
comments :
"ignore or remove occurrances of [xx:'']...it's only there for compatibility with Internet Explorer 9..." ,
xx:''
} ;
</script>
<!----------------------------------------------------------------------------------------------------------------------
>
<meta
name="viewport" content="width=device-width" >
<script src='file:///android_asset/app.js'></script>
<!----------------------------------------------------------------------------------------------------------------------
>
<script
id="helper_functions">
function output (_string ) {
var e = document.getElementById("output");
if(e)e.innerHTML += _string;
};
function tag (_tag,_attributes,_content,_addEndTag ) {
var space=(_attributes.length>0?' ':'');
if(_addEndTag
)return '<'+_tag + space
+_attributes + '>' +_content + '</'+_tag +'>';
else return '<'+_tag + space +_attributes + '>' ;
};
function getNextSiblingByClassName (_e,_n) {
var f=_e;
while
(f&&f.className!=_n)f=f.nextSibling;
return f;
};
function getPrevSiblingByClassName (_e,_n) {
var f=_e;
while
(f&&f.className!=_n)f=f.previousSibling;
return f;
};
function toggleDisplay (_e,_s1,_s2) {
if (_e&&_e.style.display ==_s1)_e.style.display =_s2;
else if(_e) _e.style.display =_s1;
};
function toggleBackgroundColor (_e,_s1,_s2,_toggleScrollbar) {
var c = _e&&_e.style.backgroundColor==_s1?_s2:_s1;
if(_e)
if
(_toggleScrollbar)
_e.style.scrollbarBaseColor =
_e.style.scrollbarFaceColor
=
_e.style.scrollbarTrackColor=
_e.style.backgroundColor = c;
else
_e.style.backgroundColor = c;
};
function preserveText () {
var x,t=document.getElementsByTagName("textarea");
for(x in t) { t[x].innerHTML = t[x].value; }
};
function getClipboardText () {
var
t;
try { t = app.GetClipboardText(); }
catch (_err) { t = window.clipboardData.getData("Text"); }
return t;
};
function setClipboardText (_t) {
try { app.SetClipboardText(_t); }
catch
(_err) { window.clipboardData.setData("Text",_t); }
};
function runScript (_text,_appendToBody) {
if(_appendToBody) {
try {
var script = document.createElement('script');
var head = document.getElementsByTagName('head')[0];
if
(script.text=='') {
script.text = _text;
head.appendChild(script);
}
else {
script.appendChild(document.createTextNode(_text));
head.appendChild(script);
}
}
catch(e) { alert(e);
return; }
}
else {
try { eval(_text);
}
catch(e) { alert(e); return; }
}
};
function addStyleSheet (_text) {
try {
var styleNode = document.createElement('style');
var head =
document.getElementsByTagName('head')[0];
styleNode.type = "text/css";
if(!!
(window.attachEvent && !window.opera)) {
styleNode.styleSheet.cssText = _text;
head.appendChild(styleNode);
}
else {
styleNode.appendChild(document.createTextNode(_text));
head.appendChild(styleNode);
}
}
catch(e) { alert(e); return; }
}
</script>
<!----------------------------------------------------------------------------------------------------------------------
>
<script
id="layout_settings">
var settings = {
buttons :
{
size : "128px",
xx:''
} ,
color : {
background : "#fff"
,
foreground : "#000"
,
newTask : "#0ff"
,
delTask : "#f0f"
,
activate : "#f00"
,
check : "#0f0"
,
editor : "#ff0" ,
xx:''
} ,
messages :
{
onCopy : "task list copied to
clipboard"
,
onPaste : "clipboard text copied to task list
" ,
emailError
: "function email(...) is not supported on this device"
,
textError : "function text(...) is not supported on this
device" , xx:''
} ,
script
: {
appendToBody : false , xx:''
} ,
text : {
label
:
"codeBox..."
,
task : "textarea.rows=32;\r\n//www.w3schools.com -> \"Learn JavaScript\"" , xx:''
} , xx:''
};
var css = {
body:
{
type :
"tag" ,
declaration :
"color:"
+ settings.color.foreground + ";"
+
"background-
color:" + settings.color.background + ";" +
"" , xx:''
} ,
frame : {
type :
"id" ,
declaration :
"font-
family:Arial;" +
"width:100%;"
+
"height:100%;"
+
"color:"
+ settings.color.foreground + ";"
+
"background-
color:" + settings.color.background + ";" +
"" , xx:''
} ,
button : {
type :
"tag" ,
declaration :
"height:"
+ settings.buttons.size + ";" +
"width:"
+ settings.buttons.size + ";" +
"border:8px
" + settings.color.foreground +
" solid;" +
"" , xx:''
} ,
newTask : {
type :
"class" ,
declaration :
"margin:16px;"
+
"font-
size:56pt;" +
"background-color:" +
settings.color.newTask + ";" +
"border-
radius:" + settings.buttons.size + ";" +
"" , xx:''
} ,
delTask : {
type :
"class" ,
declaration :
"margin:16px;"
+
"font-
size:56pt;" +
"background-color:" +
settings.color.delTask + ";" +
"" , xx:''
} ,
container : {
type :
"class" ,
declaration :
"margin:0px;"
+
"" , xx:''
} ,
label : {
type :
"class" ,
declaration :
"white-
space:nowrap;" +
"font-family:times new roman;" +
"font-
size:72pt;" +
"padding:4px 0px 0px 160px;" +
"margin-bottom:16px;" +
"" , xx:''
} ,
codeBox : {
type :
"class" ,
declaration :
"display:block;"
+
"margin:0px
56px 24px 56px;" +
"padding:0px;"
+
"border:8px
" + settings.color.foreground +
" solid;" +
"" , xx:''
} ,
//..
activate : {
type :
"class" ,
declaration :
"background-color:" +
settings.color.activate + ";" +
"border-
radius:" + settings.buttons.size +
";" +
"float:left;" +
"" , xx:''
} ,
activateGrayed : {
type :
"class" ,
declaration :
"border-
radius:" + settings.buttons.size + ";" +
"float:left;"
+
"" , xx:''
} ,
//..
check : {
type :
"class" ,
declaration :
"margin:0px;"
+
"background-
color:" + settings.color.check + ";" +
"float:right;"
+
"" , xx:''
} ,
checkGrayed : {
type :
"class" ,
declaration
:
"margin:0px;"
+
"float:right;"
+
"" , xx:''
} ,
//..
editor : {
type :
"class" ,
declaration :
"width:100%;"
+
"font-
weight:bold;" +
"font-family:courier new;" +
"font-
size:20pt;" +
"border:0px;"
+
"padding:16px;"
+
"background-
color:" + settings.color.editor + ";" +
"scrollbar-base-
color:" + settings.color.editor + ";" +
"scrollbar-face-
color:" + settings.color.editor + ";" +
"scrollbar-track-
color:" + settings.color.editor + ";" +
"scrollbar-arrow-
color:" + settings.color.foreground + ";" +
"scrollbar-DarkShadow-
Color:" + settings.color.foreground + ";" +
"" , xx:''
} ,
editorGrayed : {
type :
"class" ,
declaration
:
"width:100%;"
+
"font-
weight:bold;" +
"font-family:courier new;" +
"font-
size:20pt;" +
"border:0px;"
+
"padding:16px;"
+
"scrollbar-arrow-
color:" + settings.color.foreground + ";"
+
"scrollbar-DarkShadow-Color:" +
settings.color.foreground + ";" +
"" , xx:''
} , xx:''
};
var style = {
//...
scale : 1.0 ,
paddingBottom :
"" ,
//[Dd] i encountered
problems with popup onscreen keyboards obscuring text entry boxes,
// so i added
padding to the bottom of the "list" (see: id="list" ..below) based on
// screen
size..
//...
getHTML : function ( _selector ) { return style.getCSS
(_selector,true); } ,
getCSS : function ( _selector , _includeHTML ) {
var a,b,c,d,e;
function split (){
a=css[_selector].declaration.match(/[\d]+px|[\d]+pt/g); if(a==null)return;
b=css[_selector].declaration.split(/
[\d]+px|[\d]+pt/g);
c=a.join("").split
(/px|pt/g);
d=a.join("").match(/px|pt/g);
}
function scale (){ if(a==null)return;
for(e in a)c[e]=parseInt(parseInt(c[e])*style.scale);
}
function join (){ if
(a==null)return;
for(e in
a){b[e]+=c[e]+d[e];} a=b.join("");
}
split();
scale();
join ();
if(_includeHTML)return "style=\"" + (a?a:css[_selector].declaration) + "\"";
else return
(a?a:css[_selector].declaration) ;
} ,
initialize :
function () {
function injectStyle () {
function createRule (_selector,_type,_declaration){
var prefix;
switch(_type){
case "class": prefix = "."; break;
case "id": prefix = "#"; break;
default: prefix = "" ; break;
}
return prefix +_selector + "{" +_declaration + "}"
;
}
var
x,t="";
for(x in css)if(css[x].type){t+=createRule(x,css[x].type,style.getCSS(x));}
addStyleSheet(t);
}
var w = screen.width ;
var h = screen.height;
style.scale = (w<h?w:h)/1360.0
;
style.paddingBottom = parseInt((w>h?w:h)/ 1.0)+"px";
injectStyle();
} , xx:''
};
</script>
<!----------------------------------------------------------------------------------------------------------------------
>
<script
id="main">
function main () {
style.initialize();
document.getElementById("list" ).style.paddingBottom = style.paddingBottom;
document.getElementById("tools").innerHTML =
tag ( "button" , "class=\"newTask\" onclick=\"newTask()\"" ,
"+" , true ) +
tag ( "button" , "class=\"delTask\"
onclick=\"delTask()\"" , "-" , true ) ;
try{ app.SetScreenMode( "Full" ); } catch (_err){ }
};
function newTask ( ) {
function buttonActivate ( ) {
return tag ( "button" ,
"class=\"activate\" onclick=\"onActivate
(this)\"" , "" , true );
};
function buttonLabel ( ) {
return tag ( "div" , "class=\"label\" onclick=\"onLabel(this)\"
contenteditable" , settings.text.label , true );
};
function buttonCheck ( ) {
return tag ( "button" ,
"class=\"check\" onclick=\"onCheck
(this)\"" , "" , true );
};
function textareaEditor ( ) {
return tag ( "textarea" , "class=\"editor\" contenteditable rows=
\"4\"" , settings.text.task , true );
};
var div = document.getElementById('list');
preserveText();
div.innerHTML =
tag ( "div" , "class=\"container\"" , buttonActivate() + buttonCheck() +
buttonLabel() +
tag ( "div" , "class=\"codeBox\"" , textareaEditor
()
,
true ),
true ) +
div.innerHTML;
};
function delTask ( ) {
var p,e,c;
if(confirm("Confirm: \"delete all active
tasks\"?")) {
p = document.getElementById("list");
e = p.childNodes[0];
while(e){
if(e.childNodes[0].className=="activate") {
c=e; e=e.nextSibling; p.removeChild(c);
}
else {
e=e.nextSibling;
}
}
}
};
</script>
<!---------------------------------------------------------------------------------------------------------------------->
<script id="event_handlers">
var textarea;
function onActivate
(_e) {
if(_e.className!="activate")return;
var f=getNextSiblingByClassName(_e,"codeBox").childNodes[0];
textarea=f; if(f)runScript
(f.value,settings.script.appendToBody);
};
function
onLabel (_e) {
toggleDisplay (getNextSiblingByClassName(_e,"codeBox"),"none","block");
};
function onCheck (_e) {
if(_e.className=="check")
{
getPrevSiblingByClassName (_e,"activate") .className="activateGrayed";
_e
.className="checkGrayed" ;
getNextSiblingByClassName (_e,"codeBox" ).childNodes[0].className="editorGrayed" ;
}
else {
getPrevSiblingByClassName (_e,"activateGrayed") .className="activate" ;
_e
.className="check" ;
getNextSiblingByClassName (_e,"codeBox" ).childNodes[0].className="editor" ;
}
};
</script>
<!---------------------------------------------------------------------------------------------------------------------->
<script id="api">
function getTaskList ( ) { preserveText(); return
document.getElementById('list').innerHTML; }
function setTaskList (_s,_options) {
switch(_options) {
case "top": {
t = document.getElementById('list').innerHTML;
document.getElementById('list').innerHTML =_s+t;
break;
}
case "bottom":
{
document.getElementById('list').innerHTML
+=_s ;
break;
}
default: {
document.getElementById('list').innerHTML =_s ;
break;
}
}
}
function copy ( ) {
setClipboardText(getTaskList());
try { app.ShowPopup
(settings.messages.onCopy ); } catch (_err) { }
}
function paste (_options) {
setTaskList( getClipboardText() , _options
);
try { app.ShowPopup(settings.messages.onPaste); } catch (_err) { }
}
function
email (_address,_subject,_body,_attachment) {
try {
app.SendMail (_address,_subject,_body,_attachment);
}
catch (_err) {
alert(settings.messages.emailError);
}
}
function
text (_number,_message) {
try {
var sms = app.CreateSMS();
sms.SetOnStatus
( sms_OnStatus );
sms.SetOnMessage
( sms_OnMessage );
sms.Send ( _number,_message
);
}
catch (_err) {
alert( settings.messages.textError );
}
};
function sms_OnStatus ( _status
) { app.ShowPopup(_status); }
function
sms_OnMessage ( _number, _msg ) { app.ShowPopup(_number + ": " + _msg); }
</script>
<!---------------------------------------------------------------------------------------------------------------------->
</head>
<body onload="main();">
<div id="frame">
<div id="tools" align="center"></div>
<div id="list" align="left" ></div>
</div>
<div id="output"></div>
</body>
</html>
<!---------------------------------------------------------------------------------------------------------------------->