{"id":361,"date":"2025-05-19T11:55:50","date_gmt":"2025-05-19T15:55:50","guid":{"rendered":"https:\/\/driscollart.com\/bikelatchdev\/?page_id=361"},"modified":"2025-05-19T11:57:01","modified_gmt":"2025-05-19T15:57:01","slug":"my-searches","status":"publish","type":"page","link":"https:\/\/bikelatch.com\/bikelatchdev\/my-profile\/my-searches\/","title":{"rendered":"My Searches"},"content":{"rendered":"<input type='hidden' id='ajax-nonce-token-not-logged-in' value='fe8539fed4'\/><div id=\"login-pass-form-container\">\n    <div>\n        <p><span id=\"nliHeaderText\" data-bind=\"html: headerText\"><\/span><br>Not a member yet? <a id=\"nliSignupLink\" data-bind=\"attr: {href: signUpUrl}\">Sign up!<\/a><\/p>\n    <\/div>\n    <div id=\"login-pass-form\">\n        <form>\n            <div class=\"form-group\">\n                <div class=\"label-container\">\n                    <span class=\"invalid-field\" data-bind=\"visible: showFormErrors() && !userNameFieldValid()\" style=\"display: none;\">*<\/span>\n                    <label>User Name:<\/label>\n                <\/div>\n                <div class=\"field-container\">\n                    <input id=\"nliUserName\" type=\"text\" data-bind=\"textInput: userNameField\" maxlength=\"60\">\n                <\/div>\n            <\/div>\n            <div class=\"form-group\">\n                <div class=\"label-container\">\n                    <span class=\"invalid-field\" data-bind=\"visible: showFormErrors() && !passwordFieldValid()\" style=\"display: none;\">*<\/span>\n                    <label>Password:<\/label>\n                <\/div>\n                <div class=\"field-container\"><input id=\"nliPassword\" type=\"password\" data-bind=\"textInput: passwordField\" maxlength=\"255\">\n                <\/div>\n            <\/div>\n            <div class=\"form-group\">\n                <div class=\"label-container\">&nbsp;\n                <\/div>\n                <div class=\"field-container\"><button id=\"nliLoginButton\" data-bind=\"click: clickLogin\">Log In<\/button><\/div>\n            <\/div>\n            <div class=\"form-group\">\n                <div class=\"label-container\">&nbsp;\n                <\/div>\n                <div class=\"field-container\">\n                    <a id=\"nliForgotUserName\" data-bind=\"attr: { href: forgotUserNameUrl }\">forgot username?<\/a>\n                    <a id=\"nliForgotPassword\" data-bind=\"attr: { href: forgotPasswordUrl }\">forgot password?<\/a>\n                <\/div>\n\n            <\/div>\n        <\/form>\n\n    <\/div>\n<\/div>\n<div id=\"login-dialog\" title=\"Dialog Title\">\n    <p id=\"login-dialog-body\"><\/p>\n<\/div>\n<div id=\"modal-wait-dialog\" style=\"display: none;\" data-bind=\"visible: updateActive\">\n    <div class='progress-spinner' style='margin: auto;'><\/div>\n    <p style=\"text-align: center;\" id=\"wait-dialog-body\"><\/p>\n<\/div>\n\n<script>\n    var pageValidator = (function () {\n        if (typeof window !== 'undefined' && typeof window.bikeLatchSharedValidationHelper === 'function') {\n            return new window.bikeLatchSharedValidationHelper();\n        }\n        if (typeof bikeLatchSharedValidationHelper === 'function') {\n            return new bikeLatchSharedValidationHelper();\n        }\n        return {\n            isNullUndefinedBlankOrWhitespace: function (valueToParse) {\n                return valueToParse === null ||\n                    valueToParse === undefined ||\n                    valueToParse === '' ||\n                    valueToParse.toString().trim().length === 0;\n            }\n        };\n    })();\n\n    function notLoggedInViewModel(ajaxUrl, headerText, signUpUrl, forgotUserNameUrl, forgotPasswordUrl, apiBaseUrl, apiGuid) {\n        var self = this;\n        self.headerText = ko.observable(headerText);\n        self.ajaxUrl = ko.observable(ajaxUrl);\n        self.signUpUrl = ko.observable(signUpUrl);\n        self.forgotUserNameUrl = ko.observable(forgotUserNameUrl);\n        self.forgotPasswordUrl = ko.observable(forgotPasswordUrl);\n        self.apiBaseUrl = apiBaseUrl || (window.bikeLatchAuthApi ? window.bikeLatchAuthApi.base : '');\n        self.apiGuid = apiGuid || (window.bikeLatchAuthApi ? window.bikeLatchAuthApi.guid : '');\n        self.waitDialogTitle = ko.observable('Please Wait');\n        self.waitDialogBody = ko.observable('Logging you in...');\n\n        self.showFormErrors = ko.observable(false);\n\n        self.userNameField = ko.observable();\n        self.passwordField = ko.observable();\n        self.updateActive = ko.observable(false);\n\n        self.updateActive.subscribe(function (newValue) {\n            if (newValue === false) {\n                self.hideWaitDialog();\n            } else {\n                self.showWaitDialog();\n            }\n        });\n\n        self.showWaitDialog = function () {\n\n            \/\/ timing issue, set dialog manually\n            jQuery('#wait-dialog-body').html(ko.unwrap(self.waitDialogBody));\n\n            jQuery(\"#modal-wait-dialog\").dialog({\n                modal: true,\n                title: ko.unwrap(self.waitDialogTitle),\n                resizable: false,\n                draggable: false,\n                closeOnEscape: false,\n                open: function (event, ui) {\n                    jQuery(\"#modal-wait-dialog\").closest(\".ui-dialog\").find(\".ui-dialog-titlebar-close\").hide(); \/\/ Hide the close button\n                }\n            });\n        };\n\n        self.hideWaitDialog = function () {\n            jQuery(\"#modal-wait-dialog\").dialog(\"close\");\n        };\n\n        self.formValid = ko.pureComputed(function () {\n            return self.userNameFieldValid() && self.passwordFieldValid();\n        }, this);\n\n        self.userNameFieldValid = ko.pureComputed(function () {\n            return !pageValidator.isNullUndefinedBlankOrWhitespace(self.userNameField());\n        }, this);\n\n        self.passwordFieldValid = ko.pureComputed(function () {\n            return !pageValidator.isNullUndefinedBlankOrWhitespace(self.passwordField());\n        }, this);\n\n        self.buildApiUrl = function (path) {\n            if (!self.apiBaseUrl) {\n                return '';\n            }\n\n            if (path.startsWith('\/')) {\n                return self.apiBaseUrl + path;\n            }\n\n            return self.apiBaseUrl + '\/' + path;\n        };\n\n        self.ensureApiConfig = function () {\n            if (!self.apiBaseUrl || !self.apiGuid) {\n                throw new Error('Login API is not configured on this site.');\n            }\n        };\n\n        self.fetchAuthNonce = function () {\n            return new Promise(function (resolve, reject) {\n                try {\n                    self.ensureApiConfig();\n                } catch (configError) {\n                    reject(configError);\n                    return;\n                }\n\n                jQuery.ajax({\n                    url: self.buildApiUrl('\/auth\/nonce'),\n                    type: 'POST',\n                    contentType: 'application\/json',\n                    data: JSON.stringify({guid: self.apiGuid})\n                }).done(function (nonceResponse) {\n                    if (nonceResponse && nonceResponse.data && nonceResponse.data.nonce) {\n                        resolve(nonceResponse.data.nonce);\n                    } else {\n                        reject(new Error('Unable to retrieve login nonce.'));\n                    }\n                }).fail(function (jqXHR) {\n                    var message = 'Unable to retrieve login nonce.';\n                    if (jqXHR.responseJSON && jqXHR.responseJSON.error && jqXHR.responseJSON.error.message) {\n                        message = jqXHR.responseJSON.error.message;\n                    }\n                    reject(new Error(message));\n                });\n            });\n        };\n\n        self.showDialog = function (title, body) {\n            loginShowDialog(title, body);\n        };\n\n        self.performLogin = function (wp_user_name, wp_pass) {\n            return self.fetchAuthNonce().then(function (nonce) {\n                return new Promise(function (myResolve, myReject) {\n                    jQuery.ajax({\n                        url: self.buildApiUrl('\/auth\/login'),\n                        type: 'POST',\n                        headers: {'X-BikeLatch-Nonce': nonce},\n                        contentType: 'application\/json',\n                        data: JSON.stringify({\n                            user_name: wp_user_name,\n                            password: wp_pass\n                        })\n                    }).done(function (loginResult) {\n                        var success = loginResult && loginResult.data && loginResult.data.success === true;\n                        var exception = loginResult && loginResult.error && loginResult.error.message ? loginResult.error.message : null;\n                        myResolve({success: success, exception: exception});\n                    }).fail(function (failData) {\n                        console.log(failData);\n                        myReject({success: false, data: [], errorData: failData});\n                    });\n                });\n            }).catch(function (error) {\n                return {success: false, exception: error.message};\n            });\n        };\n\n        self.clickLogin = function () {\n            self.showFormErrors(true);\n            if (!self.formValid())\n                return;\n\n            self.updateActive(true);\n\n            self.performLogin(self.userNameField(), self.passwordField()).then(function (loginResult) {\n                self.updateActive(false);\n                if (loginResult.success) {\n                    location.reload(true);\n                } else {\n                    self.showDialog('Unable To Log In', 'Invalid username\/password combination');\n                }\n            }, function (loginFailure) {\n                self.updateActive(false);\n                self.showDialog('Error', 'Unable to perform login.');\n                console.log(loginFailure);\n            });\n        };\n\n    }\n    ;\n\n    function loginShowDialog(title, body) {\n        setTimeout(function () {\n            var opt = {\n                autoOpen: false,\n                modal: true,\n                title: title\n            };\n            jQuery('#login-dialog-body').html(body);\n            var loginRegisterDialog = jQuery('#login-dialog').dialog(opt);\n            loginRegisterDialog.dialog(\"open\");\n        }, 500);\n    }\n    ;\n\n\n\n<\/script>\n<script type='text\/javascript'>\n            jQuery(document).ready(function () {\n               ko.applyBindings(new notLoggedInViewModel('https:\/\/bikelatch.com\/bikelatchdev\/wp-admin\/admin-ajax.php', 'Please log in to access your saved searches.', 'signup', 'signup\/#\/login\/forgotusername', 'signup\/#\/login\/forgotpassword', 'https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/bikelatch\/api\/v2', '0532ebc8-5dbb-4a96-a405-aea65b3f5849'), jQuery('#login-pass-form-container')[0]);\n            });\n        <\/script>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":101,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-361","page","type-page","status-publish","hentry","","tg-column-two"],"_links":{"self":[{"href":"https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/wp\/v2\/pages\/361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/wp\/v2\/comments?post=361"}],"version-history":[{"count":1,"href":"https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/wp\/v2\/pages\/361\/revisions"}],"predecessor-version":[{"id":362,"href":"https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/wp\/v2\/pages\/361\/revisions\/362"}],"up":[{"embeddable":true,"href":"https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/wp\/v2\/pages\/101"}],"wp:attachment":[{"href":"https:\/\/bikelatch.com\/bikelatchdev\/wp-json\/wp\/v2\/media?parent=361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}