Skip to content

Instantly share code, notes, and snippets.

@truth3
Last active September 15, 2021 16:04
Show Gist options
  • Select an option

  • Save truth3/48a5117310a5ce1bc7c41ced27e77d0d to your computer and use it in GitHub Desktop.

Select an option

Save truth3/48a5117310a5ce1bc7c41ced27e77d0d to your computer and use it in GitHub Desktop.

Revisions

  1. truth3 revised this gist Jul 14, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions iForm-PageJavascript-Weather.js
    Original file line number Diff line number Diff line change
    @@ -31,6 +31,7 @@ var xmlHttp;
    if(xmlHttp != null)
    {
    xmlHttp.open( "GET", url, false );
    xmlHttp.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:221.0) Gecko/20100101 Firefox/31.0");
    xmlHttp.send( null );
    resp = xmlHttp.responseText;
    }
  2. truth3 revised this gist Oct 9, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion iForm-PageJavascript-Weather.js
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ return allWeatherStr;


    function getCurrentConditions(lat, lng) {
    var url = "http://forecast.weather.gov/MapClick.php?lat=" + lat + "&lon=" + lng + "&FcstType=json";
    var url = "https://forecast.weather.gov/MapClick.php?lat=" + lat + "&lon=" + lng + "&FcstType=json";
    var resp;
    var xmlHttp;

  3. truth3 created this gist Jun 16, 2016.
    39 changes: 39 additions & 0 deletions iForm-PageJavascript-Weather.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    function getCurrentWeather(lat, lng) {

    var json = getCurrentConditions(lat, lng);
    var obj = JSON.parse(json);
    var currentWeather = obj.currentobservation.Weather;
    var tempF = obj.currentobservation.Temp;
    var currentWindSpeed = obj.currentobservation.Winds;
    var currentWindDirection = obj.currentobservation.Windd;
    var currentWindGust = obj.currentobservation.Gust;
    var currentHumidity = obj.currentobservation.Relh;
    var currentPressure = obj.currentobservation.SLP;
    var currentStation = obj.currentobservation.name;
    var currentStationElev = obj.currentobservation.elev;
    var currentWindChill = obj.currentobservation.WindChill;
    var forecastPeriod = obj.time.startPeriodName[0];
    var forecastText = obj.data.text[0];
    var allWeatherStr = (currentWeather + "||" + tempF + "||" + currentWindSpeed+ "||" + currentWindDirection+ "||" + currentWindGust+ "||" + currentHumidity+ "||" + currentPressure+ "||" + currentStation+ "||" + currentStationElev+ "||" + currentWindChill+ "||" + forecastPeriod+ "||" + forecastText);

    return allWeatherStr;
    }


    function getCurrentConditions(lat, lng) {
    var url = "http://forecast.weather.gov/MapClick.php?lat=" + lat + "&lon=" + lng + "&FcstType=json";
    var resp;
    var xmlHttp;

    resp = "" ;
    xmlHttp = new XMLHttpRequest();

    if(xmlHttp != null)
    {
    xmlHttp.open( "GET", url, false );
    xmlHttp.send( null );
    resp = xmlHttp.responseText;
    }

    return resp;
    }