javascriptjqueryfreeswitchmod-verto

Javascript - how to update the cookie so that it dial new number instead of the default number?


When i call manual_dial() it always dial 12127773456 instead of 32448899000. Why the pop method is not updating the cookie verto_demo_ext ?

Any advise?

// Cookie library
// https://freeswitch.org/stash/projects/FS/repos/freeswitch/raw/html5/verto/video_demo/js/jquery.cookie.js?at=67dad0639867bbc64fa404b30caad2889ea80899

var dial______________________number = '12127773456';
function pop(id, cname, dft) {
  var tmp = $.cookie(cname) || dft;
  $.cookie(cname, tmp, {
    expires: 365
  });
  $(id).val(tmp).change(function () {
    $.cookie(cname, $(id).val(), {
      expires: 365
    });
  });
}

function init() {
  pop("#ext", "verto_demo_ext", dial______________________number);
}

function manual_dial() {
  pop("#ext", "verto_demo_ext", '32448899000');
}

Solution

  • Change the line var tmp = $.cookie(cname) || dft; to var tmp = dft || $.cookie(cname);

    You are giving preference to the cookie over the value passed to the function. Change the order to giving preference to the value passed into the function