blob: 6568550589ef652a77df352978a84bcfc97be752 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
$(function() {
function finish() {
$(".pkg_wiz_1").hide()
$(".pkg_wiz_2").hide()
$(".pkg_repo").show()
$(".pkg_meta").show()
}
function repoIsSupported(url) {
try {
return URI(url).hostname() == "github.com"
} catch(e) {
return false
}
}
$(".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()
performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) {
console.log(result)
$("#name").val(result.name || "")
$("#title").val(result.title || "")
const desc = result.description || ""
if (desc.length > 0) {
const idx = desc.indexOf(".")
$("#shortDesc").val((idx < 5 || idx > 100) ? desc.substring(0, Math.min(desc.length, 100)) : desc.substring(0, idx))
$("#desc").val(desc)
}
finish()
}).catch(function(e) {
alert(e)
$(".pkg_wiz_1").show()
$(".pkg_wiz_2").hide()
$(".pkg_repo").show()
// finish()
})
} else {
finish()
}
})
})
|