Skip to content

Commit

Permalink
Merge pull request zulip#137 from brockwhittaker/landing-page-redesign
Browse files Browse the repository at this point in the history
Redesign the landing page to look more inline with brand design.
  • Loading branch information
akashnimare authored Apr 13, 2017
2 parents 5a04612 + c1f6159 commit df91c20
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 386 deletions.
48 changes: 39 additions & 9 deletions app/main/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,37 @@ const request = require('request');
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
const data = db.getData('/');

console.log(data.domain);
window.addDomain = function () {
const el = sel => {
return document.querySelector(sel);
};

const $el = {
error: el('#error'),
main: el('#main'),
section: el('section')
};

const event = sel => {
return {
on: (event, callback) => {
document.querySelector(sel).addEventListener(event, callback);
}
};
};

const displayError = msg => {
$el.error.innerText = msg;
$el.error.classList.add('show');
$el.section.classList.add('shake');
};

let newDomain = document.getElementById('url').value;
newDomain = newDomain.replace(/^https?:\/\//, '');
newDomain = newDomain.replace(/^http?:\/\//, '');
if (newDomain === '') {
document.getElementById('server-status').innerHTML = 'Please input a value';
displayError('Please input a valid URL.');
} else {
document.getElementById('main').innerHTML = 'Checking...';
el('#main').innerHTML = 'Checking...';
if (newDomain.indexOf('localhost:') >= 0) {
const domain = 'http://' + newDomain;
const checkDomain = domain + '/static/audio/zulip.ogg';
Expand All @@ -24,8 +46,8 @@ window.addDomain = function () {
db.push('/domain', domain);
ipcRenderer.send('new-domain', domain);
} else {
document.getElementById('main').innerHTML = 'Connect';
document.getElementById('server-status').innerHTML = 'Not a valid Zulip Local Server.';
$el.main.innerHTML = 'Connect';
displayError('Not a valid Zulip local server');
}
});
// });
Expand All @@ -35,14 +57,22 @@ window.addDomain = function () {

request(checkDomain, (error, response) => {
if (!error && response.statusCode !== 404) {
document.getElementById('main').innerHTML = 'Connect';
$el.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 valid Zulip Server.';
$el.main.innerHTML = 'Connect';
displayError('Not a valid Zulip server');
}
});
}
}

event('#url').on('input', () => {
el('#error').classList.remove('show');
});

event('section').on('animationend', function () {
this.classList.remove('shake');
});
};
Loading

0 comments on commit df91c20

Please sign in to comment.