-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting preliminary work. Encouraged.
- Loading branch information
Terrence Ryan
committed
Jun 18, 2012
1 parent
e60582a
commit 93c5633
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */ | ||
/*global define, $, brackets, window */ | ||
|
||
/** Simple extension that adds a "File > Hello World" menu item */ | ||
define(function (require, exports, module) { | ||
'use strict'; | ||
|
||
var CommandManager = brackets.getModule("command/CommandManager"), | ||
Menus = brackets.getModule("command/Menus"); | ||
|
||
// Local modules | ||
require('phonegapbuild'); | ||
var phonegapbuild = new PhoneGapBuild(); | ||
//hardcode for now. Eventually, we'll save the token in local storage. | ||
phonegapbuild.getToken("", ""); | ||
|
||
|
||
// Function to run when the menu item is clicked | ||
function handlePGList() { | ||
var list = ""; | ||
for (var i = 0; i < phonegapbuild.list.length; i++){ | ||
list += phonegapbuild.list[i].title + ", "; | ||
} | ||
|
||
|
||
window.alert(list); | ||
} | ||
|
||
|
||
// First, register a command - a UI-less object associating an id to a handler | ||
var PG_LIST = "PhoneGap.list"; | ||
CommandManager.register("List Build Projects", PG_LIST, handlePGList); | ||
|
||
// Then create a menu item bound to the command | ||
// The label of the menu item is the name we gave the command (see above) | ||
var menu; | ||
menu = Menus.addMenu("PhoneGap", "tpryan.phonegap.phonegap"); | ||
menu.addMenuItem(PG_LIST); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
var PhoneGapBuild = function() { | ||
|
||
var URL_BASE = "https://build.phonegap.com"; | ||
var URL_TOKEN = URL_BASE + "/token"; | ||
var URL_LIST = URL_BASE + "/api/v1/apps"; | ||
|
||
var self = this; | ||
|
||
this.token = ""; | ||
this.list ="List of PhoneGap Build projects." | ||
this.getToken = getToken; | ||
this.getList = getList; | ||
|
||
|
||
function setToken(token){ | ||
self.token = token; | ||
console.log(this); | ||
} | ||
|
||
function setList(list){ | ||
self.list = list; | ||
} | ||
|
||
function getToken(username,password){ | ||
console.log(this); | ||
$.ajax({ | ||
url: URL_TOKEN, | ||
type:"post", | ||
error: errorHandler, | ||
context: PhoneGapBuild, | ||
success: handleTokenSuccess, | ||
username: username, | ||
password: password, | ||
cache:false, | ||
crossDomain:true | ||
}); | ||
} | ||
|
||
function handleTokenSuccess(response, status, jqXHR){ | ||
console.log("Token Retreived"); | ||
console.log(response); | ||
setToken(response.token); | ||
getList(); | ||
} | ||
|
||
function errorHandler(error){ | ||
console.log("Login Error"); | ||
console.log(error.responseText); | ||
} | ||
|
||
function getList(){ | ||
$.ajax({ | ||
url: URL_LIST + "?auth_token=" + this.token, | ||
success: handleListSuccess, | ||
dataType: 'jsonp', | ||
type:"get", | ||
error: errorHandler, | ||
cache:false, | ||
crossDomain:true | ||
}); | ||
} | ||
|
||
function handleListSuccess(response, status, jqXHR){ | ||
console.log("List Retreived"); | ||
console.log(response.apps); | ||
setList(response.apps); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |