diff --git a/view/vcontextmenu.js b/view/vcontextmenu.js index 23266997d810f64c95b9e285f22403353bfe286e..dcf3f325c81ae068477a469f56072f0f03a882b2 100644 --- a/view/vcontextmenu.js +++ b/view/vcontextmenu.js @@ -17,6 +17,49 @@ function cfContextMenu(evt, view, dt) { let menu = $(view.dom).find('.contextmenu').get(0) let title = $(`<div>${text}</div>`).addClass('contextTitle').get(0) $(view.dom).find('.contextmenu').append(title) + // // add the text window, select it ... + // also want: keyboard and enter ... track which is selected, then ? + let tinput = $('<input>').attr('type', 'text').attr('size', 28).attr('value', '').get(0) + $(view.dom).find('.contextmenu').children('.contextTitle').get(0).append(tinput) + $(tinput).focus() + $(tinput).select() + tinput.addEventListener('keyup', (evt) => { + let arr = $(view.dom).find('.contextmenu').children('li').toArray() + if (evt.keyCode == 13) { + // enter case + let pick = $(view.dom).find('.contextmenu').children('.highlighted').get(0) + pick.click() + } else { + // key character ? + let filts = tinput.value.toUpperCase().split(' ') + console.log(filts) + let sel = false + // separate items by space, search for either, + // reorder by search quality + for (let item of arr) { + // we want the items that match *some part of both items in the filt* + let pass = true + for (let conf of filts) { + if ($(item).text().toUpperCase().indexOf(conf) < 0) { + pass = false + } + } + if (pass) { + item.style.display = "" + // mark as selected, then this is our enter-docu + if (!sel) { + $(item).addClass('highlighted') + sel = true + } else { + $(item).removeClass('highlighted') + } + } else { + item.style.display = "none" + $(item).removeClass('highlighted') + } + } + } + }) } let fadeOut = (ms) => { @@ -62,7 +105,7 @@ function cfContextMenu(evt, view, dt) { // the view we would issue from, let scope = evt.target.hunk - if (!scope){ + if (!scope) { console.error('contextmenu, no scope') return false } @@ -82,42 +125,6 @@ function cfContextMenu(evt, view, dt) { changeContextTitle('do: ') // on of the options will ... - // add the text window, select it ... - // also want: keyboard and enter ... track which is selected, then ? - let tinput = $('<input>').attr('type', 'text').attr('size', 28).attr('value', '').get(0) - $(view.dom).find('.contextmenu').children('.contextTitle').get(0).append(tinput) - $(tinput).focus() - $(tinput).select() - tinput.addEventListener('keyup', (evt) => { - if(evt.keyCode == 13){ - // enter case - let pick = $(view.dom).find('.contextmenu').children('.highlighted').get(0) - pick.click() - } else { - // key character ? - let filt = tinput.value.toUpperCase() - let arr = $(view.dom).find('.contextmenu').children('li').toArray() - let sel = false - // separate items by space, search for either, - // reorder by search quality - for(let item of arr){ - if($(item).text().toUpperCase().indexOf(filt) > -1){ - item.style.display = "" - // mark as selected, then this is our enter-docu - if(!sel){ - $(item).addClass('highlighted') - sel = true - } else { - $(item).removeClass('highlighted') - } - } else { - item.style.display = "none" - $(item).removeClass('highlighted') - } - } - } - }) - /* --------------------------- ---------------------------- */ /* ---------------- LOCAL OPTIONS, for SCOPE ----------------- */ /* --------------------------- ---------------------------- */ @@ -235,22 +242,22 @@ function cfContextMenu(evt, view, dt) { // for posterity, bc of often-broken-due-to-def-rewrite (bugfarm!), // we run a GO before we do this... let debug = true - if(debug) console.log(`SS: running GO`) + if (debug) console.log(`SS: running GO`) view.globalOrganize() // the top ... scope = view, so let tlp = view.patchset.writeCurrent() // heirarchichal traverse, let recursor = (scope, branch, ld) => { - if(debug) console.log(`SS: recurse at ${scope.name} thru ${ld.name}`) + if (debug) console.log(`SS: recurse at ${scope.name} thru ${ld.name}`) // ld -> link def // scope -> view that this link lives within let localScope = view.trace(ld.outputs[1], debug) - if(debug) console.log("SAVESYS: traces to ", localScope) + if (debug) console.log("SAVESYS: traces to ", localScope) // if this link traces up to a view, if (localScope && localScope.parent.type === 'view' && localScope.parent.hunk.hasRefreshed) { // for the reciprocal link, nest localScope = localScope.parent.hunk - if(debug) console.log("SAVESYS: traces to view") + if (debug) console.log("SAVESYS: traces to view") // we can use this view to write its contents let nlp = localScope.patchset.writeCurrent() // now we need to put it ...