Select Git revision
vmsg.js 3.97 KiB
// micro html console
function MessageBox(View) {
let view = View
// and things inside of it,
this.zoomCheckbox = {}
// tracking a load,
this.briefState = {
recipName: '',
recipVersion: '',
numHunksLeft: 0,
numLinksLeft: 0,
isStateHappenning: false,
setFromBrief: function(brief) {
this.recipVer = brief.interpreterVersion
this.recipName = brief.interpreterName
this.numHunksLeft = brief.numHunks
briefStateToDom(this)
},
decrementHunks: function() {
this.numHunksLeft--
briefStateToDom(this)
},
incrementHunks: function() {
this.numHunksLeft++
briefStateToDom(this)
},
decrementLinks: function() {
this.numLinksLeft--
briefStateToDom(this)
},
incrementLinks: function() {
this.numLinksLeft++
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`
}
$(this.msgbox).find('#titleBox').html(str)
}
this.msgbox = {}
/* --------------------------- ---------------------------- */
/* ------------------------- STARTUP ------------------------- */
/* --------------------------- ---------------------------- */
this.init = () => {
//view.log('message box alive')
console.log("MSGBOXHELLO")
// a box,
this.msgbox = $('<div>').addClass('msgbox').get(0)
// the title, and id of your manager
this.msgbox.append($('<div>').attr('id', 'titleBox').addClass('msgboxmsg').append('name and interpreter:<br>~ unknown ~<br>truly').get(0))
// say hello to your manager,
this.msgbox.append($('<div><i class="em em-wave"></i>').addClass('msgboxbutton').addClass('msgboxmsg').append(' say hello').click((evt) => {
view.sayHelloToManager()
}).get(0))
// a refresh button
this.msgbox.append($('<div><i class="em em-arrows_counterclockwise"></i>').addClass('msgboxbutton').addClass('msgboxmsg').append(' refresh view').click((evt) => {
evt.preventDefault()
view.refresh()
}).get(0))