Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getConfWidgetContent(){
- var theCookies = document.cookie.split(';');
- var params={};
- var end=false;
- for (var i = 1 ; i <= theCookies.length; i++) {
- if(theCookies[i-1].trim().substr(0, 3)==='cf_'){
- var cookie=theCookies[i-1].trim().split('=');
- params[cookie[0].trim()]=cookie[1];
- }
- }
- $j.post('http://'+window.location.hostname+'/ajax-configurator',{
- data:JSON.stringify(params)
- },function(data){
- data=JSON.parse(data);
- console.log(data['debug']);
- if(data['code']!=''){
- var html='<div class="hn_cw_subline">'+data['label'];
- if(data['info']!=''){
- html=html+'<div class="hn_cw_info">i</div>';
- }
- html=html+'</div><select class="hn_cw_select">';
- $j.each(data['options'],function(index,value){
- if(value.value==''){
- value.value=0;
- value.label=data['a'];
- }
- html=html+'<option value="'+value.value+'">'+value.label+'</option>';
- });
- html=html+'</select><input type="button" value="'+data['b']+'" class="hn_cw_button hn_cw_back" /></select><input type="button" value="'+data['c']+'" class="hn_cw_button hn_cw_go" />';
- }else{
- var html='<div class="hn_cw_subline">\
- '+data['d']+'<br />\
- </div>\
- ';
- end=true;
- console.log('#'+end);
- }
- $j('#hn_cw_transition').html(html);
- $j('.hn_cw_wrapper').animate({
- marginTop: '0px'
- }, 200, function() {
- $j('#hn_cw_form').html(html);
- if(data['info']!=''){
- $j('.hn_cw_info').click(function(){
- if($j('.hn_cw_popup').css('display')!='block'){
- $j('.hn_cw_popup').fadeIn(200);
- $j('.hn_cw_popup').html(data['info']).css('top','-270px').animate({
- top:"-250px"
- },{duration: 200, queue: false});
- }else{
- $j('.hn_cw_popup').fadeOut(200);
- $j('.hn_cw_popup').html(data['info']).animate({
- top:"-270px"
- },{duration: 200, queue: false});
- }
- });
- $j('.hn_cw_popup').click(function(){
- $j('.hn_cw_popup').fadeOut(200);
- $j('.hn_cw_popup').html(data['info']).animate({
- top:"-270px"
- },{duration: 200, queue: false});
- });
- }
- $j('.hn_cw_go').click(function(){
- var select=$j('#hn_cw_form .hn_cw_select').val();
- if(select!="0"){
- setCookie(data['code'], select, 60);
- setTimeout(getConfWidgetContent(), 1500);
- $j('.hn_cw_popup').fadeOut(200);
- $j('.hn_cw_popup').html(data['info']).animate({
- top:"-270px"
- },{duration: 200, queue: false});
- }else{
- //keine option wurde gewählt
- }
- });
- $j('.hn_cw_back').click(function(){
- if(deleteLastConfCookies()) setTimeout(getConfWidgetContent(), 1500);
- });
- $j('.hn_cw_wrapper').css('margin-top','-108px');
- });
- });
- $j.post('http://'+window.location.hostname+'/ajax-configurator/index/state',{
- data:JSON.stringify(params)
- },function(data){
- data=JSON.parse(data);
- var html='';
- $j.each(data,function(index,value){
- if($j.type(value)=='object')$j.each(value,function(field,option){
- if(html=='')html=html+'<span class="hn_cw_foot_headline">'+data['z']+':</span><br />';
- html=html+'<span>• '+field+': '+option+' ';
- });
- });
- if(html!=''){
- console.log('+'+end);
- if(!end) html=html+'<div><input type="button" value="'+data['y']+'" class="hn_cw_reset" /></div>';
- else html=html+'<div><input type="button" value="'+data['x']+'" class="hn_cw_result" /></div>';
- $j('.hn_configurator_widget_foot').html(html);
- $j('.hn_cw_reset').click(function(){
- deleteConfCookies();
- setTimeout(getConfWidgetContent(), 1500);
- });
- $j('.hn_cw_result').click(function(){
- window.open('http://'+window.location.hostname+'/'+getConfURL(),'_self');
- });
- }else{
- $j('.hn_configurator_widget_foot').html('');
- }
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement