CountryFlags = { init : function (){ CountryFlags.domElem = $('.Domlanguages'); CountryFlags.getData('CountryName'); $('.contry-selector-hover a').click(function() { $('.country-selector-div').css("display","block"); }); $("#closebtn").click(function() { $('.country-selector-div').css("display","none"); }); }, getData : function (type) { var CountryName = ""; var url = '/italy/en/assets/js/Locations-Languages-json.js'; CountryFlags.CountryName = []; CountryFlags.storeCountryName = {} // stores Country Name's from json $.getJSON(url , function(data){ for(var i=0,l=data.countries.length;i

').data("Name"); CountryFlags.CountryName.push( CountryName ); //item.Name = CountryName; CountryFlags.storeCountryName[CountryName] = item; } } CountryFlags.CountryName.sort(); CountryFlags.CountryName.sort(function(a,b){ if(a == "Mars Global") return 1; else if(b == "Mars Global") return -1; return a.toLowerCase().localeCompare(b.toLowerCase()); // return a-b; }); CountryFlags.displayResults(); CountryFlags.buildLangLinks(); }); }, // Display Countries Data function displayResults : function(){ var loop = CountryFlags.storeCountryName; var key_loop = CountryFlags.CountryName; CountryFlags.sortBy = "CountryName"; var results = ''; var results1 = ''; var results2 = ''; var results3 = ''; var results4 = ''; var results5 = ''; var count=0; CountryFlags.domElem.empty(); var col1,col2,col3,col4,col5; $(".Domlanguages").append('
'); for(var m=0,n=key_loop.length;m'+item.FlagAlt+'

'+item.Name+'

'; //CountryFlags.buildLangLinks(item["LanguageLink"] , item.Name); } if(count<=7) { var results1 ='
'+item.FlagAlt+'

'+item.Name+'

'; $(".col1").append(results1); CountryFlags.buildLangLinks(item["LanguageLink"] , item.Name); } else if(count>7 && count<=15) { var results2 ='
'+item.FlagAlt+'

'+item.Name+'

'; $(".col2").append(results2); CountryFlags.buildLangLinks(item["LanguageLink"] , item.Name); } else if(count>15 && count<=23) { var results3 = '
'+item.FlagAlt+'

'+item.Name+'

'; $(".col3").append(results3); CountryFlags.buildLangLinks(item["LanguageLink"] , item.Name); } else if(count>23 && count<=31) { var results4 = '
'+item.FlagAlt+'

'+item.Name+'

'; $(".col4").append(results4); CountryFlags.buildLangLinks(item["LanguageLink"] , item.Name); } else { var results5 = '
'+item.FlagAlt+'

'+item.Name+'

'; $(".col5").append(results5); CountryFlags.buildLangLinks(item["LanguageLink"] , item.Name); } count++; } }, //To display Links in COuntries buildLangLinks : function(objLangLinks ,id){ var str = ""; $.each(objLangLinks , function(index ,value){ str = ''; var idname=id.split(" "); id=idname[0]; //alert(str); $("."+id).append(str); }); } } $(document).ready(function() { CountryFlags.init(); });