2018-05-09 18:44:58 +02:00
|
|
|
$(function() {
|
|
|
|
function finish() {
|
|
|
|
$(".pkg_wiz_1").hide()
|
|
|
|
$(".pkg_wiz_2").hide()
|
|
|
|
$(".pkg_repo").show()
|
|
|
|
$(".pkg_meta").show()
|
|
|
|
}
|
|
|
|
|
2018-05-11 13:57:16 +02:00
|
|
|
function repoIsSupported(url) {
|
2018-05-09 18:44:58 +02:00
|
|
|
try {
|
2018-05-11 13:57:16 +02:00
|
|
|
return URI(url).hostname() == "github.com"
|
2018-05-09 18:44:58 +02:00
|
|
|
} catch(e) {
|
2018-05-11 13:57:16 +02:00
|
|
|
return false
|
2018-05-09 18:44:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(".pkg_meta").hide()
|
|
|
|
$(".pkg_wiz_1").show()
|
|
|
|
$("#pkg_wiz_1_next").click(function() {
|
|
|
|
const repoURL = $("#repo").val();
|
|
|
|
if (repoIsSupported(repoURL)) {
|
|
|
|
$(".pkg_wiz_1").hide()
|
|
|
|
$(".pkg_wiz_2").show()
|
|
|
|
$(".pkg_repo").hide()
|
|
|
|
|
2018-05-11 13:57:16 +02:00
|
|
|
performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) {
|
|
|
|
console.log(result)
|
2018-05-11 14:25:42 +02:00
|
|
|
$("#name").val(result.name || "")
|
|
|
|
$("#title").val(result.title || "")
|
2018-05-12 18:28:04 +02:00
|
|
|
$("#repo").val(result.repo || repoURL)
|
|
|
|
$("#issueTracker").val(result.issueTracker || "")
|
|
|
|
$("#desc").val(result.description || "")
|
|
|
|
$("#shortDesc").val(result.short_description || "")
|
2018-05-11 13:57:16 +02:00
|
|
|
finish()
|
|
|
|
}).catch(function(e) {
|
|
|
|
alert(e)
|
2018-05-09 18:44:58 +02:00
|
|
|
$(".pkg_wiz_1").show()
|
|
|
|
$(".pkg_wiz_2").hide()
|
|
|
|
$(".pkg_repo").show()
|
2018-05-11 13:57:16 +02:00
|
|
|
// finish()
|
2018-05-09 18:44:58 +02:00
|
|
|
})
|
|
|
|
} else {
|
|
|
|
finish()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|