Skip to content

Commit

Permalink
search box optimizations/bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bulk88 committed Mar 20, 2024
1 parent e080bc6 commit 97d0006
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/ac.appcache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CACHE MANIFEST
# v Wed Mar 20 14:30:28 2024
# v Wed Mar 20 15:33:56 2024

CACHE:
index.html
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<html manifest=ac.appcache><link href=https://www.googleapis.com rel=preconnect crossorigin><link href=//carrier.natasha.cat rel=preconnect><link href=https://content-people-pa.googleapis.com rel=preconnect crossorigin><link href=https://proxya6d0.us.to rel=preconnect><link href=thread.html rel=prefetch><meta charset=utf-8 content=0 name=mobileoptimized><style>body{margin-top:0px;}button{line-height:1.5}</style><script src=client.js></script><script>initLnkFmt();var d,u,t,e,n=0;function l(e,n,s,o){getAuthToken(function(t){r(!0,t,e,n,s,o)})}function r(t,e,n,s,o,a){var i=new XMLHttpRequest;i.open("POST","https://www.googleapis.com/voice/v1/voiceclient/api2thread/list?alt="+(n?"json&prettyPrint=false":"protojson"),1),i.setRequestHeader("Content-Type","application/json+protobuf"),i.setRequestHeader("Authorization","Bearer "+e),i.onreadystatechange=function(){4==i.readyState&&(503==i.status?r(t,e,n,s,o,a):t&&401==i.status&&resp401Unauth(i.response)?(wvWipeAuthToken(),getAuthToken(function(t){r(!1,t,n,s,o,a)})):200!=i.status?(401!=i.status&&alert("status: "+i.status+"\nresp:"+i.response),a(i.response||-1)):a(!1,n?JSON.parse(i.response):i.response))},i.send((n?"["+(o?6:2)+",100,1":"["+(o?6:2)+",1,1")+(s?',"'+s+'"]':"]"))}function g(i){(i=i.target).textContent=" ▽⌛";var r=i.getAttribute("data-pgtok");l(r,r,sessionStorage.getItem("wvArchView"),function(t,e){if(t)i.textContent=" ▽✘";else if(r)C(r,e,u);else{var n=document.getElementById("threadList"),s=n.firstChild&&n.firstChild.getAttribute("data-mid");if(e.substr(25,40)!=s)l(1,0,sessionStorage.getItem("wvArchView"),function(t,e){t?i.textContent=" ▽✘":(C(0,e,u),i.textContent=" ▽✔")}),u=v();else{i.textContent=" ▽✔";for(var o,a=0;a<n.children.length;a++)"DIV"===(t=n.children[a]).nodeName&&(o=(t=t.firstChild.firstChild).firstChild).nodeValue.match(/^\+\d+$/)&&p(t,o.nodeValue)}}}),r&&(u=v())}function refreshNoUI(){g({target:{textContent:0,getAttribute:function(){}}})}lazySignedInEmail()&&(d=1,refreshNoUI())</script>Welcome To Whogle Voice<button style=visibility:hidden>B</button><div id=sign-in-bar></div><button style=width:4em;height:2em;text-align:left; onclick=g(event) id=rfsh title=Refresh> ▽</button> <label><input type=checkbox id=archive onchange='sessionStorage.setItem("wvArchView",this.checked?"1":""),document.getElementById("threadList").innerHTML=localStorage.getItem(this.checked?"wvThdListA":"wvThdListM");var i=this.parentNode.previousSibling.previousSibling;i.onclick({target:i})'title=Archive>A</label> <input type=tel oninput=a(event) placeholder="New num here"size=10><button style=min-width:5em onclick=o(event)>To ABC</button><div id=threadList></div><script>function s(o){var l=document.getElementById("threadList");o.length?h(o,e,function(n,a){if(!n&&a.thread&&a.thread.length){var i={},r=document.createElement("select");for(n in r.size=a.thread.length+1,r.style.width="100%",r.onchange=function(t){(t=t.target.value)?(12===t.length&&"+"===t[0]&&"1"===t[1]&&(t=t.slice(2)),window.location="thread.html#"+t):(e+=5,s(o))},a.thread.forEach(function(e){var n,a=r.appendChild(document.createElement("option")),o=e.contact[0].name,o=u[o]||o;t[o]||o.match(/^\+\d+$/)&&((n=i[o])||(i[o]=n=[]),n.push(a)),a.value=e.contact[0].phoneNumber,a.innerText=o+" - "+e.item[0].messageText}),(a=r.appendChild(document.createElement("option"))).innerText="More",a.value="",n=l.parentNode,"SELECT"===(a=l.previousElementSibling).nodeName?n.replaceChild(r,a):n.insertBefore(r,l),i)f(i[n],n)}else s("")}):"SELECT"===(o=l.previousElementSibling).nodeName&&l.parentNode.removeChild(o)}function a(e){var e=e.target,t=e.nextElementSibling.firstChild,n=t.nodeValue;e.value.length?"To ABC"===n?t.nodeValue="Go #":("To Num"===n&&(t.nodeValue="Clear"),s(e.value)):"Go #"===n?t.nodeValue="To ABC":"Clear"===n&&(t.nodeValue="To Num",s(""))}function o(n){var a=(n=n.target).firstChild,n=n.previousSibling,o=a.nodeValue;"To ABC"===o?(e=5,n.type="text",n.placeholder="Search Contacts",n.removeAttribute("size"),a.nodeValue="To Num",n.focus(),t={},u=u||v()):"To Num"===o?(n.type="tel",n.placeholder="New num here",n.size=10,a.nodeValue="To ABC",n.focus()):"Go #"===o?window.location="thread.html#"+c(n.value):"Clear"===o?(a.nodeValue="To Num",s(n.value="")):alert("unk state")}function h(t,n,a){getAuthToken(function(e){m(!0,e,t,n,a)})}function m(e,t,n,a,o){var i=new XMLHttpRequest;i.open("POST","https://www.googleapis.com/voice/v1/voiceclient/api2thread/search?alt=json&prettyPrint=false",1),i.setRequestHeader("Content-Type","application/json+protobuf"),i.setRequestHeader("Authorization","Bearer "+t),i.onreadystatechange=function(){4==i.readyState&&(503==i.status?m(e,t,n,a,o):e&&401==i.status&&resp401Unauth(i.response)?(wvWipeAuthToken(),getAuthToken(function(e){m(!1,e,n,a,o)})):200!=i.status?(401!=i.status&&alert("status: "+i.status+"\nresp:"+i.response),o(i.response||-1)):o(!1,JSON.parse(i.response)))},i.send("["+JSON.stringify(n)+","+a+",null,null,null,[null,1,1]]")}function p(a,e){n++,getContactName(e.slice(2),function(e,t){n--,t&&((e=a.firstChild).nodeValue!==t[0]&&(e.nodeValue=t[0]),a.setAttribute("data-pid",t[1]),t[2]&&a.setAttribute("data-url",t[2]),t[3]&&a.setAttribute("data-lec",t[3]),n||localStorage.setItem(sessionStorage.getItem("wvArchView")?"wvThdListA":"wvThdListM",document.getElementById("threadList").innerHTML))})}function f(a,o){getContactName(o.slice(2),function(e,n){if(!e)if(n)for(e in u[o]=n[0],a)(e=e.firstChild).nodeValue=n[0]+e.nodeValue.slice(o.length);else t[o]=1})}function c(e){return/1?\(?([0-9]{3})\)?[-.\s]?([0-9]{3})[-.\s]?([0-9]{4})/.exec(e)[0].replace(/\D/g,"").substr(-10,10)}function v(){for(var e,t,n=0,a={},o=document.getElementById("threadList").querySelectorAll("a");n<o.length;n++)(e=(t=o[n]).firstChild.nodeValue).match(/^\+?\d+$/)||(a["+1"+t.hash.slice(1)]=e);return a}function C(e,t,n){var a,o=document.createDocumentFragment();t.paginationToken&&((a=document.createElement("button")).textContent=" Load More ",a.setAttribute("data-pgtok",t.paginationToken),a.setAttribute("onclick","g(event)")),t=t.thread;for(var i=0;i<t.length;i++){var r=document.createElement("div"),l=t[i].item[0],s=(i||r.setAttribute("data-mid",l.id),o.appendChild(r),l.isArtificialErrorMessage?r.style.backgroundColor="red":r.style.outline="1px solid black",r.appendChild(document.createElement("div"))),u=(s.align="left",s=s.appendChild(document.createElement("a")),l.contact.phoneNumber);12===u.length&&"+"===u[0]&&"1"===u[1]&&(u=u.slice(2)),s.href="thread.html#"+u,u=l.contact.name,s.textContent=n[u]||u,u.match(/^\+\d+$/)&&p(s,u),(s=r.appendChild(document.createElement("div"))).align="smsIn"==l.type?"left":"right",s.textContent=l.mmsMessage?"[IMG]"+l.mmsMessage.text:l.messageText}a&&o.appendChild(a);var h=document.getElementById("threadList");if(e)h.replaceChild(o,h.lastChild);else{for(;h.lastChild;)h.removeChild(h.lastChild);h.appendChild(o),localStorage.setItem(sessionStorage.getItem("wvArchView")?"wvThdListA":"wvThdListM",h.innerHTML)}}!function(){var e=sessionStorage.getItem("wvArchView"),t=(document.getElementById("archive").checked=e,document.getElementById("threadList").innerHTML=localStorage.getItem(e?"wvThdListA":"wvThdListM"),navigator.clipboard);t&&t.readText&&((e=(e=document).body.insertBefore(e.createElement("button"),e.getElementById("threadList"))).textContent="ㅤPasteㅤ",e.onclick=function(){t.readText().then(function(e){window.location="thread.html#"+c(e)})}),drawLoginBar()}(),d||refreshNoUI(),window.ononline=refreshNoUI,window.onpageshow=function(e){e.persisted&&document.getElementById("rfsh").click()},document.addEventListener("visibilitychange",function(e){"visible"===e.target.visibilityState&&setTimeout(function(){document.getElementById("rfsh").click()},0)})</script>
<html manifest=ac.appcache><link href=https://www.googleapis.com rel=preconnect crossorigin><link href=//carrier.natasha.cat rel=preconnect><link href=https://content-people-pa.googleapis.com rel=preconnect crossorigin><link href=https://proxya6d0.us.to rel=preconnect><link href=thread.html rel=prefetch><meta charset=utf-8 content=0 name=mobileoptimized><style>body{margin-top:0px;}button{line-height:1.5}</style><script src=client.js></script><script>initLnkFmt();var d,u,t,e,n=0;function l(e,n,s,o){getAuthToken(function(t){r(!0,t,e,n,s,o)})}function r(t,e,n,s,o,a){var i=new XMLHttpRequest;i.open("POST","https://www.googleapis.com/voice/v1/voiceclient/api2thread/list?alt="+(n?"json&prettyPrint=false":"protojson"),1),i.setRequestHeader("Content-Type","application/json+protobuf"),i.setRequestHeader("Authorization","Bearer "+e),i.onreadystatechange=function(){4==i.readyState&&(503==i.status?r(t,e,n,s,o,a):t&&401==i.status&&resp401Unauth(i.response)?(wvWipeAuthToken(),getAuthToken(function(t){r(!1,t,n,s,o,a)})):200!=i.status?(401!=i.status&&alert("status: "+i.status+"\nresp:"+i.response),a(i.response||-1)):a(!1,n?JSON.parse(i.response):i.response))},i.send((n?"["+(o?6:2)+",100,1":"["+(o?6:2)+",1,1")+(s?',"'+s+'"]':"]"))}function g(i){(i=i.target).textContent=" ▽⌛";var r=i.getAttribute("data-pgtok");l(r,r,sessionStorage.getItem("wvArchView"),function(t,e){if(t)i.textContent=" ▽✘";else if(r)C(r,e,u);else{var n=document.getElementById("threadList"),s=n.firstChild&&n.firstChild.getAttribute("data-mid");if(e.substr(25,40)!=s)l(1,0,sessionStorage.getItem("wvArchView"),function(t,e){t?i.textContent=" ▽✘":(C(0,e,u),i.textContent=" ▽✔")}),u=v();else{i.textContent=" ▽✔";for(var o,a=0;a<n.children.length;a++)"DIV"===(t=n.children[a]).nodeName&&(o=(t=t.firstChild.firstChild).firstChild).nodeValue.match(/^\+\d+$/)&&p(t,o.nodeValue)}}}),r&&(u=v())}function refreshNoUI(){g({target:{textContent:0,getAttribute:function(){}}})}lazySignedInEmail()&&(d=1,refreshNoUI())</script>Welcome To Whogle Voice<button style=visibility:hidden>B</button><div id=sign-in-bar></div><button style=width:4em;height:2em;text-align:left; onclick=g(event) id=rfsh title=Refresh> ▽</button> <label><input type=checkbox id=archive onchange='sessionStorage.setItem("wvArchView",this.checked?"1":""),document.getElementById("threadList").innerHTML=localStorage.getItem(this.checked?"wvThdListA":"wvThdListM");var i=this.parentNode.previousSibling.previousSibling;i.onclick({target:i})'title=Archive>A</label> <input type=tel oninput=a(event) placeholder="New num here"size=10><button style=min-width:5em onclick=o(event)>To ABC</button><div id=threadList></div><script>function s(o){var l=document.getElementById("threadList");o.length?h(o,e,function(n,a){if(!n&&a.thread&&a.thread.length){var i={},r=document.createElement("select");for(n in r.style.width="100%",r.onchange=function(t){t=t.target,(name=t.value)?(12===name.length&&"+"===name[0]&&"1"===name[1]&&(name=name.slice(2)),t.selectedIndex=-1,window.location="thread.html#"+name):(e+=5,s(o))},a.thread.forEach(function(e){var n,a=r.appendChild(document.createElement("option")),o=e.contact[0].name,o=u[o]||o;t[o]||o.match(/^\+\d+$/)&&((n=i[o])||(i[o]=n=[]),n.push(a)),a.value=e.contact[0].phoneNumber,a.textContent=o+" - "+e.item[0].messageText}),r.selectedIndex=-1,a=a.thread.length,r.size=a+1,a===e&&((a=r.appendChild(document.createElement("option"))).textContent="More",a.value=""),n=l.parentNode,"SELECT"===(a=l.previousElementSibling).nodeName?n.replaceChild(r,a):n.insertBefore(r,l),i)f(i[n],n)}else s("")}):"SELECT"===(o=l.previousElementSibling).nodeName&&l.parentNode.removeChild(o)}function a(e){var e=e.target,t=e.nextElementSibling.firstChild,n=t.nodeValue;e.value.length?"To ABC"===n?t.nodeValue="Go #":"To Num"===n?(t.nodeValue="Clear",s(e.value)):"Clear"===n&&s(e.value):"Go #"===n?t.nodeValue="To ABC":"Clear"===n&&(t.nodeValue="To Num",s(""))}function o(n){var a=(n=n.target).firstChild,n=n.previousSibling,o=a.nodeValue;"To ABC"===o?(e=5,n.type="text",n.placeholder="Search Contacts",n.removeAttribute("size"),a.nodeValue="To Num",n.focus(),t={},u=u||v()):"To Num"===o?(n.type="tel",n.placeholder="New num here",n.size=10,a.nodeValue="To ABC",n.focus()):"Go #"===o?window.location="thread.html#"+c(n.value):"Clear"===o?(a.nodeValue="To Num",s(n.value="")):alert("unk state")}function h(t,n,a){getAuthToken(function(e){m(!0,e,t,n,a)})}function m(e,t,n,a,o){var i=new XMLHttpRequest;i.open("POST","https://www.googleapis.com/voice/v1/voiceclient/api2thread/search?alt=json&prettyPrint=false",1),i.setRequestHeader("Content-Type","application/json+protobuf"),i.setRequestHeader("Authorization","Bearer "+t),i.onreadystatechange=function(){4==i.readyState&&(503==i.status?m(e,t,n,a,o):e&&401==i.status&&resp401Unauth(i.response)?(wvWipeAuthToken(),getAuthToken(function(e){m(!1,e,n,a,o)})):200!=i.status?(401!=i.status&&alert("status: "+i.status+"\nresp:"+i.response),o(i.response||-1)):o(!1,JSON.parse(i.response)))},i.send("["+JSON.stringify(n)+","+a+",null,null,null,[null,1,1]]")}function p(a,e){n++,getContactName(e.slice(2),function(e,t){n--,t&&((e=a.firstChild).nodeValue!==t[0]&&(e.nodeValue=t[0]),a.setAttribute("data-pid",t[1]),t[2]&&a.setAttribute("data-url",t[2]),t[3]&&a.setAttribute("data-lec",t[3]),n||localStorage.setItem(sessionStorage.getItem("wvArchView")?"wvThdListA":"wvThdListM",document.getElementById("threadList").innerHTML))})}function f(a,o){getContactName(o.slice(2),function(e,n){if(!e)if(n)for(e in u[o]=n[0],a)(e=e.firstChild).nodeValue=n[0]+e.nodeValue.slice(o.length);else t[o]=1})}function c(e){return/1?\(?([0-9]{3})\)?[-.\s]?([0-9]{3})[-.\s]?([0-9]{4})/.exec(e)[0].replace(/\D/g,"").substr(-10,10)}function v(){for(var e,t,n=0,a={},o=document.getElementById("threadList").querySelectorAll("a");n<o.length;n++)(e=(t=o[n]).firstChild.nodeValue).match(/^\+?\d+$/)||(a["+1"+t.hash.slice(1)]=e);return a}function C(e,t,n){var a,o=document.createDocumentFragment();t.paginationToken&&((a=document.createElement("button")).textContent=" Load More ",a.setAttribute("data-pgtok",t.paginationToken),a.setAttribute("onclick","g(event)")),t=t.thread;for(var i=0;i<t.length;i++){var r=document.createElement("div"),l=t[i].item[0],s=(i||r.setAttribute("data-mid",l.id),o.appendChild(r),l.isArtificialErrorMessage?r.style.backgroundColor="red":r.style.outline="1px solid black",r.appendChild(document.createElement("div"))),u=(s.align="left",s=s.appendChild(document.createElement("a")),l.contact.phoneNumber);12===u.length&&"+"===u[0]&&"1"===u[1]&&(u=u.slice(2)),s.href="thread.html#"+u,u=l.contact.name,s.textContent=n[u]||u,u.match(/^\+\d+$/)&&p(s,u),(s=r.appendChild(document.createElement("div"))).align="smsIn"==l.type?"left":"right",s.textContent=l.mmsMessage?"[IMG]"+l.mmsMessage.text:l.messageText}a&&o.appendChild(a);var h=document.getElementById("threadList");if(e)h.replaceChild(o,h.lastChild);else{for(;h.lastChild;)h.removeChild(h.lastChild);h.appendChild(o),localStorage.setItem(sessionStorage.getItem("wvArchView")?"wvThdListA":"wvThdListM",h.innerHTML)}}!function(){var e=sessionStorage.getItem("wvArchView"),t=(document.getElementById("archive").checked=e,document.getElementById("threadList").innerHTML=localStorage.getItem(e?"wvThdListA":"wvThdListM"),navigator.clipboard);t&&t.readText&&((e=(e=document).body.insertBefore(e.createElement("button"),e.getElementById("threadList"))).textContent="ㅤPasteㅤ",e.onclick=function(){t.readText().then(function(e){window.location="thread.html#"+c(e)})}),drawLoginBar()}(),d||refreshNoUI(),window.ononline=refreshNoUI,window.onpageshow=function(e){e.persisted&&document.getElementById("rfsh").click()},document.addEventListener("visibilitychange",function(e){"visible"===e.target.visibilityState&&setTimeout(function(){document.getElementById("rfsh").click()},0)})</script>
26 changes: 18 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,15 @@
if(!err && resp.thread && resp.thread.length) {
var batchedCNUpdate = {};
var el = document.createElement('select');
el.size = resp.thread.length+1;
el.style.width="100%";
el.onchange = function (name) {
name = name.target.value;
el.onchange = function (selEL) {
selEL = selEL.target;
name = selEL.value;
if(name) {
if (name.length === 12 && name[0] === '+' && name[1] === '1') {
name = name.slice(2);
}
selEL.selectedIndex = -1;
window.location = 'thread.html#'+name;
} else {
search_res_count += 5;
Expand All @@ -184,13 +185,22 @@
}
}
o.value = e.contact[0].phoneNumber;
o.innerText =
o.textContent =
name+' - '+
e.item[0].messageText;
});
resp = el.appendChild(document.createElement('option'));
resp.innerText = "More";
resp.value = '';
//if 1 item, its selected automatic, and no onchange evt fires
//deselect the box always
el.selectedIndex = -1;
//always keep blank at end, so full list shown, no double taps for
//single item lists (open/select)
resp = resp.thread.length;
el.size = resp+1;
if(resp === search_res_count) {
resp = el.appendChild(document.createElement('option'));
resp.textContent = "More";
resp.value = '';
}
err = threadListEl.parentNode;
//can't be factored out, no debounce on key strokes, oth double draw
if ((resp = threadListEl.previousElementSibling).nodeName === "SELECT") {
Expand Down Expand Up @@ -219,7 +229,7 @@
} else if (lbl === 'To Num') {
buttonTN.nodeValue = 'Clear';
drawSug(textboxEl.value);
} else if('Clear') {
} else if(lbl === 'Clear') {
drawSug(textboxEl.value);
}
} else {
Expand Down

0 comments on commit 97d0006

Please sign in to comment.