Most significant is the creation of generic dialog boxes and an app screen with status bar on top and bottom this reduces development time very significantly.
i use first a subdomain of my base domain ( daps.*** ) if this ok if i make a DroidScript app store (for free spk/apks)? :)
if no: can i try to make a selfmade site? :)
thx
Still can't download, but an example of what I have so far can be found here: https://app.box.com/s/kar2hz4zeelyz2ofkjbkgr9zfxtwmdo6 (Tried to post SPK, but I think my phone is too tired right now. Wonder why? ;-))
"use strict";
var browser;
var user_api = "https://api.github.com/users/DroidScript";
var repos_api = "https://api.github.com/users/DroidScript/repos";
function OnStart() {
browser = new Browser();
app.AddLayout(browser.layout);
getUser();
getRepos();
}
function getUser() {
get(user_api)
.then(JSON.parse)
.then(
function(user) {
browser.setText(user);
});
}
function getRepos() {
var repoList = [];
get(repos_api)
.then(JSON.parse)
.then(
function(userRepos) {
userRepos.forEach(
function(repo) {
repoList.push(repo.name);
});
browser.setList(repoList);
});
}
function getDownload(title) {
app.OpenUrl("https://github.com/DroidScript/"+title+"/archive/master.zip");
}
function Browser() {
this.layout = app.CreateLayout("Linear", "FillXY");
var userText = createLabeledText(this.layout, "Repository:");
var fileList = app.CreateList("", 1.0, 0.8, "WhiteGrad");
fileList.SetTextColor1("#ff555558");
fileList.SetTextColor2("#ff555558");
fileList.SetTextMargins(0.04, 0, 0, 0);
fileList.SetOnTouch(getDownload);
this.layout.AddChild(fileList);
/* Set user and repository name. */
this.setText = function(user) {
userText.SetText(user.login);
};
/* Set branch or directory contents list. */
this.setList = function(array) {
fileList.SetList(array.join(","));
};
}
/**
* Create a pair of side by side text boxes,
* making the left text a label for the right
* text.
* @arg layout is which layout to add to.
* @arg label is what text to use for left text.
* @return right text.
*/
function createLabeledText(layout, label) {
var ltext = app.CreateText(label, 0.23, 0.08, "Left");
var rtext = app.CreateText("", 0.77, 0.08, "Left, Multiline");
var hlayout = app.CreateLayout("Linear", "Horizontal, FillX, Top");
rtext.SetTextSize(20);
hlayout.SetPadding(0.02, 0.01, 0.01, 0.01);
hlayout.SetBackColor("#225588");
hlayout.AddChild(ltext);
hlayout.AddChild(rtext);
layout.AddChild(hlayout);
return rtext;
}
/**
* Sends XMLHttpRequest GET request as new Promise.
* @arg {string} url - URL to receive request.
*/
function get(url) {
// Return a new promise.
// Great article on Promises at http://www.html5rocks.com/en/tutorials/es6/promises/
return new Promise(
function(resolve, reject) {
// Do the usual XHR stuff
var req = new XMLHttpRequest();
req.open('GET', url);
req.setRequestHeader("Accept", "application/vnd.github.v3+json");
req.onload = function() {
// This is called even on 404 etc
// so check the status
if (req.status == 200) {
// Resolve the promise with the response text
resolve(req.response);
}
else {
// Otherwise reject with the status text
// which will hopefully be a meaningful error
reject(Error(req.statusText));
}
};
// Handle network errors
req.onerror = function() {
reject(Error("Network Error"));
};
// Make the request
req.send();
});
}//end get