mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-26 18:12:51 +08:00
34 lines
554 B
Ucode
34 lines
554 B
Ucode
#!/usr/bin/env ucode
|
|
|
|
'use strict';
|
|
|
|
import { readfile, writefile } from 'fs';
|
|
|
|
const HISTORY_FILE = '/var/lib/wifihistory/history.json';
|
|
|
|
const methods = {
|
|
getHistory: {
|
|
call: function() {
|
|
let content = readfile(HISTORY_FILE);
|
|
if (content == null)
|
|
return { history: {} };
|
|
|
|
try {
|
|
return { history: json(content) || {} };
|
|
}
|
|
catch (e) {
|
|
return { history: {} };
|
|
}
|
|
}
|
|
},
|
|
|
|
clearHistory: {
|
|
call: function() {
|
|
writefile(HISTORY_FILE, '{}');
|
|
return { result: true };
|
|
}
|
|
}
|
|
};
|
|
|
|
return { 'luci.wifihistory': methods };
|