Override JS function from another file

I am trying to override a JS function from Bigcartel. I do not have access to the JS file.

Original:

updateCart: function(cart) {
    $('aside .cart .count, .main header .cart').htmlHighlight(cart.item_count);
    return $('aside .cart .total').htmlHighlight(Format.money(cart.total, true, true));
  }, 

And I'm trying to change it to this:

updateCart: function(cart) {
  $('aside .cart .count, .sml .cart, .big .cart .count').htmlHighlight(cart.item_count);
  return $('aside .cart .total').htmlHighlight(Format.money(cart.total, true, true));
},

I know others have asked similar questions, but I'm a complete noob when it comes to understanding how to implement JS (I only know how to tweek through trial version and error)

If someone can be so kind as to help me, giving me an answer that would be great.

Thanks,

iWed-


EDIT [10.10.13 :: 21: 24hr]

To clarify, I do not have direct access to the source JS file. I can only view it through chrome. I only have access to html files. This is for the Big Cartel Edit theme.

Here is a link to copied JS using chrome. Line 216 is the code if this helps: http://jsfiddle.net/w9GTJ/

+4
2

EDIT: . , updateCart window.Store . , script:

window.Store.updateCart = function(cart) {
  $('aside .cart .count, .sml .cart, .big .cart .count').htmlHighlight(cart.item_count);
  return $('aside .cart .total').htmlHighlight(Format.money(cart.total, true, true));
};

:

, -, , , script :

<script>
var x = 5; // original script
</script>
<script>
x = 2; // your inserted script
</script>

:

var x = {
   updateCart : function(cart) {
     // stuff
   }
}

, , :

x.updateCart = function(cart) {
  // your code
}

, , , :

function() {
   var x = {
      updateCart: function(){}
   }
}()

// No way to access x.updateCart here
+10

, js:

[theTargetObject].prototype.updateCart= function(cart) {
          $('aside .cart .count, .sml .cart, .big .cart .count').htmlHighlight(cart.item_count);
          return $('aside .cart .total').htmlHighlight(Format.money(cart.total, true, true));
}
0

All Articles