-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathmanifest.js
108 lines (85 loc) · 2.83 KB
/
manifest.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
102
103
104
105
106
107
// dynamic manifest
let manifest = {
"name": "Codeit",
"short_name": "Codeit",
"description": "Mobile code editor connected to Git.",
"background_color": "#313744",
"theme_color": "#313744",
"display": "standalone",
"scope": window.location.origin,
"start_url": window.location.origin + "/full",
"id": "/full",
"orientation": "any",
"icons": [
{
"src": window.location.origin + "/icons/android-app-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
}
],
"file_handlers": [
{
"action": window.location.origin + "/full",
"name": "file",
"accept": {
"text/plain": [".js",".html",".css",".c",".cs",".py",".jsx",".atom",".xss",".do",".action",".xml",".svg",".md",".gitignore",".json",".aspx",".kt",".sass",".less",".asp",".axd",".asx",".asmx",".ashx",".sh",".bash",".sh",".shell",".bat",".cmd",".dotnet",".csharp",".ejs",".editorconfig",".java",".webmanifest",".mathml",".ssml",".php",".perl",".pug",".scss",".rb",".ruby",".swift",".turtle",".trig",".ts",".tsconfig",".uscript",".uc",".wasm",".yaml",".ps1",".ps2",".objc",".kt",".kts",".emacs",".elisp",".lisp",".cgi",".dll",".lua",".makefile",".hs",".go",".git",".haml",".hbs",".mustache",".graphql",".haml",".erl",".hrl",".tex",".h",".m",".mm",".cpp",".xls",".xlsx",".csv",".coffee",".cmake",".basic",".adoc",".ino"]
}
}
],
"share_target": {
"action": window.location.origin + "/full",
"method": "POST",
"enctype": "multipart/form-data",
"params": {
"files": [
{
"name": "file",
"accept": ["text/*", "application/json"]
}
]
}
},
"handle_links": "preferred",
"launch_type": "multiple-clients",
"launch_handler": {
"route_to": "new-client"
},
"capture_links": "new-client"
};
// if not on mobile, display special icons
if (!isMobile) {
if (isMac) {
manifest.icons = [
{
"src": window.location.origin + "/icons/mac-icon-512-padding.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
}
];
} else {
manifest.icons = [
{
"src": window.location.origin + "/icons/app-favicon.png",
"sizes": "256x256",
"type": "image/png",
"purpose": "any"
}
];
}
// change page favicon
var link = document.querySelector("link[rel*='icon']");
link.href = '/icons/app-favicon.png';
} else if (!isSafari) {
manifest.background_color = '#0b0d1a';
}
if (isDev) {
manifest.name = 'Codeit [DEV]';
manifest.short_name = 'Codeit [DEV]';
}
// apply dynamic manifest
let linkElem = document.createElement('link');
linkElem.setAttribute('rel', 'manifest');
linkElem.setAttribute('href', 'data:application/json,' + encodeURIComponent(JSON.stringify(manifest)));
document.head.appendChild(linkElem);