Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
install apps
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Mar 25, 2020
1 parent 689e8b0 commit 8bec403
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 19 deletions.
31 changes: 19 additions & 12 deletions application/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ let dataSet;
let panels = ["All"];
let current_panel = 0;

let server_list = ["https://banana-hackers.gitlab.io/store-db/data.json", " https://farooqkz.github.io/data.json"]
let server_list = ["https://banana-hackers.gitlab.io/store-db/data.json", " https://farooqkz.github.io/data.json"];


$(document).ready(function() {

Expand Down Expand Up @@ -70,7 +71,7 @@ $(document).ready(function() {

getJson(server_list[0]);

let contributors = [];
let contributors = ["40min"];

function addAppList() {

Expand Down Expand Up @@ -98,7 +99,7 @@ $(document).ready(function() {

//unique author list
if (contributors.indexOf(item_author) === -1) {
contributors.push(data.author)
contributors.push(item_author)
}


Expand All @@ -116,7 +117,7 @@ $(document).ready(function() {
set_tabindex();
let update_time = moment(dataSet.generated_at).format('DD.MM.YYYY, HH:mm');

let about_text = "<h1>Contributors</h1>" + contributors.toString() + "<div class='footer'> Last update: " + update_time + "</div>"
let about_text = "<div>An alternative app store by free developers for free devices.The database of apps is hosted https://banana-hackers.gitlab.io/store-db , further can be added by a pull request.</div><div id='contributors'><h1>Contributors</h1>" + contributors.toString() + "</div><div class='footer'> Last update: " + update_time + "</div>"

let article = $("<article class='About'>" + about_text + "</article>");
$('div#app-panels').append(article);
Expand Down Expand Up @@ -311,7 +312,11 @@ $(document).ready(function() {
window.location.assign(link_target);


notify("Message", "App downloaded", false, true);
//notify("Message", "App downloaded", false, true);

window.open('file://downloads/', '_self ')





Expand Down Expand Up @@ -390,11 +395,17 @@ $(document).ready(function() {
break;

case 'ArrowLeft':
nav_panels("left");
if (window_status == "article-list") {
nav_panels("left");

}
break;

case 'ArrowRight':
nav_panels("right");
if (window_status == "article-list") {
nav_panels("right");

}
break;


Expand All @@ -405,11 +416,7 @@ $(document).ready(function() {
}
break;

case '1':
if (window_status == "single-article") {
open_url();
}
break;


case 'SoftRight':
if (window_status == "single-article") {
Expand Down
16 changes: 11 additions & 5 deletions application/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -216,22 +216,28 @@
div#app div#app-panels article.About {
background: black!Important;
color: white!Important;
width: 100vw;
min-width: 100vw;
max-width: 100vw;
height: 100vh;
font-size: 0.8rem;
padding: 50px 3px 3px 3px;
padding: 10px 5px 40px 5px;
margin: -5px 0 0 0;
display: none;
}

div#app div#app-panels article.About div#contributors {
margin: 8px 0 0 0;
}

div.footer {
position: fixed;
bottom: 5px;
bottom: 0px;
left: 0px;
right: 0px;
background: black!Important;
color: yellow!Important;
width: 100%;
width: 99%;
height: 30px;
padding: 0px 3px 3px 3px;
text-align: center;
font-size: 0.8rem;
}
Expand Down
93 changes: 93 additions & 0 deletions application/assets/js/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
var path;


window.addEventListener('DOMContentLoaded', function() {
var sdcard = navigator.getDeviceStorage('sdcard');

sdcard.addEventListener("change", function(event) {
var reason = event.reason;
var path = event.path;

install(path)

});

function install(param) {

var request = sdcard.get(param);

request.onsuccess = function() {
var file = this.result;
//alert("Get the file: " + file.name);
installPkg(file)
}

request.onerror = function() {
//alert("Unable to get the file: " + this.error);
}
}


var request = sdcard.get("my-file.txt");

request.onsuccess = function() {
var file = this.result;
console.log("Get the file: " + file.name);
}

request.onerror = function() {
console.warn("Unable to get the file: " + this.error);
}






function fparts(fName) {
let parts = fName.split('/')
let basename = parts.pop()
return { dirname: parts.join('/'), basename: basename }
}






function installPkg(packageFile) {
navigator.mozApps.mgmt.import(packageFile).then(function() {
alert('Installation successful!')
}).catch(e => {
alert('Installation error: ' + e.name + ' ' + e.message)
})
let appGetter = navigator.mozApps.mgmt.getAll()
appGetter.onsuccess = function() {
let apps = appGetter.result
alert.dir(apps)
}
appGetter.onerror = function(e) {
alert.dir(this.error)
}
}



window.addEventListener('keydown', function(e) {
switch (e.key) {

case '1':
alert(path)
installPkg(path)

break;





}
})


}, false)
4 changes: 3 additions & 1 deletion application/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<div id="button-bar">
<div class="inner flex justify-content-spacebetween width-100">
<div id="button-left">visit code</div>
<div id="button-right">download</div>
<div id="button-right">install</div>
</div>
</div>
</div>
Expand All @@ -56,6 +56,8 @@
<script defer src="assets/js/jQuery-3.1.0.js"></script>
<script defer src="assets/js/moments.min.js"></script>
<script defer src="assets/js/helper.js"></script>
<script defer src="assets/js/install.js"></script>

<script defer src="app.js"></script>

</body>
Expand Down
4 changes: 3 additions & 1 deletion application/manifest.webapp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "bHacker",
"description": "An app to download apps",
"launch_path": "/index.html",
"type": "privileged",
"type": "certified",
"fullscreen": "true",


Expand Down Expand Up @@ -46,6 +46,8 @@






}

Expand Down
Binary file modified build/bhacker-store.zip
Binary file not shown.

0 comments on commit 8bec403

Please sign in to comment.