window.addEvent('load', function() { var swiffy = new FancyUpload2($('photo-status'), $('photo-list'), { 'url': $('uploadurl').value, // 'url': "http://www.digiprint24.de/digi2008/test.php?XTCsid=2hg2alpkb07vkkg01vogaqahl7", 'fieldName': 'photoupload', 'path': 'js/Swiff.Uploader.swf', 'onLoad': function() { $('photo-status').removeClass('hide'); $('photo-fallback').addClass('hide') //$('photo-fallback').destroy(); }, // The changed parts! debug: true, // enable logs, uses console.log target: 'browse-images', // the element for the overlay (Flash 10 only) 'fileComplete' : function(ele, response) { //alert('file complete: '+ele+' resp: '+response); //var myObject = JSON.decode(response); //alert(myObject.result); //var json = $H(JSON.decode(response, true)); var json = JSON.decode(response); //alert(json.result); if (json.result == '__success__') { //alert('remove'); swiffy.removeFile(ele); }else{ alert(json.get('error')); } updateImagelist(); }, 'fileCreate': function(file) { file.info = new Element('span', {'class': 'file-info'}); file.element = new Element('li', {'class': 'file'}).adopt( new Element('span', {'class': 'file-size', 'html': this.sizeToKB(file.size)}), new Element('a', { 'class': 'file-remove', 'href': '#', 'html': 'Löschen', 'events': { 'click': function() { this.removeFile(file); return false; }.bind(this) } }), new Element('span', {'class': 'file-name', 'html': file.name}), file.info ).inject(this.list); } }); /** * Various interactions */ if($('demo-browse-all') != null){ $('demo-browse-all').addEvent('click', function() { /** * Doesn't work anymore with Flash 10: swiffy.browse(); * FancyUpload moves the Flash movie as overlay over the link. * (see opeion "target" above) */ swiffy.browse(); return false; }); } $('browse-images').addEvent('click', function() { swiffy.browse({'Images (*.jpg, *.jpeg, *.gif, *.png)': '*.jpg; *.jpeg; *.gif; *.png;*.JPG; *.JPEG;'}); return false; }); /*$('clear-list').addEvent('click', function() { swiffy.removeFile(); return false; });*/ $('upload').addEvent('click', function() { swiffy.upload(); return false; }); }); function updateImagelist() { var url = "imageList.php?HTML"; url +='&info='; var liste = $('photoimages'); if(liste !=null){ var myAjax = new Ajax(url, {method: 'get',onSuccess: function(transport){ //alert(transport) }, update: $('photoimages')}); myAjax.request(); /* new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { liste.update(transport.responseText); } });*/ } return false; } function incQuantity(product, image){ var url = '/updateQuantity.php'; url +='?pID='+product; url +='&image='+image; url +='&mode=up'; //alert(url); var myAjax = new Ajax(url, { method: 'get', onSuccess: function(transport){ var el = $('image-'+image+'-quantity'); el.innerHTML = transport; } } ); myAjax.request(); /* new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { var el = $('image-'+image+'-quantity'); el.innerHTML = transport.responseText; } } );*/ return false; } function decQuantity(product, image){ var url = '/updateQuantity.php'; url +='?pID='+product; url +='&image='+image; url +='&mode=down'; var myAjax = new Ajax(url, { method: 'get', onSuccess: function(transport){ var el = $('image-'+image+'-quantity'); el.innerHTML = transport; } } ); myAjax.request(); return false; } function delImage(product, image){ var url = '/updateQuantity.php'; url +='?pID='+product; url +='&image='+image; url +='&mode=del'; //alert(url); var myAjax = new Ajax(url, { method: 'get', onSuccess: function(transport){ //alert(transport); updateImagelist(); } } ); myAjax.request(); return false; }