contentdb/app/public/static/package_create.js

64 lines
1.5 KiB
JavaScript
Raw Normal View History

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
$(function() {
function finish() {
$(".pkg_wiz_1").hide()
$(".pkg_wiz_2").hide()
$(".pkg_repo").show()
$(".pkg_meta").show()
}
$(".pkg_meta").hide()
$(".pkg_wiz_1").show()
2018-12-21 15:10:46 +01:00
$("#pkg_wiz_1_skip").click(finish)
$("#pkg_wiz_1_next").click(function() {
const repoURL = $("#repo").val();
2018-06-06 00:45:15 +02:00
if (repoURL.trim() != "") {
$(".pkg_wiz_1").hide()
$(".pkg_wiz_2").show()
$(".pkg_repo").hide()
function setField(id, value) {
2018-12-29 19:41:09 +01:00
if (value && value != "") {
2020-12-04 03:34:08 +01:00
const ele = $(id);
2018-05-27 23:03:54 +02:00
ele.val(value);
ele.trigger("change");
// EasyMDE doesn't always refresh the codemirror correctly
if (ele[0].easy_mde) {
setTimeout(() => {
ele[0].easy_mde.value(value);
ele[0].easy_mde.codemirror.refresh()
}, 100);
}
2018-05-27 23:03:54 +02:00
}
}
performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) {
setField("#name", result.name);
setField("#title", result.title);
setField("#repo", result.repo || repoURL);
setField("#issueTracker", result.issueTracker);
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) {
$("#type").val(result.type);
2018-06-05 20:51:01 +02:00
}
finish();
}).catch(function(e) {
alert(e);
$(".pkg_wiz_1").show();
$(".pkg_wiz_2").hide();
$(".pkg_repo").show();
// finish()
});
} else {
finish()
}
})
})