var location = require('locationobject'); var webservice = require('webservice'); var whereishotparser = require ('whereishotparser'); // gettin' user location location.setLocation(); var coordinates = Ti.App.Properties.getObject('coordinates'), latitude = coordinates.lat, longitude = coordinates.lon; // discover Town Name webservice.getTownName(longitude,latitude); Ti.API.info(1); var townNameJSON = Ti.App.Properties.getObject('townNameJSON'); Ti.API.info(2); // town Json has been taken whereishotparser.getTownNameFromJSON(townNameJSON); Ti.API.info(3); var townName = Ti.App.Properties.getObject('townName'); Ti.API.info(4); $.thePlace.text = townName; // woeid JSON part webservice.getWoeidFromCityName(townName); Ti.API.info(5); var woeidJSON = Ti.App.Properties.getObject('woeidDataJSON'); Ti.API.info(6); // woeid taking Part whereishotparser.getWoeidFromJSON(woeidJSON); Ti.API.info(7); var woeid = Ti.App.Properties.getObject('woeidName'); Ti.API.info(8); //final weather information gatherin
function Controller() { function takeAPic() { Titanium.UI.currentWindow; Titanium.Media.showCamera({ success: function(event) { var image = event.media; var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, "camera_photo.png"); f.write(image); $.index.backgroundImage = f.nativePath; }, cancel: function() {}, error: function(error) { var a = Titanium.UI.createAlertDialog({ title: "Camera" }); error.code == Titanium.Media.NO_CAMERA ? a.setMessage("Device does not have video recording capabilities") : a.setMessage("Unexpected error: " + error.code); a.show(); }, saveToPhotoGallery: false, allowEditing: false }); } function getDate() { var currentTime = new Date(); return currentTime.getDate() + "." + currentTime.getMonth() + "." + currentTime.getFullYear() + " - " + currentTime.getHours() + ":" + currentTime.getMinutes(); } function saveIt() { Ti.Media.takeScreenshot(function(e) { Ti.Media.saveToPhotoGallery(e.media); alert("Saved Successfully!"); }); } function changeBg() { $.index.backgroundImage = "/bgDefault.jpg"; } require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments)); this.__controllerPath = "index"; arguments[0] ? arguments[0]["__parentSymbol"] : null; arguments[0] ? arguments[0]["$model"] : null; arguments[0] ? arguments[0]["__itemTemplate"] : null; var $ = this; var exports = {}; var __defers = {}; $.__views.index = Ti.UI.createWindow({ backgroundImage: "/bgDefault.jpg", id: "index" }); $.__views.index && $.addTopLevelView($.__views.index); $.__views.pictureTake = Ti.UI.createButton({ backgroundColor: "#fff", borderRadius: "3px", top: 20, opacity: .8, color: "#000", left: 5, title: "Take A Picture!", id: "pictureTake" }); $.__views.index.add($.__views.pictureTake); takeAPic ? $.__views.pictureTake.addEventListener("click", takeAPic) : __defers["$.__views.pictureTake!click!takeAPic"] = true; $.__views.saveThis = Ti.UI.createButton({ backgroundColor: "#fff", borderRadius: "3px", top: 20, opacity: .8, color: "#000", title: "Save!", id: "saveThis" }); $.__views.index.add($.__views.saveThis); saveIt ? $.__views.saveThis.addEventListener("click", saveIt) : __defers["$.__views.saveThis!click!saveIt"] = true; $.__views.changeBack = Ti.UI.createButton({ backgroundColor: "#fff", borderRadius: "3px", top: 20, opacity: .8, color: "#000", right: 5, title: "Reset", id: "changeBack" }); $.__views.index.add($.__views.changeBack); changeBg ? $.__views.changeBack.addEventListener("click", changeBg) : __defers["$.__views.changeBack!click!changeBg"] = true; $.__views.thePlace = Ti.UI.createLabel({ width: Ti.UI.SIZE, height: Ti.UI.SIZE, color: "#000", backgroundColor: "#fff", opacity: .6, padding: "10px", borderRadius: "3px", left: 10, font: { fontSize: 36 }, bottom: 75, text: "Loading...", id: "thePlace" }); $.__views.index.add($.__views.thePlace); $.__views.degree = Ti.UI.createLabel({ width: Ti.UI.SIZE, height: Ti.UI.SIZE, color: "#000", backgroundColor: "#fff", opacity: .6, padding: "10px", borderRadius: "3px", left: 10, font: { fontSize: 36 }, bottom: 20, text: "- C", id: "degree" }); $.__views.index.add($.__views.degree); $.__views.theDateandTime = Ti.UI.createLabel({ width: Ti.UI.SIZE, height: Ti.UI.SIZE, color: "#000", backgroundColor: "#fff", opacity: .6, padding: "10px", borderRadius: "3px", right: 10, font: { fontSize: 18 }, bottom: 20, text: "Loading", id: "theDateandTime" }); $.__views.index.add($.__views.theDateandTime); $.__views.weatherCondition = Ti.UI.createLabel({ width: Ti.UI.SIZE, height: Ti.UI.SIZE, color: "#000", backgroundColor: "#fff", opacity: .6, padding: "10px", borderRadius: "3px", right: 10, font: { fontSize: 18 }, bottom: 45, text: "Loading", id: "weatherCondition" }); $.__views.index.add($.__views.weatherCondition); exports.destroy = function() {}; _.extend($, $.__views); var location = require("locationobject"); var webservice = require("webservice"); var whereishotparser = require("whereishotparser"); location.setLocation(); var coordinates = Ti.App.Properties.getObject("coordinates"), latitude = coordinates.lat, longitude = coordinates.lon; webservice.getTownName(longitude, latitude); Ti.API.info(1); var townNameJSON = Ti.App.Properties.getObject("townNameJSON"); Ti.API.info(2); whereishotparser.getTownNameFromJSON(townNameJSON); Ti.API.info(3); var townName = Ti.App.Properties.getObject("townName"); Ti.API.info(4); $.thePlace.text = townName; webservice.getWoeidFromCityName(townName); Ti.API.info(5); var woeidJSON = Ti.App.Properties.getObject("woeidDataJSON"); Ti.API.info(6); whereishotparser.getWoeidFromJSON(woeidJSON); Ti.API.info(7); var woeid = Ti.App.Properties.getObject("woeidName"); Ti.API.info(8); webservice.getWeatherfromWoeid(woeid); var woeidXML = Ti.App.Properties.getObject("weatherWoeidXML"); whereishotparser.xmlToDictionary(woeidXML); var current = Ti.App.Properties.getObject("current"); currentWeather = current.weather; currentType = current.type; $.theDateandTime.text = getDate(); $.degree.text = current.weather + " C "; $.weatherCondition.text = currentType; $.index.open(); __defers["$.__views.pictureTake!click!takeAPic"] && $.__views.pictureTake.addEventListener("click", takeAPic); __defers["$.__views.saveThis!click!saveIt"] && $.__views.saveThis.addEventListener("click", saveIt); __defers["$.__views.changeBack!click!changeBg"] && $.__views.changeBack.addEventListener("click", changeBg); _.extend($, exports); }