-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.js
More file actions
29 lines (24 loc) · 791 Bytes
/
Copy pathModel.js
File metadata and controls
29 lines (24 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.pragma library
// Pure helpers for RandomSaver Panel.qml. No File/Process access here —
// file IO lives in a FileView and execution in a Process (Quickshell.Io).
function defaultWords() {
return ["hello", "world", "omarchy", "random", "screensaver"];
}
function parseWords(content) {
var lines = String(content || "").split("\n");
var words = [];
for (var i = 0; i < lines.length; i++) {
var w = lines[i].trim();
if (w !== "")
words.push(w);
}
return words.length > 0 ? words : defaultWords();
}
function serializeWords(words) {
return words.join("\n") + "\n";
}
function pickRandom(words) {
if (!words || words.length === 0)
return defaultWords()[0];
return words[Math.floor(Math.random() * words.length)];
}