diff --git a/plugins/mezuro/public/javascripts/validations.js b/plugins/mezuro/public/javascripts/validations.js
index c298a8a..142f896 100644
--- a/plugins/mezuro/public/javascripts/validations.js
+++ b/plugins/mezuro/public/javascripts/validations.js
@@ -1,64 +1,107 @@
jQuery(function (){
jQuery('#range_submit').live("click", validate_new_range_configuration);
jQuery('#metric_configuration_submit').live("click", validate_metric_configuration);
+ jQuery('#repository_submit').live("click", validate_new_repository);
});
function validate_code(code){
return true;
}
-function validate_metric_configuration(){
- var code = jQuery('#metric_configuration_code').val();
- if (is_null(code))
- {
- alert("Code must be filled out");
- return false;
- }
- return true;
+
+function validate_new_repository() {
+ if (allRequiredFieldsAreFilled()))
+ return addressAndTypeMatch();
+ return false;
}
-function is_null(value){
- if(value == "" || value == null){
- return true;
- }
+function allRequiredFieldsAreFilled() {
+ var name = jQuery('#repository_name').val();
+ var address = jQuery('#repository_address').val();
+
+ if (is_null(name) || is_null(address)) {
+ alert("Please fill all fields marked with (*).");
return false;
+ }
+ return true;
}
-function IsNotNumeric(value){
- if(value.match(/[0-9]*\.?[0-9]+/))
- {
- return false;
- }
+function addressAndTypeMatch() {
+ var type = jQuery('#repository_type').val();
+ var address = jQuery('#repository_address').val();
+
+ switch (type) {
+ case "BAZAAR": return matchBAZAAR(address);
+ case "CVS": return matchCVS(address);
+ case "GIT": return matchGIT(address);
+ case "MERCURIAL": return matchMercurial(address);
+ case "REMOTE_TARBALL": return matchRemoteTarball(address);
+ case "REMOTE_ZIP": return matchRemoteZIP(address);
+ case "SUBVERSION": return matchSubversion(address);
+ }
+}
+
+function matchGIT(address) {
+ if (address.match(/^[ http(s)?:\/\/git(hub)?\. | git:\/\/git(hub.com | orious.org)\/ | git@git(hub.com | orious.org):].+.git$/))
+ return true;
+ alert("Adress does not match type GIT chosen.");
+ return false;
+}
+
+function matchSubversion(address) {
+ if (address.match(/^http(s)?:\/\/.+\/svn.+$/))
return true;
+ alert("Adress does not match type Subversion chosen.");
+ return false;
}
-function IsNotInfinite(value){
- if(value.match(/INF/)){
+function validate_metric_configuration() {
+ var code = jQuery('#metric_configuration_code').val();
+ if (is_null(code)) {
+ alert("Code must be filled out");
return false;
- }
+ }
+ return true;
+}
+
+function is_null(value) {
+ if (value == "" || value == null) {
return true;
+ }
+ return false;
}
-function validate_new_range_configuration(event){
- var beginning = jQuery("#range_beginning").val();
- var end = jQuery("#range_end").val();
+function IsNotNumeric(value) {
+ if (value.match(/[0-9]*\.?[0-9]+/)) {
+ return false;
+ }
+ return true;
+}
- if (is_null(beginning) || is_null(end))
- {
- alert("Please fill all fields marked with (*).");
- return false;
- }
- if ( (IsNotNumeric(beginning) && IsNotInfinite(beginning)) || (IsNotNumeric(end) && IsNotInfinite(end)))
- {
- alert("Beginning, End and Grade must be numeric values.");
+function IsNotInfinite(value) {
+ if (value.match(/INF/)) {
+ return false;
+ }
+ return true;
+}
+
+function validate_new_range_configuration(event) {
+ var beginning = jQuery("#range_beginning").val();
+ var end = jQuery("#range_end").val();
+
+ if (is_null(beginning) || is_null(end)) {
+ alert("Please fill all fields marked with (*).");
+ return false;
+ }
+ if ( (IsNotNumeric(beginning) && IsNotInfinite(beginning)) || (IsNotNumeric(end) && IsNotInfinite(end))) {
+ alert("Beginning, End and Grade must be numeric values.");
+ return false;
+ }
+ if (parseInt(beginning) > parseInt(end)) {
+ if (IsNotInfinite(beginning) && IsNotInfinite(end)) {
+ alert("End must be greater than Beginning.");
return false;
- }
- if (parseInt(beginning) > parseInt(end))
- {
- if(IsNotInfinite(beginning) && IsNotInfinite(end)){
- alert("End must be greater than Beginning.");
- return false;
- }
- }
- return true;
+ }
+ }
+ return true;
}
diff --git a/plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb b/plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
index 2872e82..6064eea 100644
--- a/plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
+++ b/plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
@@ -1 +1,3 @@
+
+
<%= render :partial => "form" %>
diff --git a/plugins/mezuro/views/mezuro_plugin_repository/new.html.erb b/plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
index 2872e82..6064eea 100644
--- a/plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
+++ b/plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
@@ -1 +1,3 @@
+
+
<%= render :partial => "form" %>
--
libgit2 0.21.2