jslint
[Portfolio.git] / skins / cart_widgets.js
index 9615bc9..9f59306 100644 (file)
@@ -1,10 +1,7 @@
 /*
-* © 2009 Luxia SAS. All rights reserved.
-* Contributors
-* — Benoît Pin <pinbe@luxia.fr>
-* 
-* 
-* 
+* 2009 Benoit Pin - MINES ParisTech
+* http://plinn.org
+* Licence GPL
 */
 
 
@@ -22,7 +19,7 @@ CartWidget = function(slide, url) {
        req.send(null);
        hideProgressImage();
        
-       if (req.status != 200){
+       if (req.status !== 200){
                alert(req.status);
                return;
        }
@@ -30,12 +27,12 @@ CartWidget = function(slide, url) {
        var wdgtNode = this.wdgtNode = getCopyOfNode(doc);
        slide.appendChild(wdgtNode);
        
-       var descriptions = this.descriptions = new Array();
+       var descriptions = this.descriptions = [];
        var divs = wdgtNode.getElementsByTagName('div');
-       var d;
-       for (var i=0; i<divs.length; i++) {
+       var d, i;
+       for (i=0; i<divs.length; i++) {
                d = divs[i];
-               if (d.className =='ppt-description') {
+               if (d.className =='ppt-description') {
                        descriptions[d.getAttribute('name')] = d;
                }
        }
@@ -47,31 +44,26 @@ CartWidget = function(slide, url) {
        fm.onBeforeSubmit  = function(fm, evt){return thisCart.onBeforeSubmit(fm, evt);};
        fm.onResponseLoad = function(req){return thisCart.loadResponse(req);};
 
-       with (descriptions[itemSelector.value].style) {
-               visibility = 'visible';
-               display='block';
-       }
+       descriptions[itemSelector.value].style.visibility = 'visible';
+       descriptions[itemSelector.value].style.display='block';
        this.selectedItem = itemSelector.value;
        
-       addListener(itemSelector, 'change', function(evt){thisCart.selectItem(evt)})
-}
+       addListener(itemSelector, 'change', function(evt){thisCart.selectItem(evt);});
+};
 
 CartWidget.prototype.selectItem = function(evt) {
-       with(this.descriptions[this.selectedItem].style) {
-               visibility = 'hidden';
-               display = 'none'
-       }
+       this.descriptions[this.selectedItem].style.visibility = 'hidden';
+       this.descriptions[this.selectedItem].style.display = 'none';
        var name = this.itemSelector.value;
        
-       with (this.descriptions[name].style) {
-               visibility = 'visible';
-               display='block';
-       }
+       this.descriptions[name].style.visibility = 'visible';
+       this.descriptions[name].style.display='block';
+
        this.selectedItem = name;
 };
 
 CartWidget.prototype.onBeforeSubmit = function(fm, evt) {
-       if (fm.submitButton.name == 'cancel') {
+       if (fm.submitButton.name === 'cancel') {
                this.onCancel();
                return 'cancelSubmit';
        }
@@ -90,7 +82,7 @@ CartWidget.prototype.loadResponse = function(req) {
                        confirm.innerHTML = text;
                        slide.appendChild(confirm);
 
-                       var duration = parseInt(doc.getAttribute('duration')) * 1000;
+                       var duration = parseInt(doc.getAttribute('duration'), 10) * 1000;
                        var thisCart = this;
 
                        setTimeout(function(){
@@ -115,4 +107,4 @@ CartWidget.prototype.onCancel = function() {
 
 CartWidget.prototype.onAfterConfirm = function(){};
 
-})();
\ No newline at end of file
+}());
\ No newline at end of file