Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.8 kB
1
Indexable
Never
let langSupport = Object()

function deleteLang(this1) {
    let text = $(this1).parent().text();
    let [langs, time] = text.slice(0, text.length - 3).split("-").filter((item) => { return item })
    let indexOfLangToDelete = langSupport[time.trim()].indexOf(langs.trim())

    if (indexOfLangToDelete > -1) {
        langSupport[time.trim()].splice(indexOfLangToDelete, 1);
    }
    // update session storage, JSON.parse first
    localStorage.setItem('select139',JSON.stringify(langSupport))
    $(this1).parent().remove();
}



function preview()
{

if($("#select139").val().length===0 || $("#select139").val()==="--Select--" || $("#select139").val()==="--select--")    
{
	messagePopup("Please Select the Language")	
}
else if($("#select140").val().length===0 || $("#select140").val()==="--Select--" || $("#select140").val()==="--select--")
{
messagePopup("Please Select the support Coverage")
}

else
{
var name1= $("#select139").val();
var name2= $("#select140").val();

if(!$("#Label244").text().includes(name1+" - "+name2)){
$("#Label244").append("<p class='w3-animate-left' >"+name1+" - "+name2+"<span title='Remove' onclick='deleteLang(this)' class='xSymbol'>  &times;</span></p>");
$('#select139').change(function(){
    $('#select140').prop('selectedIndex',0);
});
}
else{
	messagePopup('Selected values is already added to the Preview')
}
}

let selectedLanguages = ($("#select139").val())
    let timeValue = $("#select140").val();
    if (timeValue in langSupport) {
        let existingLangs = langSupport[timeValue];
        existingLangs.push(selectedLanguages.join(","))
        selectedLanguages = existingLangs
    }
    langSupport[timeValue] = selectedLanguages;
    localStorage.setItem('select139',JSON.stringify(langSupport))
    // update session storage, JSON.parse first


}