Newer
Older
/*
view/vmsg.js
largely unused appendage
Jake Read at the Center for Bits and Atoms
(c) Massachusetts Institute of Technology 2019
This work may be reproduced, modified, distributed, performed, and
displayed for any purpose, but must acknowledge the squidworks and cuttlefish projects.
Copyright is retained and must be preserved. The work is provided as is;
no warranty is provided, and users accept all liability.
*/
// micro html console
function MessageBox(View) {
let view = View
// and things inside of it,
this.zoomCheckbox = {}
// tracking a load,
this.briefState = {
recipName: '',
recipVersion: '',

Jake Read
committed
this.recipVer = brief.interpreterVersion
this.recipName = brief.interpreterName
this.numHunksLeft = brief.numHunks
},
incrementHunks: function() {
this.numHunksLeft++
},
decrementLinks: function() {
this.numLinksLeft--
incrementLinks: function() {
briefStateToDom(this)
}
}
let briefStateToDom = (brief) => {
let str
if (brief.numHunksLeft > 0) {
str = `interpreter: ${brief.recipName} ${brief.recipVer} <br> awaiting ${brief.numHunksLeft} hunks`
} else {
str = `interpreter: ${brief.recipName} ${brief.recipVer} <br> all loaded OK`
/* --------------------------- ---------------------------- */
/* ------------------------- STARTUP ------------------------- */
/* --------------------------- ---------------------------- */
this.init = () => {
this.msgbox = $('<div>').addClass('msgbox').get(0)
this.msgbox.append($('<div>').attr('id', 'titleBox').addClass('msgboxmsg').append('name and interpreter:<br>~ unknown ~<br>truly').get(0))
this.msgbox.append($('<div><i class="em em-wave"></i>').addClass('msgboxbutton').addClass('msgboxmsg').append(' say hello').click((evt) => {

Jake Read
committed
view.sayHelloToManager()
this.msgbox.append($('<div><i class="em em-arrows_counterclockwise"></i>').addClass('msgboxbutton').addClass('msgboxmsg').append(' refresh view').click((evt) => {
this.toggleHidden = () => {
if(this.isHidden){
$(this.msgbox).show()
} else {
$(this.msgbox).hide()
}
}
let tpad = 10
this.setTopMargin = (num) => {
tpad = num
this.checkHeight()
}
this.checkHeight = () => {
let ht = view.dom.clientHeight
$(this.msgbox).css('height', `${ht - 30 - tpad}px`).css('margin-top', `${tpad}px`)
$(this.msgbox).css('display', 'none')
$(this.msgbox).css('display', 'inline')
/* --------------------------- ---------------------------- */
/* -------------------------- WRITE -------------------------- */
/* --------------------------- ---------------------------- */
this.write = (data) => {
this.msgbox.append($('<div> -> ' + data + '</div>').addClass('msgboxmsg').get(0))
// def check
let heightcheck = () => {
let height = 0;
$(this.msgbox).children().each(function(child) {
// jquery.each() syntax is a bit odd / different than elsewhere, sorry for inconsistency
height += this.clientHeight + 5
})
return height
}
// if too tall, remove
$(this.msgbox).children().get(3).remove()
// two at most, sloppy but fast
if (heightcheck() > ch) {
$(this.msgbox).children().get(3).remove()
this.clear = () => {
while($(this.msgbox).children().length > 3){
$(this.msgbox).children().get(3).remove()