mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-03 05:23:17 +00:00
😓 Fixing Jquery bug attempt 2
This commit is contained in:
38
app/main/domain.js
Normal file
38
app/main/domain.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const JsonDB = require('node-json-db');
|
||||
const {app} = require('electron').remote;
|
||||
const request = require('request');
|
||||
const ipcRenderer = require('electron').ipcRenderer;
|
||||
|
||||
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
||||
const data = db.getData('/');
|
||||
|
||||
|
||||
console.log(data.domain);
|
||||
|
||||
// if (data.domain && window.location.href.indexOf(data.domain) === -1) {
|
||||
// window.location.href = data.domain
|
||||
// }
|
||||
// require('electron-connect').client.create();
|
||||
|
||||
window.addDomain = function () {
|
||||
|
||||
document.getElementById('main').innerHTML = 'checking...';
|
||||
|
||||
let newDomain = document.getElementById('url').value;
|
||||
newDomain = newDomain.replace(/^https?:\/\//, '');
|
||||
|
||||
const domain = 'https://' + newDomain;
|
||||
const checkDomain = domain + '/static/audio/zulip.ogg';
|
||||
|
||||
request(checkDomain, (error, response) => {
|
||||
if (!error && response.statusCode !== 404) {
|
||||
document.getElementById('main').innerHTML = 'Connect';
|
||||
db.push('/domain', domain);
|
||||
ipcRenderer.send('new-domain', domain);
|
||||
} else {
|
||||
document.getElementById('main').innerHTML = 'Connect';
|
||||
document.getElementById('server-status').innerHTML = 'Not a vaild Zulip Server.';
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,7 +29,16 @@ let mainWindow;
|
||||
let targetLink;
|
||||
|
||||
// Load this url in main window
|
||||
const targetUrl = 'file://' + path.join(__dirname, '../renderer', 'index.html');
|
||||
const staticURL = 'file://' + path.join(__dirname, '../renderer', 'index.html');
|
||||
|
||||
const targetURL = function() {
|
||||
if (data.domain !== undefined) {
|
||||
return data.domain
|
||||
}
|
||||
else {
|
||||
return staticURL
|
||||
}
|
||||
}
|
||||
|
||||
const isAlreadyRunning = app.makeSingleInstance(() => {
|
||||
if (mainWindow) {
|
||||
@@ -90,13 +99,13 @@ function createMainWindow() {
|
||||
minHeight: 400,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
nodeIntegration: true,
|
||||
plugins: true,
|
||||
allowDisplayingInsecureContent: true
|
||||
}
|
||||
allowDisplayingInsecureContent: true,
|
||||
nodeIntegration: false,
|
||||
},
|
||||
});
|
||||
|
||||
win.loadURL(targetUrl);
|
||||
win.loadURL(targetURL());
|
||||
win.on('closed', onClosed);
|
||||
win.setTitle('Zulip');
|
||||
|
||||
|
||||
@@ -53,3 +53,5 @@ ipcRenderer.on('shortcut', () => {
|
||||
const nodes = document.querySelectorAll('.dropdown-menu li:nth-child(4) a');
|
||||
nodes[nodes.length - 1].click();
|
||||
});
|
||||
|
||||
require('./domain');
|
||||
|
||||
@@ -6,17 +6,6 @@
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>Login - Zulip</title>
|
||||
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen">
|
||||
<script type="text/javascript">
|
||||
const JsonDB = require('node-json-db');
|
||||
const {app} = require('electron').remote;
|
||||
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
||||
const data = db.getData('/');
|
||||
|
||||
if (data.domain) {
|
||||
window.location.href = data.domain;
|
||||
}
|
||||
</script>
|
||||
<script>require('electron-connect').client.create()</script>
|
||||
</head>
|
||||
<body class="container-layout">
|
||||
<div class="section-main">
|
||||
@@ -49,6 +38,5 @@
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user