diff --git a/templates/layerindex/editlayer.html b/templates/layerindex/editlayer.html
index ba37ee9..e2b4fcb 100644
--- a/templates/layerindex/editlayer.html
+++ b/templates/layerindex/editlayer.html
@@ -168,43 +168,67 @@
};
}
- auto_web_fields = function (e) {
- repoval = $('#id_vcs_url').val()
+ function AutoWebFields(repoval) {
if( repoval[repoval.length-1] == '/' )
repoval = repoval.slice(0, repoval.length-1)
if( repoval.startsWith('git://git.openembedded.org/') ) {
reponame = repoval.replace(/^.*\//, '')
- $('#id_vcs_web_url').val('http://cgit.openembedded.org/cgit.cgi/' + reponame)
- $('#id_vcs_web_tree_base_url').val('http://cgit.openembedded.org/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%')
- $('#id_vcs_web_file_base_url').val('http://cgit.openembedded.org/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%')
+ this.vcs_web_url = 'http://cgit.openembedded.org/cgit.cgi/' + reponame
+ this.vcs_web_tree_base_url = 'http://cgit.openembedded.org/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
+ this.vcs_web_file_base_url = 'http://cgit.openembedded.org/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
}
else if( repoval.indexOf('git.yoctoproject.org/') > -1 ) {
reponame = repoval.replace(/^.*\//, '')
- $('#id_vcs_web_url').val('http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame)
- $('#id_vcs_web_tree_base_url').val('http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%')
- $('#id_vcs_web_file_base_url').val('http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%')
+ this.vcs_web_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame
+ this.vcs_web_tree_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
+ this.vcs_web_file_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
}
else if( repoval.indexOf('github.com/') > -1 ) {
reponame = repoval.replace(/^.*github.com\//, '')
reponame = reponame.replace(/.git$/, '')
- $('#id_vcs_web_url').val('http://github.com/' + reponame)
- $('#id_vcs_web_tree_base_url').val('http://github.com/' + reponame + '/tree/%branch%/')
- $('#id_vcs_web_file_base_url').val('http://github.com/' + reponame + '/blob/%branch%/')
+ this.vcs_web_url = 'http://github.com/' + reponame
+ this.vcs_web_tree_base_url = 'http://github.com/' + reponame + '/tree/%branch%/'
+ this.vcs_web_file_base_url = 'http://github.com/' + reponame + '/blob/%branch%/'
}
else if( repoval.indexOf('gitorious.org/') > -1 ) {
reponame = repoval.replace(/^.*gitorious.org\//, '')
reponame = reponame.replace(/.git$/, '')
- $('#id_vcs_web_url').val('http://gitorious.org/' + reponame)
- $('#id_vcs_web_tree_base_url').val('http://gitorious.org/' + reponame + '/trees/%branch%/')
- $('#id_vcs_web_file_base_url').val('http://gitorious.org/' + reponame + '/blobs/%branch%/')
+ this.vcs_web_url = 'http://gitorious.org/' + reponame
+ this.vcs_web_tree_base_url = 'http://gitorious.org/' + reponame + '/trees/%branch%/'
+ this.vcs_web_file_base_url = 'http://gitorious.org/' + reponame + '/blobs/%branch%/'
}
else if( repoval.indexOf('bitbucket.org/') > -1 ) {
reponame = repoval.replace(/^.*bitbucket.org\//, '')
reponame = reponame.replace(/.git$/, '')
- $('#id_vcs_web_url').val('http://bitbucket.org/' + reponame)
- $('#id_vcs_web_tree_base_url').val('http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%')
- $('#id_vcs_web_file_base_url').val('http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%')
+ this.vcs_web_url = 'http://bitbucket.org/' + reponame
+ this.vcs_web_tree_base_url = 'http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%'
+ this.vcs_web_file_base_url = 'http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%'
+ }
+ else {
+ this.vcs_web_url = ''
+ this.vcs_web_tree_base_url = ''
+ this.vcs_web_file_base_url = ''
+ }
+ }
+
+ auto_web_fields = function (e) {
+ repoval = $('#id_vcs_url').val()
+ awf = new AutoWebFields(repoval)
+ if (awf.vcs_web_url) {
+ if (e) {
+ $('#id_vcs_web_url').val(awf.vcs_web_url)
+ $('#id_vcs_web_tree_base_url').val(awf.vcs_web_tree_base_url)
+ $('#id_vcs_web_file_base_url').val(awf.vcs_web_file_base_url)
+ }
+ $('#id_vcs_web_url').prop('disabled', true);
+ $('#id_vcs_web_tree_base_url').prop('disabled', true);
+ $('#id_vcs_web_file_base_url').prop('disabled', true);
+ }
+ else {
+ $('#id_vcs_web_url').prop('disabled', false);
+ $('#id_vcs_web_tree_base_url').prop('disabled', false);
+ $('#id_vcs_web_file_base_url').prop('disabled', false);
}
};
@@ -256,6 +280,7 @@
$('#addanothermaintainer').click(expand_maintainer)
$('#id_vcs_url').change(auto_web_fields)
+ auto_web_fields(null)
firstfield = $("#edit_layer_form input:text, #edit_layer_form textarea").first();
if( ! firstfield.val() )