-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d65ae0
commit feb4364
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
function generateManifest() { | ||
var name = document.getElementById("name").value; | ||
var description = document.getElementById("description").value; | ||
var version = document.getElementById("version").value; | ||
var uuid = generateUUID(); | ||
var uuid2 = generateUUID2(); | ||
var minimum_api_version = document.getElementById("minimum_api_version").value; | ||
var author = document.getElementById("author").value; | ||
|
||
var manifest = { | ||
"format_version": 2, | ||
"header": { | ||
"name": name, | ||
"description": description, | ||
"uuid": uuid, | ||
"version": [parseInt(version.split(".")[0]), parseInt(version.split(".")[1]), parseInt(version.split(".")[2])], | ||
"min_engine_version": [parseInt(minimum_api_version.split(".")[0]), parseInt(minimum_api_version.split(".")[1]), parseInt(minimum_api_version.split(".")[2])], | ||
"author": author | ||
}, | ||
"modules": [ | ||
{ | ||
"type": "resources", | ||
"uuid": uuid2, | ||
"version": [parseInt(version.split(".")[0]), parseInt(version.split(".")[1]), parseInt(version.split(".")[2])] | ||
} | ||
] | ||
}; | ||
|
||
var manifestJson = JSON.stringify(manifest, null, 2); | ||
|
||
var blob = new Blob([manifestJson], { type: "application/json" }); | ||
var url = URL.createObjectURL(blob); | ||
|
||
var link = document.createElement("a"); | ||
link.href = url; | ||
link.download = "manifest.json"; | ||
link.click(); | ||
} | ||
|
||
function generateUUID() { | ||
var d = new Date().getTime(); | ||
if (typeof performance !== 'undefined' && typeof performance.now === 'function') { | ||
d += performance.now(); | ||
} | ||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | ||
var r = (d + Math.random() * 16) % 16 | 0; | ||
d = Math.floor(d / 16); | ||
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); | ||
}); | ||
} | ||
|
||
function generateUUID2() { | ||
var d = new Date().getTime(); | ||
if (typeof performance !== 'undefined' && typeof performance.now === 'function') { | ||
d += performance.now(); | ||
} | ||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | ||
var r = (d + Math.random() * 16) % 16 | 0; | ||
d = Math.floor(d / 16); | ||
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); | ||
}); | ||
} |