commit 7d1dcaa0e9b9b27dbe411af5423d375ce6e013b7 Author: mikeshoup@gmail.com Date: Fri Dec 17 04:42:46 2010 +0000 new project diff --git a/share-a-bike/app/assistants/main-assistant.js b/share-a-bike/app/assistants/main-assistant.js new file mode 100644 index 0000000..6cba37c --- /dev/null +++ b/share-a-bike/app/assistants/main-assistant.js @@ -0,0 +1,90 @@ +function MainAssistant(argFromPusher) { +} + +MainAssistant.prototype = { + setup: function() { + Ares.setupSceneAssistant(this); + }, + cleanup: function() { + Ares.cleanupSceneAssistant(this); + }, + + // The find button has been tapped + findButtonTap: function(inSender) { + // Start Spinning + this.showSpinner(true); + + // API URL for BCycle + var url = 'http://api.bcycle.com/services/mobile.svc/ListKiosks'; + var gpsSuccess = true; + var gpsResult = 0; + + var onGpsSuccess = function(result) { + gpsResult = result; + }; + + var onGpsFailure = function(result) { + gpsSuccess = false; + this.showSpinner(false); + }; + + // Function for when AJAX request is complete + var onAjaxComplete = function(transport) { + var kiosks = [5]; + kiosks[0] = {name: "Name 1", distance: "0.1 mi", address: "100 Fake St", bikes: "0", docks: "1"}; + kiosks[1] = {name: "Name 2", distance: "0.2 mi", address: "100 Fake St", bikes: "0", docks: "1"}; + kiosks[2] = {name: "Name 3", distance: "0.3 mi", address: "100 Fake St", bikes: "0", docks: "1"}; + kiosks[3] = {name: "Name 4", distance: "0.4 mi", address: "100 Fake St", bikes: "0", docks: "1"}; + kiosks[4] = {name: "Name 5", distance: "12.2 mi", address: "100 Fake St", bikes: "0", docks: "1"}; + // Display Kiosks + this.listModel = { + items: kiosks + }; + this.controller.setWidgetModel("kioskList", this.listModel); + // We're done, stop spinning + this.showSpinner(false); + }.bind(this); + + var onAjaxFailure = function(transport) { + // There has been a failure, stop spinning + this.showSpinner(false); + }; + + // Get GPS Coord + this.getGpsCoord(onGpsSuccess, onGpsFailure); + + if(gpsSuccess) { + // Place AJAX request + this.ajaxRequest(url, onAjaxComplete, onAjaxFailure); + }; + }, + + // Find GPS Coordinate + getGpsCoord: function(onSuccess, onFailure) { + this.controller.serviceRequest('palm://com.palm.location', { + method:"getCurrentPosition", + parameters:{}, + onSuccess: onSuccess, + onFailure: onFailure + }); + }, + + // Perform AJAX request to BCycle API + ajaxRequest: function(url, onComplete, onFailure) { + var kioskRequest = new Ajax.Request(url, { + method: "get", + evalJSON: 'force', + contentType: 'application/x-www-form-urlencoded', + requestHeaders: { + "USER_AGENT": navigator.userAgent + }, + onComplete: onComplete, + onFailure: onFailure + }); + }, + + // Function to start/stop spinning + showSpinner: function(show) { + this.controller.get('findButton').mojo[(show ? 'activate' : 'deactivate')](); + }, +}; \ No newline at end of file diff --git a/share-a-bike/app/assistants/stage-assistant.js b/share-a-bike/app/assistants/stage-assistant.js new file mode 100644 index 0000000..de5247b --- /dev/null +++ b/share-a-bike/app/assistants/stage-assistant.js @@ -0,0 +1,7 @@ +function StageAssistant() { +} + +StageAssistant.prototype.setup = function() { + this.controller.pushScene({name: "main", disableSceneScroller: true}); + this.controller.setWindowOrientation("free"); +}; \ No newline at end of file diff --git a/share-a-bike/app/views/main/main-chrome.js b/share-a-bike/app/views/main/main-chrome.js new file mode 100644 index 0000000..b8a5107 --- /dev/null +++ b/share-a-bike/app/views/main/main-chrome.js @@ -0,0 +1,54 @@ +opus.Gizmo({ + name: "main", + dropTarget: true, + ontap: "mainTap", + type: "Palm.Mojo.Panel", + h: "100%", + styles: { + zIndex: 2, + opacity: 1, + bgImage: "images/Sharrow-BG.jpg" + }, + chrome: [ + { + name: "findButton", + ontap: "findButtonTap", + disabled: undefined, + label: "Find Kiosks", + type: "Palm.Mojo.ActivityButton", + l: 0, + t: 0 + }, + { + name: "scroller1", + scrollPosition: { + left: 0, + top: 0 + }, + type: "Palm.Mojo.Scroller", + l: 0, + t: 261, + styles: { + cursor: "move", + overflow: "hidden" + }, + controls: [ + { + name: "kioskList", + dropTarget: true, + items: [], + useSampleData: false, + title: undefined, + itemHtml: "
\n
\n
#{name}
\n
#{address}
\n
\n
\n
#{distance}
\n
#{bikes}B #{docks}D
\n
\n
", + swipeToDelete: false, + rowTapHighlight: false, + rowFocusHighlight: false, + type: "Palm.Mojo.List", + l: 0, + t: 0, + h: 100 + } + ] + } + ] +}); \ No newline at end of file diff --git a/share-a-bike/app/views/main/main-scene.html b/share-a-bike/app/views/main/main-scene.html new file mode 100644 index 0000000..e69de29 diff --git a/share-a-bike/appinfo.json b/share-a-bike/appinfo.json new file mode 100644 index 0000000..d1ebd42 --- /dev/null +++ b/share-a-bike/appinfo.json @@ -0,0 +1,9 @@ +{ + "id": "com.mikeshoup.share-a-bike", + "version": "0.0.1", + "vendor": "ShoupTech", + "type": "web", + "main": "index.html", + "title": "Share-a-Bike", + "icon": "icon.png" +} diff --git a/share-a-bike/ares.js b/share-a-bike/ares.js new file mode 100644 index 0000000..1a303e9 --- /dev/null +++ b/share-a-bike/ares.js @@ -0,0 +1,107 @@ +opus = { + paths: {}, + depends: [], + path: { + // match $[anything]/ + pattern: /\$([^\/\\]*)(\/)?/g, + // replace macros of the form $pathname with the mapped value of paths.pathname + rewrite: function(inPath) { + var working, result = inPath; + do { + working = false; + result = result.replace(this.pattern, function(macro, name) { + working = true; + var path = opus.paths[name]; + return path ? (path.charAt(path.length-1) == "/" ? path : path + "/") : ""; + }); + } while (working); + return result; + } + }, + argify: function(inSearch) { + var args = inSearch.slice(1).split("&"); + for (var i=0, a, nv; a=args[i]; i++) { + // convert "name=value" to [name, value] + nv = args[i] = a.split("="); + // and then to name: value + args[nv[0]] = nv.length > 1 ? nv[1] : true; + } + return args; + }, + locateScript: function(inName) { + var l = inName.length; + var scripts = document.getElementsByTagName("script"); + for(var i=0, s, src; (s=scripts[i]); i++) { + src = s.getAttribute("src") || ""; + if(src.slice(-l) == inName) { + return src.slice(0, -l); + } + } + }, + /* + depends() does (when evaluated in JS, basically, debug mode): + for dependencies that are packages (no extension [ug?]) + - determine name, establish path (paths["opus-Aerie"] = "$opus/library/Aerie") + - load the package dependencies ($opus/library/Aerie/opus-Aerie-depends.js) + for all others: + - load the resources + */ + _depend: function(inPath) { + var tag, path = opus.path.rewrite(inPath); + if (path.slice(-3) == "css") { + // css + tag = ''; + //console.log("(css): " + path); + } else if (path.slice(-2) == "js") { + // js + //console.log("(js): " + path); + } else { + // package + // must encoded like so: + // [folder]/[name of package without extension] + var parts = path.split("/"); + var name = parts.pop(); + var folder = parts.join("/") + (parts.length ? "/" : ""); + opus.paths[name] = folder; + //console.log("make alias: " + name + ": " + folder); + path = folder + name + "-depends.js"; + //console.log("(depends): " + path); + } + if (!tag) { + tag = ''; + } + document.write(tag); + }, + depends: function(inDepends) { + //console.info("processing dependencies"); + var d; + if (d = inDepends.paths) { + for (var n in d) { + opus.paths[n] = d[n]; + } + } + if (d = inDepends.nobuild) { + for (i=0; b=d[i]; i++) { + this._depend(b); + } + } + if (d = inDepends.build) { + for (var i=0, b; b=d[i]; i++) { + this._depend(b); + } + } + } +}; + +(function(){ + if (!opus.paths.opus) { + opus.paths.opus = opus.locateScript("bootloader.js"); + } + opus.args = opus.argify(location.search); + var app = opus.args.app || (opus.args.debug ? "depends.js" : "app.js"); + document.write(''); + opus._tryDebug = function() { + app = "depends.js"; + document.write(''); + }; +})(); \ No newline at end of file diff --git a/share-a-bike/ares_version.json b/share-a-bike/ares_version.json new file mode 100644 index 0000000..7bb393e --- /dev/null +++ b/share-a-bike/ares_version.json @@ -0,0 +1,4 @@ +{ + "Mojo": "0.1.0 (311)", + "Ares": "1.0.4" +} \ No newline at end of file diff --git a/share-a-bike/framework_config.json b/share-a-bike/framework_config.json new file mode 100644 index 0000000..cbd68cf --- /dev/null +++ b/share-a-bike/framework_config.json @@ -0,0 +1,3 @@ +{ + "logLevel": 99 +} \ No newline at end of file diff --git a/share-a-bike/icon.png b/share-a-bike/icon.png new file mode 100644 index 0000000..56dd7bc Binary files /dev/null and b/share-a-bike/icon.png differ diff --git a/share-a-bike/images/Sharrow-BG.jpg b/share-a-bike/images/Sharrow-BG.jpg new file mode 100644 index 0000000..6b132e4 Binary files /dev/null and b/share-a-bike/images/Sharrow-BG.jpg differ diff --git a/share-a-bike/index.html b/share-a-bike/index.html new file mode 100644 index 0000000..cfcf83b --- /dev/null +++ b/share-a-bike/index.html @@ -0,0 +1,12 @@ + + + + + Share-a-Bike + + + + + + diff --git a/share-a-bike/sources.json b/share-a-bike/sources.json new file mode 100644 index 0000000..b8bfce2 --- /dev/null +++ b/share-a-bike/sources.json @@ -0,0 +1,13 @@ +[ + { + "source": "app\/assistants\/stage-assistant.js" + }, + { + "source": "app\/views\/main\/main-chrome.js", + "scenes": "main" + }, + { + "source": "app\/assistants\/main-assistant.js", + "scenes": "main" + } +] diff --git a/share-a-bike/stylesheets/style.css b/share-a-bike/stylesheets/style.css new file mode 100644 index 0000000..a037621 --- /dev/null +++ b/share-a-bike/stylesheets/style.css @@ -0,0 +1,25 @@ +.kiosk_left_col { + float: left; +} +.kiosk_right_col { + float: right; +} + +.kiosk_name { + font-weight: bold; + font-size: 1em; +} + +.kiosk_distance { + font-size: 1em; +} + +.kiosk_address { + font-size: 0.8em; +} + +.kiosk_availability { + font-size: 0.8em; + font-weight: bold; + text-align: right; +} \ No newline at end of file