Skip to content

Commit 40f9a6e

Browse files
committed
I'm crushing your head!
1 parent f3e4e8f commit 40f9a6e

2 files changed

Lines changed: 50 additions & 48 deletions

File tree

coms/net/fs.js

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,13 +1782,15 @@ const unsanitizeKey=(safeKey)=>{//«
17821782
const AWAIT_UPDATE_MS = 5000;
17831783
let update_num = 1;
17841784

1785-
const update = async (...args) => {
1785+
const update = async (refarg, obj) => {//«
17861786
/*
17871787
This "safe" update sets a timeout for a "reasonable" period, and warns if the server has
17881788
not completed within the specified interval. If after returning, we have previously warned,
17891789
then we let the user know that the update has finished. In case everything works fine,
17901790
nothing is reported.
17911791
*/
1792+
if (isStr(refarg)) refarg = get_ref(refarg);
1793+
17921794
let have_num = update_num;
17931795
update_num++;
17941796
let did_warn = false;
@@ -1797,7 +1799,7 @@ cwarn(`update#${have_num} has not returned after: ${AWAIT_UPDATE_MS}ms!`);
17971799
did_warn = true;
17981800
}, AWAIT_UPDATE_MS);
17991801
try {
1800-
await _update(...args);
1802+
await _update(refarg, obj);
18011803
clearTimeout(timeout);
18021804
if (did_warn){
18031805
log(`update#${have_num} has finally returned!`);
@@ -1807,7 +1809,7 @@ log(`update#${have_num} has finally returned!`);
18071809
cwarn(`An error has occurred for update#${have_num}`);
18081810
cerr(e);
18091811
}
1810-
};
1812+
};//»
18111813
const parallel_sort = (primary, secondary, if_rev) => {//«
18121814
/*«
18131815
Say you are given 2 JS arrays of equal length. One of them must be sorted
@@ -2070,7 +2072,7 @@ let update_obj = {
20702072
//log(base_path);
20712073
//log(ref(base_path));
20722074

2073-
update(get_ref(base_path), update_obj);
2075+
update(base_path, update_obj);
20742076

20752077
/*«
20762078
let path_ref = get_ref(`${base_path}/kids/${enc_path}`);
@@ -2108,39 +2110,6 @@ const{args}=this;
21082110
}
21092111
»*/
21102112

2111-
const com_fbstats = class extends Com{//«
2112-
2113-
async run(){
2114-
const{args}=this;
2115-
2116-
//Change this to go back further in time
2117-
let mins_ago = 72;
2118-
2119-
//Change this to get more/less statuses
2120-
let num_recent_stats = 10;
2121-
2122-
let start_time = new Date().getTime() - (mins_ago * 60000);
2123-
let c1 = orderByChild('time');
2124-
let c2 = startAt(start_time);
2125-
let c3 = limitToLast(num_recent_stats);
2126-
let ref = get_ref("status");
2127-
let q = query(ref, c1, c2, c3);
2128-
let snap = await get_value(q);
2129-
if (isErr(snap)){
2130-
return this.no(snap.message);
2131-
}
2132-
if (!snap.exists()){
2133-
return this.no(`no statuses were found`);
2134-
}
2135-
snap.forEach(kid=>{
2136-
let val = kid.val();
2137-
let arr = (new Date(val.time)+"").split(" ");
2138-
let str = `${arr[1]} ${arr[2]} ${arr[3]} ${arr[4]}`
2139-
this.out(`${kid.key} (${str}): ${val.content}`);
2140-
});
2141-
this.ok();
2142-
}
2143-
}//»
21442113
const com_ghname2id = class extends Com{//«
21452114

21462115
async run(){
@@ -2513,10 +2482,12 @@ if (snap.exists()){
25132482
return;
25142483
}
25152484

2516-
let home_ref = get_ref(`/user/${gh.uid}`);
2485+
//let home_ref = get_ref(`/user/${gh.uid}`);
2486+
2487+
//let rv = await run_transaction(home_ref, NEW_DIR);
2488+
//if (isErr(rv)) return this.no(rv.message);
25172489

2518-
let rv = await run_transaction(home_ref, NEW_DIR);
2519-
if (isErr(rv)) return this.no(rv.message);
2490+
update("/user", {[`${gh.uid}`]: NEW_DIR});
25202491
this.ok();
25212492

25222493
}
@@ -2566,9 +2537,6 @@ this.ok();
25662537
}
25672538
}//»
25682539
const com_fbstat = class extends Com {//«
2569-
/*This allows for the ability to run a query on the numerical ids, and get back whatever relevant
2570-
information they might want to provide.
2571-
*/
25722540
async run(){
25732541
const{args}=this;
25742542

@@ -2577,17 +2545,51 @@ information they might want to provide.
25772545
if (!args.length){
25782546
return this.no("Nothing given!");
25792547
}
2580-
let ref = get_ref(`/status/${ghid}`);
25812548
let obj = {
2582-
// time: Math.floor((new Date().getTime())/1000),
25832549
time: serverTimestamp(),
25842550
content: args.join(" ")
25852551
};
2586-
let rv = await run_transaction(ref, obj);
2587-
if (isErr(rv)) return this.no(rv.message);
2552+
update("/status", {[ghid]: obj});
25882553
this.ok();
25892554
}
25902555
}//»
2556+
const com_fbstats = class extends Com{//«
2557+
2558+
/*This allows for the ability to run a query on the numerical ids, and get back whatever relevant
2559+
information they might want to provide.
2560+
*/
2561+
2562+
async run(){
2563+
const{args}=this;
2564+
2565+
//Change this to go back further in time
2566+
let mins_ago = 72;
2567+
2568+
//Change this to get more/less statuses
2569+
let num_recent_stats = 10;
2570+
2571+
let start_time = new Date().getTime() - (mins_ago * 60000);
2572+
let c1 = orderByChild('time');
2573+
let c2 = startAt(start_time);
2574+
let c3 = limitToLast(num_recent_stats);
2575+
let ref = get_ref("status");
2576+
let q = query(ref, c1, c2, c3);
2577+
let snap = await get_value(q);
2578+
if (isErr(snap)){
2579+
return this.no(snap.message);
2580+
}
2581+
if (!snap.exists()){
2582+
return this.no(`no statuses were found`);
2583+
}
2584+
snap.forEach(kid=>{
2585+
let val = kid.val();
2586+
let arr = (new Date(val.time)+"").split(" ");
2587+
let str = `${arr[1]} ${arr[2]} ${arr[3]} ${arr[4]}`
2588+
this.out(`${kid.key} (${str}): ${val.content}`);
2589+
});
2590+
this.ok();
2591+
}
2592+
}//»
25912593

25922594
//»
25932595

list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11255","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/100323","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12602"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/61912"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/11295","fs.js/28783","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44068","net",["fs.js/83600"],"shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2026","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1436"],"index.html/486","login",["index.html/11711"],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9655","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/185293"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162727"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7969","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/1211"],"sys",["config.js/9491","desk.js/219653","fs.js/69727","terminal.js/4307","three.js/3443","util.js/33015"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]
1+
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11255","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/100323","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12602"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/61912"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/11295","fs.js/28783","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44068","net",["fs.js/83560"],"shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2026","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1436"],"index.html/486","login",["index.html/11711"],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9655","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/185293"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162727"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7969","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/1211"],"sys",["config.js/9491","desk.js/219653","fs.js/69727","terminal.js/4307","three.js/3443","util.js/33015"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]

0 commit comments

Comments
 (0)