/* * Send Requests to Server */ ringdata = new Array(); var globalprice; function savering(set) { var set = set; if (set == 'new') { var cookieName = $('#hd_name').val(); newId=""; if ( $.cookies.get('hd_' + cookieName) ){ if (confirm('Ein Ring mit diesem Namen existiert bereits. Wollen Sie ihn überschreiben?')){ $.ajax({ url: 'system/gateway/saveconfiguration', async: false, cache: false, dataType: 'json', data: ({save : 'true'}), success: function(data){ if(!(data.id)) { $("#saveUI").hide(); $("#savedUIError").show(); return false; } var cookieName = $('#hd_name').val(); var date = new Date(); date.setTime(date.getTime() + (31 * 24 * 60 * 60 * 1000)); newId=data.id; $.cookies.set('hd_' + cookieName, data.id, { path: '/', expiresAt: date }); $("#saveUI").hide(); $("#savedUI").show(); setTimeout("closeLayer('saveloadlayer')",2500); } }); return (newId); } }else{ $.ajax({ url: 'system/gateway/saveconfiguration', async: false, cache: false, dataType: 'json', data: ({save : 'true'}), success: function(data){ if(!(data.id)) { $("#saveUI").hide(); $("#savedUIError").show(); return false; } var cookieName = $('#hd_name').val(); var date = new Date(); date.setTime(date.getTime() + (31 * 24 * 60 * 60 * 1000)); newId=data.id; $.cookies.set('hd_' + cookieName, data.id, { path: '/', expiresAt: date }); $("#saveUI").hide(); $("#savedUI").show(); setTimeout("closeLayer('saveloadlayer')",2500); } }); return (newId); } } else if (set=="over") { var cookieName = $('#myRings').val(); if (cookieName=="") return false; newId=""; $.ajax({ url: 'system/gateway/saveconfiguration/overwrite/1', async: false, cache: false, dataType: 'json', data: ({save : 'true'}), success: function(data){ if(!(data.id)) { $("#saveUI").hide(); $("#savedUIError").show(); return false; } var cookieName = $('#myRings').val(); var date = new Date(); date.setTime(date.getTime() + (31 * 24 * 60 * 60 * 1000)); newId=data.id; $.cookies.set('hd_' + cookieName, data.id, { path: '/', expiresAt: date }); $("#saveUI").hide(); $("#savedUI").show(); setTimeout("closeLayer('saveloadlayer')",2500); } }); return (newId); } else if (set=="email") { $.ajax({ url: 'system/gateway/saveconfiguration', async: false, cache: false, dataType: 'json', data: ({save : 'true'}), success: function(data){ newId=data.id; } }); setTimeout("closeLayer('saveloadlayer')",2500); return (newId); } else if (set=="facebook") { $.ajax({ url: 'system/gateway/saveconfiguration/overwrite/1', async: false, cache: false, dataType: 'json', data: ({save : 'true', saveType : 'facebook'}), success: function(data){ newId=data.id; } }); setTimeout("closeLayer('saveloadlayer')",2500); return (newId); } } function LoadConfiguration(id) { $.ajax({ url: 'system/gateway/loadconfiguration', async: false, cache: false, data: ({id : id}), success: function(data){ var id = location.href; id = id.split('?meineRinge='); location.href=id[0]; //location.reload(true); return true; } }); } function getPersonalData() { $.ajax({ url: 'system/gateway/getpersonaldata', async: true, cache: false, dataType: 'json', data: ({values : 0}), success: function(data){ ReFillForm(data); } }); } function SavePersonalData(values) { $.ajax({ url: 'system/gateway/savepersonaldata', async: true, cache: false, data: ({values : values}), success: function(data){ if(data == '"true"'){ $('#customerdata #successmessage').fadeIn().delay(3000).fadeOut(); } } }); } function setAcutalSelection(selection) { $.ajax({ url: 'system/gateway/selection', async: false, cache: false, data: ({selection : selection}), success: function(data){ ReloadCollageImage(); UpdatePriceLabel(); return data; } }); } function RemoveThirdRing(gender) { $.ajax({ url: 'system/gateway/remove', async: false, cache: false, data: ({selection : gender}), success: function(data){ ReloadCollageImage(); UpdatePriceLabel(); return data; } }); } function ReInit() { $.ajax({ url: 'system/gateway/reinit', async: false, cache: false, data: ({init : 'do'}), success: function(data){ return data; } }); } function InitConfigurator(type) { $.ajax({ url: 'system/gateway/initconfigurator', async: false, cache: false, data: ({init : type}), success: function(data){ window.location.href = "configurator.php"; return data; } }); } function SetActiveRing(Ring) { $.ajax({ url: 'system/gateway/setactivering', async: false, cache: false, data: ({ring: Ring}) }); } /**/ function testkj(data) { AnalyzeSetData(data); //Bild laden + Price Update /* GetAvalibleItems('femalering','alloy_au',ShowAvailableAlloyAu); GetAvalibleItems('femalering','alloy_pt',ShowAvailableAlloyPt); GetAvalibleItems('femalering','alloy_pd',ShowAvailableAlloyPd); */ } function lade() { /* if(setGender=='pairring'){ GetAvalibleItems('femalering','alloy_au',ShowAvailableAlloyAu); GetAvalibleItems('femalering','alloy_au2',ShowAvailableAlloyAu2); GetAvalibleItems('femalering','alloy_pt',ShowAvailableAlloyPt); GetAvalibleItems('femalering','alloy_pd',ShowAvailableAlloyPd); }else{ GetAvalibleItems(setGender,'alloy_au',ShowAvailableAlloyAu); GetAvalibleItems(setGender,'alloy_au2',ShowAvailableAlloyAu2); GetAvalibleItems(setGender,'alloy_pt',ShowAvailableAlloyPt); GetAvalibleItems(setGender,'alloy_pd',ShowAvailableAlloyPd); } */ } function setze(object,item,value) { SetItemValue(object,item,value,lade); } /**/ function GetAvalibleItems(object,item,functionname) { $.ajax({ url: 'system/gateway/getproperties', async: true, cache: false, dataType: 'json', data: ({item : item, object : object}), success: functionname }); } function GetActiveItem(object,item,functionname) { $.ajax({ url: 'system/gateway/getvalue', async: true, cache: false, dataType: 'json', data: ({item : item, object : object}), success: functionname }); } function SetItemValueDirect(object,item,value,callback) { $.ajax({ url: 'system/gateway/setproberty', async: false, cache: false, dataType: 'json', data: ({item : item, object : object, value : value}), success: callback }); } function SetItemValue(object,item,value,nonreloadimage) { SetItemValueDirect(object, item, value, AnalyzeSetData); } function SetItemValueWithCallback(object, item, value, callback) { SetItemValueDirect(object, item, value, function(data) { AnalyzeSetData(data); callback(data); }); } /** * Callback for SetValue */ function AnalyzeSetData(data) { //huhu = 1234; // alert(data.price.prices.malering); // globalprice = ; UpdatePriceLabel1(data.price); $('#productimage').attr('src','/images/' + data.image.key + '.jpg'); infoscrren = data.infoscreen; if(infoscrren != null){ $.each(infoscrren, function(i,info){ $('
'+info+'
').appendTo($('#infolayer')); }); $('#infolayer').fadeIn(); setInfo(); } if(data.error) ShowError(data.error); if(data.autoapaption) $.each(data.autoapaption, function(i,item) { ShowAutoAdaptHints(item); }); // ReloadCollageImage(); //getLiveupdate(); return; } /** * Show Error */ function ShowError(error) { alert(error); } /** *Show Adaption hints */ function ShowAutoAdaptHints(autoadaptionhint) { // alert(autoadaptionhint); } /** * Reload the Image with the rings */ function ReloadCollageImage() { // alert('reloadimage'); var a = 1 + 44*(Math.random()); sleep(0); $.getJSON("system/image/showcollage", null, function(data) { $('#productimage').attr('src','/images/' + data.key + '.jpg'); return data; }); // UpdatePriceLabel(); } function sleep(ms){ var zeit=(new Date()).getTime(); var stoppZeit=zeit+ms; while((new Date()).getTime()'+info+'').appendTo($('#infolayer')); }); $('#infolayer').fadeIn(); setInfo(); }else{ //alert('nix'); } }, error: function(data){ //alert('error'); } }); } function ObjectLoader(object) { $.ajax({ url: 'http://beta.designyourring.de/system/gateway/getall', async: false, cache: false, dataType: 'json', data: ({object : object}), success: function(data){ LoadCache(data,object); } }); } function UpdatePriceLabel1(globalprice) { //alert('test pl 1'); if(globalprice.prices.malering != null){ $('#malringprice').html('$ ' + globalprice.prices.malering + ',-' ); $('#maleringli').show(); }else{ $('#maleringli').hide(); } if(globalprice.prices.femalering != null){ $('#femalringprice').html('$ ' + globalprice.prices.femalering + ',-' ); $('#femaleringli').show(); }else{ $('#femaleringli').hide(); } if(globalprice.prices.thirdring != null){ $('#thirdringprice').html('$ ' + globalprice.prices.thirdring + ',-' ); $('#thirdringli').hide(); }else{ $('#thirdringli').hide(); } $('#pricesum').html('$ ' + globalprice.prices.sum + ',-' ); if(globalprice.thirdRing == 'none' || globalprice.thirdRing == 'malering' || globalprice.thirdRing == 'femalering'){ $('#thirdringli').css('display','none'); }else if(globalprice.prices.thirdring == '-'){ $('#thirdringli').css('display','block'); $('#thirdringprice').html('on demand'); }else{ $('#thirdringli').css('display','block'); } $('#thirdRingLabel').html(globalprice.thirdRing); return true; } function UpdatePriceLabel() { //alert('test pl'); $.ajax({ url: 'system/pricelabel/getprices', async: false, dataType: 'json', data: null, success: function(data){ if(data.prices.malering != null){ $('#malringprice').html('$ ' + data.prices.malering + ',-' ); $('#maleringli').show(); }else{ $('#maleringli').hide(); } if(data.prices.femalering != null){ $('#femalringprice').html('$ ' + data.prices.femalering + ',-' ); $('#femaleringli').show(); }else{ $('#femaleringli').hide(); } if(data.prices.thirdring != null){ $('#thirdringprice').html('$ ' + data.prices.thirdring + ',-' ); $('#thirdringli').hide(); }else{ $('#thirdringli').hide(); } $('#pricesum').html('$ ' + data.prices.sum + ',-' ); if(data.thirdRing == 'none' || data.thirdRing == 'malering' || data.thirdRing == 'femalering'){ $('#thirdringli').hide(); }else if(data.prices.thirdring == '-'){ $('#thirdringli').show(); $('#thirdringprice').html('on demand'); }else{ $('#thirdringli').show(); } $('#thirdRingLabel').html(data.thirdRing); $('#thirdringli .topopup').click(function () { //binding third ring info layer popup popUpInfo(data.thirdRing); }); } }); }