This repository was archived by the owner on Oct 27, 2024. It is now read-only.
forked from eli-schwartz/cookieclicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmobile.js
66 lines (66 loc) · 2.73 KB
/
mobile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var LaunchMobile = function() {
alert("Sorry, this game uses a file that can't be found");
/*
Game.m = { fileSystem: {} }; //handle for every thing mobile
//docs for this stuff : http://docs.phonegap.com/en/3.0.0/cordova_file_file.md.html
Game.m.readSaveRequest = function () {
Debug('Load save request');
Game.m.fileSystem.root.getFile(Game.SaveTo + '.txt', {
create: true,
exclusive: false
}, Game.m.readFileEntry, Game.m.fail);
}
Game.m.readSaveResponse = function (response) {
Debug('Load save response');
Game.LoadSave(unescape(response));
}
Game.m.writeSaveRequest = function () {
Debug('Write save request');
Game.m.fileSystem.root.getFile(Game.SaveTo + '.txt', {
create: true,
exclusive: false
}, Game.m.writeFileEntry, Game.m.fail);
}
Game.m.onDeviceReady = function () {
Debug('Ready');
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, Game.m.gotFileSystem, Game.m.fail); //ask for the file system
}
Game.m.gotFileSystem = function (fileSystem) {
Debug('Got file system');
Game.m.fileSystem = fileSystem; //did we get the file system? Good, save it
Game.LoadSave(); //load the save for good measure
}
Game.m.readFileEntry = function (fileEntry) {
Debug('Read file entry');
fileEntry.file(Game.m.readFile, Game.m.fail); //did we get the requested file entry? That's just super, get ready to read it
}
Game.m.readFile = function (file) {
Debug('Read file');
var reader = new FileReader(); //we got the file we wanted? Radical. Let's read it now
reader.onloadend = function (evt) {
Game.m.readSaveResponse(evt.target.result);
//console.log(evt.target.result);
};
reader.readAsText(file);
}
Game.m.writeFileEntry = function (fileEntry) {
Debug('Write file entry');
fileEntry.createWriter(Game.m.writeFile, Game.m.fail); //did we get the requested file entry? Joy and butterflies, now we can write to it
}
Game.m.writeFile = function (writer) {
Debug('Write file');
writer.onwriteend = function (evt) //why this plugin isn't using unquestionably superior camel-case is beyond me
{};
writer.write(Game.saveData); //well oh my goodness I think we're done here
}
Game.m.fail = function (evt) //well I guess something went wrong
{
Debug('Failed');
console.log(evt.target.error.code);
Game.Popup(evt.target.error.code);
}
//Wait for device API libraries to load
Debug('Readying mobile');
document.addEventListener('deviceready', Game.m.onDeviceReady, false);
*/
};