Skip to content

Commit

Permalink
uwu preparing for early alpha release owo
Browse files Browse the repository at this point in the history
  • Loading branch information
novafurry committed Aug 7, 2024
1 parent 49006e6 commit 51a2f0a
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 17 deletions.
26 changes: 21 additions & 5 deletions assets/code/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ var app = {
}
},
},
// sysAi: {
// runs: false,
// name: 'NovaOS System AI Models',
// onstartup: async function() {
// try {
// const model = await use.load();
// console.log("Model loaded");
// window.novaAImodel= model;
// } catch (error) {
// app.sysAi.onstartup();
// console.error("Failed to load model", error);
// }
// },
// },
txter:{
runs: true,
name: 'txter editor',
Expand All @@ -273,15 +287,15 @@ var app = {
docai: {
runs: true,
name: 'DocAI',
init: async function () {
init: async function (query = "") {
const win = tk.mbw('DocAI', '500px', 'auto', true, undefined, undefined, "docai");
var div = tk.c('div', win.main);
// div.innerText = "DocAI is not yet available in this version of NovaOS.";
div.innerHTML = `
<h2>DocAI</h2>
<i>Your personal AI.</i><br>
<b>DocAI <u>NEVER HALLUCINATES</u></b><br>
<input class="i1" id="question" placeholder="Ask your documents!">
<input class="i1" id="question" placeholder="Ask your documents!" value="${query}">
<button id="ask" class="b1">Answer</button>
<h3>Answers:</h3>
<div id="answers"></div>
Expand All @@ -291,8 +305,7 @@ var app = {
if(window.docAImodel){
var model = window.docAImodel
askBtn.removeAttribute('disabled');
// Find the answers
askBtn.addEventListener('click', async function () {
async function ask() {
window.ans = []
var resp = await fs.ls('/user/Documents/');
console.log(resp)
Expand Down Expand Up @@ -407,7 +420,10 @@ var app = {
processDocuments(documents);


});
}
if(query !== ""){ask()}
// Find the answers
askBtn.addEventListener('click', ask);
} else {
document.querySelector("#docai").remove();
document.querySelector("#docaitbn").remove();
Expand Down
90 changes: 78 additions & 12 deletions assets/code/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ var wd = {
},
desktop: function (name, deskid, waitopt) {
ui.dest(tk.g('setuparea'));
function smApps(apps = app) {
document.querySelectorAll(".appItem").forEach(function (e) {
e.remove();
});
for (var key in apps) {
if (apps.hasOwnProperty(key)) {
if (apps[key].hasOwnProperty("runs") && apps[key].runs === true) {
console.log(`<i> ${apps[key].name} is launchable!`);
const btn = tk.cb('b1', apps[key].name, apps[key].init.bind(apps[key]), el.sm);
btn.classList.add("appItem");
btn.addEventListener('click', function () {
ui.dest(el.sm, 150);
el.sm = undefined;
});
} else {
console.log(`<i> ${apps[key].name} is not launchable! :(`);
}
}
}
}
function startmenu() {
if (el.sm == undefined) {
if (document.querySelector(".contcent")) {
Expand All @@ -92,20 +112,65 @@ var wd = {
const btm = el.taskbar.getBoundingClientRect();
el.sm.style.bottom = btm.height + btm.x + 4 + "px";
tk.p(`Hello, ${name}!`, 'h2', el.sm);
for (var key in app) {
if (app.hasOwnProperty(key)) {
if (app[key].hasOwnProperty("runs") && app[key].runs === true) {
console.log(`<i> ${app[key].name} is launchable!`);
const btn = tk.cb('b1', app[key].name, app[key].init.bind(app[key]), el.sm);
btn.addEventListener('click', function () {
ui.dest(el.sm, 150);
el.sm = undefined;
});
} else {
console.log(`<i> ${app[key].name} is not launchable! :(`);
console.log(el.sm)
var searchbar = tk.mkel('input', ['i1'], '', el.sm);
searchbar.placeholder = "Search for anything...";
searchbar.addEventListener('input', async function (event) {
var results = {};
var search = event.target.value.trim();
var searchAsWords = search.split(" ");
var appIds = Object.keys(app);
appIds.forEach(function (appId, index) {
appIds[index] = appId.toLowerCase();
})
searchAsWords.forEach(srch => {
if (appIds.includes(srch.toLowerCase())) {
results[srch] = app[srch];
};
});
// search by app names
searchAsWords.forEach(srch => {
for (var key in app) {
console.log(app[key])
if (app.hasOwnProperty(key) && app[key].hasOwnProperty("name")) {
console.log(app[key].name)
if (app[key].name.toLowerCase().includes(srch.toLowerCase())) {
results[key] = app[key];
}
}
}
});
console.log(results)
smApps(results)
if (document.querySelector(".aiResponse") == null) { var aiResponse = tk.c('p', el.sm, 'aiResponse') };
document.querySelector(".aiResponse").innerText = "";

// const = {
// queries: [search],
// responses: [
// `Your system colour is set to ${await fs.read('/user/info/color')}.`,
// `Your system colour scheme is set to ${await fs.read('/user/info/lightdark') || "default"}.`,
// `Your name is ${await fs.read('/user/info/name') || "unset, somehow (how did you get here without triggering setup lmaoo)"}.`,
// ]
// };
if((search.includes("what") && search.includes("your") && search.includes("name")) || (search.includes("who") && search.includes("you")) || (search.includes("ai") && search.includes("you"))){
document.querySelector(".aiResponse").innerText = "I'm NovaAI! (not really ai lmao im just some if loops uwu)";
} else if (search.includes("what") && search.includes("my") && search.includes("name")) {
document.querySelector(".aiResponse").innerText = `Your name is ${await fs.read('/user/info/name') || "unset, somehow (how did you get here without triggering setup lmaoo)"}!`;
} else if (search.includes("what") && (search.includes("color") || search.includes("colour"))&& (search.includes("theme") || search.includes("accent"))) {
document.querySelector(".aiResponse").innerText = `Your system colour is set to ${await fs.read('/user/info/color') || "unknown"}.`;
} else if (search.includes("what") && (search.includes("color") || search.includes("colour")) && (search.includes("scheme") || search.includes("mode"))) {
document.querySelector(".aiResponse").innerText = `Your system colour mode is set to ${await fs.read('/user/info/lightdark') || "default"}.`;
} else if (search.includes("what") && (search.includes("time") || search.includes("clock") || search.includes("hour") || search.includes("minute"))) {
document.querySelector(".aiResponse").innerHTML = `It is currently <div class="time">${wd.clock() || "Unknown"}</div>`;
} else if (app.hasOwnProperty("docai")) {
document.querySelector(".aiResponse").innerHTML = `No results found.<br> Would you like to <button class="b1" onclick="app.docai.init('${search}')">Search for it with DocAI?</button>`;
}
}
else{
document.querySelector(".aiResponse").innerText = "No results found, and DocAI is not found on your system!";
}
});
smApps(app)
} else {
ui.dest(el.sm, 150);
el.sm = undefined;
Expand Down Expand Up @@ -142,6 +207,7 @@ var wd = {
for (let i = 0; i < elements.length; i++) {
elements[i].innerText = formattedTime;
}
return formattedTime;
},
finishsetup: function (name, div1, div2) {
ui.sw2(div1, div2); ui.masschange('name', name); fs.write('/user/info/name', name);
Expand Down
13 changes: 13 additions & 0 deletions assets/code/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,18 @@ var tk = {
document.body.appendChild(windowDiv);
wd.win(); $(windowDiv).fadeIn(130); ui.center(windowDiv);
return { win: windowDiv, main: contentDiv, tbn, title: titlebarDiv };
},
mkel: function(element, classes, innerHtml, parent){
const el = document.createElement(element);
if(typeof classes === "string"){
el.classList.add(classes);
} else{
classes.forEach(function (item) {
el.classList.add(item);
});
}
el.innerHTML = innerHtml;
parent.appendChild(el);
return el;
}
}
3 changes: 3 additions & 0 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ p {
z-index: 303369;
overflow-x: auto;
white-space: nowrap;
overflow: hidden;
}


Expand Down Expand Up @@ -838,6 +839,7 @@ select:active {
overflow-x: auto;
white-space: nowrap;
bottom: unset !important;
overflow: hidden;

}
.topbar *{
Expand Down Expand Up @@ -946,6 +948,7 @@ select:active {
margin-left: 60px;
overflow: scroll;
border-radius: var(--rad2);
margin-bottom: -10px;
}
.smico{
display: none;
Expand Down
2 changes: 2 additions & 0 deletions desktop.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"> </script>
<!-- Load the qna model. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/qna"> </script>
<!-- Load the Universal Sentence Encoder. This is required to use the novaOS AI. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/universal-sentence-encoder"></script>
</head>
<script>
var abt = {
Expand Down

0 comments on commit 51a2f0a

Please sign in to comment.