case 'opac.hold_notify':
var template = localeStrings.HOLD_NOTIFY_PHONE + '<span name="hold_phone"></span> '
+ localeStrings.HOLD_NOTIFY_EMAIL + '<span name="hold_email"></span>';
- if(orgSettings['sms.enable']) {
- template += ' ' + localeStrings.HOLD_NOTIFY_SMS + '<span name="hold_sms"></span>';
- }
+ template += ' ' + localeStrings.HOLD_NOTIFY_SMS + '<span name="hold_sms"></span>';
getByName(row, 'widget').innerHTML = template;
var setting = userSettings['opac.hold_notify'];
if(setting == null) setting = 'phone:email';
var cb_email = new dijit.form.CheckBox({scrollOnFocus:false}, getByName(row, 'hold_email'));
cb_email.attr('value', setting.indexOf('email') != -1);
var cb_sms = null;
- if(orgSettings['sms.enable']) {
- cb_sms = new dijit.form.CheckBox({scrollOnFocus:false}, getByName(row, 'hold_sms'));
- cb_sms.attr('value', setting.indexOf('sms') != -1);
- }
+ cb_sms = new dijit.form.CheckBox({scrollOnFocus:false}, getByName(row, 'hold_sms'));
+ cb_sms.attr('value', setting.indexOf('sms') != -1);
var func = function() {
var newVal = '';
var splitter = '';
newVal+= splitter + 'email';
splitter = ':';
}
- if(orgSettings['sms.enable'] && cb_sms.checked) {
+ if(cb_sms.checked) {
newVal+= splitter + 'sms';
splitter = ':';
}
dojo.connect(select, 'onChange', function(newVal) { userSettingsToUpdate[stype.name()] = newVal; });
break;
case 'opac.default_sms_notify':
- if(!orgSettings['sms.enable']) return; // Skip when SMS is disabled
case 'opac.default_phone':
var tb = new dijit.form.TextBox({scrollOnFocus:false}, getByName(row, 'widget'));
tb.attr('value', userSettings[stype.name()]);
- dojo.connect(tb, 'onChange', function(newVal) { userSettingsToUpdate[stype.name()] = newVal; });
+ if (stype.name() === 'opac.default_sms_notify') {
+ dojo.create("div", {innerHTML: "<img id='sms_lookup_result'></img>"}, row);
+ }
+ dojo.connect(tb, 'onChange', function(newVal) {
+ if (newVal === '' || newVal.match(/\s+/)) {
+ userSettingsToUpdate[stype.name()] = '';
+ return;
+ }
+ var digits = newVal.replace(/\D/g, '');
+ var digits_trimmed = digits.replace(/^1/, '');
+ if (digits_trimmed.length == 10) {
+ dojo.style(tb.domNode, "background-color", "");
+ var formatted = digits_trimmed.replace(/(\d{3})(\d{3})(\d{4})/, "$1-$2-$3");
+ tb.attr("value", formatted);
+ if (newVal !== formatted) {
+ newVal = formatted;
+ } else {
+ // only trigger this if we did NOT just change the value
+ // (avoid double-lookup)
+ if (stype.name() === 'opac.default_sms_notify') {
+ dojo.byId('sms_lookup_result').src = 'https://util-ext.catalog.tadl.org/lookup_image/' + newVal + '?t=' + openils.User.authtoken;
+ }
+ }
+ } else {
+ dojo.style(tb.domNode, "background-color", "yellow");
+ }
+ userSettingsToUpdate[stype.name()] = newVal; });
break;
default:
var cb = new dijit.form.CheckBox({scrollOnFocus:false}, getByName(row, 'widget'));