-
Notifications
You must be signed in to change notification settings - Fork 127
/
api.js
63 lines (43 loc) · 1.38 KB
/
api.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
/**
* api.js
*
* API For encoding and decoding URL hash objects
*
* Created by Jacob Strieb
* July 2020
*/
/*******************************************************************************
* Global Variables
******************************************************************************/
const LATEST_API_VERSION = "0.2.0";
var apiVersions = {};
/*******************************************************************************
* API Version 0.2.0 (Latest)
******************************************************************************/
apiVersions["0.2.0"] = {
VERSION: "0.2.0",
/* Return a link to view the page */
getViewLink: function(pageData) {
var urlData = {
version: this.VERSION,
compressed: false,
body: pageData,
};
const hashObject = b64.encode(JSON.stringify(urlData));
return `http://jstrieb.github.io/urlpages/#${hashObject}`;
},
/* Return the page data from the object */
decode: function(urlData) {
return urlData.body;
},
}
/*******************************************************************************
* API Version 0.0.1 (Original)
******************************************************************************/
apiVersions["0.0.1"] = {
VERSION: "0.0.1",
/* Return a link to view the page */
getViewLink: function(pageData) {
return `http://jstrieb.github.io/urlpages/#${b64.encode(pageData)}`;
},
}