Skip to content

Commit

Permalink
last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
deep5050 committed Jul 1, 2018
1 parent 3452195 commit 0c8dfcf
Show file tree
Hide file tree
Showing 12 changed files with 5,480 additions and 137 deletions.
67 changes: 46 additions & 21 deletions minimal-weather/app/renderer/main-ui.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@

const { remote, ipcRenderer } = require('electron');
var req = new XMLHttpRequest;
const shell = require('electron').shell;
const remote = require('electron').remote;
// const remote = require('electron').remote;
const app = require('electron').remote.app;
const ipcRenderer = require('electron').ipcRenderer;

const BrowserWindow = require('electron').remote.BrowserWindow;
const path = require('path');
const url = require('url');
var user_city = "kolkata";
var api_key = "48ff1d472cdeee40ccb395bc03863b73";
var settingsWindowVisible = 0;
let settingsWindow;





// dummy open weather map api data object when no internet connection available




// default open weather map api data object when no internet connection available
var got_data = 0;
// var fetched_data;
var fetched_data = {
Expand Down Expand Up @@ -180,7 +190,7 @@ function update_success_content() {
var celsius_temp = kelvin_cel(fetched_data.main.temp);
document.getElementById("temp-val").innerHTML = celsius_temp + '℃';
console.log(celsius_temp);
document.getElementById("city").innerHTML = fetched_data.name;
document.getElementById("city").innerHTML = fetched_data.name.toLocaleUpperCase();
console.log(fetched_data.name);
var wind_data ='SPEED: '+ fetched_data.wind.speed + '</br>' +'DEG: ' +Math.round(fetched_data.wind.deg);
document.getElementById("show-wind").innerHTML = wind_data;
Expand Down Expand Up @@ -238,34 +248,49 @@ function get_data() {
console.log("send cmplt");

}

ipcRenderer.on('set_city_name', function (event, arg) {
alert("got in main-ui");
})
// update whole app interface
function updateApp() {

updating();
get_data();

document.getElementById('close-btn').addEventListener('click', e => {
remote.getCurrentWindow().close();
remote.getFocusedWindow().close();
});

document.getElementById('settings').addEventListener('click', e => {

var settingsWindow = new BrowserWindow({ height: 570, width: 370 });
settingsWindow.loadURL(url.format({
pathname: path.join(__dirname, 'settings.html'),
protocol: 'file:',
slashes: true,
show: false
}));
settingsWindow.once('ready-to-show', () => {
settingsWindow.show();
})

});



function openSettingsWindow() {
var settingsWindow = new BrowserWindow({
height: 580,
width: 380
});
settingsWindow.loadURL(url.format({
pathname: path.join(__dirname, 'settings.html'),
protocol: 'file:',
slashes: true,
show: true
}));
settingsWindow.webContents.openDevTools();
settingsWindow.on('close', () => {
settingsWindowVisible = 0;
})
}


document.getElementById('settings').addEventListener('click', () => {
if (settingsWindowVisible == 0 ){
settingsWindowVisible = 1;
openSettingsWindow();

}
});
}

ipcRenderer.on('city_name', (event, message) => { console.log(message); });

}
35 changes: 22 additions & 13 deletions minimal-weather/app/renderer/settings.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@

const { remote, ipcRenderer } = require('electron');
const shell = require('electron').shell;
const remote = require('electron').remote;
const app = require('electron').remote.app;
const ipcRenderer = require('electron').ipcRenderer;


function runscript(x) {
var open_weather = document.getElementById('open-weather');
open_weather.addEventListener('click', () => {
shell.openExternal('https://openweathermap.org/city');
});
var fork_me = document.getElementById('fork-me');
fork_me.addEventListener('click', () => {
shell.openExternal('http://github.com/deep5050/minimal-weather');
});
// const ipcRenderer = require('electron').ipcRenderer;
const BrowserWindow = require('electron').remote.BrowserWindow;
const path = require('path');
const url = require('url');
var submit;
var city_name;

function runscript() {
submit = document.getElementById("submit");
var city_id = document.getElementById("city_code");
city_name = document.getElementById("city_name");

submit.addEventListener('click', () => {

let mainWindow = remote.getGlobal ('mainWindow');
var city_val = city_name.value;
if (mainWindow) {
mainWindow.webContents.send('city_name', 'city_val');
console.log('sent');
}
console.log(city_val);
})

}
File renamed without changes
Binary file added minimal-weather/assets/icons/win/icon.ico
Binary file not shown.
Loading

0 comments on commit 0c8dfcf

Please sign in to comment.