Commit f2e67034 authored by Job Cuppen's avatar Job Cuppen

done

parent 26fee0d8
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html style="width: 100%; height: 100%;">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="/css/itasks-modules.css" type="text/css" >
<!-- ABC interpreter -->
<script type="text/javascript" src="/js/abc-interpreter.js"></script>
<script type="text/javascript" src="/js/itasks-abc-interpreter.js"></script>
<!-- iTasks framework -->
<script type="text/javascript" src="/js/itasks-core.js"></script>
<script type="text/javascript" src="/js/itasks-components-raw.js"></script>
<script type="text/javascript" src="/js/itasks-components-form.js"></script>
<script type="text/javascript" src="/js/itasks-components-display.js"></script>
<script type="text/javascript" src="/js/itasks-components-selection.js"></script>
<script type="text/javascript" src="/js/itasks-components-container.js"></script>
<!-- load iTasks viewport -->
<script type="text/javascript">
window.onload = function() {
itasks.viewport({syncTitle: true}, document.body);
};
</script>
</head>
<body style="width: 100%; height: 100%">
</body>
</html>
This diff is collapsed.
"use strict";
var ABC=null;
const ABC_loading_promise=ABCInterpreter.instantiate({
bytecode_path: '/js/app.pbc',
heap_size: 8<<20,
stack_size: 512<<10,
encoding: 'utf-8',
util_imports: {
has_host_reference: function (index) {
if (index>=ABC.shared_clean_values.length)
return 0;
if (ABC.shared_clean_values[index]==null)
return -1;
return ABC.shared_clean_values[index].ref;
},
update_host_reference: function (index, new_location) {
ABC.shared_clean_values[index].ref=new_location;
},
},
interpreter_imports: {
handle_illegal_instr: function (pc, instr, asp, bsp, csp, hp, hp_free) {
if (ABCInterpreter.instructions[instr]=='instruction') {
const arg=ABC.memory_array[(pc+8)/4];
switch (arg) {
case 0: /* evaluation finished */
return 0;
case 1: /* iTasks.UI.JS.Interface: set_js */
var v=ABC.get_clean_string(ABC.memory_array[asp/4], true);
var x=ABC.get_clean_string(ABC.memory_array[asp/4-2], true);
if (ABC_DEBUG)
console.log(v,'.=',x);
try {
var ref=eval(v+'.shared_clean_value_index');
if (typeof ref != 'undefined') {
if (ABC_DEBUG)
console.log('removing old reference to Clean',ref);
ABC.clear_shared_clean_value(ref);
}
} catch (e) {}
Function(v+'='+x)();
break;
case 2: /* iTasks.UI.JS.Interface: eval_js */
var string=ABC.get_clean_string(ABC.memory_array[asp/4], true);
if (ABC_DEBUG)
console.log('eval',string);
Function(string)();
break;
case 3: /* iTasks.UI.JS.Interface: eval_js_with_return_value */
var string=ABC.get_clean_string(ABC.memory_array[asp/4], true);
if (ABC_DEBUG)
console.log('eval',string);
var result=eval('('+string+')'); // the parentheses are needed for {}, for instance
var copied=ABC.copy_js_to_clean(result, asp);
ABC.interpreter.instance.exports.set_hp(copied.hp);
ABC.interpreter.instance.exports.set_hp_free(copied.hp_free);
break;
case 4: /* iTasks.UI.JS.Interface: share */
var attach_to=ABC.memory_array[bsp/4];
var index=ABC.share_clean_value(ABC.memory_array[asp/4],ABC.js[attach_to]);
ABC.memory_array[bsp/4]=index;
break;
case 5: /* iTasks.UI.JS.Interface: fetch */
var index=ABC.memory_array[bsp/4];
ABC.memory_array[asp/4]=ABC.shared_clean_values[index].ref;
break;
case 6: /* iTasks.UI.JS.Interface: deserialize */
var hp_ptr=ABC.memory_array[asp/4];
ABC.memory_array[asp/4]=ABC.deserialize_from_unique_string(hp_ptr);
break;
case 7: /* iTasks.UI.JS.Interface: initialize_client in wrapInitUIFunction */
var array=ABC.memory_array[asp/4]+24;
ABC.addresses.JSInt= ABC.memory_array[ABC.memory_array[array/4]/4];
ABC.addresses.JSBool= ABC.memory_array[ABC.memory_array[array/4+2]/4];
ABC.addresses.JSString= ABC.memory_array[ABC.memory_array[array/4+4]/4];
ABC.addresses.JSReal= ABC.memory_array[ABC.memory_array[array/4+6]/4];
ABC.addresses.JSNull= ABC.memory_array[ABC.memory_array[array/4+8]/4];
ABC.addresses.JSUndefined=ABC.memory_array[ABC.memory_array[array/4+10]/4];
ABC.addresses.JSArray= ABC.memory_array[ABC.memory_array[array/4+12]/4];
ABC.addresses.JSRef= ABC.memory_array[ABC.memory_array[array/4+14]/4];
ABC.addresses.JSCleanRef= ABC.memory_array[ABC.memory_array[array/4+16]/4];
ABC.util.instance.exports.set_js_ref_constructor(ABC.addresses.JSRef);
ABC.initialized=true;
break;
case 10: /* iTasks.UI.JS.Interface: add CSS */
var url=ABC.get_clean_string(ABC.memory_array[asp/4], false);
var css=document.createElement('link');
css.rel='stylesheet';
css.type='text/css';
css.async=true;
css.href=url;
document.head.appendChild(css);
break;
case 11: /* iTasks.UI.JS.Interface: add JS */
var url=ABC.get_clean_string(ABC.memory_array[asp/4], false);
var callback=ABC.get_clean_string(ABC.memory_array[asp/4-2], true);
var js=document.createElement('script');
js.type='text/javascript';
js.async=false;
if (callback.length>0)
js.onload=Function(callback+'();');
document.head.appendChild(js);
js.src=url;
break;
default:
throw new ABCError('unknown instruction',arg);
}
return pc+16;
}
return 0;
},
illegal_instr: function (addr, instr) {
ABC.empty_log_buffer();
if (ABCInterpreter.instructions[instr]=='instruction')
/* `instruction 0` ends the interpretation, so this is no error */
return;
throw new ABCError('illegal instruction',instr);
},
},
}).then(function(instance){
ABC=instance;
ABC.initialized=false;
// Overwrite ap to return a result (in the case of jsWrapFunWithResult)
ABC.ap=function(index){
var f=function () {
var args=[];
for (var i=0; i<arguments.length; i++)
args[i]=arguments[i];
ABC.interpret(new SharedCleanValue(index), args);
var result=undefined;
const new_asp=ABC.interpreter.instance.exports.get_asp();
const hp_ptr=ABC.memory_array[new_asp/4];
if (ABC.memory_array[hp_ptr/4]!=25*8+2) { // INT, i.e. JSWorld
// Assume we have received a tuple with the first element as the result
const str_ptr=ABC.memory_array[hp_ptr/4+2];
const string=ABC.get_clean_string(ABC.memory_array[str_ptr/4+2], false);
if (ABC_DEBUG)
console.log('result:',string);
result=eval('('+string+')');
}
if (typeof result!='undefined')
return result;
};
f.shared_clean_value_index=index;
return f;
};
});
itasks.Container = {
cssCls: 'container'
};
itasks.Panel = {
cssCls: 'panel',
initDOMEl: function() {
var me = this,
isTab = (me.parentCmp && me.parentCmp.type == 'TabSet');
//Create header
if(me.attributes.title && !isTab) {
me.headerEl = document.createElement('div');
me.headerEl.classList.add(me.cssPrefix + 'header');
me.headerEl.innerHTML = '<span>' + me.attributes.title + '</span>';
me.domEl.appendChild(me.headerEl);
}
//Create separate container div
me.containerEl = document.createElement('div');
me.containerEl.classList.add(me.cssPrefix + 'inner');
me.domEl.appendChild(me.containerEl);
//Add sizers
if(me.attributes.resizable) {
for(var i = 0; i < me.attributes.resizable.length; i++) {
me.domEl.append(me.createSizer(me.attributes.resizable[i]));
}
}
//Fullscreenable
if(me.attributes.fullscreenable){
me.domEl.style.position = 'relative';
var fullscreener = document.createElement('a');
var button = document.createElement('div');
button.classList.add(me.cssPrefix + "button-icon");
button.classList.add("icon-fullscreen");
fullscreener.appendChild(button);
fullscreener.style.position = 'absolute';
fullscreener.style.bottom = 0;
fullscreener.style.right = 0;
fullscreener.href = '#';
me.fullscreen = false;
fullscreener.onclick = function () {
if(me.fullscreen){
me.domEl.style.position = 'relative';
me.domEl.style.top = null;
me.domEl.style.left = null;
me.domEl.style.right = null;
me.domEl.style.bottom = null;
me.domEl.style.width = null;
me.domEl.style.height = null;
fullscreener.style.zIndex = null;
me.domEl.style.zIndex = null;
me.fullscreen = false;
} else {
me.domEl.style.position = 'absolute';
me.domEl.style.top = 0;
me.domEl.style.left = 0;
me.domEl.style.right = 0;
me.domEl.style.bottom = 0;
me.domEl.style.width = '100%';
me.domEl.style.height = '100%';
fullscreener.style.zIndex = 999;
me.domEl.style.zIndex = 998;
me.fullscreen = true;
}
};
me.domEl.appendChild(fullscreener);
}
},
createSizer: function(side) {
var me = this,
el = document.createElement('div');
el.classList.add(me.cssPrefix + 'sizer-' + side);
el.addEventListener('mousedown', function init (e){
function preventDefault(e) { e.preventDefault(); }
window.addEventListener('selectstart', preventDefault);
if(side == 'top' || side == 'bottom') {
var startPos = e.clientY;
var startSize = parseInt(window.getComputedStyle(me.domEl).getPropertyValue('height').slice(0,-2));
me.domEl.style['height'] = startSize + 'px';
} else {
var startPos = e.clientX;
var startSize = parseInt(window.getComputedStyle(me.domEl).getPropertyValue('width').slice(0,-2));
me.domEl.style['width'] = startSize + 'px';
}
//Disable flexing
me.domEl.style.flex = '0 0 auto';
var resize = function resize(ev) {
switch(side) {
case 'bottom': me.domEl.style['height'] = (startSize + (ev.clientY - startPos)) + 'px'; break;
case 'top': me.domEl.style['height'] = (startSize + (startPos - ev.clientY)) + 'px'; break;
case 'right': me.domEl.style['width'] = (startSize + (ev.clientX - startPos)) + 'px'; break;
case 'left': me.domEl.style['width'] = (startSize + (startPos - ev.clientX)) + 'px'; break;
}
//Trigger resize event on all siblings
me.parentCmp.children.forEach(function(child) {
child.onResize();
});
};
window.addEventListener('mousemove', resize, false);
window.addEventListener('mouseup', function stop(e){
window.removeEventListener('selectstart', preventDefault);
window.removeEventListener('mousemove', resize, false);
window.removeEventListener('mouseup', stop, false);
}, false);
}, false);
return el;
},
setTitle(title) {
var me = this;
if(me.headerEl != null) {
var titleEl = me.headerEl.getElementsByTagName('span')[0];
titleEl.textContent = title;
} else if(me.tabEl != null) {
var titleEl = me.tabEl.getElementsByTagName('span')[0];
titleEl.textContent = title;
}
},
onAttributeChange: function(name,value) {
if(name == 'title') {
this.setTitle(value);
}
}
};
itasks.TabSet = {
cssCls: 'tabset',
activeTab: 0,
attributes: {
height: 'flex',
width: 'flex'
},
replacing: false,
initDOMEl: function() {
var me = this,
el = me.domEl;
me.tabBar = document.createElement('ul');
me.tabBar.classList.add(me.cssPrefix + 'tabbar');
//Create tabs for the initial children
me.children.forEach(function(child,i) {
me.tabBar.appendChild(me.createTabEl(child, i == me.activeTab));
});
me.domEl.appendChild(me.tabBar);
me.containerEl = document.createElement('div');
me.containerEl.classList.add(me.cssPrefix + 'tabitems');
me.domEl.appendChild(me.containerEl);
},
createTabEl: function (cmp, selected) {
var me = this, tab, label, icon;
tab = document.createElement('li');
label = document.createElement('a');
if (cmp.type == 'Button'){
label.innerHTML = '<span>'+ (cmp.attributes.text || '-')+'</span>';
label.href = '#';
label.addEventListener('click',function(e) {
if(cmp.attributes.enabled) {
cmp.doEditEvent(cmp.attributes.taskId,cmp.attributes.editorId,cmp.attributes.value);
}
e.preventDefault();
},me);
if(!cmp.attributes.enabled) {
tab.classList.add(me.cssPrefix + 'tab-disabled');
}
cmp.domEl.style.display = "none";
} else {
label.innerHTML = '<span>'+ (cmp.attributes.title || '-')+'</span>';
label.href = '#';
label.addEventListener('click',function(e) {
var tabEl = e.target.parentElement.parentElement,
tabBar = tabEl.parentElement,
idx = Array.prototype.indexOf.call(tabBar.children,tabEl);
me.setActiveTab(idx);
e.preventDefault();
},me);
}
if(cmp.attributes.iconCls) {
icon = document.createElement('div');
icon.classList.add(me.cssPrefix + 'tabicon');
icon.classList.add(cmp.attributes.iconCls);
label.insertBefore(icon,label.childNodes[0]);
}
tab.appendChild(label);
if (cmp.type !== 'Button'){
if(cmp.attributes.closeTaskId) {
closeLink = document.createElement('a');
closeLink.innerHTML = 'x';
closeLink.href = '#';
closeLink.classList.add(me.cssPrefix + 'tabclose');
closeLink.addEventListener('click',function(e) {
me.doEditEvent(cmp.attributes.closeTaskId,null,'Close');
e.preventDefault();
},me);
tab.appendChild(closeLink);
}
if(selected) {
tab.classList.add(me.cssPrefix + 'selected');