mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 15:24:55 +00:00
3 lines
20 KiB
JavaScript
Executable File
3 lines
20 KiB
JavaScript
Executable File
/*eslint-disable*/
|
|
|
|
!function(){function e(e,t){var n='',s=e.match(/\d/g);if(!s)return'';var i=s.join('');return t.split('').forEach(function(e){if(i.length){if('x'!==e)return void(n+=e);n+=i[0],i=i.substring(1)}}),n;}function t(e){return 1===e.length&&!!e.match(/\d/);}function n(e,n){var s=0;return n.split('').forEach(function(n){e>0&&s++,t(n)&&e--}),s;}function s(){window.phoneInputUtil={formatValue:e,placeCursor:n}}s()}(),function(){function e(this, t, n) {if(!(this instanceof e))return new e(t);n=n||{},this.inputEl=t,this.formatString=n.formatString||s,this.onFormatValue=n.onFormatValue||function(){},this.addListeners()}function t(t,n){new e(t,n)}function n(){window.phoneNumberInput={createPhoneNumberInput:t,PhoneInput:e}}var s='(xxx) xxx-xxxx',i=e.prototype;i.addListeners=function(){this.inputEl.addEventListener('input',this.onChange.bind(this)),this.inputEl.addEventListener('change',this.onChange.bind(this))},i.onChange=function(e){var t=e.target.value,n=e.target.selectionStart,s=t.slice(0,n).replace(/\D/g,'').length,i=window.phoneInputUtil.formatValue(t,this.formatString),o=window.phoneInputUtil.placeCursor(s,i);e.target.value=i,e.target.setSelectionRange(o,o),this.onFormatValue(i,e.target)},n()}(),function(){function e(e){return[].slice.call(arguments,1).forEach(function(t){Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}function t(e,t,n){var s=document.createElement(e);return s.setAttribute('class',t),n&&n.appendChild(s),s}function n(e){var t=[].slice.call(e.querySelectorAll('option')),n={};return t.forEach(function(e){e.disabled||(n[e.value]=e.text)}),n}function s(e){return e.getAttribute('data-searchable-select-input-placeholder')}function i(e){return e.getAttribute('data-searchable-select-no-results-message')}function o(e,t){if(!t.trim())return!0;var n=t.trim().toLowerCase().split(' ').filter(Boolean),s=e.toLowerCase();return n.every(function(e){return-1!==s.indexOf(e)});}function r(e,t){for(;e.children.length>0;)e.removeChild(e.children[0]);t.forEach(function(t){e.appendChild(t)})}function a(e){var t=-1;return[].slice.call(e.parentElement.children).forEach(function(n,s){n===e&&(t=s)}),t}function l(e){var t=e.slice();return t.sort(function(e,t){return e.length>t.length?1:t.length>e.length?-1:0}),t;}function c(e,t){return l(e).reduce(function(e,n){n=n.toLowerCase();for(var s=0;s<t.length;++s)t.substring(s,s+n.length).toLowerCase()===n&&(e[s]=t.substring(s,s+n.length));return e},[]);}function u(e,t){if(!e)return t;for(var n=e.toLowerCase().split(/\s+/).filter(Boolean),s=c(n,t),i=0,o='';i<t.length;)s[i]?(o+='<strong>'+s[i]+'</strong>',i+=s[i].length):(o+=t[i],i++);return o}function h(e,t){var n=e.offsetTop+Math.ceil(e.clientHeight/2),s=n<t.scrollTop,i=n>t.scrollTop+t.clientHeight;s?d(e,t,!0):i&&d(e,t,!1)}function d(e,t,n){t.scrollTop=n?e.offsetTop:e.offsetTop-t.clientHeight+e.clientHeight}function p(e,t){var n=document.createEvent('Event');n.initEvent&&e.dispatchEvent&&(n.initEvent(t,!0,!0),e.dispatchEvent(n))}function f(){window.searchableSelectUtil={findIndexInParent:a,getValuesFromSelect:n,getSearchPlaceholder:s,getNoResultsMessage:i,highlightQueryInValue:u,makeElement:t,objectAssign:e,replaceChildren:r,scrollIntoViewIfNeeded:h,triggerEvent:p,valueMatchesQuery:o}}f()}(),function(){function e(this, e, t) {this.props={},this.props.resultsListEl=e,this.props.onResultSelect=t.onResultSelect||function(){},this.props.noResultsMessage=t.noResultsMessage||'No results found.',this.props.searchEnabled=t.searchEnabled,this.state={results:{},highlightIndex:null},this.addListeners()}function t(e){return e.classList.contains('searchable-select-result')?e:null===e.parentElement||'BODY'===e.tagName?null:t(e.parentElement)}function n(){window.searchableSelect=window.searchableSelect||{},window.searchableSelect.ResultsList=e}var s=e.prototype,i=window.searchableSelectUtil;s.addListeners=function(){this.props.resultsListEl.addEventListener('mouseover',this.onResultMouseover.bind(this)),this.props.resultsListEl.addEventListener('click',this.onResultClick.bind(this))},s.onResultMouseover=function(e){e.target.classList.contains('searchable-select-result')&&this.highlightResultElement(e.target)},s.onResultClick=function(e){var n=t(e.target);n&&(e.stopPropagation(),this.props.onResultSelect(n.getAttribute('data-value')))},s.setResults=function(e,t,n){var s=this.renderSearchResults(e,t,n);s.length||(s=[this.renderEmptySearchResults()]),i.replaceChildren(this.props.resultsListEl,s),this.state.results=i.objectAssign({},e),this.props.searchEnabled?(this.setHighlightIndex(null),this.props.resultsListEl.scrollTop=0):this.highlightSelectedResult()},s.renderSearchResults=function(e,t,n){return e=i.objectAssign({},e),Object.keys(e).map(function(s){var o=i.makeElement('li','searchable-select-result');return o.setAttribute('data-value',s),o.innerHTML=i.highlightQueryInValue(t,e[s]),n===s&&o.classList.add('selected'),o})},s.highlightSelectedResult=function(){var e=this.props.resultsListEl.querySelector('.selected');e&&this.highlightResultElement(e)},s.highlightResultElement=function(e){var t=i.findIndexInParent(e);this.setHighlightIndex(t),this.scrollHighlightedResult(t)},s.setHighlightIndex=function(e){this.getSearchResultEls().forEach(function(t,n){n===e?t.classList.add('highlighted'):t.classList.remove('highlighted')}),this.state.highlightIndex=e},s.highlightPreviousResult=function(){if(this.getSearchResultEls().length){var e=this.state.highlightIndex-1;null===this.state.highlightIndex&&(e=0),e=Math.max(e,0),this.setHighlightIndex(e),this.scrollHighlightedResult(e)}},s.highlightNextResult=function(){var e=this.getSearchResultEls().length;if(e){var t=this.state.highlightIndex+1;null===this.state.highlightIndex&&(t=0),t=Math.min(t,e-1),this.setHighlightIndex(t),this.scrollHighlightedResult(t)}},s.getSearchResultEls=function(){return[].slice.call(this.props.resultsListEl.querySelectorAll('.searchable-select-result'))},s.scrollHighlightedResult=function(e){var t=this.getSearchResultEls()[e];i.scrollIntoViewIfNeeded(t,this.props.resultsListEl)},s.renderEmptySearchResults=function(){var e=i.makeElement('li','searchable-select-no-results');return e.textContent=this.props.noResultsMessage,e},n()}(),function(){function e(this, e, t) {this.props={},this.props.searchInputEl=e,this.props.onQueryChange=t.onQueryChange||function(){},this.props.onQueryChange=t.onQueryChange||function(){},this.addListeners()}function t(){window.searchableSelect=window.searchableSelect||{},window.searchableSelect.SearchInput=e}var n=e.prototype;n.addListeners=function(){this.props.searchInputEl.addEventListener('input',this.onInput.bind(this))},n.onInput=function(e){this.props.onQueryChange(e.target.value)},n.onSearchInput=function(e){e.stopPropagation(),this.props.onQueryChange(this.props.searchInputEl.value)},t()}(),function(){function e(this, t, n) {if(!(this instanceof e))return new e(t,n);e.allInstances=e.allInstances||[],e.allInstances.push(this),this.props={},this.props.originalSelect=t,this.props.allValues=s.getValuesFromSelect(this.props.originalSelect),this.props.aliases=n.aliases||{},this.props.onOpen=n.onOpen||function(){},this.props.onClose=n.onClose||function(){},this.props.valueMatchesQuery=s.valueMatchesQuery||n.valueMatchesQuery,this.props.searchEnabled=!0,n.hasOwnProperty('searchEnabled')&&(this.props.searchEnabled=!!n.searchEnabled),this.props.searchPlaceholder=s.getSearchPlaceholder(this.props.originalSelect)||'Search...',this.props.noResultsMessage=s.getNoResultsMessage(this.props.originalSelect)||'No results found.',this.state={open:!1,query:'',searchResults:s.getValuesFromSelect(this.props.originalSelect),selectedValue:this.props.originalSelect.value},this.createElements(),this.createComponents(),this.props.originalSelect.parentElement.appendChild(this.elements.containerEl),this.addListeners(),this.render()}function t(t,n){return new e(t,n)}function n(){window.searchableSelect={createSearchableSelect:t,SearchableSelect:e}}var s=window.searchableSelectUtil,i=window.searchableSelect.SearchInput,o=window.searchableSelect.ResultsList,r=e.prototype;r.createComponents=function(){var e;this.props.searchEnabled&&(e=new i(this.elements.searchInputEl,{onQueryChange:this.onQueryChange.bind(this),searchPlaceholder:this.props.searchPlaceholder}));var t=new o(this.elements.searchResultsEl,{onResultSelect:this.onResultSelect.bind(this),noResultsMessage:this.props.noResultsMessage,searchEnabled:this.props.searchEnabled});this.components={searchInput:e,resultsList:t}},r.createElements=function(){var e,t=s.makeElement('div','searchable-select-container'),n=s.makeElement('div','searchable-select-dropdown',t);this.props.searchEnabled&&(e=s.makeElement('input','searchable-select-input',n),e.setAttribute('placeholder',this.props.searchPlaceholder),e.setAttribute('autocorrect','off'),e.setAttribute('autocomplete','off'),e.setAttribute('spellcheck','false'));var i=s.makeElement('ul','searchable-select-results',n);this.elements={containerEl:t,containerParentEl:this.props.originalSelect.parentElement,dropdownEl:n,searchInputEl:e,searchResultsEl:i}},r.reloadValuesFromSelect=function(){this.props.allValues=s.getValuesFromSelect(this.props.originalSelect),this.setState({query:'',searchResults:s.getValuesFromSelect(this.props.originalSelect),selectedValue:this.props.originalSelect.value})},r.addListeners=function(){this.elements.containerParentEl.addEventListener('click',this.onContainerClick.bind(this)),document.body.addEventListener('click',this.onBodyClick.bind(this)),document.body.addEventListener('keydown',this.onBodyKeydown.bind(this)),this.props.originalSelect.addEventListener('focus',this.onSelectFocus.bind(this)),this.elements.containerEl.addEventListener('focusout',this.onFocusOut.bind(this))},r.onSelectFocus=function(e){e.stopPropagation(),e.target.blur(),this.state.open||this.open()},r.onQueryChange=function(e){this.setQuery(e)},r.onResultSelect=function(e){this.setSelection(e)},r.onBodyKeydown=function(e){this.state.open&&-1!==[13,27,38,40].indexOf(e.keyCode)&&(e.stopPropagation(),e.preventDefault(),40===e.keyCode?this.components.resultsList.highlightNextResult():38===e.keyCode?this.components.resultsList.highlightPreviousResult():13===e.keyCode?this.selectHighlightedResult():27===e.keyCode&&this.close())},r.onContainerClick=function(e){e.stopPropagation(),e.preventDefault(),this.state.open?e.target!==this.elements.containerParentEl&&e.target!==this.props.originalSelect||this.close():this.open()},r.onBodyClick=function(){this.close()},r.onFocusOut=function(){setTimeout(function(this) {'ontouchstart'in window&&this.close()}.bind(this),10)},r.selectHighlightedResult=function(){var e=this.components.resultsList.state.highlightIndex,t=Object.keys(this.state.searchResults),n=t[e];n||1!==t.length||(n=t[0]),n&&this.setSelection(n)},r.setSelection=function(e){this.setState({open:!1,selectedValue:e}),this.elements.searchInputEl&&this.elements.searchInputEl.blur()},r.setState=function(e){var t=s.objectAssign({},this.state,e);this.state=t,this.render()},r.filterValuesByQuery=function(e){var t={},n=this.props.allValues,i=this.props.aliases||{},o=this.props.valueMatchesQuery||s.valueMatchesQuery;return Object.keys(n).forEach(function(s){var i=n[s];(o(i,e)||o(s,e))&&(t[s]=i)}),Object.keys(i).forEach(function(s){var r=i[s];o(s,e)&&(t[r]=n[r])}),t},r.render=function(){this.components.resultsList.setResults(this.state.searchResults,this.state.query,this.state.selectedValue),this.state.open?(this.elements.containerEl.classList.add('dropdown-open'),this.props.originalSelect.classList.add('dropdown-open')):(this.elements.containerEl.classList.remove('dropdown-open'),this.props.originalSelect.classList.remove('dropdown-open')),this.state.selectedValue!==this.props.originalSelect.value&&(this.props.originalSelect.value=this.state.selectedValue,s.triggerEvent(this.props.originalSelect,'change')),this.props.originalSelect.value?this.props.originalSelect.classList.add('has-value'):this.props.originalSelect.classList.remove('has-value')},r.closeAllInstances=function(){e.allInstances.forEach(function(e){e.close()})},r.open=function(){this.closeAllInstances(),this.setState({open:!0}),this.elements.searchInputEl&&this.elements.searchInputEl.focus(),this.props.onOpen({searchableSelect:this,containerEl:this.elements.containerEl})},r.close=function(){this.setState({open:!1}),this.elements.searchInputEl&&this.elements.searchInputEl.blur(),this.props.onClose({searchableSelect:this,containerEl:this.elements.containerEl})},r.setQuery=function(e){if(this.state.query!==e){var t=this.filterValuesByQuery(e);this.setState({query:e,searchResults:t,highlightedIndex:0})}},n()}(),function(){function e(){var e=document.querySelector('form'),t=document.querySelector('.phone-number-form');e.addEventListener('change',n),e.addEventListener('submit',i),t.addEventListener('submit',o)}function t(e){if(window.Analytics&&window.Analytics.getPreviousEventId()){var t=Analytics.getPreviousEventId();e.querySelector('[name="analytics_event_id"]').value=t}}function n(e){s(e.target.getAttribute('name'))}function s(e){var t='contact_sales_form_changed_'+e;p.emitActionOnce(t)}function i(e){window.contactSales.formValidation.validateForm()&&(t(e.target),l(),h(),u())}function o(e){t(e.target),c()}function r(){p.emitAction('contact_sales_form_error')}function a(){p.emitAction('contact_sales_phone_form_error')}function l(){p.emitAction('contact_sales_form_success')}function c(){p.emitAction('contact_sales_phone_form_success')}function u(){window.ga&&window.ga('send','event','Forms','Message to Sales','Message to Sales')}function h(){window.siteAnalytics&&window.siteAnalytics.trackFacebookEvent&&window.siteAnalytics.trackFacebookEvent('Lead')}function d(){window.contactSales=window.contactSales||{},window.contactSales.analytics={sendSubmitError:r,sendSubmitPhoneError:a}}var p=window.siteAnalyticsUtil;d(),document.addEventListener('DOMContentLoaded',e)}(),function(){function e(){var e=document.querySelector('form');return[].slice.call(e.querySelectorAll('[name]')).reduce(function(e,t){return e[t.getAttribute('name')]=t.value,e},{})}function t(){d(),n()}function n(){var e=document.querySelector('form'),t=e.querySelector('[name=country]');e.addEventListener('focusin',i),e.addEventListener('focusout',o),t.addEventListener('change',r)}function s(e){return e.classList.contains('form-row')}function i(){u()}function o(){u()}function r(e){a(e.target.value)}function a(e){var t=window.contactSales.volumeOptions.dataForCountry(e),n=document.querySelector('[name="volume"]');if(t){for(var s=t.map(function(e){var t=document.createElement('option');return t.textContent=e.label,t.value=e.value,t});n.children.length>0;)n.removeChild(n.children[0]);s.forEach(function(e){n.appendChild(e)}),n.value='',n.options[0].selected=!0,v.reloadValuesFromSelect()}}function l(e){var t=h(e.containerEl,s);u(),t.classList.add('has-focus')}function c(e){var t=h(e.containerEl,s);u(),t.classList.remove('has-focus')}function u(){var e=document.activeElement,t=h(e,s);[].slice.call(document.querySelectorAll('.form-row')).forEach(function(e){e===t?e.classList.add('has-focus'):e.classList.remove('has-focus')})}function h(e,t){e.parentElement;return document.body===e||null===e.parentElement?null:t(e)?e:h(e.parentElement,t)}function d(){var e=document.querySelector('form'),t=e.querySelector('[name=country]'),n=e.querySelector('[name=volume]'),s={'u.s.':'US','u.s.a.':'US',us:'US',usa:'US',uk:'GB','u.k.':'GB'},i={aliases:s,onOpen:l,onClose:c},o={onOpen:l,onClose:c,searchEnabled:!1};m=window.searchableSelect.createSearchableSelect(t,i),v=window.searchableSelect.createSearchableSelect(n,o)}function p(){return m}function f(){return v}function g(){window.contactSales=window.contactSales||{},window.contactSales.inputs={getCountryInput:p,getVolumeInput:f,getFormValues:e}}var m=null,v=null;g(),document.addEventListener('DOMContentLoaded',t)}(),function(){function e(){return t()}function t(){var e=document.querySelector('form'),t=[].slice.call(e.querySelectorAll('[required]'));return t.forEach(function(e){n(e)}),t.every(function(e){return-1===e.className.indexOf('invalid')})}function n(e){e.value?e.classList.remove('invalid-missing'):e.classList.add('invalid-missing'),'email'===e.getAttribute('name')&&s(e),'website'===e.getAttribute('name')&&i(e)}function s(e){o(e.value)?e.classList.remove('invalid-value'):e.classList.add('invalid-value')}function i(e){r(e.value)?e.classList.remove('invalid-value'):e.classList.add('invalid-value')}function o(e){e=e.trim();var t=e.match(/@/g);return!(!t||1!==t.length)&&('@'!==e[0]&&'@'!==e[e.length-1])}function r(e){var t=e.lastIndexOf('.');return-1===[-1,0,e.length-1].indexOf(t)}function a(e){-1!==['SELECT','INPUT','TEXTAREA'].indexOf(e.target.tagName)&&e.target.hasAttribute('required')&&n(e.target)}function l(){var e=document.querySelector('form');e.addEventListener('change',a),e.addEventListener('focusout',a)}function c(){window.contactSales=window.contactSales||{},window.contactSales.formValidation={validateForm:e}}c(),document.addEventListener('DOMContentLoaded',l)}(),function(){function e(e){try{return JSON.parse(e)}catch(t){return e}}function t(e,t,n){s('POST',e,t,n)}function n(e,t){s('GET',e,null,t)}function s(t,n,s,i){var o=document.querySelector('form [name=csrf-token]').getAttribute('value'),r=new XMLHttpRequest;r.open(t,n),s&&r.setRequestHeader('Content-Type','application/json;charset=UTF-8'),r.setRequestHeader('x-oneuptime-csrf-token',o),i&&(r.onreadystatechange=function(){4==r.readyState&&i(e(r.responseText),r)}),s?r.send(JSON.stringify(s)):r.send()}function i(){window.contactSales=window.contactSales||{},window.contactSales.request={postRequest:t,getRequest:n}}i()}(),function(){function e(e){e.preventDefault(),u||window.contactSales.formValidation.validateForm()&&(c=window.contactSales.inputs.getFormValues(),window.contactSales.request.postRequest(e.target.action,c,s),t(e.target),o(!1,c.email))}function t(e){var t=e.querySelector('.spinner'),n=e.querySelector('input[type="submit"]');u=!0,n.disabled=!0,n.classList.add('common-Button--disabled'),t&&t.classList.add('shown')}function n(e){var t='submit'===e.target.getAttribute('type');13!==e.keyCode||t||e.preventDefault()}function s(){}function i(){document.body.classList.add('no-phone')}function o(e){var t=document.querySelector('.submitted-email');e||i(),t&&(t.textContent=c.email),document.body.classList.add('form-submitted')}function r(){return l}function a(){var t=document.querySelector('form');t.addEventListener('submit',e),t.addEventListener('keydown',n),window.contactSales.initialForm={getFormToken:r}}var l,c,u=!1;document.addEventListener('DOMContentLoaded',a)}(),function(){function e(e){if(e.preventDefault(),!c&&i(e.target)){n(e.target);var s=t(e.target);window.contactSales.request.postRequest(e.target.action,s,function(){}),r()}}function t(e){var t=[].slice.call(e.querySelectorAll('[name]')),n=t.reduce(function(e,t){return e[t.getAttribute('name')]=t.value,e},{});return n.phone=n.phone.split(/\D+/).join(''),n;}function n(e){var t=window.contactSales.inputs.getFormValues(),n=t.email,s=window.contactSales.initialForm.getFormToken(),i=e.querySelector('[name="email"]'),o=e.querySelector('[name="token"]');i.value=n,o.value=s}function s(e,t){e&&t.classList.remove('invalid-missing'),o(e)&&t.classList.remove('invalid-value')}function i(e){var t=e.querySelector('[name="phone"]');if(t.classList.remove('invalid-value'),t.classList.remove('invalid-missing'),!t.value)return t.classList.add('invalid-missing'),!1;var n=o(t.value);return n||t.classList.add('invalid-value'),n}function o(e){var t=(e||'').match(/\d/g);return t&&10===t.length}function r(){var e=document.querySelector('.phone-number-form'),t=e.querySelector('input[type="submit"]');document.body.classList.add('phone-finished'),c=!0,t.disabled=!0,t.classList.add('common-Button--disabled')}function a(){var t=document.querySelector('.phone-number-form'),n=t.querySelector('[name="phone"]');t.addEventListener('submit',e),window.phoneNumberInput.createPhoneNumberInput(n,{formatString:l,onFormatValue:s})}var l='(xxx) xxx-xxxx',c=!1;document.addEventListener('DOMContentLoaded',a)}(),function(){function e(){window.contactSales.request.getRequest('/contact/sales/volume_options',t)}function t(e){i=e,o=!0}function n(e){return o?[i.empty_volume_option,i.just_starting_volume_option].concat(i.data_by_country[e]).map(function(e){var t=e.value;return'object'==typeof t&&(t=JSON.stringify(t)),e.value=t,e}):null}function s(){window.contactSales=window.contactSales||{},window.contactSales.volumeOptions={dataForCountry:n},window.addEventListener('load',e)}var i={},o=!1;s()}(); |