selectAccount = function ( oSelect, sSide ) { //alert( oSelect.value ); var aParts = oSelect.value.split( ':' ); var nId = aParts[0]; var sType = aParts[1]; if( nId == 66 && sType == 'MSC' ) { $.ajax({ type: 'GET', url: 'ajax/ajx_segments.cfm', data: 'side=' + sSide, success: function( oRequest ) { $('#socket_2' + sSide ).html( oRequest ); } }); } else if ( sType == 'BRO' || sType == 'CHO' ) { $.ajax({ type: 'GET', url: 'ajax/ajx_lists.cfm', data: 'ownerId=' + nId + '&ownerType=' + sType + '&side=' + sSide, success: function( oRequest ) { $('#socket_2' + sSide ).html( oRequest ); } }); } else { $('#socket_2' + sSide).html(''); //empty the socket } } edit = function( sMethod, nSourceId, nId, sStatus ) { $.ajax({ url: 'ajax/ajx_edit.cfm', cache: 0, data: 'method=' + sMethod + '&sourceId=' + nSourceId + '&id=' + nId, success: function( result ) { $( '#cho_data_' + nId ).html( result ); } }); } save = function( nId ) { //alert( 'saveFields function' );{ var validated = true; var postData = $( '#frm_edit_' + nId ).serializeArray(); $( postData ).each( function( i ) { var eInput = $( '[name=' + postData[i].name + ']' ); if( eInput.prop( 'required' ) && eInput.val() == '' ) { alert( eInput.attr( 'message' ) ); eInput.focus(); validated = false; return validated; } }); if( validated ) { $( '#frm_edit_' + nId ).submit( function( e ) { var formURL = $( this ).attr( "action" ); $.ajax({ url: formURL, type: "POST", data: postData, success: function( result, textStatus, xhr ) { var bgStatus = xhr.getResponseHeader( 'x-fse-bg-status' ); $( '#cho_data_' + postData[0].value ).html( result ); $( '#cho_data_' + postData[0].value ).addClass( bgStatus ); } }); e.preventDefault(); }); $( '#frm_edit_' + nId ).submit(); } } copy = function( nSourceId, nId ) { $( '#cho_name_' + nId ).val( $('#name_' + nSourceId ).text() ); $( '#cho_address_' + nId ).val( $('#address_' + nSourceId ).text() ); $( '#cho_city_' + nId ).val( $('#city_' + nSourceId ).text() ); $( '#cho_state_' + nId ).val( $('#state_' + nSourceId ).text() ); $( '#cho_zipcode_' + nId ).val( $('#zipcode_' + nSourceId ).text() ); } create = function( sMethod, nSourceId ) { //alert( 'copyFields function' ); var validated = true; $( '#method_' + nSourceId ).val( sMethod ); var postData = $( '#frm_create_' + nSourceId ).serializeArray(); $( postData ).each( function( i ) { var eInput = $( '[name=' + postData[i].name + ']' ); if( eInput.prop( 'required' ) && eInput.val() == '' ) { alert( eInput.attr( 'message' ) ); eInput.focus(); validated = false; return validated; } }); if( validated ) { $( '#frm_create_' + nSourceId ).submit( function( e ) { var formURL = $( this ).attr( "action" ); $.ajax({ url: formURL, type: "POST", data: postData, success: function( result, textStatus, xhr ) { var nNewChoId = xhr.getResponseHeader( 'x-fse-new-cho-id' ); var bgStatus = xhr.getResponseHeader( 'x-fse-bg-status' ); $( '#copy_' + nSourceId ).html( result ); $( '#copy_' + nSourceId ).attr( 'id', 'cho_data_' + nNewChoId ); $( '#cho_data_' + nNewChoId ).removeClass().addClass( bgStatus ); } }); e.preventDefault(); }); $( '#frm_create_' + nSourceId ).submit(); } } startLoader = function( sLoadingClass, sContainer ) { $( '.' + sLoadingClass ).show(); $( '.' + sContainer ).css( { opacity:0.2 } ); } endLoader = function( sLoadingClass, sContainer ) { $( '.' + sLoadingClass ).hide(); $( '.' + sContainer ).css( { opacity:1.0 } ); } compare = function( oForm ) { $( '#results' ).html('') //empty the results everytime var postData = $( oForm ).serializeArray(); var validated = true; $( postData ).each( function( i ){ var eInput = $( '[name=' + postData[i].name + ']' ); if( eInput.prop( 'required' ) && eInput.val() == '' ) { alert( eInput.attr( 'message' ) ); eInput.focus(); validated = false; return validated; } }); if( validated ) { $.ajax({ url: 'ajax/ajx_results.cfm', type: "GET", data: postData, beforeSend: function() { startLoader( 'loading', 'container' ); }, complete: function() { endLoader( 'loading', 'container' ); }, success: function( result, textStatus, xhr ) { $( '#results' ).html( result ); if( xhr.getResponseHeader( 'x-fse-total-pages' ) > 0 ) { $('#pagination').twbsPagination({ totalPages: xhr.getResponseHeader( 'x-fse-total-pages' ), visiblePages: 7, href: 'javascript:paginate( {{number}} )' }); } } }); } } paginate = function( nPage ) { var postData = $( '#frm_criteria' ).serializeArray(); $.ajax({ url: 'ajax/ajx_results.cfm?page=' + nPage, type: "GET", data: postData, beforeSend: function() { startLoader( 'loading', 'container' ); }, complete: function() { endLoader( 'loading', 'container' ); }, success: function( result, textStatus, xhr ) { $( '#results' ).html( result ); $('#pagination').twbsPagination({ totalPages: xhr.getResponseHeader( 'x-fse-total-pages' ), startPage: nPage, visiblePages: 7, href: 'javascript:paginate( {{number}} )' }); } }); } map = function( nSourceId, nId, sMethod ) { $.ajax({ url: 'ajax/ajx_map.cfm', type: 'POST', data: 'sourceId=' + nSourceId + '&id=' + nId, success: function( result, textStatus, xhr ) { var bgStatus = xhr.getResponseHeader( 'x-fse-bg-status' ); if( sMethod == 'new' ) { $( '#copy_' + nSourceId ).attr( 'id', 'cho_data_' + nId ); } $( '#cho_data_' + nId ).html( result ); $( '#cho_data_' + nId ).removeClass().addClass( bgStatus ); $( '#myModal' ).modal( 'hide' ); } }); } sanitize = function( nSourceId ) { /*var oName = document.getElementById( 'cho_name_' + nSourceId ); var str = oName.value; str = str.toLowerCase().replace(/(^|\s)[a-z]/g, function( letter ) { return letter.toUpperCase(); }); oName.value = str;*/ var oElements = []; oElements = [ 'cho_name', 'cho_address', 'cho_city' ]; for( var e = 0; e < oElements.length; e++ ) { var eInput = document.getElementById( oElements[e] + '_' + nSourceId ); var str = eInput.value; str = str.toLowerCase().replace( /(^|\s|-)[a-z]/g, function( letter ) { return letter.toUpperCase(); }); eInput.value = str; } } searchModal = function( nOwnerId, sOwnerType, nSourceId ) { $.ajax({ url: 'ajax/ajx_search.cfm', type: 'GET', data: 'ownerId=' + nOwnerId + '&ownerType=' + sOwnerType + '&sourceId=' + nSourceId, success: function( result ) { var $myModal = $( '#myModal' ); $myModal.html( result ); $myModal.modal( 'show' ); } }); } mappingSearch = function( nSourceId ) { //alert( 'mappingSearch function triggered' ); var sSelect = document.getElementById( 'searchOpt' ).value; var sText = document.getElementById( 'searchTxt' ).value; var sURL = 'ajax/inc_searchResults.cfm?sourceId=' + nSourceId + '&searchOpt=' + sSelect + '&searchTxt=' + sText; $( '#searchResults').html( '
Searching, please wait...
' ), $.ajax({ url: sURL, type: 'GET', success: function( result ) { $( '#searchResults' ).html( result ); $( '#oprCount' ).html( $( '#fsecount' ).attr( 'fse:count' ) ); } }); } operatorSearchTimeout = null; mappingSearchTrigger = function( nSourceId ) { var nTimeout = 600; if( operatorSearchTimeout ) { clearTimeout( operatorSearchTimeout ) operatorSearchTimeout = null; } operatorSearchTimeout = setTimeout( function(){ mappingSearch( nSourceId ) }, 600 ); }