-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.html
138 lines (116 loc) · 4.78 KB
/
configuration.html
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html>
<head>
<title>Configurable</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
</head>
<body>
<div data-role="page" id="main">
<div data-role="header" class="jqm-header">
<h1>Pebble Feedly Configurable</h1>
</div>
<div data-role="content">
<!--
<div data-role="fieldcontain">
<label for="name">Name:</label>
<textarea cols="40" rows="8" name="name" id="name"></textarea>
</div>
-->
<!--
<div data-role="fieldcontain">
<label for="special-feature">Activate special feature:</label>
<select name="special-feature" id="special-feature" data-role="slider">
<option value="off">Off</option>
<option value="on">On</option>
</select>
</div>
-->
<!--
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>Choose as many snacks as you'd like:</legend>
<input type="checkbox" name="checkbox-cheetos" id="checkbox-cheetos" class="custom" />
<label for="checkbox-cheetos">Cheetos</label>
<input type="checkbox" name="checkbox-doritos" id="checkbox-doritos" class="custom" />
<label for="checkbox-doritos">Doritos</label>
<input type="checkbox" name="checkbox-fritos" id="checkbox-fritos" class="custom" />
<label for="checkbox-fritos">Fritos</label>
<input type="checkbox" name="checkbox-sunchips" id="checkbox-sunchips" class="custom" />
<label for="checkbox-sunchips">Sun Chips</label>
</fieldset>
</div>
</div>
-->
<button type="submit" data-theme="a" id="b-login">Login</button>
<button type="submit" data-theme="d" id="b-logout">Logout</button>
<div class="ui-body ui-body-b">
<fieldset class="ui-grid-a">
<div class="ui-block-a"><button type="submit" data-theme="d" id="b-cancel">Cancel</button></div>
<div class="ui-block-b"><button type="submit" data-theme="a" id="b-submit">Submit</button></div>
</fieldset>
</div>
</div>
</div>
</div>
<script>
function getUrlParameter(param_name) {
param_name = param_name + "=";
var param_name_start_index = window.location.search.indexOf(param_name);
if (param_name_start_index != -1) {
var param = window.location.search.substring(param_name_start_index + param_name.length);
// Remove extra params (if they exist)
var param_end_index = param.indexOf("&");
if (param_end_index != -1) {
param = param.substring(0, param_end_index);
}
return param;
} else {
return null;
}
}
$().ready(function() {
$("#b-cancel").click(function() {
console.log("Cancel");
document.location = "pebblejs://close";
});
$("#b-submit").click(function() {
console.log("Submit");
var location = "pebblejs://close#" + encodeURIComponent(JSON.stringify(secret_configuration));
console.log("Warping to: " + location);
console.log(location);
document.location = location;
});
$("#b-login").click(function() {
window.location = feedly_url + "/v3/auth/auth"
+ "?response_type=code&scope=https://cloud.feedly.com/subscriptions"
+ "&redirect_uri=" + redirect_uri
+ "&state=" + encodeURIComponent(JSON.stringify(configuration))
+ "&client_id=" + client_id;
});
$("#b-logout").click(function() {
secret_configuration.oauth_token = null;
});
var feedly_url = "https://sandbox.feedly.com";
var redirect_uri = document.location.origin + document.location.pathname;
var client_id = "sandbox";
var client_secret = "FUFNPXDNP2J0BF7RCEUZ";
var auth_code = getUrlParameter("code");
var configuration = getUrlParameter("configuration");
var secret_configuration = {
"configuration": configuration,
"oauth_token": null
}
// If auth_code is not null, it has just been generated.
if (auth_code != null) {
// Reload configuration from "state"
configuration = getUrlParameter("state");
secret_configuration.oauth_token = auth_code;
}
});
</script>
</body>
</html>