Edit case issues fixed - Now add case and edit case are working fine
This commit is contained in:
@@ -31,8 +31,7 @@ Owner of DHTMLgoodies.com
|
||||
var ajax_list_externalFile = 'getlocality'; // Path to external file
|
||||
var minimumLettersBeforeLookup = 1; // Number of letters entered before a lookup is performed.
|
||||
|
||||
var ajax_list_objects = new Array();
|
||||
var ajax_list_cachedLists = new Array();
|
||||
var ajax_list_cachedLists = new Array();
|
||||
var ajax_list_activeInput = false;
|
||||
var ajax_list_activeItem;
|
||||
var ajax_list_optionDivFirstItem = false;
|
||||
@@ -75,11 +74,11 @@ Owner of DHTMLgoodies.com
|
||||
ajax_list_activeInput.value = tmpValue;
|
||||
if(document.getElementsByName(ajax_list_activeInput.name + '_hidden')[0])
|
||||
{
|
||||
document.getElementsByName(ajax_list_activeInput.name + '_hidden')[0].value = inputObj.id.split("#-#")[0];
|
||||
if(ajax_list_externalFile == 'getlocality')
|
||||
{
|
||||
document.getElementsByName(ajax_list_activeInput.name + '_pincode')[0].value = inputObj.id.split("#-#")[1];
|
||||
document.getElementsByName(ajax_list_activeInput.name + '_citylist')[0].value = inputObj.id.split("#-#")[2];
|
||||
document.getElementsByName(ajax_list_activeInput.name + '_hidden')[0].value = inputObj.dataset.localityId;
|
||||
if(ajax_list_externalFile == 'getlocality')
|
||||
{
|
||||
document.getElementsByName(ajax_list_activeInput.name + '_pincode')[0].value = inputObj.dataset.pincode;
|
||||
document.getElementsByName(ajax_list_activeInput.name + '_citylist')[0].value = inputObj.dataset.city;
|
||||
}
|
||||
}
|
||||
ajax_options_hide();
|
||||
@@ -113,7 +112,7 @@ Owner of DHTMLgoodies.com
|
||||
|
||||
ajax_optionDiv.innerHTML = '';
|
||||
ajax_list_activeItem = false;
|
||||
if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length<=1){
|
||||
if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length===0){
|
||||
ajax_options_hide();
|
||||
return;
|
||||
}
|
||||
@@ -123,19 +122,20 @@ Owner of DHTMLgoodies.com
|
||||
ajax_list_optionDivFirstItem = false;
|
||||
var optionsAdded = false;
|
||||
for(var no=0;no<ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length;no++){
|
||||
if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()][no].length==0)continue;
|
||||
optionsAdded = true;
|
||||
var div = document.createElement('DIV');
|
||||
var items = ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()][no].split(/!C0L!/gi);
|
||||
|
||||
if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length==1 && ajax_list_activeInput.value == items[0]){
|
||||
ajax_options_hide();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
div.innerHTML = items[items.length-1];
|
||||
div.id = items[0];
|
||||
var locality = ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()][no];
|
||||
if(!locality || !locality.location)continue;
|
||||
optionsAdded = true;
|
||||
var div = document.createElement('DIV');
|
||||
|
||||
if(ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()].length==1 && ajax_list_activeInput.value == locality.location){
|
||||
ajax_options_hide();
|
||||
return;
|
||||
}
|
||||
|
||||
div.textContent = locality.location;
|
||||
div.dataset.localityId = locality.id;
|
||||
div.dataset.pincode = locality.pincode || '';
|
||||
div.dataset.city = locality.city || '';
|
||||
div.className='optionDiv';
|
||||
div.onmouseover = function(){ ajax_options_rollOverActiveItem(this,false); };
|
||||
div.onclick = ajax_option_setValue;
|
||||
@@ -150,17 +150,6 @@ Owner of DHTMLgoodies.com
|
||||
|
||||
}
|
||||
|
||||
function ajax_option_list_showContent(ajaxIndex,inputObj,paramToExternalFile,whichIndex)
|
||||
{
|
||||
if(whichIndex!=currentListIndex)return;
|
||||
var letters = inputObj.value;
|
||||
var content = ajax_list_objects[ajaxIndex].response;
|
||||
var elements = content.split('!R0W!');
|
||||
ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()] = elements;
|
||||
ajax_option_list_buildList(letters,paramToExternalFile);
|
||||
|
||||
}
|
||||
|
||||
function ajax_option_resize(inputObj)
|
||||
{
|
||||
ajax_optionDiv.style.top = (ajax_getTopPos(inputObj) + inputObj.offsetHeight + ajaxBox_offsetY) + 'px';
|
||||
@@ -244,18 +233,27 @@ Owner of DHTMLgoodies.com
|
||||
if(ajax_list_cachedLists[paramToExternalFile][inputObj.value.toLowerCase()]){
|
||||
ajax_option_list_buildList(inputObj.value,paramToExternalFile,currentListIndex);
|
||||
}else{
|
||||
var tmpIndex=currentListIndex/1;
|
||||
ajax_optionDiv.innerHTML = '';
|
||||
var ajaxIndex = ajax_list_objects.length;
|
||||
ajax_list_objects[ajaxIndex] = new sack();
|
||||
if(cityval.toUpperCase() == "GURGAON") {
|
||||
cityval = "Gurugram";
|
||||
}
|
||||
//var url = ajax_list_externalFile + '?' + paramToExternalFile + '='+cityval+'&letters=' + inputObj.value.replace(" ","+");
|
||||
var url = ajax_list_externalFile + '?city='+cityval+'&letters=' + inputObj.value.replace(" ","+");
|
||||
ajax_list_objects[ajaxIndex].requestFile = url; // Specifying which file to get
|
||||
ajax_list_objects[ajaxIndex].onCompletion = function(){ ajax_option_list_showContent(ajaxIndex,inputObj,paramToExternalFile,tmpIndex); }; // Specify function that will be executed after file has been found
|
||||
ajax_list_objects[ajaxIndex].runAJAX(); // Execute AJAX function
|
||||
var tmpIndex=currentListIndex/1;
|
||||
ajax_optionDiv.innerHTML = '';
|
||||
if(cityval.toUpperCase() == "GURGAON") {
|
||||
cityval = "Gurugram";
|
||||
}
|
||||
var letters=inputObj.value;
|
||||
var url=ajax_list_externalFile+'?'+new URLSearchParams({city:cityval,letters:letters}).toString();
|
||||
fetch(url,{method:'GET',credentials:'same-origin',headers:{Accept:'application/json'}})
|
||||
.then(function(response){return response.json().then(function(body){return {response:response,body:body};});})
|
||||
.then(function(result){
|
||||
if(!result.response.ok || !result.body || !result.body.success) throw result.body && result.body.message ? result.body.message : {};
|
||||
var localities=Array.isArray(result.body.data && result.body.data.localities) ? result.body.data.localities : [];
|
||||
ajax_list_cachedLists[paramToExternalFile][letters.toLowerCase()]=localities;
|
||||
if(tmpIndex==currentListIndex) ajax_option_list_buildList(letters,paramToExternalFile);
|
||||
})
|
||||
.catch(function(error){
|
||||
if(tmpIndex!=currentListIndex)return;
|
||||
ajax_options_hide();
|
||||
CygnusNotifications.show({type:'danger',code:error.code || 'APP-5002',
|
||||
message:error.message || 'Cygnus could not load localities.',referenceId:error.referenceId});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user