2018-05-17 16:18:20 +02:00
|
|
|
// @author rubenwardy
|
|
|
|
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
|
|
|
|
|
2023-08-26 13:34:55 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
function hide(sel) {
|
|
|
|
document.querySelectorAll(sel).forEach(x => x.classList.add("d-none"));
|
|
|
|
}
|
|
|
|
|
|
|
|
function show(sel) {
|
|
|
|
document.querySelectorAll(sel).forEach(x => x.classList.remove("d-none"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener("load", () => {
|
2018-05-09 18:44:58 +02:00
|
|
|
function finish() {
|
2023-08-26 13:34:55 +02:00
|
|
|
hide(".pkg_wiz_1");
|
|
|
|
hide(".pkg_wiz_2");
|
|
|
|
show(".pkg_repo");
|
|
|
|
show(".pkg_meta");
|
2018-05-09 18:44:58 +02:00
|
|
|
}
|
|
|
|
|
2023-08-26 13:34:55 +02:00
|
|
|
hide(".pkg_meta");
|
|
|
|
show(".pkg_wiz_1");
|
2018-12-21 15:10:46 +01:00
|
|
|
|
2023-08-26 13:34:55 +02:00
|
|
|
document.getElementById("pkg_wiz_1_skip").addEventListener("click", finish);
|
|
|
|
document.getElementById("pkg_wiz_1_next").addEventListener("click", () => {
|
|
|
|
const repoURL = document.getElementById("repo").value;
|
|
|
|
if (repoURL.trim() !== "") {
|
|
|
|
hide(".pkg_wiz_1");
|
|
|
|
show(".pkg_wiz_2");
|
|
|
|
hide(".pkg_repo");
|
2018-05-09 18:44:58 +02:00
|
|
|
|
2023-08-26 13:34:55 +02:00
|
|
|
function setField(sel, value) {
|
|
|
|
if (value && value !== "") {
|
|
|
|
const ele = document.querySelector(sel);
|
|
|
|
ele.value = value;
|
|
|
|
ele.dispatchEvent(new Event("change"));
|
2021-02-28 03:36:31 +01:00
|
|
|
|
|
|
|
// EasyMDE doesn't always refresh the codemirror correctly
|
2023-08-26 13:34:55 +02:00
|
|
|
if (ele.easy_mde) {
|
2021-02-28 03:36:31 +01:00
|
|
|
setTimeout(() => {
|
2023-08-26 13:34:55 +02:00
|
|
|
ele.easy_mde.value(value);
|
|
|
|
ele.easy_mde.codemirror.refresh()
|
2021-02-28 03:36:31 +01:00
|
|
|
}, 100);
|
|
|
|
}
|
2018-05-27 23:03:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-11 13:57:16 +02:00
|
|
|
performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) {
|
2018-12-28 15:32:11 +01:00
|
|
|
setField("#name", result.name);
|
|
|
|
setField("#title", result.title);
|
|
|
|
setField("#repo", result.repo || repoURL);
|
|
|
|
setField("#issueTracker", result.issueTracker);
|
2021-02-28 03:36:31 +01:00
|
|
|
setField("#desc", result.desc);
|
|
|
|
setField("#short_desc", result.short_desc);
|
|
|
|
setField("#forums", result.forums);
|
2018-06-05 20:51:01 +02:00
|
|
|
if (result.type && result.type.length > 2) {
|
2023-08-26 13:34:55 +02:00
|
|
|
setField("[name='type']", result.type);
|
2018-06-05 20:51:01 +02:00
|
|
|
}
|
|
|
|
|
2018-12-28 15:32:11 +01:00
|
|
|
finish();
|
2018-05-11 13:57:16 +02:00
|
|
|
}).catch(function(e) {
|
2018-12-28 15:32:11 +01:00
|
|
|
alert(e);
|
2023-08-26 13:34:55 +02:00
|
|
|
show(".pkg_wiz_1");
|
|
|
|
hide(".pkg_wiz_2");
|
|
|
|
show(".pkg_repo");
|
2018-05-11 13:57:16 +02:00
|
|
|
// finish()
|
2018-12-28 15:32:11 +01:00
|
|
|
});
|
2018-05-09 18:44:58 +02:00
|
|
|
} else {
|
2023-08-26 13:34:55 +02:00
|
|
|
finish();
|
2018-05-09 18:44:58 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|