This repository has been archived by the owner on Feb 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
101 lines (82 loc) · 2.54 KB
/
popup.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
$(document).ready(function () {
$('#planetLoginWithUserAndPwd').submit(function () {
planetLogin($('#planetLogin').val(),$('#planetPassword').val());
return false;
});
$('#planetLoginWithAPIKey').submit(function () {
setPlanetApiKey($('#PlanetApiKey').val());
return false;
});
$('#setPlanetGeePath').submit(function () {
setPlanetGeePath($('#PlanetGeePath').val());
return false;
});
$('#setDropAreaGeePath').submit(function () {
setDropAreaGeePath($('#DropAreaGeePath').val());
return false;
});
$('#setPlanetSetings').submit(function () {
setPlanetSetings($('#numberMinOfTileToDisp').val(),$('#dispTunail').prop('checked'));
return false;
});
$('#PlanetGeePath').val
chrome.storage.local.get(["planet_api_key", "planetPathInGEE", "DropAreaPathInGEE","numberMinOfTileToDisp", "dispTunail"],function(vals){
$('#PlanetApiKey').val(vals.planet_api_key);
$('#PlanetGeePath').val(vals.planetPathInGEE);
$('#DropAreaGeePath').val(vals.DropAreaPathInGEE);
$('#numberMinOfTileToDisp').val(vals.numberMinOfTileToDisp);
$('#dispTunail').prop('checked',vals.dispTunail);
});
});
$( function() {
$( "#accordion" ).accordion({
heightStyle: "content",
collapsible: true,
active: false
});
} );
/*** ***/
function setDropAreaGeePath(path){
chrome.storage.local.set({ "DropAreaPathInGEE": path});
}
/*** Planet ***/
function planetLoginWithUserAndPwd(){
alert("planetLoginWithUserAndPwd");
}
function planetLoginWithAPIKey(){
alert("planetLoginWithAPIKey");
}
function planetLogin( user, pwd){
var body={"email": user, "password": pwd}
var request={
url:"https://api.planet.com/auth/v1/experimental/public/users/authenticate",
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(body),
success: function(result){
console.debug('success');
console.debug(result);
var decodeOutput=JSON.parse(atob(result.token.split('.')[1]));
setPlanetApiKey(decodeOutput.api_key);
$('#PlanetApiKey').val(decodeOutput.api_key);
},
function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
console.debug('error');
console.debug(err.Message);
}
}
$.ajax(request);
}
function setPlanetApiKey(key){
chrome.storage.local.set({ "planet_api_key": key});
}
function setPlanetGeePath(path){
chrome.storage.local.set({ "planetPathInGEE": path});
}
function setPlanetSetings(numberMinOfTileToDisp,dispTunail){
chrome.storage.local.set({ "numberMinOfTileToDisp": numberMinOfTileToDisp});
chrome.storage.local.set({ "dispTunail": dispTunail});
}
/*** End Planet ***/