Make jshint happy.

multiprovider
Jens Lody 11 years ago
parent 997890f532
commit 6b238c2593
  1. 1
      src/convenience.js
  2. 39
      src/extension.js
  3. 23
      src/prefs.js

@ -1,3 +1,4 @@
/* jshint esnext:true */
/* -*- mode: js -*- */ /* -*- mode: js -*- */
/* /*
Copyright (c) 2011-2012, Giovanni Campagna <scampa.giovanni@gmail.com> Copyright (c) 2011-2012, Giovanni Campagna <scampa.giovanni@gmail.com>

@ -1,3 +1,4 @@
/* jshint esnext:true */
/* /*
* *
* Weather extension for GNOME Shell * Weather extension for GNOME Shell
@ -144,7 +145,7 @@ const WeatherMenuButton = new Lang.Class({
text: _('...') text: _('...')
}); });
if (St.TextDirection == undefined) { if (St.TextDirection === undefined) {
// Panel icon // Panel icon
this._weatherIcon = new St.Icon({ this._weatherIcon = new St.Icon({
icon_name: 'view-refresh' + this.icon_type(), icon_name: 'view-refresh' + this.icon_type(),
@ -196,7 +197,7 @@ const WeatherMenuButton = new Lang.Class({
Main.panel._rightBox.insert_child_at_index(this.actor, 0); Main.panel._rightBox.insert_child_at_index(this.actor, 0);
break; break;
} }
if (Main.panel._menus == undefined) if (Main.panel._menus === undefined)
Main.panel.menuManager.addMenu(this.menu); Main.panel.menuManager.addMenu(this.menu);
else else
Main.panel._menus.addMenu(this.menu); Main.panel._menus.addMenu(this.menu);
@ -295,8 +296,8 @@ const WeatherMenuButton = new Lang.Class({
}, },
stop: function() { stop: function() {
if (_httpSession != undefined) if (_httpSession !== undefined)
!_httpSession.abort(); _httpSession.abort();
_httpSession = undefined; _httpSession = undefined;
@ -721,7 +722,7 @@ const WeatherMenuButton = new Lang.Class({
if (!cities[0]) if (!cities[0])
cities = []; cities = [];
if (cities.length == 0) { if (cities.length === 0) {
this._cities = "2516479>Eivissa (CA)"; this._cities = "2516479>Eivissa (CA)";
this.updateCities(); this.updateCities();
return; return;
@ -734,7 +735,7 @@ const WeatherMenuButton = new Lang.Class({
type: 'like' type: 'like'
}; };
if (this._appid) if (this._appid)
params['APPID'] = this._appid; params.APPID = this._appid;
this.load_json_async(WEATHER_URL_CURRENT, params, Lang.bind(this, this._updateCitiesCallback)); this.load_json_async(WEATHER_URL_CURRENT, params, Lang.bind(this, this._updateCitiesCallback));
return; return;
@ -769,7 +770,7 @@ const WeatherMenuButton = new Lang.Class({
}, },
_onOpenStateChanged: function(menu, open) { _onOpenStateChanged: function(menu, open) {
if (open && this._forecastScrollBox != undefined && this._forecastBox != undefined && this._currentWeather != undefined) { if (open && this._forecastScrollBox !== undefined && this._forecastBox !== undefined && this._currentWeather !== undefined) {
this._forecastScrollBox.set_width(this._currentWeather.get_width()); this._forecastScrollBox.set_width(this._currentWeather.get_width());
this._forecastScrollBox.show(); this._forecastScrollBox.show();
if (this._forecastBox.get_width() > this._currentWeather.get_width()) { if (this._forecastBox.get_width() > this._currentWeather.get_width()) {
@ -1142,7 +1143,7 @@ weather-storm.png = weather-storm-symbolic.svg
}, },
load_json_async: function(url, params, fun) { load_json_async: function(url, params, fun) {
if (_httpSession == undefined) { if (_httpSession === undefined) {
if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) { if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) {
// Soup session (see https://bugzilla.gnome.org/show_bug.cgi?id=661323#c64) (Simon Legner) // Soup session (see https://bugzilla.gnome.org/show_bug.cgi?id=661323#c64) (Simon Legner)
_httpSession = new Soup.SessionAsync(); _httpSession = new Soup.SessionAsync();
@ -1171,7 +1172,7 @@ weather-storm.png = weather-storm-symbolic.svg
}, },
parseWeatherCurrent: function() { parseWeatherCurrent: function() {
if (this.currentWeatherCache == undefined) { if (this.currentWeatherCache === undefined) {
this.refreshWeatherCurrent(); this.refreshWeatherCurrent();
return; return;
} }
@ -1231,10 +1232,10 @@ weather-storm.png = weather-storm-symbolic.svg
let iconname = this.get_weather_icon_safely(json.weather[0].id, now < sunrise || now > sunset); let iconname = this.get_weather_icon_safely(json.weather[0].id, now < sunrise || now > sunset);
if (this.lastBuildId == undefined) if (this.lastBuildId === undefined)
this.lastBuildId = 0; this.lastBuildId = 0;
if (this.lastBuildDate == undefined) if (this.lastBuildDate === undefined)
this.lastBuildDate = 0; this.lastBuildDate = 0;
if (this.lastBuildId != json.dt || !this.lastBuildDate) { if (this.lastBuildId != json.dt || !this.lastBuildDate) {
@ -1398,7 +1399,7 @@ weather-storm.png = weather-storm-symbolic.svg
if (!wind) if (!wind)
this._currentWeatherWind.text = '\u2013'; this._currentWeatherWind.text = '\u2013';
else if (wind == 0 || !wind_direction) else if (wind === 0 || !wind_direction)
this._currentWeatherWind.text = parseFloat(wind).toLocaleString() + ' ' + wind_unit; this._currentWeatherWind.text = parseFloat(wind).toLocaleString() + ' ' + wind_unit;
else // i.e. wind > 0 && wind_direction else // i.e. wind > 0 && wind_direction
this._currentWeatherWind.text = wind_direction + ' ' + parseFloat(wind).toLocaleString() + ' ' + wind_unit; this._currentWeatherWind.text = wind_direction + ' ' + parseFloat(wind).toLocaleString() + ' ' + wind_unit;
@ -1418,7 +1419,7 @@ weather-storm.png = weather-storm-symbolic.svg
units: 'metric' units: 'metric'
}; };
if (this._appid) if (this._appid)
params['APPID'] = this._appid; params.APPID = this._appid;
this.load_json_async(WEATHER_URL_CURRENT, params, function(json) { this.load_json_async(WEATHER_URL_CURRENT, params, function(json) {
if (json && (Number(json.cod) == 200)) { if (json && (Number(json.cod) == 200)) {
@ -1454,7 +1455,7 @@ weather-storm.png = weather-storm-symbolic.svg
}, },
parseWeatherForecast: function() { parseWeatherForecast: function() {
if (this.forecastWeatherCache == undefined) { if (this.forecastWeatherCache === undefined) {
this.refreshWeatherForecast(); this.refreshWeatherForecast();
return; return;
} }
@ -1466,7 +1467,7 @@ weather-storm.png = weather-storm-symbolic.svg
for (let i = 0; i < this._days_forecast; i++) { for (let i = 0; i < this._days_forecast; i++) {
let forecastUi = this._forecast[i]; let forecastUi = this._forecast[i];
let forecastData = forecast[i]; let forecastData = forecast[i];
if (forecastData == undefined) if (forecastData === undefined)
continue; continue;
let t_low = forecastData.temp.min; let t_low = forecastData.temp.min;
@ -1553,7 +1554,7 @@ weather-storm.png = weather-storm-symbolic.svg
cnt: '13' cnt: '13'
}; };
if (this._appid) if (this._appid)
params['APPID'] = this._appid; params.APPID = this._appid;
this.load_json_async(WEATHER_URL_FORECAST, params, function(json) { this.load_json_async(WEATHER_URL_FORECAST, params, function(json) {
if (json && (Number(json.cod) == 200)) { if (json && (Number(json.cod) == 200)) {
@ -1586,12 +1587,12 @@ weather-storm.png = weather-storm-symbolic.svg
}, },
destroyCurrentWeather: function() { destroyCurrentWeather: function() {
if (this._currentWeather.get_child() != null) if (this._currentWeather.get_child() !== null)
this._currentWeather.get_child().destroy(); this._currentWeather.get_child().destroy();
}, },
destroyFutureWeather: function() { destroyFutureWeather: function() {
if (this._futureWeather.get_child() != null) if (this._futureWeather.get_child() !== null)
this._futureWeather.get_child().destroy(); this._futureWeather.get_child().destroy();
}, },
@ -1722,7 +1723,7 @@ weather-storm.png = weather-storm-symbolic.svg
}, },
scrollForecastBy: function(delta) { scrollForecastBy: function(delta) {
if (this._forecastScrollBox == undefined) if (this._forecastScrollBox === undefined)
return; return;
this._forecastScrollBox.hscroll.adjustment.value += delta; this._forecastScrollBox.hscroll.adjustment.value += delta;
}, },

@ -1,3 +1,4 @@
/* jshint esnext:true */
/* /*
* *
* Weather extension for GNOME Shell preferences * Weather extension for GNOME Shell preferences
@ -160,7 +161,7 @@ const WeatherPrefsWidget = new GObject.Class({
this.Window.get_object("tree-toolbutton-remove").sensitive = Boolean(this.city.length); this.Window.get_object("tree-toolbutton-remove").sensitive = Boolean(this.city.length);
if (mCities != this.city) { if (mCities != this.city) {
if (this.liststore != undefined) if (this.liststore !== undefined)
this.liststore.clear(); this.liststore.clear();
if (this.city.length > 0) { if (this.city.length > 0) {
@ -290,7 +291,7 @@ const WeatherPrefsWidget = new GObject.Class({
selectionChanged: function(select) { selectionChanged: function(select) {
let a = select.get_selected_rows(this.liststore)[0][0]; let a = select.get_selected_rows(this.liststore)[0][0];
if (a != undefined) if (a !== undefined)
if (this.actual_city != parseInt(a.to_string())) if (this.actual_city != parseInt(a.to_string()))
this.actual_city = parseInt(a.to_string()); this.actual_city = parseInt(a.to_string());
}, },
@ -349,7 +350,7 @@ const WeatherPrefsWidget = new GObject.Class({
id: id id: id
}, function() { }, function() {
d.sensitive = 0; d.sensitive = 0;
if (arguments[0] == undefined) if (arguments[0] === undefined)
return 0; return 0;
let city = arguments[0]; let city = arguments[0];
@ -357,7 +358,7 @@ const WeatherPrefsWidget = new GObject.Class({
if (Number(city.cod) != 200) if (Number(city.cod) != 200)
return 0; return 0;
if (Number(city.count) == 0) if (Number(city.count) === 0)
return 0; return 0;
d.sensitive = 1; d.sensitive = 1;
@ -376,8 +377,8 @@ const WeatherPrefsWidget = new GObject.Class({
q: location q: location
}; };
if (this.appid) if (this.appid)
params['APPID'] = this.appid; params.APPID = this.appid;
if (testLocation(location) == 0) if (testLocation(location) === 0)
this.loadJsonAsync(WEATHER_URL_FIND, params, function() { this.loadJsonAsync(WEATHER_URL_FIND, params, function() {
if (!arguments[0]) if (!arguments[0])
return 0; return 0;
@ -441,7 +442,7 @@ const WeatherPrefsWidget = new GObject.Class({
type: 'accurate' type: 'accurate'
}; };
if (this.appid) if (this.appid)
params['APPID'] = this.appid; params.APPID = this.appid;
this.loadJsonAsync(WEATHER_URL_CURRENT, params, Lang.bind(this, function() { this.loadJsonAsync(WEATHER_URL_CURRENT, params, Lang.bind(this, function() {
if (!arguments[0]) if (!arguments[0])
return 0; return 0;
@ -505,7 +506,7 @@ const WeatherPrefsWidget = new GObject.Class({
dialog_area.pack_start(label, 0, 0, 0); dialog_area.pack_start(label, 0, 0, 0);
dialog.connect("response", Lang.bind(this, function(w, response_id) { dialog.connect("response", Lang.bind(this, function(w, response_id) {
if (response_id) { if (response_id) {
if (city.length == 0) if (city.length === 0)
city = []; city = [];
if (city.length > 0 && typeof city != "object") if (city.length > 0 && typeof city != "object")
@ -538,7 +539,7 @@ const WeatherPrefsWidget = new GObject.Class({
}, },
loadJsonAsync: function(url, params, fun, id) { loadJsonAsync: function(url, params, fun, id) {
if (_httpSession == undefined) { if (_httpSession === undefined) {
if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) { if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) {
// Soup session (see https://bugzilla.gnome.org/show_bug.cgi?id=661323#c64) (Simon Legner) // Soup session (see https://bugzilla.gnome.org/show_bug.cgi?id=661323#c64) (Simon Legner)
_httpSession = new Soup.SessionAsync(); _httpSession = new Soup.SessionAsync();
@ -551,10 +552,10 @@ const WeatherPrefsWidget = new GObject.Class({
let message = Soup.form_request_new_from_hash('GET', url, params); let message = Soup.form_request_new_from_hash('GET', url, params);
if (this.asyncSession == undefined) if (this.asyncSession === undefined)
this.asyncSession = {}; this.asyncSession = {};
if (this.asyncSession[id] != undefined && this.asyncSession[id]) { if (this.asyncSession[id] !== undefined && this.asyncSession[id]) {
_httpSession.abort(); _httpSession.abort();
this.asyncSession[id] = 0; this.asyncSession[id] = 0;
} }

Loading…
Cancel
Save