Skip to content

Commit

Permalink
resolving conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
matusfaro committed Apr 21, 2013
2 parents b751a27 + c1f0645 commit e11a6a2
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 120 deletions.
92 changes: 0 additions & 92 deletions WeatherPrediction/PredictFuture.js

This file was deleted.

6 changes: 5 additions & 1 deletion app.js
Expand Up @@ -3,6 +3,8 @@
* Module dependencies.
*/


//Defining our routes.
var express = require('express')
, solar = require('./controllers/solar.js')
, wind = require('./controllers/wind.js')
Expand All @@ -12,7 +14,7 @@ var express = require('express')
, http = require('http')
, path = require('path');


//This is a hackathon, put it in express mode we don't have time to setup.
var app = express();

app.configure(function(){
Expand All @@ -35,6 +37,8 @@ app.configure('development', function(){
app.use(express.errorHandler());
});


//more routes
app.get('/', routes.index);
app.get('/users', user.list);
app.get('/ajax', routes.ajax);
Expand Down
9 changes: 8 additions & 1 deletion controllers/solar.js
Expand Up @@ -50,17 +50,24 @@ var solar = (function() {
}
};


//Get the prediction data.
solar.prototype.getPrediction = function(userLongitude, userLatitude, callback) {
console.log("solar: getPrediction ", userLongitude, userLatitude);
solarReturnFun = callback;
//Getting the closest dataset to what you've entered.
solarDatabaseConn.query("SELECT (ABS(" + solarDatabaseConn.escape(userLongitude) + " - solar_prediction_coordinates.longitude) + ABS(" + solarDatabaseConn.escape(userLatitude) + " - solar_prediction_coordinates.latitude)) AS closeness, solar_prediction_coordinates.longitude, solar_prediction_coordinates.latitude FROM `solar_prediction_coordinates` ORDER BY closeness ASC LIMIT 1", this.getPredictionCallback)
};

//Get some solar data (the long version)
solar.prototype.getPredictionCallback = function(data) {
console.log("solar: getPredictionCallback ", data);
if(!data[0]){
console.log("solar: getPredictionCallback: input data is empty")
//Found nothing in the database!
console.log("solar: getPredictionCallback: input data is empty");
solarReturnFun(-1);
}else{
//Get the data for every week over the past 8 years.
solarDatabaseConn.query("SELECT solar_prediction_data.week, solar_prediction_data.year, solar_prediction_data.unit FROM `solar_prediction_data` JOIN `solar_prediction_coordinates` ON solar_prediction_coordinates.id = solar_prediction_data.coordinates WHERE solar_prediction_coordinates.longitude=\""+data[0].longitude+"\" and solar_prediction_coordinates.latitude=\""+data[0].latitude+"\" ORDER BY solar_prediction_data.week ASC, solar_prediction_data.year ASC", solarReturnFun)
}
};
Expand Down
63 changes: 42 additions & 21 deletions public/javascripts/index.js
Expand Up @@ -47,26 +47,32 @@ $(document).ready(function() {

//Make the bg transparent
$("body").prepend("<a class='location_home' href='#'><div class='location_name'>"+locationName+"</div><img src='images/location white.png'></a>")
$(".location_home").addClass("location_home_animate");
$(".landingMain").append(data);
$(".background_image").css("opacity", "0");


//Now animate the stuff from the right inwards
setTimeout(function() {
$(".location_home").addClass("location_home_animate");
$('.overview_columns').addClass("animate_left_no3d");
//initializing some rankings
var highest = 0;
var best = ""
var count = 1;

//Now we fill in all of these rankings (the circles) and determine whos best
$("#wind_column").find(".rating_circle").each(function() {
if(highest < count) {
highest = count;
best = "WIND POWER"
}
if (count <= ratings.windRating) {
$(this).css("background-color", "#9FCE62");
console.log("ffff")
}
count += 1;
})

//Solar info
count = 1;
$("#solar_column").find(".rating_circle").each(function() {
if(highest < count) {
Expand All @@ -79,6 +85,8 @@ $(document).ready(function() {
}
count += 1;
})

//Geo info
count = 1;
$("#geo_column").find(".rating_circle").each(function() {
if(highest < count) {
Expand All @@ -91,13 +99,16 @@ $(document).ready(function() {
}
count += 1;
})
//Yay! Show who is the bestest.
$(".winner_large").html(best)
}, 100);

//Returning to landing page

//Just reverse what we did to show this stuff. animate out and in.
$(".location_home").bind("click", function(e) {
e.preventDefault();
$(".background_image").css("opacity", "1");
console.log("cliiiiicked")
$(".location_home").remove();
$(".overview_columns").removeClass("animate_left_no3d");
$(".title").removeClass("animate_left")
Expand All @@ -107,11 +118,14 @@ $(document).ready(function() {
}, 1000)
})

//Clicking on an information column.
$(".column").click(function(e) {
if (!($(e.target).hasClass("column"))) {
$(e.target).parent().trigger("click");
return
}


if ($(e.target).hasClass("disabled"))
return
$(e.target).append("<div class='loading_spinner'><img src='images/loading.gif'></img></div>");
Expand All @@ -125,52 +139,66 @@ $(document).ready(function() {
}
console.log(resource)


//Sliding the summary block n.
var id = e.target.id;
console.log(id)
var left = $("#" + id).position().left;
var top = $("#" + id).position().top;
$("#" + id).clone().appendTo(".overview_columns").css({"position": "absolute", "top": top + "px", "left": left + "px",
"-webkit-transition": "all 1s ease"}).addClass("slide_column")


//Disable the functionality of the other columns
$(".column").each(function() {
if (!($(this).hasClass("slide_column")))
$(this).addClass("disabled");
})

//Clicking the back button during the summary
$(".slide_column").click(function(e2) {
if (!($(e2.target).hasClass("column"))) {
$(e2.target).parent().trigger("click");
return
}
$(e2.target).remove();
$(".summaryContainer").remove();

//Remove the summary container
$(e2.target).css("left", "-150%");
$(".summaryContainer").css("left", "150%");

$(".column").each(function() {
$(this).removeClass("disabled");
})
setTimeout(function() {
$(e2.target).remove();
$(".summaryContainer").remove();

}, 1000)

})

//This is getting the data we pull in for the summary
setTimeout(function() {
$.ajax({
type: "get",
url: "/summary",
success: function(data) {
$(".overview_columns").append(data);

//Done loading!
$(".loading_spinner").remove();
setTimeout(function() {
//Sliding things around. Hiding the other 3 columns
$(".slide_column").css({"left": "12.5%", "margin-left": "3%", "margin-right": "3%"});
$(".summaryContainer").css("left", "29.4%");
//Spinning the little back button
$(".slide_column").find(".next_container").find("img").css("-webkit-transform", "rotateY(180deg)");
//$("#predict_button").find("img").click(function() {

//})



console.log(resource)
if (resource == "wind") {
$("#kwhTitle").html((ratings.windInfo[0].unit / 1000).toFixed(2) + " kwh/m&#178;");
$("#fun_fact").html("Between 2008 and 2012, wind power has provided 36.5% of all new generating capacity in the United States.")
//$(".prof_links").html("<a href='http://www.advancedgreenbuilders.com'>Advanced Green Builders</a> <br> <br><a href='http://www.awstruepower.com/'>AWS True Power</a>")
//Change the fun stuff based on whats being shown
} else if (resource == "solar") {
$("#kwhTitle").html(ratings.solarInfo[0].unit + " kwh");
$("#fun_fact").html("Every hour the sun beams onto Earth more than enough energy to satisfy global energy needs for an entire year.")
Expand All @@ -180,6 +208,8 @@ $(document).ready(function() {
//$(".prof_links").html("<a href='http://www.silverstaterenewables.com/'>Silver State Renewables, Inc</a> <br> <br><a href='http://www.quantumgeothermal.com/'>Quantum Geothermal</a>")
$("#kwhTitle").html(ratings.geoInfo[0].unit + " &#186;C/m");
}

//Close the map. Make it fancy. Slide.
function closemap() {
$(".prof_map").html("");
$("#close_map").css("display", "none");
Expand Down Expand Up @@ -234,7 +264,7 @@ $(document).ready(function() {
})
}, 1000)
}
});
}); //timeout
}, 1000);

})
Expand All @@ -244,14 +274,5 @@ $(document).ready(function() {
});
});

//var items = (0,9)
//items[0][0] = 1;
//items[1][2] =2;

//console.log(items[0][0]);





});
22 changes: 22 additions & 0 deletions public/javascripts/location.js
Expand Up @@ -50,6 +50,24 @@ $(function(){
map_canvas = $(".map_canvas");
geocoder = new google.maps.Geocoder();


//Creating a new map style to get rid of the 'report an error' on google maps
//because it was so close to the get started button.
//YES this is okay by their TOS.
var MAP_STYLE = [
{
featureType: "road",
elementType: "all",
stylers: [
{ visibility: "on" }
]
}
];
var styleOptions = {
name: "No Report Style"
};


//Set the starting position to Toronto
var latlng = new google.maps.LatLng(43.647566,-79.384847);
var mapOptions = {
Expand All @@ -61,6 +79,10 @@ $(function(){
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(map_canvas[0], mapOptions);
//Applying the map style
var mapType = new google.maps.StyledMapType(MAP_STYLE, styleOptions);
map.mapTypes.set("No Report Style", mapType);
map.setMapTypeId("No Report Style");


//Getting the enter key. How is this not default behaviour? blah.
Expand Down
4 changes: 2 additions & 2 deletions public/stylesheets/overview.css
@@ -1,12 +1,12 @@
.location_home {
position: absolute;
left:-20%;
left:-10%;
top: 20%;
height: 35%;
width: 3em;
z-index: 10;
background-color: #434343;
-webkit-transition: all 2s ease;
-webkit-transition: all 1s ease;
}
.location_home_animate {
left:0;
Expand Down

0 comments on commit e11a6a2

Please sign in to comment.