summaryrefslogtreecommitdiff
path: root/Postman/Postman-Configuration/postman_manual_config.js
diff options
context:
space:
mode:
Diffstat (limited to 'Postman/Postman-Configuration/postman_manual_config.js')
-rw-r--r--Postman/Postman-Configuration/postman_manual_config.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/Postman/Postman-Configuration/postman_manual_config.js b/Postman/Postman-Configuration/postman_manual_config.js
new file mode 100644
index 0000000..14d4d9f
--- /dev/null
+++ b/Postman/Postman-Configuration/postman_manual_config.js
@@ -0,0 +1,78 @@
+var transports = [];
+
+jQuery(document).ready(
+ function() {
+
+ // display password on entry
+ enablePasswordDisplayOnEntry('input_basic_auth_password',
+ 'togglePasswordField');
+
+ // tabs
+ jQuery("#config_tabs").tabs();
+
+ // on first viewing, determine whether to show password or
+ // oauth section
+ reloadOauthSection();
+
+ // add an event on the transport input field
+ // when the user changes the transport, determine whether
+ // to show or hide the SMTP Settings
+ jQuery('select#input_transport_type').change(function() {
+ hide('#wizard_oauth2_help');
+ reloadOauthSection();
+ switchBetweenPasswordAndOAuth();
+ });
+
+ // add an event on the authentication input field
+ // on user changing the auth type, determine whether to show
+ // password or oauth section
+ jQuery('select#input_auth_type').change(function() {
+ switchBetweenPasswordAndOAuth();
+ doneTyping();
+ });
+
+ // setup before functions
+ var typingTimer; // timer identifier
+ var doneTypingInterval = 250; // time in ms, 5 second for
+ // example
+
+ // add an event on the hostname input field
+ // on keyup, start the countdown
+ jQuery(postman_hostname_element_name).keyup(function() {
+ clearTimeout(typingTimer);
+ if (jQuery(postman_hostname_element_name).val) {
+ typingTimer = setTimeout(doneTyping, doneTypingInterval);
+ }
+ });
+
+ // user is "finished typing," do something
+ function doneTyping() {
+ if (jQuery(postman_input_auth_type).val() == 'oauth2') {
+ reloadOauthSection();
+ }
+ }
+ });
+function reloadOauthSection() {
+ var hostname = jQuery(postman_hostname_element_name).val();
+ var transport = jQuery('#input_transport_type').val();
+ var authtype = jQuery('select#input_auth_type').val();
+ var data = {
+ 'action' : 'manual_config',
+ 'auth_type' : authtype,
+ 'hostname' : hostname,
+ 'transport' : transport,
+ };
+ jQuery.post(ajaxurl, data, function(response) {
+ if (response.success) {
+ handleConfigurationResponse(response);
+ }
+ }).fail(function(response) {
+ ajaxFailed(response);
+ });
+}
+function switchBetweenPasswordAndOAuth() {
+ var transportName = jQuery('select#input_transport_type').val();
+ transports.forEach(function(item) {
+ item.handleTransportChange(transportName);
+ })
+}