Skip to content

Commit

Permalink
ai-gate
Browse files Browse the repository at this point in the history
  • Loading branch information
inulute committed Aug 4, 2023
1 parent a49ba44 commit 2e61a20
Show file tree
Hide file tree
Showing 21 changed files with 417 additions and 0 deletions.
8 changes: 8 additions & 0 deletions assets/css/no-topbar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#webview {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: inline-flex !important;
}
6 changes: 6 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
body {
margin: 0;
padding: 0;
-webkit-app-region: drag;
-webkit-user-select: none;
}
Binary file added assets/icons/inulute/inulute_icn.ico
Binary file not shown.
Binary file added assets/icons/png/aigate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/png/aigate1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/win/favicon.ico
Binary file not shown.
45 changes: 45 additions & 0 deletions assets/js/renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const getControlsHeight = () => {
const controls = document.querySelector("#controls");
if (controls) {
return controls.offsetHeight;
}
return 0;
};

const calculateLayoutSize = () => {
const webview = document.querySelector("webview");
const windowWidth = document.documentElement.clientWidth;
const windowHeight = document.documentElement.clientHeight;
const controlsHeight = getControlsHeight();
const webviewHeight = windowHeight - controlsHeight;

webview.style.width = windowWidth + "px";
webview.style.height = webviewHeight + "px";
};

window.addEventListener("DOMContentLoaded", () => {
calculateLayoutSize();

// Dynamic resize function (responsive)
window.onresize = calculateLayoutSize;

// Home button exists
if (document.querySelector("#home")) {
document.querySelector("#home").onclick = () => {
const home = document.getElementById("webview").getAttribute("data-home");
document.querySelector("webview").src = home;
};
}

// Print button exits
if (document.querySelector("#print_button")) {
document
.querySelector("#print_button")
.addEventListener("click", async () => {
const url = document.querySelector("webview").getAttribute("src");

// Launch print window
await window.electron.print(url);
});
}
});
Binary file added assets/screenshots/screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/screenshot4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/screenshot5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/screenshot6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/no-topbar.css">
<script defer src="assets/js/renderer.js"></script>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline';">
</head>
<body>
<webview id="webview" autosize="on" src="https://aigate.vercel.app"></webview>
</body>
</html>
74 changes: 74 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const { app, BrowserWindow, ipcMain } = require("electron");
const path = require("path");

app.allowRendererProcessReuse = true;

let mainWindow;
let dialogWindow; // Declare the dialogWindow variable here

app.on("ready", () => {
const window = require("./src/window");
mainWindow = window.createBrowserWindow(app);
mainWindow.setMenu(null);

const createCustomDialog = () => {
dialogWindow = new BrowserWindow({ // Assign the dialogWindow variable here
parent: mainWindow,
modal: true,
show: false,
width: 400,
height: 570,
backgroundColor: "#272829",
webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: false,
contextIsolation: true,
},
frame: false,
autoHideMenuBar: true,
});

dialogWindow.loadFile(path.join(__dirname, "select.html"));

dialogWindow.once("ready-to-show", () => {
dialogWindow.show();
});

ipcMain.on("dialog-response", (event, response) => {
handleDialogResponse(response);
dialogWindow.close();
});
};

const handleDialogResponse = (response) => {
// Handle the user's choice here
if (response === 0) {
mainWindow.loadURL("https://chat.openai.com");
} else if (response === 1) {
mainWindow.loadURL("https://bard.google.com/");
} else if (response === 2) {
mainWindow.loadURL("https://perplexity.ai");
} else if (response === 3) {
mainWindow.loadURL("https://labs.perplexity.ai");
} else if (response === 4) {
mainWindow.loadURL("https://claude.ai");
}
};

ipcMain.on("close-dialog", () => {
if (dialogWindow) {
// Load the desired URL in the main window when the cross button is clicked
mainWindow.loadURL("https://aigate.vercel.app/");
dialogWindow.close();
}
});

// Show the custom dialog when app is ready
createCustomDialog();

const print = require("./src/print");
});

app.on("window-all-closed", () => {
app.quit();
});
32 changes: 32 additions & 0 deletions preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { ipcRenderer } = require("electron");

document.addEventListener("DOMContentLoaded", () => {
const closeButton = document.getElementById("closeButton");

closeButton.addEventListener("click", () => {
ipcRenderer.send("close-dialog");
});

const chatgpt = document.getElementById("chatgpt");
const bard = document.getElementById("bard");
const perplexSearch = document.getElementById("perplexSearch");
const perplexChat = document.getElementById("perplexChat");
const claude = document.getElementById("claude");

chatgpt.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 0);
});
bard.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 1);
});
perplexSearch.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 2);
});
perplexChat.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 3);
});
claude.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 4);
});
});

122 changes: 122 additions & 0 deletions select.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Custom Dialog</title>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
<style>
body {
background-color: #272829;
color: #fff;
text-align: center;
padding-top: 50px;
font-family: 'Montserrat', sans-serif;
border-radius: 10px; /* Adjust the value to control the amount of rounding */
}


/* Style the cross icon */
.cross-icon {
position: absolute;
top: 10px;
right: 10px;
cursor: pointer;
font-size: 20px;
}

/* Style the logo image */
#logo {
display: block;
margin: 0 auto;
max-width: 250px;
}

/* Style the buttons */
.button-container {
display: flex;
flex-direction: column;
align-items: center;
}

button {
width: 200px; /* Set a fixed width for the buttons */
margin: 10px;
padding: 10px 20px;
font-size: 16px;
background-color: #8dc53e;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
transform: scale(1);
transition: background-color 0.3s ease-in-out, transform 0.2s ease-in-out;
font-family: 'Montserrat', sans-serif;
font-weight: 520;
}

/* Hover effect on buttons */
button:hover {
background-color: #8dc53e;
transform: scale(1.05); /* Adjust the scale value as desired */
}

/* Hide the scrollbar */
body::-webkit-scrollbar {
width: 0.5em;
}

body::-webkit-scrollbar-track {
background-color: transparent;
}

body::-webkit-scrollbar-thumb {
background-color: #8dc53e;
}
</style>
</head>
<body>
<!-- Add the cross icon with an ID -->
<span id="closeButton" class="cross-icon"></span>
<!-- Add the logo image -->
<img id="logo1" src="assets/icons/png/aigate1.png" alt="Logo 1" style="position: absolute; top: 10px; left: 10px; max-width: 30px;">
<img id="logo" src="assets/icons/png/aigate.png" alt="Logo">
<h2>Choose an AI to navigate:</h2>
<div class="button-container">
<button id="chatgpt">ChatGPT</button>
<button id="bard">Google Bard</button>
<button id="perplexSearch">Perplexity AI: AI Search</button>
<button id="perplexChat">Labs Perplexity AI: AI Chat</button>
<button id="claude">Claude 2</button>
</div>

<script>
const { ipcRenderer } = require("electron");

const chatgpt = document.getElementById("chatgpt");
const bard = document.getElementById("bard");
const perplexSearch = document.getElementById("perplexSearch");
const perplexChat = document.getElementById("perplexChat");
const claude = document.getElementById("claude");

closeButton.addEventListener("click", () => {
ipcRenderer.send("close-dialog");
});

chatgpt.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 0);
});
bard.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 1);
});
perplexSearch.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 2);
});
perplexChat.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 3);
});
claude.addEventListener("click", () => {
ipcRenderer.send("dialog-response", 4);
});
</script>
</body>
</html>
71 changes: 71 additions & 0 deletions src/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
exports.createTemplate = (name) => {
let template = [
{
label: "Edit",
submenu: [
{ role: "undo" },
{ role: "redo" },
{ type: "separator" },
{ role: "cut" },
{ role: "copy" },
{ role: "paste" },
{ role: "pasteandmatchstyle" },
{ role: "delete" },
{ role: "selectAll" }, // Changed "selectall" to "selectAll" to match Electron role names.
],
},
{
label: "View",
submenu: [
{ role: "reload" },
{ role: "forcereload" },
{ role: "toggledevtools" },
{ type: "separator" },
{ role: "resetzoom" },
{ role: "zoomin" },
{ role: "zoomout" },
{ type: "separator" },
{ role: "togglefullscreen" },
],
},
{
role: "window",
submenu: [{ role: "minimize" }, { role: "close" }],
},
];

if (process.platform === "darwin") {
template.unshift({
label: name,
submenu: [
{ role: "about" }, // Added "about" role for macOS app info.
{ type: "separator" },
{ role: "services", submenu: [] },
{ type: "separator" },
{ role: "hide" },
{ role: "hideothers" },
{ role: "unhide" },
{ type: "separator" },
{ role: "quit" },
],
});

template[1].submenu.push(
{ type: "separator" },
{
label: "Speech",
submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }],
}
);

template[3].submenu = [
{ role: "close" },
{ role: "minimize" },
{ role: "zoom" },
{ type: "separator" },
{ role: "front" },
];
}

return template;
};
11 changes: 11 additions & 0 deletions src/print.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { ipcMain, BrowserWindow } = require("electron");

ipcMain.handle("print", async (event, arg) => {
let printWindow = new BrowserWindow({ autoHideMenuBar: true });

printWindow.webContents.on("did-finish-load", () => {
printWindow.webContents.print({ silent: false });
});

printWindow.loadURL(arg);
});
Loading

0 comments on commit 2e61a20

Please sign in to comment.