diff options
author | rubenwardy <rw@rubenwardy.com> | 2018-05-23 21:12:52 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-05-23 21:15:21 +0100 |
commit | d5342d7096e8bb568f1af7bdc9200b03537bb9fc (patch) | |
tree | b59e4d6a9b0b8c289cec58b597c9fccbba15e8cd /app/public/static/package_create.js | |
parent | 59f75bb71c361ae442febf3666838ef055849c30 (diff) | |
download | cheatdb-d5342d7096e8bb568f1af7bdc9200b03537bb9fc.tar.xz |
Move static and uploads to public dir
Diffstat (limited to 'app/public/static/package_create.js')
-rw-r--r-- | app/public/static/package_create.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/app/public/static/package_create.js b/app/public/static/package_create.js new file mode 100644 index 0000000..2b992f5 --- /dev/null +++ b/app/public/static/package_create.js @@ -0,0 +1,51 @@ +// @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() + } + + 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) { + $("#name").val(result.name || "") + $("#title").val(result.title || "") + $("#repo").val(result.repo || repoURL) + $("#issueTracker").val(result.issueTracker || "") + $("#desc").val(result.description || "") + $("#shortDesc").val(result.short_description || "") + if (result.forumId) { + $("#forums").val(result.forumId) + } + finish() + }).catch(function(e) { + alert(e) + $(".pkg_wiz_1").show() + $(".pkg_wiz_2").hide() + $(".pkg_repo").show() + // finish() + }) + } else { + finish() + } + }) +}) |