/** * Copyright JS Foundation and other contributors, http://js.foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ RED.projects.userSettings = (function() { var gitUsernameInput; var gitEmailInput; function createGitUserSection(pane) { var currentGitSettings = RED.settings.get('git') || {}; currentGitSettings.user = currentGitSettings.user || {}; var title = $('
').text(RED._("editor:sidebar.project.userSettings.committerDetail")).appendTo(pane); var gitconfigContainer = $('').appendTo(pane); $('').appendTo(gitconfigContainer).text(RED._("editor:sidebar.project.userSettings.committerTip")); var row = $('').appendTo(gitconfigContainer); $('').text(RED._("editor:sidebar.project.userSettings.userName")).appendTo(row); gitUsernameInput = $('').appendTo(row); gitUsernameInput.val(currentGitSettings.user.name||""); row = $('').appendTo(gitconfigContainer); $('').text(RED._("editor:sidebar.project.userSettings.email")).appendTo(row); gitEmailInput = $('').appendTo(row); gitEmailInput.val(currentGitSettings.user.email||""); } function createSSHKeySection(pane) { var container = $('').appendTo(pane); var popover; var title = $('').text(RED._("editor:sidebar.project.userSettings.sshKeys")).appendTo(container); var subtitle = $('').appendTo(container).text(RED._("editor:sidebar.project.userSettings.sshKeysTip")); var addKeyButton = $('') .appendTo(subtitle) .click(function(evt) { addKeyButton.attr('disabled',true); saveButton.attr('disabled',true); // bg.children().removeClass("selected"); // addLocalButton.click(); addKeyDialog.slideDown(200); keyNameInput.focus(); }); var validateForm = function() { var valid = /^[a-zA-Z0-9\-_]+$/.test(keyNameInput.val()); keyNameInput.toggleClass('input-error',keyNameInputChanged&&!valid); // var selectedButton = bg.find(".selected"); // if (selectedButton[0] === addLocalButton[0]) { // valid = valid && localPublicKeyPathInput.val().length > 0 && localPrivateKeyPathInput.val().length > 0; // } else if (selectedButton[0] === uploadButton[0]) { // valid = valid && publicKeyInput.val().length > 0 && privateKeyInput.val().length > 0; // } else if (selectedButton[0] === generateButton[0]) { var passphrase = passphraseInput.val(); var validPassphrase = passphrase.length === 0 || passphrase.length >= 8; passphraseInput.toggleClass('input-error',!validPassphrase); if (!validPassphrase) { passphraseInputSubLabel.text(RED._("editor:sidebar.project.userSettings.passphraseShort")); } else if (passphrase.length === 0) { passphraseInputSubLabel.text(RED._("editor:sidebar.project.userSettings.optional")); } else { passphraseInputSubLabel.text(""); } valid = valid && validPassphrase; // } saveButton.attr('disabled',!valid); if (popover) { popover.close(); popover = null; } }; var row = $('').appendTo(container); var addKeyDialog = $('').hide().appendTo(row); $('