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
|
|
|
|
|
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-06-05 01:10:47 +02:00
|
|
|
// try {
|
|
|
|
// return URI(url).hostname() == "github.com"
|
|
|
|
// } catch(e) {
|
|
|
|
// return false
|
|
|
|
// }
|
|
|
|
return true
|
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-27 23:03:54 +02:00
|
|
|
function setSpecial(id, value) {
|
|
|
|
if (value != "") {
|
|
|
|
var ele = $(id);
|
|
|
|
ele.val(value);
|
|
|
|
ele.trigger("change")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-11 13:57:16 +02:00
|
|
|
performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) {
|
2018-05-11 14:25:42 +02:00
|
|
|
$("#name").val(result.name || "")
|
2018-06-05 01:10:47 +02:00
|
|
|
setSpecial("#provides_str", result.provides || "")
|
2018-05-11 14:25:42 +02:00
|
|
|
$("#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-27 23:03:54 +02:00
|
|
|
setSpecial("#harddep_str", result.depends || "")
|
|
|
|
setSpecial("#softdep_str", result.optional_depends || "")
|
|
|
|
$("#shortDesc").val(result.short_description || "")
|
2018-05-12 19:50:09 +02:00
|
|
|
if (result.forumId) {
|
|
|
|
$("#forums").val(result.forumId)
|
|
|
|
}
|
2018-06-05 20:51:01 +02:00
|
|
|
|
|
|
|
if (result.type && result.type.length > 2) {
|
|
|
|
$("#type").val(result.type);
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|