Commits

Anonymous committed e0e6430

Final Changes

Comments (0)

Files changed (20)

Source/WebClient/Web.Azure/Profiles/dataupDevelopment.azurePubxml

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <AzureCredentials>Pay-As-You-Go</AzureCredentials>
+    <AzureHostedServiceName>dataupclientdev</AzureHostedServiceName>
+    <AzureHostedServiceLabel>dataupclientdev</AzureHostedServiceLabel>
+    <AzureSlot>Production</AzureSlot>
+    <AzureEnableIntelliTrace>False</AzureEnableIntelliTrace>
+    <AzureEnableProfiling>False</AzureEnableProfiling>
+    <AzureEnableWebDeploy>False</AzureEnableWebDeploy>
+    <AzureStorageAccountName>dataupdev</AzureStorageAccountName>
+    <AzureStorageAccountLabel>dataupdev</AzureStorageAccountLabel>
+    <AzureDeploymentLabel>Web.Client</AzureDeploymentLabel>
+    <AzureSolutionConfiguration>Release</AzureSolutionConfiguration>
+    <AzureServiceConfiguration>Local</AzureServiceConfiguration>
+    <AzureAppendTimestampToDeploymentLabel>True</AzureAppendTimestampToDeploymentLabel>
+    <AzureEnableRemoteDesktop>False</AzureEnableRemoteDesktop>
+    <AzureDeploymentReplacementMethod>AutomaticUpgrade</AzureDeploymentReplacementMethod>
+    <AzureDeleteDeploymentOnFailure>False</AzureDeleteDeploymentOnFailure>
+    <AzureFallbackToDeleteAndRecreateIfUpgradeFails>False</AzureFallbackToDeleteAndRecreateIfUpgradeFails>
+  </PropertyGroup>
+</Project>

Source/WebClient/Web.Azure/Profiles/dataupProduction-Staging.azurePubxml

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <AzureCredentials>Pay-As-You-Go</AzureCredentials>
+    <AzureHostedServiceName>dataup</AzureHostedServiceName>
+    <AzureHostedServiceLabel>dataup</AzureHostedServiceLabel>
+    <AzureSlot>Staging</AzureSlot>
+    <AzureEnableIntelliTrace>False</AzureEnableIntelliTrace>
+    <AzureEnableProfiling>False</AzureEnableProfiling>
+    <AzureEnableWebDeploy>False</AzureEnableWebDeploy>
+    <AzureStorageAccountName>datatupstorage</AzureStorageAccountName>
+    <AzureStorageAccountLabel>datatupstorage</AzureStorageAccountLabel>
+    <AzureDeploymentLabel>Web.Client</AzureDeploymentLabel>
+    <AzureSolutionConfiguration>Release</AzureSolutionConfiguration>
+    <AzureServiceConfiguration>Cloud</AzureServiceConfiguration>
+    <AzureAppendTimestampToDeploymentLabel>True</AzureAppendTimestampToDeploymentLabel>
+    <AzureEnableRemoteDesktop>False</AzureEnableRemoteDesktop>
+    <AzureDeploymentReplacementMethod>AutomaticUpgrade</AzureDeploymentReplacementMethod>
+    <AzureDeleteDeploymentOnFailure>False</AzureDeleteDeploymentOnFailure>
+    <AzureFallbackToDeleteAndRecreateIfUpgradeFails>False</AzureFallbackToDeleteAndRecreateIfUpgradeFails>
+  </PropertyGroup>
+</Project>

Source/WebClient/Web.Azure/ServiceDefinition.build.csdef

   **********************************************************************************************
 -->
 <ServiceDefinition name="Web.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-05.1.7">
-  <WebRole name="Web.Client" vmsize="Medium">
+  <WebRole name="Web.Client" vmsize="Large">
     <Sites>
       <Site name="Web">
         <Bindings>

Source/WebClient/Web.Azure/ServiceDefinition.csdef

 <?xml version="1.0" encoding="utf-8"?>
 <ServiceDefinition name="Web.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-05.1.7">
-  <WebRole name="Web.Client" vmsize="Medium">
+  <WebRole name="Web.Client" vmsize="Large">
     <Sites>
       <Site name="Web">
         <Bindings>

Source/WebClient/Web.Azure/Web.Azure.ccproj

     <Folder Include="Profiles" />
   </ItemGroup>
   <ItemGroup>
-    <PublishProfile Include="Profiles\dcxlstagingProduction.azurePubxml" />
-    <PublishProfile Include="Profiles\dcxlstagingDevelopment.azurePubxml" />
-    <PublishProfile Include="Profiles\datauptest.azurePubxml" />
+    <PublishProfile Include="Profiles\dataupDevelopment.azurePubxml" />
+    <PublishProfile Include="Profiles\dataupProduction-Staging.azurePubxml" />
   </ItemGroup>
   <!-- Import the target files for this project template -->
   <PropertyGroup>

Source/WebClient/Web.Client/Scripts/DataUpv3.js

-$(function () {
-    dataUp.initialize();
-    $("#publishFile, #addContent").bind("change", function () {
-        var _this = this;
-        dataUp.constants.submittedFileName = $(this).val().substr(($(this).val().lastIndexOf("\\") < 0) ? 0 : $(this).val().lastIndexOf("\\") + 1);
-        var fileExtension = $(this).val().substr($(this).val().lastIndexOf(".")).toLowerCase();
-        //if (dataUp.constants.allowedFileFormat.indexOf(fileExtension) >= 0) {
-        if(fileExtension==".xlsx" || fileExtension==".csv")
-        {
-            if ($(this).attr("id") === "addContent") {
-                $(this).parents("form").attr("action", $(this).parents("form").attr("action").replace("UploadedPostedFile", "AddPostedFile"));
-            }
-            dataUp.showBusy();
-            $.post("/Document/CheckDuplicate", { fileNames: dataUp.constants.submittedFileName }, function (status) {
-                dataUp.hideBusy();
-                if (status.DuplicateFileNames === "") {
-                    dataUp.showBusy();
-                    $(_this).parents("form").submit();
-                }
-                else if (confirm("The file already exists. Do you want to overwrite?")) {
-                    dataUp.showBusy();
-                    $(_this).parents("form").submit();
-                }
-            });
-        }
-        else {
-            alert("Only .xlsx and .csv files can be uploaded");
-        }
-    });
-
-    $("#signIn").click(function () {
-        $("#SignInpopup").show();
-    });
-
-    $(".closeCircle").click(function () {
-        $("#SignInpopup").hide();
-    });
-
-    $("#ieUploadFrame").bind("load", function () {
-        if ($("body").hasClass("busy")) {
-            dataUp.reloadList(1, dataUp.constants.submittedFileName);
-        }
-    });
-
-    $(".errorContainer li").bind("click", function () {
-        $(".errorContainer li").removeClass("selected");
-        $(this).addClass("selected");
-        if ($(this).attr("sheetName") === "All") {
-            $(".errorContainer table tbody tr").show();
-        }
-        else {
-            $(".errorContainer table tbody tr").hide();
-            $(".errorContainer table tbody tr[sheetName='" + $(this).attr("sheetName") + "']").show();
-        }
-    });
-
-    $("fieldset legend").bind("click", function () {
-        if ($(this).text().indexOf("-") >= 0) {
-            $(this).text($(this).text().replace("-", "+"));
-            $(this).siblings("div").hide();
-        }
-        else {
-            $(this).text($(this).text().replace("+", "-"));
-            $(this).siblings("div").show();
-        }
-    });
-
-    // Binds the click event on the delete icon beside each document
-    $(".deleteLink").live("click", function () {
-        if (confirm($(this).attr("errormessage").replace("\\n", "\n"))) {
-            dataUp.deleteDocument(this);
-        }
-    });
-
-    $("div#divMultipleFileUploadPopup .btnHolder input.cancel").bind("click", function () {
-        $("div#divMultipleFileUploadPopup").hide();
-    });
-
-    $("div#divMultipleFileUploadPopup .btnHolder input.upload").bind("click", function () {
-        if ($("div#divMultipleFileUploadPopup .uploadedDocument").hasClass("remove") && dataUp.constants.transferedFiles !== "") {
-            $("#divMultipleFileUploadPopup .btnHolder input").attr("disabled", "disabled");
-            $("div#divMultipleFileUploadPopup .uploadedDocument").removeClass("remove");
-            var files = dataUp.constants.transferedFiles;
-            var count = files.length;
-            var validFileCount = 0;
-            for (var fileIndex = 0; fileIndex < count; fileIndex++) {
-                var file = files[fileIndex];
-                var fileExtension = file.name.substr(file.name.lastIndexOf(".")).toLowerCase();
-                if (dataUp.constants.allowedFileFormat.indexOf(fileExtension) >= 0 && $("div#divMultipleFileUploadPopup .uploadedDocument label span:contains('" + file.name + "')").length > 0) {
-                    handleFiles(file);
-                    validFileCount++;
-                }
-            }
-        }
-
-        dataUp.constants.transferedFiles = "";
-        // $("#divMultipleFileUploadPopup .btnHolder input.cancel").removeAttr("disabled");
-        $("div#divMultipleFileUploadPopup").hide();
-        dataUp.reloadList(validFileCount, file.name);
-    });
-
-    $("div#divMultipleFileUploadPopup .uploadedDocument.remove a").live("click", function () {
-        $(this).parent("div.uploadedDocument").remove();
-        $("div#divMultipleFileUploadPopup .btnHolder input.upload").attr("disabled", "disabled");
-    });
-
-    // Binds the click event on the delete icon beside each document
-    $(".getIdentifier").bind("click", function () {
-        dataUp.getIdentifier(this);
-    });
-
-    $("a[helpcontent]").bind("mouseover", function () {
-        $("#divHelpContent").text($(this).attr("helpcontent")).removeClass("hide").css("left", $(this).position().left + 30).css("top", $(this).position().top);
-    });
-
-    $("a[helpcontent]").bind("mouseout", function () {
-        $("#divHelpContent").addClass("hide");
-    });
-
-    $("#updateCitation").bind("click", function () {
-        dataUp.updateCitation(this);
-        var publisher = $("#citationPublisher").val();
-        var publicationYear = $("#citationPublicationYear").val();
-        var title = $("#citationTitle").val();
-        var version = $("#Citation_Version").val();
-        var identifier = $("#hiddenGetIdentifier").val();
-
-        $("#txtCitation").val(publisher + "(" + publicationYear + "): " + title + ". " + version + ". " + publisher + ". " + identifier);
-        $("#hiddenCitation").val(publisher + "(" + publicationYear + "): " + title + ". " + version + ". " + publisher + ". " + identifier);
-       $("#updateCitation").val("Generate Citation");
-    });
-
-    $(".btnHolder .btnDetailSave, .btnHolder .btnDetailPost").bind("click", function () {
-        var formReference = $("#saveDocumentDetail");
-        if (dataUp.validateMetadata()) {
-            if (($(this).hasClass("btnDetailPost") && dataUp.validateRepositoryDetails("docMetadataItmHolder"))) {
-                dataUp.showBusy();
-                var data = formReference.serializeArray(); 
-                data.push({name: 'name', value: $("#postRepositories option:selected").text()}); 
-
-                $.ajax({
-                    url: (($(this).hasClass("btnDetailPost")) ? formReference.attr("postUrl") : formReference.attr("action")),
-                    data: data,
-                    type: "post",
-                    success: function (json) {
-                        dataUp.hideBusy();
-                        dataUp.hideInfoHeader();
-                        if ($(this).hasClass("btnDetailPost")) {
-                            dataUp.persistAgreement($("#postRepositories option:selected").text(), $("#postUsername").val());
-                        }
-                        if (json.Type === "Post") {
-                            if (json.Status === true) {
-                                // alert(json.Message);
-                                $("#filePostSuccessPopup .identifier").text(json.Message);
-                                $("#filePostSuccessPopup").show();
-                            }
-                            else {
-                                alert(json.Message);
-                            }
-                        }
-                        else {
-                            alert(json.Message);
-                        }
-                    },
-                    error: function (req,timeout,errorMessage) {
-                        dataUp.hideBusy();
-                        alert(timeout + " :" + errorMessage);
-                    }
-                });
-            }
-        }
-    });
-
-    $(".btnDetailSave").bind("click", function () {
-        var formReference = $("#saveDocumentDetail");
-        if (($("#errorsId div").hasClass("active")) || dataUp.validateMetadata())
-        {
-            dataUp.showBusy();
-            $.ajax({
-                ifModified: false, 
-                cache: false, 
-                url: "/Document/SaveDetail",
-                data: formReference.serialize(),
-                type: "post",
-                success: function (json) {
-                    dataUp.hideBusy();
-                    dataUp.hideInfoHeader();
-                    if (json.Type === "Save") {
-                        if (json.Status === true) {
-                            //Update html
-                            $("#parameterDataPartial").html(json.PartialViewHtml);                           
-                            $('.savedSuccessfullydiv').html('');
-                            $('.savedSuccessfullydiv').html(json.Message);
-                            $("#successfullySavedPopup").show();                            
-                        }
-                        else {
-                            alert(json.Message);
-                        }
-                    }
-                    else {
-                        alert(json.Message);
-                    }
-                },
-                error: function (req,timeout,errorMessage) {
-                    dataUp.hideBusy();
-                    alert(timeout + " :" + errorMessage);
-                }
-            });
-        }
-    });
-
-    $(".popupButtonContainer").bind("click", function () {
-        location.href = "/document/Index";
-    });
-
-    $(".RemoveButtonContainer").click(function () {
-        $('#RemovedPopup').hide();
-
-    });
-    $(".saveButtonContainer").click(function () {
-        $('#successfullySavedPopup').hide();
-
-    });
-
-    $("a.closeBtn").bind("click", function () {
-        $(this).parent().parent("div").hide();
-    });
-
-    $("input[type='text']").bind("change", function () {
-        dataUp.showInfoHeader();
-    });
-
-    // If the header checkbox is checked then check all the child checkboxes otherwise uncheck all the checkboxes.
-    $(".gridHeader input[type='checkbox']").live("change", function () {
-        var sheetId = $(".documentSubTab a.active").attr("sheetId");
-        if ($(this).attr("checked")) {
-            $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled").attr("checked", "checked");
-        }
-        else {
-            $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled").removeAttr("checked");
-        }
-    });
-
-
-    // If the header checkbox is checked then check all the child checkboxes otherwise uncheck all the checkboxes.
-    $(".documentListScrollStp input[type='checkbox']:enabled").live("change", function () {
-        var sheetId = $(this).parent("td").parent("tr").attr("id");
-
-        var selectedCheckBoxed = $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled:checked");
-        if (selectedCheckBoxed.length === $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled").length) {
-            $(".gridHeader input[type='checkbox']").attr("checked", "checked");
-        }
-        else {
-            $(".gridHeader input[type='checkbox']").removeAttr("checked");
-        }
-    });
-
-    $(".documentErorTableContainerTD1 input[type='checkbox']").live("click", function () {    
-  
-        var sheetId = $(this).parent("td").parent("tr").attr("id");
-        if ($("tr[id='" + sheetId + "'] :input:checked").length > 0) {
-                $('.docRemovBtn').removeClass('disabled');
-            } else {
-                $('.docRemovBtn').addClass('disabled');
-            }
-  });
-
-
-    $('.docRemovBtn').live("click", function () {
-        if($(this).is(".disabled"))
-        {
-           return;
-        }
-        var sheetName = $(".documentSubTab a.active").attr("sheetName");
-        var sheetId = $(".documentSubTab a.active").attr("sheetId");
-
-        var selectedId = "";
-        
-        $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled:checked").each(function (index, element) {
-            selectedId = selectedId + $(element).attr("errorAddress") +"+"+$(element).next('input[type=hidden]').val() +"-";
-            $(element).parents("tr:first").remove();
-        });
-
-        var list = $("tr[id='" + sheetId + "'] input[type='checkbox']");
-        if(list.length == 0)
-        {
-             var tab = $("div#st_horizontal a[sheetId='"+sheetId+"']").attr("sheetName");
-             $("div#st_horizontal a[sheetId='"+sheetId+"']").text(tab+"(0)");
-             $(".documentErorTableContainer .docErrorTable").append("<tr id = '"+ sheetId +"' ><td><div class='NoErrorbackground'>No Item found</div></td></tr>");
-//             $('.docRemovBtn').addClass('disabled');
-        }
-        else{
-            var tab = $("div#st_horizontal a[sheetId='"+sheetId+"']").attr("sheetName");
-             $("div#st_horizontal a[sheetId='"+sheetId+"']").text(tab+"("+(list.length)+")");
-//             if(($("tr[id='" + sheetId + "'] input[type='checkbox']:enabled")).length == 0)
-//             {
-//                $('.docRemovBtn').addClass('disabled');
-//             }
-        }
-         $('.docRemovBtn').addClass('disabled');
-        if (selectedId !== "") {
-            var funreturndata = null;
-            $.post($(this).attr("actionUrl"), { ids: selectedId, sheetName: sheetName }, function (returnHtml) {
-               $('div#st_horizontal').slideTabs({classTabActive:'active'});
-            });
-        }
-    });
-
-    $('.btnDemo').live("click", function() {
-      window.open('/Demo/Index', '_blank' );  
-  });
-     
-    $(document).keyup(function (e) { 
-        if (e.keyCode == 27) { 
-            $("#SignInpopup").hide();
-            if($('.dropdwn').is(':visible')){
-                $(".MyTestForm").click();
-            }
-        } 
-    });
-
-    $(".rangeTextbox").blur( function () {
-        var element = $(this).siblings("span");
-
-        if($(this).val() !== "" && $(element).is(":visible"))
-        {
-            var inputValue = parseFloat($(this).val());
-            var minAllowedValue = parseFloat($(this).attr("minAllowedValue"));
-            var maxAllowedValue = parseFloat($(this).attr("maxAllowedValue"));
-            if(isNaN(inputValue) || (inputValue < minAllowedValue || inputValue > maxAllowedValue))
-            {
-                $(element).text($(this).attr("rangeErrorMessage")).removeClass("field-validation-valid").addClass("field-validation-error");
-                isValid = false;
-            }
-            else
-            {
-                $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
-            }
-        }
-        else
-        {
-            $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
-        }
-    });
-});
-
- function showMetadataRequired(isParameterMetaData)
-    {
-        if(isParameterMetaData)
-        {
-            $('.metadataDefinition').css("display", "none"); 
-            $('.paramtrHolder').css("display", "block"); 
-            $('.columnDefinitionAnchor').addClass('active'); 
-            $('.dataDefinitionAnchor').removeClass('active'); 
-        }
-        else
-        {
-            $('.metadataDefinition').css("display", "block"); 
-            $('.paramtrHolder').css("display", "none"); 
-            $('.dataDefinitionAnchor').addClass('active'); 
-            $('.columnDefinitionAnchor').removeClass('active'); 
-        }
-    }
-
-var dataUp = {
-    constants: {
-        dropAndDragAction: "/document/UploadDropedFile",
-        allowedFileFormat: ".xlsx, .csv",
-        submittedFileName: "",
-        transferedFiles: ""
-    },
-
-    showInfoHeader: function () {
-        $(".docfileHeader .info").show();
-    },
-
-    hideInfoHeader: function () {
-        $(".docfileHeader .info").hide();
-    },
-
-    initialize: function () {
-        if (document.documentMode) {
-            $("body").addClass("ie");
-        }
-    },
-
-    // This displays the load indicator
-    showBusy: function () {
-        $("body").addClass("busy");
-    },
-
-    // This displays the load indicator
-    hideBusy: function () {
-        $("body").removeClass("busy");
-    },
-
-    // It deletes the entity (content/community)
-    deleteDocument: function (reference) {
-        $("body").addClass("busy");
-        var formReference = $(reference).parent("form");
-        var action = formReference.attr("action");
-        var antiForgeryToken = formReference.find("[name='__RequestVerificationToken']").val();
-        $.post(action, { __RequestVerificationToken: antiForgeryToken }, function (returnedList) {
-            $("#documentList").html(returnedList);
-            $("body").removeClass("busy");
-        });
-    },
-
-    getIdentifier: function (reference) {
-        dataUp.showInfoHeader();
-        var formReference = $(reference).parents("form");
-        var action = formReference.attr("action");
-        var repositoyName = $("#repositories option:selected").text();
-        var whoValue = $("#citationPublisher").val();
-        var whenValue = $("#citationPublicationYear").val();
-        var whatValue = $("#citationTitle").val();
-        var usernameValue = $("#repositoryUsername").val();
-        var passwordValue = $("#repositoryPassword").val();
-
-        var antiForgeryToken = formReference.find("[name='__RequestVerificationToken']").val();
-        if (dataUp.validateRepositoryDetails("repositoryPopup")) {
-            $("body").addClass("busy");
-            $.ajax({
-                url: action,
-                data: { __RequestVerificationToken: antiForgeryToken, Who: whoValue, What: whatValue, When: whenValue, UserName: usernameValue, Password: passwordValue, RepositoryName: repositoyName },
-                type: "post",
-                success: function (returnedList) {
-                    if (returnedList != "") {
-                        var result = returnedList.split("|");
-                        if(result[0] === "true")
-                        {
-                            $("#txtGetIdentifier").val(result[1]);
-                            $("#hiddenGetIdentifier").val(result[1]);
-                            $('#loginRepositoryPopup').hide();
-                            $("#getusername").val(usernameValue);
-                            dataUp.persistAgreement(repositoyName, usernameValue);
-                            $("body").removeClass("busy");
-                            $('.getIdentifierButton').attr('disabled', 'disabled');
-                            $('.getIdentifierHelp').css("display","none");
-                        }
-                        else{
-                            $("body").removeClass("busy");
-                            $('#loginRepositoryPopup').show();
-                            $('#usercredentialswrong').text('');
-                            $('#usercredentialswrong').text(result[1]);
-                            $('#usercredentialswrong').show();
-                       
-                            $(".repositoryPopup .btnHolder .getIdentifier").attr('disabled', 'disabled');
-                            $(".repositoryPopup .chkAgreement").removeAttr('checked');
-                            $("#repositoryPassword").val('');
-                        }
-                    }
-                    else {
-                        $("body").removeClass("busy");
-                        $('#loginRepositoryPopup').show();
-                        $('#usercredentialswrong').text(result[1]);
-                        $('#usercredentialswrong').show();
-                        $(".repositoryPopup .btnHolder .getIdentifier").attr('disabled', 'disabled');
-                        $(".repositoryPopup .chkAgreement").removeAttr('checked');
-                        $("#repositoryPassword").val('');
-                    }
-                },
-                error: function (req,timeout,errorMessage) {
-                    dataUp.hideBusy();
-                    alert(timeout + " :" + errorMessage);
-                }
-            });
-         }
-    },
-
-    // It deletes the entity (content/community)
-    updateCitation: function (reference) {
-        dataUp.showInfoHeader();
-        var publisher = $("#citationPublisher").val();
-        var publicationYear = $("#citationPublicationYear").val();
-        var title = $("#citationTitle").val();
-        var version = $("#Citation_Version").val();
-        var identifier = $("#hiddenGetIdentifier").val();
-
-        $("#txtCitation").val(publisher + "(" + publicationYear + "):" + title + ". " + version + ". " + publisher + ". " + identifier);
-        $("#hiddenCitation").val(publisher + "(" + publicationYear + "):" + title + ". " + version + ". " + publisher + ". " + identifier);
-        $("#updateCitation").val("Generate Citation");
-    },
-
-    reloadList: function (fileCount, filename) {
-        $.post("/document/List", function (returnedList) {
-            $("#documentList").html(returnedList);
-            $("body").removeClass("busy");
-
-            if (fileCount === 1) {
-                $(".docListTableContent tbody tr td[title='" + filename + "']").parent().find(".postingBtn")[0].click();
-            }
-        });
-    },
-
-    //Email validation
-    validateEmail: function () {
-
-        var isvalid = true;
-        var isEmailvalid = true;
-        var isContractEmailvalid = true;
-        var EmailValue = $('.docMetadataItmHolder input[value="Creator: Email"]').siblings("input").val();
-        var DataContactPersonEmailValue = $('.docMetadataItmHolder input[value="Data Contact Person: Email"]').siblings("input").val();
-        var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
-        if (EmailValue != "") {
-            if (!emailReg.test(EmailValue)) {
-                isEmailvalid = false;
-            }
-            else {
-                isEmailvalid = true;
-            }
-        }
-
-        if (DataContactPersonEmailValue != "") {
-            if (!emailReg.test(DataContactPersonEmailValue)) {
-                isContractEmailvalid = false;
-            }
-            else {
-                isContractEmailvalid = true;
-            }
-        }
-        if (isEmailvalid == false || isContractEmailvalid == false) {
-            isvalid = false;
-            $('#requiredemailformate').show();
-        }
-        if (isvalid == true) {
-            $('#requiredemailformate').hide();
-        }
-        return isvalid;
-    },
-
-    //Phone validation
-    validatePhoneNumber: function () {
-        var isvalid = true;
-        var isPhonevalid = true;
-        var isContractvalid = true;
-        var phoneValue = $('.docMetadataItmHolder input[value="Creator: Phone"]').siblings("input").val();
-        var DataContactPersonPhoneValue = $('.docMetadataItmHolder input[value="Data Contact Person: Phone"]').siblings("input").val();
-        // var phoneReg = /^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$/;      
-        var phoneReg = /^[0-9,+()-]+$/;
-        if (phoneValue != "") {
-            if (!phoneReg.test(phoneValue)) {
-                isPhonevalid = false;
-            }
-            else {
-                isPhonevalid = true;
-            }
-        }
-
-
-        if (DataContactPersonPhoneValue != "") {
-            if (!phoneReg.test(DataContactPersonPhoneValue)) {
-                isContractvalid = false;
-            }
-            else {
-                isContractvalid = true;
-            }
-        }
-        if (isPhonevalid == false || isContractvalid == false) {
-            isvalid = false;
-            $('#requiredPhoneformate').show();
-            showMetadataRequired(false);
-        }
-        if (isvalid == true) {
-            $('#requiredPhoneformate').hide();
-        }
-        return isvalid;
-    },
-
-    //Date validation
-    validateDateFormat: function () 
-    {
-        var isvalid = true;
-        var isBeginDatevalid = true;
-        var isEndDatevalid = true; 
-        var isTodayDatevalid = true;      
-        var beginningDateValue = $('.docMetadataItmHolder input[value="Temporal coverage: Beginning date"]').siblings("input").val();
-        var endDateValue = $('.docMetadataItmHolder input[value="Temporal coverage: Ending date"]').siblings("input").val();
-        var TodayDateValue =  $('.docMetadataItmHolder input[value="Today\'s date"]').siblings("input").val();
-
-          //yyyy-mm-dd format from between 1900-01-01 and 2099-12-31     
-        var dateReg = /^(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/;
-        if (beginningDateValue != "") {      
-            
-            if (!dateReg.test(beginningDateValue))
-            {
-            isBeginDatevalid = false;
-            $('#requiredDateformate').show();
-            showMetadataRequired(false);
-            }
-            else {isBeginDatevalid = true; $('#requiredDateformate').hide();}
-        }
-        if (endDateValue != "")
-        {   
-            if (!dateReg.test(endDateValue)) { isEndDatevalid = false;$('#requiredDateformate').show();showMetadataRequired(false);}
-            else {isEndDatevalid = true; $('#requiredDateformate').hide();}
-        }
-        if (TodayDateValue != "")
-        {   
-            if (!dateReg.test(TodayDateValue)) { isTodayDatevalid = false;$('#requiredDateformate').show();showMetadataRequired(false);}
-            else {isTodayDatevalid = true; $('#requiredDateformate').hide();}
-        }
-        if(isBeginDatevalid==false || isEndDatevalid==false || isTodayDatevalid==false)
-        {
-            isvalid=false;
-            $('#requiredDateformate').show();
-            showMetadataRequired(false);
-        }
-        if (isvalid == true) {
-            $('#requiredDateformate').hide();
-        }
-
-        return isvalid;
-    },
-
-    validateMetadata: function () {
-        var isValid = true;
-//        $(".metadataScroll span[data-valmsg-for]").each(function (index, element) {
-        $(".metadataScroll span.reqFld").each(function (index, element) {
-            var input = $(element).siblings("input[type='text']");
-            if($(input).length == 0)
-            {
-                input = $(element).siblings("textarea");
-                if (($.trim($(input).val()) === "") || ($.trim($(input).val()).length > 3000))
-                {
-                   $(element).text("Required").removeClass("field-validation-valid").addClass("field-validation-error");
-                   isValid = false; 
-                }
-                else {
-                    $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
-                }
-            }else{
-                if($(input).hasClass("rangeTextbox")) {
-                    if($(input).val() !== "")
-                    {
-                        if(!isNaN($(input).val()))
-                        {
-                            var inputValue = parseFloat($(input).val());
-                            var minAllowedValue = parseFloat($(input).attr("minAllowedValue"));
-                            var maxAllowedValue = parseFloat($(input).attr("maxAllowedValue"));
-                            if(isNaN(inputValue) || (inputValue < minAllowedValue || inputValue > maxAllowedValue))
-                            {
-                                $(element).text($(input).attr("rangeErrorMessage")).removeClass("field-validation-valid").addClass("field-validation-error");
-                                isValid = false;
-                            }
-                            else
-                            {
-                                $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
-                            }
-                        }
-                        else
-                        {
-                            $(element).text($(input).attr("rangeErrorMessage")).removeClass("field-validation-valid").addClass("field-validation-error");
-                            isValid = false;
-                        }
-                    }
-                }
-                else if ($.trim($(input).val()) === "") {
-                    $(element).text($(input).attr("data-val-required")).removeClass("field-validation-valid").addClass("field-validation-error");
-                    isValid = false;
-                }
-                else {
-                    $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
-                }
-            }
-        });
-        if (isValid == false) { 
-            $('#requiredField').show();
-            showMetadataRequired(false);
-            return isValid;
-        }
-
-        var list = $(".paramtrTableContainer span[data-valmsg-for]");
-        if(list.length == 1 && $(".paramtrTableContainer .parameterRows").css("display")==="none")
-        {
-           isValid == true; 
-        }
-        else{
-            list.each(function (index, element) {
-                var elem = $(element).siblings("input[type='text']");
-                if($(elem).length == 0)
-                {
-                    elem = $(element).siblings(".dropdownElementsHolder").find("input[type='text']");
-                    if ($.trim($(elem).val()) === ""){
-                        $(element).text($(elem).attr("data-val-required")).removeClass("field-validation-valid").addClass("mandtrField");
-                        isValid = false;
-                    }
-                    else {
-                        $(element).text("").addClass("field-validation-valid").removeClass("mandtrField");
-
-                        var unitsCell = $(elem).parents("td").next();
-                        var unitValue = $(unitsCell).find(".unitsText").val();
-
-                        if($(elem).hasClass("typeText") && $.trim($(elem).val()) === "Numeric")
-                        {
-                            if($.trim(unitValue) === "")
-                            {
-                                $(unitsCell).children("span.gridName").text("*").removeClass("field-validation-valid").addClass("mandtrField");
-                                isValid = false;
-                            }
-                            else
-                            {
-                                $(unitsCell).children("span.gridName").text("").addClass("field-validation-valid").removeClass("mandtrField");
-                            }
-                        }
-                        else
-                        {
-                            $(unitsCell).children("span.gridName").text("").addClass("field-validation-valid").removeClass("mandtrField");
-                        }
-                    }
-                }
-                else
-                {
-                    if ($.trim($(elem).val()) === "") {
-                        $(element).text($(elem).attr("data-val-required")).removeClass("field-validation-valid").addClass("mandtrField");
-                        isValid = false;
-                    }
-                    else {
-                        $(element).text("").addClass("field-validation-valid").removeClass("mandtrField");
-                    }
-                }
-            });
-        }
-        if (isValid == false) { 
-            showMetadataRequired(true);
-            return isValid;
-        }
-        //Adding validation for email,date and phone number
-        var isEmailValid = true;
-        var isContractEmailValid = true;
-        var isPhoneValid = true;
-        var isContractPhoneValid = true;
-        var isBeginDateValid = true;
-        var isendDateValid = true;
-        var isTodayDateValid = true;
-        $(".metadataScroll input[type='text']").each(function (index, element) {
-            var HiddenValue = $.trim($(element).siblings("input[type='hidden']").val());
-            if (HiddenValue == "Creator: Email") {
-                isEmailValid = dataUp.validateEmail();
-                //$(element).text($(element).siblings("input[type='text']").attr("data-val-regex")).removeClass("field-validation-valid").addClass("field-validation-error");
-            }
-            if (HiddenValue == "Data Contact Person: Email") { isContractEmailValid = dataUp.validateEmail(); }
-            if (HiddenValue == "Creator: Phone") {
-                isPhoneValid = dataUp.validatePhoneNumber();
-            }
-            if (HiddenValue == "Data Contact Person: Phone") { isContractPhoneValid = dataUp.validatePhoneNumber(); }
-            if (HiddenValue == "Temporal coverage: Beginning date") { isBeginDateValid = dataUp.validateDateFormat(); }
-            if (HiddenValue == "Temporal coverage: Ending date") { isendDateValid = dataUp.validateDateFormat(); }
-            if (HiddenValue == "Temporal coverage: Today\'s date") { isTodayDateValid = dataUp.validateDateFormat(); }
-        });
-        if (isEmailValid == false || isContractEmailValid == false || isPhoneValid == false || isContractPhoneValid == false || isBeginDateValid == false || isendDateValid == false || isTodayDateValid == false) {
-            isValid = false;
-        }
-
-        return isValid;
-    },
-
-
-    ValidateRequiredFields: function () {
-        var isvalid = true;
-        var phoneValue = $('.docMetadataItmHolder input[value="Creator: Phone"]').siblings("input").val();
-        // phoneValue.attr("data-val-required");
-
-        if (phoneValue != "") {
-            //var characterReg = /^[2-9]\d{2}-\d{3}-\d{4}$/; 
-            //var value = /[0-9-()+]{3,20}/;
-            //var characterReg = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/;
-            var characterReg = /^(?:\+?1[-. ]?)?\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
-            if (!characterReg.test(phoneValue)) {
-                //alert("phone no does not match");
-                $('#requiredphoneformate').show();
-                showMetadataRequired(false);
-                isvalid = false;
-            }
-        }
-        return isvalid;
-    },
-
-    validateRepositoryDetails: function (containerName) {
-        var isValid = true;
-        var userNameReference = $("." + containerName + " [name*='UserName']");
-        if (!userNameReference.is(':disabled') && $.trim(userNameReference.val()) === "") {
-            userNameReference.siblings("span[data-valmsg-for*='UserName']").text(userNameReference.attr("data-val-required")).removeClass("field-validation-valid").addClass("field-validation-error");
-            isValid = false;
-        }
-        else {
-            userNameReference.siblings("span[data-valmsg-for*='UserName']").text("").addClass("field-validation-valid").removeClass("field-validation-error");
-        }
-
-        var passwordReference = $("." + containerName + " [name*='Password']");
-        if (!passwordReference.is(':disabled') && $.trim(passwordReference.val()) === "") {
-            passwordReference.siblings("span[data-valmsg-for*='Password']").text(passwordReference.attr("data-val-required")).removeClass("field-validation-valid").addClass("field-validation-error");
-            isValid = false;
-        }
-        else {
-            passwordReference.siblings("span[data-valmsg-for*='Password']").text("").addClass("field-validation-valid").removeClass("field-validation-error");
-        }
-        $('#usercredentialswrong').hide();
-        return isValid;
-    },
-
-    fillCitation: function () {
-        var creatorValue = $(".docMetadataItmHolder input[value='Creator: Last name']").siblings("input").val() +", "+ $(".docMetadataItmHolder input[value='Creator: First name']").siblings("input").val();
-        var titleValue = $(".docMetadataItmHolder input[value='Title of dataset']").siblings("input").val();
-        var dateValue = $('.docMetadataItmHolder input[value="Today\'s date"]').siblings("input").val();
-        var Yearval=dateValue.split("-");
-
-        $("#citationPublisher").val(creatorValue);
-        $("#citationTitle").val(titleValue);
-        $("#citationPublicationYear").val(Yearval[0]);
-    },
-
-    validateUserNamePassword: function (list, selectedItem, containerName, userName, password, submitBtn) {
-        userName.val("");
-        password.val("");
-        for (i = 0; i < list.length; i++) {
-            if (list[i].Id == selectedItem.val()) {
-                $("." + containerName).find('#lblRepositoryType').val(list[i].RepoType);
-                if (list[i].Required === true) {
-                    userName.removeAttr('disabled');
-                    password.removeAttr('disabled');
-                    $("." + containerName + " .credentials").show();
-                } else {
-
-                    userName.attr('disabled', 'disabled');
-                    password.attr('disabled', 'disabled');
-                    $("." + containerName + " .credentials").hide();
-                    $("." + containerName + " span[data-valmsg-for='" + userName.attr('name') + "']").removeClass('field-validation-error').addClass('field-validation-valid');
-                    $("." + containerName + " span[data-valmsg-for='" + password.attr('name') + "']").removeClass('field-validation-error').addClass('field-validation-valid');
-                }
-            }
-        }
-        var repositoyName = selectedItem.find("option[value=" + selectedItem.val() + "]").text();
-        $("." + containerName + " .userAgreementDisplay").hide();
-        if (window.userList.cacheAgreement.get(repositoyName) === true) {
-            $("." + containerName + " .chkAgreement").attr('checked', 'checked');
-            $("." + containerName + " .userAgreementDisplay").hide();
-            submitBtn.removeAttr('disabled');
-            userName.val(window.userList.cacheName.get(repositoyName));
-        } else {
-            $("." + containerName + " .chkAgreement").removeAttr('checked');
-            submitBtn.attr('disabled', 'disabled');
-        }
-    },
-
-    persistAgreement: function (repositoryName, userName) {
-        window.userList.cacheAgreement.set(repositoryName, true);
-        window.userList.cacheName.set(repositoryName, userName);
-    },
-
-    getUserAgreement: function (element, selected) {
-        var display = element.siblings('.userAgreementDisplay');
-                 $("body").addClass("busy");
-        if (display.is(":visible")) {
-            display.hide();
-                         $("body").removeClass("busy");
-        } else {
-            //Fetch agreement text.
-            dataUp.showBusy();
-            $.post('/Document/GetAgreement', { repositoryName: selected.text() }, function (value) {
-                display.text(value);
-                dataUp.hideBusy();
-            });
-            display.show();
-        }
-    }
-};
-
-var userAgreement = function () {
-    var cacheAgreement = {};
-    var cacheName = {};
-    return {
-        cacheAgreement: {
-            get: function (key) {
-                return cacheAgreement[key];
-            },
-            set: function (key, value) {
-                cacheAgreement[key] = value;
-            }
-        },
-        cacheName: {
-            get: function (key) {
-                return cacheName[key];
-            },
-            set: function (key, value) {
-                cacheName[key] = value;
-            }
-        },
-        initAgreement: function (list) {
-            for (i = 0; i < list.length; i++) {
-                cacheAgreement[list[i].Name] = list[i].Agree;
-            }
-            return this;
-        },
-
-        initName: function (list) {
-            for (i = 0; i < list.length; i++) {
-                cacheName[list[i].Name] = list[i].UserName;
-            }
-            return this;
-        }
-    };
-};

Source/WebClient/Web.Client/Scripts/DataUpv4.js

+$(function () {
+    dataUp.initialize();
+    $("#publishFile, #addContent").bind("change", function () {
+        var _this = this;
+        dataUp.constants.submittedFileName = $(this).val().substr(($(this).val().lastIndexOf("\\") < 0) ? 0 : $(this).val().lastIndexOf("\\") + 1);
+        var fileExtension = $(this).val().substr($(this).val().lastIndexOf(".")).toLowerCase();
+        //if (dataUp.constants.allowedFileFormat.indexOf(fileExtension) >= 0) {
+        if(fileExtension==".xlsx" || fileExtension==".csv")
+        {
+            if ($(this).attr("id") === "addContent") {
+                $(this).parents("form").attr("action", $(this).parents("form").attr("action").replace("UploadedPostedFile", "AddPostedFile"));
+            }
+            dataUp.showBusy();
+            $.post("/Document/CheckDuplicate", { fileNames: dataUp.constants.submittedFileName }, function (status) {
+                dataUp.hideBusy();
+                if (status.DuplicateFileNames === "") {
+                    dataUp.showBusy();
+                    $(_this).parents("form").submit();
+                }
+                else if (confirm("The file already exists. Do you want to overwrite?")) {
+                    dataUp.showBusy();
+                    $(_this).parents("form").submit();
+                }
+            });
+        }
+        else {
+            alert("Only .xlsx and .csv files can be uploaded");
+        }
+    });
+
+    $("#signIn").click(function () {
+        $("#SignInpopup").show();
+    });
+
+    $(".closeCircle").click(function () {
+        $("#SignInpopup").hide();
+    });
+
+    $("#ieUploadFrame").bind("load", function () {
+        if ($("body").hasClass("busy")) {
+            dataUp.reloadList(1, dataUp.constants.submittedFileName);
+        }
+    });
+
+    $(".errorContainer li").bind("click", function () {
+        $(".errorContainer li").removeClass("selected");
+        $(this).addClass("selected");
+        if ($(this).attr("sheetName") === "All") {
+            $(".errorContainer table tbody tr").show();
+        }
+        else {
+            $(".errorContainer table tbody tr").hide();
+            $(".errorContainer table tbody tr[sheetName='" + $(this).attr("sheetName") + "']").show();
+        }
+    });
+
+    $("fieldset legend").bind("click", function () {
+        if ($(this).text().indexOf("-") >= 0) {
+            $(this).text($(this).text().replace("-", "+"));
+            $(this).siblings("div").hide();
+        }
+        else {
+            $(this).text($(this).text().replace("+", "-"));
+            $(this).siblings("div").show();
+        }
+    });
+
+    // Binds the click event on the delete icon beside each document
+    $(".deleteLink").live("click", function () {
+        if (confirm($(this).attr("errormessage").replace("\\n", "\n"))) {
+            dataUp.deleteDocument(this);
+        }
+    });
+
+    $("div#divMultipleFileUploadPopup .btnHolder input.cancel").bind("click", function () {
+        $("div#divMultipleFileUploadPopup").hide();
+    });
+
+    $("div#divMultipleFileUploadPopup .btnHolder input.upload").bind("click", function () {
+        if ($("div#divMultipleFileUploadPopup .uploadedDocument").hasClass("remove") && dataUp.constants.transferedFiles !== "") {
+            $("#divMultipleFileUploadPopup .btnHolder input").attr("disabled", "disabled");
+            $("div#divMultipleFileUploadPopup .uploadedDocument").removeClass("remove");
+            var files = dataUp.constants.transferedFiles;
+            var count = files.length;
+            var validFileCount = 0;
+            for (var fileIndex = 0; fileIndex < count; fileIndex++) {
+                var file = files[fileIndex];
+                var fileExtension = file.name.substr(file.name.lastIndexOf(".")).toLowerCase();
+                if (dataUp.constants.allowedFileFormat.indexOf(fileExtension) >= 0 && $("div#divMultipleFileUploadPopup .uploadedDocument label span:contains('" + file.name + "')").length > 0) {
+                    handleFiles(file);
+                    validFileCount++;
+                }
+            }
+        }
+
+        dataUp.constants.transferedFiles = "";
+        // $("#divMultipleFileUploadPopup .btnHolder input.cancel").removeAttr("disabled");
+        $("div#divMultipleFileUploadPopup").hide();
+        dataUp.reloadList(validFileCount, file.name);
+    });
+
+    $("div#divMultipleFileUploadPopup .uploadedDocument.remove a").live("click", function () {
+        $(this).parent("div.uploadedDocument").remove();
+        $("div#divMultipleFileUploadPopup .btnHolder input.upload").attr("disabled", "disabled");
+    });
+
+    // Binds the click event on the delete icon beside each document
+    $(".getIdentifier").bind("click", function () {
+        dataUp.getIdentifier(this);
+    });
+
+    $("a[helpcontent]").bind("mouseover", function () {
+        $("#divHelpContent").text($(this).attr("helpcontent")).removeClass("hide").css("left", $(this).position().left + 30).css("top", $(this).position().top);
+    });
+
+    $("a[helpcontent]").bind("mouseout", function () {
+        $("#divHelpContent").addClass("hide");
+    });
+
+    $("#updateCitation").bind("click", function () {
+        dataUp.updateCitation(this);
+        var publisher = $("#citationPublisher").val();
+        var publicationYear = $("#citationPublicationYear").val();
+        var title = $("#citationTitle").val();
+        var version = $("#Citation_Version").val();
+        var identifier = $("#hiddenGetIdentifier").val();
+
+        $("#txtCitation").val(publisher + "(" + publicationYear + "): " + title + ". " + version + ". " + publisher + ". " + identifier);
+        $("#hiddenCitation").val(publisher + "(" + publicationYear + "): " + title + ". " + version + ". " + publisher + ". " + identifier);
+       $("#updateCitation").val("Generate Citation");
+    });
+
+    $(".btnHolder .btnDetailSave, .btnHolder .btnDetailPost").bind("click", function () {
+        var formReference = $("#saveDocumentDetail");
+        if (dataUp.validateMetadata()) {
+            if (($(this).hasClass("btnDetailPost") && dataUp.validateRepositoryDetails("docMetadataItmHolder"))) {
+                dataUp.showBusy();
+                var data = formReference.serializeArray(); 
+                data.push({name: 'name', value: $("#postRepositories option:selected").text()}); 
+
+                $.ajax({
+                    url: (($(this).hasClass("btnDetailPost")) ? formReference.attr("postUrl") : formReference.attr("action")),
+                    data: data,
+                    type: "post",
+                    success: function (json) {
+                        dataUp.hideBusy();
+                        dataUp.hideInfoHeader();
+                        if ($(this).hasClass("btnDetailPost")) {
+                            dataUp.persistAgreement($("#postRepositories option:selected").text(), $("#postUsername").val());
+                        }
+                        if (json.Type === "Post") {
+                            if (json.Status === true) {
+                                // alert(json.Message);
+                                $("#filePostSuccessPopup .identifier").text(json.Message);
+                                $("#filePostSuccessPopup").show();
+                            }
+                            else {
+                                alert(json.Message);
+                            }
+                        }
+                        else {
+                            alert(json.Message);
+                        }
+                    },
+                    error: function (req,timeout,errorMessage) {
+                        dataUp.hideBusy();
+                        alert(timeout + " :" + errorMessage);
+                    }
+                });
+            }
+        }
+    });
+
+    $(".btnDetailSave").bind("click", function () {
+        var formReference = $("#saveDocumentDetail");
+        if (($("#errorsId div").hasClass("active")) || dataUp.validateMetadata())
+        {
+            dataUp.showBusy();
+            $.ajax({
+                ifModified: false, 
+                cache: false, 
+                url: "/Document/SaveDetail",
+                data: formReference.serialize(),
+                type: "post",
+                success: function (json) {
+                    dataUp.hideBusy();
+                    dataUp.hideInfoHeader();
+                    if (json.Type === "Save") {
+                        if (json.Status === true) {
+                            //Update html
+                            $("#parameterDataPartial").html(json.PartialViewHtml);                           
+                            $('.savedSuccessfullydiv').html('');
+                            $('.savedSuccessfullydiv').html(json.Message);
+                            $("#successfullySavedPopup").show();                            
+                        }
+                        else {
+                            alert(json.Message);
+                        }
+                    }
+                    else {
+                        alert(json.Message);
+                    }
+                },
+                error: function (req,timeout,errorMessage) {
+                    dataUp.hideBusy();
+                    alert(timeout + " :" + errorMessage);
+                }
+            });
+        }
+    });
+
+    $(".popupButtonContainer").bind("click", function () {
+        location.href = "/document/Index";
+    });
+
+    $(".RemoveButtonContainer").click(function () {
+        $('#RemovedPopup').hide();
+
+    });
+    $(".saveButtonContainer").click(function () {
+        $('#successfullySavedPopup').hide();
+
+    });
+
+    $("a.closeBtn").bind("click", function () {
+        $(this).parent().parent("div").hide();
+    });
+
+    $("input[type='text']").bind("change", function () {
+        dataUp.showInfoHeader();
+    });
+
+    // If the header checkbox is checked then check all the child checkboxes otherwise uncheck all the checkboxes.
+    $(".gridHeader input[type='checkbox']").live("change", function () {
+        var sheetId = $(".documentSubTab a.active").attr("sheetId");
+        if ($(this).attr("checked")) {
+            $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled").attr("checked", "checked");
+        }
+        else {
+            $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled").removeAttr("checked");
+        }
+    });
+
+
+    // If the header checkbox is checked then check all the child checkboxes otherwise uncheck all the checkboxes.
+    $(".documentListScrollStp input[type='checkbox']:enabled").live("change", function () {
+        var sheetId = $(this).parent("td").parent("tr").attr("id");
+
+        var selectedCheckBoxed = $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled:checked");
+        if (selectedCheckBoxed.length === $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled").length) {
+            $(".gridHeader input[type='checkbox']").attr("checked", "checked");
+        }
+        else {
+            $(".gridHeader input[type='checkbox']").removeAttr("checked");
+        }
+    });
+
+    $(".documentErorTableContainerTD1 input[type='checkbox']").live("click", function () {    
+  
+        var sheetId = $(this).parent("td").parent("tr").attr("id");
+        if ($("tr[id='" + sheetId + "'] :input:checked").length > 0) {
+                $('.docRemovBtn').removeClass('disabled');
+            } else {
+                $('.docRemovBtn').addClass('disabled');
+            }
+  });
+
+
+    $('.docRemovBtn').live("click", function () {
+        if($(this).is(".disabled"))
+        {
+           return;
+        }
+        var sheetName = $(".documentSubTab a.active").attr("sheetName");
+        var sheetId = $(".documentSubTab a.active").attr("sheetId");
+
+        var selectedId = "";
+        
+        $("tr[id='" + sheetId + "'] input[type='checkbox']:enabled:checked").each(function (index, element) {
+            selectedId = selectedId + $(element).attr("errorAddress") +"+"+$(element).next('input[type=hidden]').val() +"-";
+            $(element).parents("tr:first").remove();
+        });
+
+        var list = $("tr[id='" + sheetId + "'] input[type='checkbox']");
+        if(list.length == 0)
+        {
+             var tab = $("div#st_horizontal a[sheetId='"+sheetId+"']").attr("sheetName");
+             $("div#st_horizontal a[sheetId='"+sheetId+"']").text(tab+"(0)");
+             $(".documentErorTableContainer .docErrorTable").append("<tr id = '"+ sheetId +"' ><td><div class='NoErrorbackground'>No Item found</div></td></tr>");
+//             $('.docRemovBtn').addClass('disabled');
+        }
+        else{
+            var tab = $("div#st_horizontal a[sheetId='"+sheetId+"']").attr("sheetName");
+             $("div#st_horizontal a[sheetId='"+sheetId+"']").text(tab+"("+(list.length)+")");
+//             if(($("tr[id='" + sheetId + "'] input[type='checkbox']:enabled")).length == 0)
+//             {
+//                $('.docRemovBtn').addClass('disabled');
+//             }
+        }
+         $('.docRemovBtn').addClass('disabled');
+        if (selectedId !== "") {
+            var funreturndata = null;
+            $.post($(this).attr("actionUrl"), { ids: selectedId, sheetName: sheetName }, function (returnHtml) {
+               $('div#st_horizontal').slideTabs({classTabActive:'active'});
+            });
+        }
+    });
+
+    $('.btnDemo').live("click", function() {
+      window.open('/Demo/Index', '_blank' );  
+  });
+     
+    $(document).keyup(function (e) { 
+        if (e.keyCode == 27) { 
+            $("#SignInpopup").hide();
+            if($('.dropdwn').is(':visible')){
+                $(".MyTestForm").click();
+            }
+        } 
+    });
+
+    $(".rangeTextbox").blur( function () {
+        var element = $(this).siblings("span");
+
+        if($(this).val() !== "" && $(element).is(":visible"))
+        {
+            var inputValue = parseFloat($(this).val());
+            var minAllowedValue = parseFloat($(this).attr("minAllowedValue"));
+            var maxAllowedValue = parseFloat($(this).attr("maxAllowedValue"));
+            if(isNaN(inputValue) || (inputValue < minAllowedValue || inputValue > maxAllowedValue))
+            {
+                $(element).text($(this).attr("rangeErrorMessage")).removeClass("field-validation-valid").addClass("field-validation-error");
+                isValid = false;
+            }
+            else
+            {
+                $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
+            }
+        }
+        else
+        {
+            $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
+        }
+    });
+});
+
+ function showMetadataRequired(isParameterMetaData)
+    {
+        if(isParameterMetaData)
+        {
+            $('.metadataDefinition').css("display", "none"); 
+            $('.paramtrHolder').css("display", "block"); 
+            $('.columnDefinitionAnchor').addClass('active'); 
+            $('.dataDefinitionAnchor').removeClass('active'); 
+        }
+        else
+        {
+            $('.metadataDefinition').css("display", "block"); 
+            $('.paramtrHolder').css("display", "none"); 
+            $('.dataDefinitionAnchor').addClass('active'); 
+            $('.columnDefinitionAnchor').removeClass('active'); 
+        }
+    }
+
+var dataUp = {
+    constants: {
+        dropAndDragAction: "/document/UploadDropedFile",
+        allowedFileFormat: ".xlsx, .csv",
+        submittedFileName: "",
+        transferedFiles: ""
+    },
+
+    showInfoHeader: function () {
+        $(".docfileHeader .info").show();
+    },
+
+    hideInfoHeader: function () {
+        $(".docfileHeader .info").hide();
+    },
+
+    initialize: function () {
+        if (document.documentMode) {
+            $("body").addClass("ie");
+        }
+    },
+
+    // This displays the load indicator
+    showBusy: function () {
+        $("body").addClass("busy");
+    },
+
+    // This displays the load indicator
+    hideBusy: function () {
+        $("body").removeClass("busy");
+    },
+
+    // It deletes the entity (content/community)
+    deleteDocument: function (reference) {
+        $("body").addClass("busy");
+        var formReference = $(reference).parent("form");
+        var action = formReference.attr("action");
+        var antiForgeryToken = formReference.find("[name='__RequestVerificationToken']").val();
+        $.post(action, { __RequestVerificationToken: antiForgeryToken }, function (returnedList) {
+            $("#documentList").html(returnedList);
+            $("body").removeClass("busy");
+        });
+    },
+
+    getIdentifier: function (reference) {
+        dataUp.showInfoHeader();
+        var formReference = $(reference).parents("form");
+        var action = formReference.attr("action");
+        var repositoyName = $("#repositories option:selected").text();
+        var whoValue = $("#citationPublisher").val();
+        var whenValue = $("#citationPublicationYear").val();
+        var whatValue = $("#citationTitle").val();
+        var usernameValue = $("#repositoryUsername").val();
+        var passwordValue = $("#repositoryPassword").val();
+
+        var antiForgeryToken = formReference.find("[name='__RequestVerificationToken']").val();
+        if (dataUp.validateRepositoryDetails("repositoryPopup")) {
+            $("body").addClass("busy");
+            $.ajax({
+                url: action,
+                data: { __RequestVerificationToken: antiForgeryToken, Who: whoValue, What: whatValue, When: whenValue, UserName: usernameValue, Password: passwordValue, RepositoryName: repositoyName },
+                type: "post",
+                success: function (returnedList) {
+                    if (returnedList != "") {
+                        var result = returnedList.split("|");
+                        if(result[0] === "true")
+                        {
+                            $("#txtGetIdentifier").val(result[1]);
+                            $("#hiddenGetIdentifier").val(result[1]);
+                            $('#loginRepositoryPopup').hide();
+                            $("#getusername").val(usernameValue);
+                            dataUp.persistAgreement(repositoyName, usernameValue);
+                            $("body").removeClass("busy");
+                            $('.getIdentifierButton').attr('disabled', 'disabled');
+                            $('.getIdentifierHelp').css("display","none");
+                        }
+                        else{
+                            $("body").removeClass("busy");
+                            $('#loginRepositoryPopup').show();
+                            $('#usercredentialswrong').text('');
+                            $('#usercredentialswrong').text(result[1]);
+                            $('#usercredentialswrong').show();
+                       
+                            $(".repositoryPopup .btnHolder .getIdentifier").attr('disabled', 'disabled');
+                            $(".repositoryPopup .chkAgreement").removeAttr('checked');
+                            $("#repositoryPassword").val('');
+                        }
+                    }
+                    else {
+                        $("body").removeClass("busy");
+                        $('#loginRepositoryPopup').show();
+                        $('#usercredentialswrong').text(result[1]);
+                        $('#usercredentialswrong').show();
+                        $(".repositoryPopup .btnHolder .getIdentifier").attr('disabled', 'disabled');
+                        $(".repositoryPopup .chkAgreement").removeAttr('checked');
+                        $("#repositoryPassword").val('');
+                    }
+                },
+                error: function (req,timeout,errorMessage) {
+                    dataUp.hideBusy();
+                    alert(timeout + " :" + errorMessage);
+                }
+            });
+         }
+    },
+
+    // It deletes the entity (content/community)
+    updateCitation: function (reference) {
+        dataUp.showInfoHeader();
+        var publisher = $("#citationPublisher").val();
+        var publicationYear = $("#citationPublicationYear").val();
+        var title = $("#citationTitle").val();
+        var version = $("#Citation_Version").val();
+        var identifier = $("#hiddenGetIdentifier").val();
+
+        $("#txtCitation").val(publisher + "(" + publicationYear + "):" + title + ". " + version + ". " + publisher + ". " + identifier);
+        $("#hiddenCitation").val(publisher + "(" + publicationYear + "):" + title + ". " + version + ". " + publisher + ". " + identifier);
+        $("#updateCitation").val("Generate Citation");
+    },
+
+    reloadList: function (fileCount, filename) {
+        $.post("/document/List", function (returnedList) {
+            $("#documentList").html(returnedList);
+            $("body").removeClass("busy");
+
+            if (fileCount === 1) {
+                $(".docListTableContent tbody tr td[title='" + filename + "']").parent().find(".postingBtn")[0].click();
+            }
+        });
+    },
+
+    //Email validation
+    validateEmail: function () {
+
+        var isvalid = true;
+        var isEmailvalid = true;
+        var isContractEmailvalid = true;
+        var EmailValue = $('.docMetadataItmHolder input[value="Creator: Email"]').siblings("input").val();
+        var DataContactPersonEmailValue = $('.docMetadataItmHolder input[value="Data Contact Person: Email"]').siblings("input").val();
+        var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
+        if (EmailValue != "") {
+            if (!emailReg.test(EmailValue)) {
+                isEmailvalid = false;
+            }
+            else {
+                isEmailvalid = true;
+            }
+        }
+
+        if (DataContactPersonEmailValue != "") {
+            if (!emailReg.test(DataContactPersonEmailValue)) {
+                isContractEmailvalid = false;
+            }
+            else {
+                isContractEmailvalid = true;
+            }
+        }
+        if (isEmailvalid == false || isContractEmailvalid == false) {
+            isvalid = false;
+            $('#requiredemailformate').show();
+        }
+        if (isvalid == true) {
+            $('#requiredemailformate').hide();
+        }
+        return isvalid;
+    },
+
+    //Phone validation
+    validatePhoneNumber: function () {
+        var isvalid = true;
+        var isPhonevalid = true;
+        var isContractvalid = true;
+        var phoneValue = $('.docMetadataItmHolder input[value="Creator: Phone"]').siblings("input").val();
+        var DataContactPersonPhoneValue = $('.docMetadataItmHolder input[value="Data Contact Person: Phone"]').siblings("input").val();
+        // var phoneReg = /^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$/;      
+        var phoneReg = /^[0-9,+()-]+$/;
+        if (phoneValue != "") {
+            if (!phoneReg.test(phoneValue)) {
+                isPhonevalid = false;
+            }
+            else {
+                isPhonevalid = true;
+            }
+        }
+
+
+        if (DataContactPersonPhoneValue != "") {
+            if (!phoneReg.test(DataContactPersonPhoneValue)) {
+                isContractvalid = false;
+            }
+            else {
+                isContractvalid = true;
+            }
+        }
+        if (isPhonevalid == false || isContractvalid == false) {
+            isvalid = false;
+            $('#requiredPhoneformate').show();
+            showMetadataRequired(false);
+        }
+        if (isvalid == true) {
+            $('#requiredPhoneformate').hide();
+        }
+        return isvalid;
+    },
+
+    //Date validation
+    validateDateFormat: function () 
+    {
+        var isvalid = true;
+        var isBeginDatevalid = true;
+        var isEndDatevalid = true; 
+        var isTodayDatevalid = true;      
+        var beginningDateValue = $('.docMetadataItmHolder input[value="Temporal coverage: Beginning date"]').siblings("input").val();
+        var endDateValue = $('.docMetadataItmHolder input[value="Temporal coverage: Ending date"]').siblings("input").val();
+        var TodayDateValue =  $('.docMetadataItmHolder input[value="Today\'s date"]').siblings("input").val();
+
+          //yyyy-mm-dd format from between 1900-01-01 and 2099-12-31     
+        var dateReg = /^(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/;
+        if (beginningDateValue != "") {      
+            
+            if (!dateReg.test(beginningDateValue))
+            {
+            isBeginDatevalid = false;
+            $('#requiredDateformate').show();
+            showMetadataRequired(false);
+            }
+            else {isBeginDatevalid = true; $('#requiredDateformate').hide();}
+        }
+        if (endDateValue != "")
+        {   
+            if (!dateReg.test(endDateValue)) { isEndDatevalid = false;$('#requiredDateformate').show();showMetadataRequired(false);}
+            else {isEndDatevalid = true; $('#requiredDateformate').hide();}
+        }
+        if (TodayDateValue != "")
+        {   
+            if (!dateReg.test(TodayDateValue)) { isTodayDatevalid = false;$('#requiredDateformate').show();showMetadataRequired(false);}
+            else {isTodayDatevalid = true; $('#requiredDateformate').hide();}
+        }
+        if(isBeginDatevalid==false || isEndDatevalid==false || isTodayDatevalid==false)
+        {
+            isvalid=false;
+            $('#requiredDateformate').show();
+            showMetadataRequired(false);
+        }
+        if (isvalid == true) {
+            $('#requiredDateformate').hide();
+        }
+
+        return isvalid;
+    },
+
+    validateMetadata: function () {
+        var isValid = true;
+//        $(".metadataScroll span[data-valmsg-for]").each(function (index, element) {
+        $(".metadataScroll span.reqFld").each(function (index, element) {
+            var input = $(element).siblings("input[type='text']");
+            if($(input).length == 0)
+            {
+                input = $(element).siblings("textarea");
+                if (($.trim($(input).val()) === "") || ($.trim($(input).val()).length > 3000))
+                {
+                   $(element).text("Required").removeClass("field-validation-valid").addClass("field-validation-error");
+                   isValid = false; 
+                }
+                else {
+                    $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
+                }
+            }else{
+                if($(input).hasClass("rangeTextbox")) {
+                    if($(input).val() !== "")
+                    {
+                        if(!isNaN($(input).val()))
+                        {
+                            var inputValue = parseFloat($(input).val());
+                            var minAllowedValue = parseFloat($(input).attr("minAllowedValue"));
+                            var maxAllowedValue = parseFloat($(input).attr("maxAllowedValue"));
+                            if(isNaN(inputValue) || (inputValue < minAllowedValue || inputValue > maxAllowedValue))
+                            {
+                                $(element).text($(input).attr("rangeErrorMessage")).removeClass("field-validation-valid").addClass("field-validation-error");
+                                isValid = false;
+                            }
+                            else
+                            {
+                                $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
+                            }
+                        }
+                        else
+                        {
+                            $(element).text($(input).attr("rangeErrorMessage")).removeClass("field-validation-valid").addClass("field-validation-error");
+                            isValid = false;
+                        }
+                    }
+                }
+                else if ($.trim($(input).val()) === "") {
+                    $(element).text($(input).attr("data-val-required")).removeClass("field-validation-valid").addClass("field-validation-error");
+                    isValid = false;
+                }
+                else {
+                    $(element).text("").addClass("field-validation-valid").removeClass("field-validation-error");
+                }
+            }
+        });
+        if (isValid == false) { 
+            $('#requiredField').show();
+            showMetadataRequired(false);
+            return isValid;
+        }
+
+        var list = $(".paramtrTableContainer span[data-valmsg-for]");
+        if(list.length == 4 && $(".paramtrTableContainer .parameterRows").css("display")==="none")
+        {
+           isValid == true; 
+        }
+        else{
+            list.each(function (index, element) {
+                var elem = $(element).siblings("input[type='text']");
+                if($(elem).length == 0)
+                {
+                    elem = $(element).siblings(".dropdownElementsHolder").find("input[type='text']");
+                    if ($.trim($(elem).val()) === ""){
+                        $(element).text($(elem).attr("data-val-required")).removeClass("field-validation-valid").addClass("mandtrField");
+                        isValid = false;
+                    }
+                    else {
+                        $(element).text("").addClass("field-validation-valid").removeClass("mandtrField");
+
+                        var unitsCell = $(elem).parents("td").next();
+                        var unitValue = $(unitsCell).find(".unitsText").val();
+
+                        if($(elem).hasClass("typeText") && $.trim($(elem).val()) === "Numeric")
+                        {
+                            if($.trim(unitValue) === "")
+                            {
+                                $(unitsCell).children("span.gridName").text("*").removeClass("field-validation-valid").addClass("mandtrField");
+                                isValid = false;
+                            }
+                            else
+                            {
+                                $(unitsCell).children("span.gridName").text("").addClass("field-validation-valid").removeClass("mandtrField");
+                            }
+                        }
+                        else
+                        {
+                            $(unitsCell).children("span.gridName").text("").addClass("field-validation-valid").removeClass("mandtrField");
+                        }
+                    }
+                }
+                else
+                {
+                    if ($.trim($(elem).val()) === "") {
+                        $(element).text($(elem).attr("data-val-required")).removeClass("field-validation-valid").addClass("mandtrField");
+                        isValid = false;
+                    }
+                    else {
+                        $(element).text("").addClass("field-validation-valid").removeClass("mandtrField");
+                    }
+                }
+            });
+        }
+        if (isValid == false) { 
+            showMetadataRequired(true);
+            return isValid;
+        }
+        //Adding validation for email,date and phone number
+        var isEmailValid = true;
+        var isContractEmailValid = true;
+        var isPhoneValid = true;
+        var isContractPhoneValid = true;
+        var isBeginDateValid = true;
+        var isendDateValid = true;
+        var isTodayDateValid = true;
+        $(".metadataScroll input[type='text']").each(function (index, element) {
+            var HiddenValue = $.trim($(element).siblings("input[type='hidden']").val());
+            if (HiddenValue == "Creator: Email") {
+                isEmailValid = dataUp.validateEmail();
+                //$(element).text($(element).siblings("input[type='text']").attr("data-val-regex")).removeClass("field-validation-valid").addClass("field-validation-error");
+            }
+            if (HiddenValue == "Data Contact Person: Email") { isContractEmailValid = dataUp.validateEmail(); }
+            if (HiddenValue == "Creator: Phone") {
+                isPhoneValid = dataUp.validatePhoneNumber();
+            }
+            if (HiddenValue == "Data Contact Person: Phone") { isContractPhoneValid = dataUp.validatePhoneNumber(); }
+            if (HiddenValue == "Temporal coverage: Beginning date") { isBeginDateValid = dataUp.validateDateFormat(); }
+            if (HiddenValue == "Temporal coverage: Ending date") { isendDateValid = dataUp.validateDateFormat(); }
+            if (HiddenValue == "Temporal coverage: Today\'s date") { isTodayDateValid = dataUp.validateDateFormat(); }
+        });
+        if (isEmailValid == false || isContractEmailValid == false || isPhoneValid == false || isContractPhoneValid == false || isBeginDateValid == false || isendDateValid == false || isTodayDateValid == false) {
+            isValid = false;
+        }
+
+        return isValid;
+    },
+
+
+    ValidateRequiredFields: function () {
+        var isvalid = true;
+        var phoneValue = $('.docMetadataItmHolder input[value="Creator: Phone"]').siblings("input").val();
+        // phoneValue.attr("data-val-required");
+
+        if (phoneValue != "") {
+            //var characterReg = /^[2-9]\d{2}-\d{3}-\d{4}$/; 
+            //var value = /[0-9-()+]{3,20}/;
+            //var characterReg = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/;
+            var characterReg = /^(?:\+?1[-. ]?)?\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
+            if (!characterReg.test(phoneValue)) {
+                //alert("phone no does not match");
+                $('#requiredphoneformate').show();
+                showMetadataRequired(false);
+                isvalid = false;
+            }
+        }
+        return isvalid;
+    },
+
+    validateRepositoryDetails: function (containerName) {
+        var isValid = true;
+        var userNameReference = $("." + containerName + " [name*='UserName']");
+        if (!userNameReference.is(':disabled') && $.trim(userNameReference.val()) === "") {
+            userNameReference.siblings("span[data-valmsg-for*='UserName']").text(userNameReference.attr("data-val-required")).removeClass("field-validation-valid").addClass("field-validation-error");
+            isValid = false;
+        }
+        else {
+            userNameReference.siblings("span[data-valmsg-for*='UserName']").text("").addClass("field-validation-valid").removeClass("field-validation-error");
+        }
+
+        var passwordReference = $("." + containerName + " [name*='Password']");
+        if (!passwordReference.is(':disabled') && $.trim(passwordReference.val()) === "") {
+            passwordReference.siblings("span[data-valmsg-for*='Password']").text(passwordReference.attr("data-val-required")).removeClass("field-validation-valid").addClass("field-validation-error");
+            isValid = false;
+        }
+        else {
+            passwordReference.siblings("span[data-valmsg-for*='Password']").text("").addClass("field-validation-valid").removeClass("field-validation-error");
+        }
+        $('#usercredentialswrong').hide();
+        return isValid;
+    },
+
+    fillCitation: function () {
+        var creatorValue = $(".docMetadataItmHolder input[value='Creator: Last name']").siblings("input").val() +", "+ $(".docMetadataItmHolder input[value='Creator: First name']").siblings("input").val();
+        var titleValue = $(".docMetadataItmHolder input[value='Title of dataset']").siblings("input").val();
+        var dateValue = $('.docMetadataItmHolder input[value="Today\'s date"]').siblings("input").val();
+        var Yearval=dateValue.split("-");
+
+        $("#citationPublisher").val(creatorValue);
+        $("#citationTitle").val(titleValue);
+        $("#citationPublicationYear").val(Yearval[0]);
+    },
+
+    validateUserNamePassword: function (list, selectedItem, containerName, userName, password, submitBtn) {
+        userName.val("");
+        password.val("");
+        for (i = 0; i < list.length; i++) {
+            if (list[i].Id == selectedItem.val()) {
+                $("." + containerName).find('#lblRepositoryType').val(list[i].RepoType);
+                if (list[i].Required === true) {
+                    userName.removeAttr('disabled');
+                    password.removeAttr('disabled');
+                    $("." + containerName + " .credentials").show();
+                } else {
+
+                    userName.attr('disabled', 'disabled');
+                    password.attr('disabled', 'disabled');
+                    $("." + containerName + " .credentials").hide();
+                    $("." + containerName + " span[data-valmsg-for='" + userName.attr('name') + "']").removeClass('field-validation-error').addClass('field-validation-valid');
+                    $("." + containerName + " span[data-valmsg-for='" + password.attr('name') + "']").removeClass('field-validation-error').addClass('field-validation-valid');
+                }
+            }
+        }
+        var repositoyName = selectedItem.find("option[value=" + selectedItem.val() + "]").text();
+        $("." + containerName + " .userAgreementDisplay").hide();
+        if (window.userList.cacheAgreement.get(repositoyName) === true) {
+            $("." + containerName + " .chkAgreement").attr('checked', 'checked');
+            $("." + containerName + " .userAgreementDisplay").hide();
+            submitBtn.removeAttr('disabled');
+            userName.val(window.userList.cacheName.get(repositoyName));
+        } else {
+            $("." + containerName + " .chkAgreement").removeAttr('checked');
+            submitBtn.attr('disabled', 'disabled');
+        }
+    },
+
+    persistAgreement: function (repositoryName, userName) {
+        window.userList.cacheAgreement.set(repositoryName, true);
+        window.userList.cacheName.set(repositoryName, userName);
+    },
+
+    getUserAgreement: function (element, selected) {
+        var display = element.siblings('.userAgreementDisplay');
+                 $("body").addClass("busy");
+        if (display.is(":visible")) {
+            display.hide();
+                         $("body").removeClass("busy");
+        } else {
+            //Fetch agreement text.
+            dataUp.showBusy();
+            $.post('/Document/GetAgreement', { repositoryName: selected.text() }, function (value) {
+                display.text(value);
+                dataUp.hideBusy();
+            });
+            display.show();
+        }
+    }
+};
+
+var userAgreement = function () {
+    var cacheAgreement = {};
+    var cacheName = {};
+    return {
+        cacheAgreement: {
+            get: function (key) {
+                return cacheAgreement[key];
+            },
+            set: function (key, value) {
+                cacheAgreement[key] = value;
+            }
+        },
+        cacheName: {
+            get: function (key) {
+                return cacheName[key];
+            },
+            set: function (key, value) {
+                cacheName[key] = value;
+            }
+        },
+        initAgreement: function (list) {
+            for (i = 0; i < list.length; i++) {
+                cacheAgreement[list[i].Name] = list[i].Agree;
+            }
+            return this;
+        },
+
+        initName: function (list) {
+            for (i = 0; i < list.length; i++) {
+                cacheName[list[i].Name] = list[i].UserName;
+            }
+            return this;
+        }
+    };
+};

Source/WebClient/Web.Client/Scripts/detailv1.js

-$(function () {
-    var activeTab = 1;
-    var sheetTabLinks = $('.documentSubTab a');
-    var removeSelectedButton = $('.docRemovBtn');
-    var removeAllButton = $('.docRemovAllBtn');
-    var headerCheckBox = $('.documentErorTableContainer tr.gridHeader input[type=checkbox]');
-    var childCheckBoxes = $('.documentErorTableContainer tr input[type=checkbox]:gt(0)');
-    var steps = $('.progressBar .step div');
-    var errorsStep = $(steps[0]);
-    var metadataStep = $(steps[1]);
-    var citationStep = $(steps[2]);
-    var postStep = $(steps[3]);
-
-    //for clickable tabs
-    var errorshow = $('#errorsId');
-    var metadatshow = $('#metadataId');
-    var citationshow = $('#citationId');
-    var postshow = $('#postId');
-
-    var errorsTab = $('#errosTab');
-    var metadataTab = $('#metadataTab');
-    var citationTab = $('#citationTab');
-    var postTab = $('#postTab');
-
-    var backButton = $('input[type=button][value=Back]');
-    var saveButton = $('input[type=button][value=Save]');
-    var nextButton = $('input[type=button][value=Next]');
-    var postButton = $('input[type=submit][value=Post]');
-    var getIdentifierButton = $('input[type=button][value="Retrieve an identifier"]');
-
-    var updateCitationButton = $('input[type=button][id="updateCitation"]');
-