var _windowScrollResize = null; var _dnsType = { A: 1, AAAA: 28, CNAME: 5, MX: 15, TXT: 16, SRV: 33, NS: 2 }; var _mainHeaderSelectedItem = 0, _mainCanUpdateHeader = true; var _scroll = { Data: [], add: function (elementId, params) { var el = jm.el(elementId); if (!el || !params) return; el.innerHTML = '
' + '
' + '
' + '
' + params.valType + '
' + '
'; _scroll.Data[elementId] = params; var line = jm.el('scrollLine_' + elementId + '_div'), selLine = jm.el('scrollLineSel_' + elementId + '_div'), pointer = jm.el('scrollPointer_' + elementId + '_div'), val = jm.el('scrollVal_' + elementId + '_div'); if (!line || !selLine || !pointer || line.offsetWidth <= 0 || selLine.offsetWidth <= 0) return; if (params.min > params.value) params.value = params.min; var pointerWidth = pointer.offsetWidth - 1, pos = (params.value - params.min) / (params.max - params.min) * (line.offsetWidth - pointerWidth) + pointerWidth; if (pos < pointerWidth - 1) pos = pointerWidth - 1; if (pos > line.offsetWidth) pos = line.offsetWidth; selLine.style.width = Math.round(pos) + "px"; pointer.style.marginLeft = (Math.round(pos) - pointerWidth) + "px"; val.style.marginLeft = Math.round((pointerWidth - Math.round(pos)) / (line.offsetWidth - pointerWidth) * 60 - 15) + "px"; val.childNodes[0].innerHTML = params.valWrite ? params.valWrite(params.value) : params.value; if (params.onscroll) params.onscroll(params.value); setTimeout(function () { jm.el('scrollPointer_' + elementId + '_div').className = "pointer anim100l"; jm.el('scrollLineSel_' + elementId + '_div').className = "lineSel anim100l"; }, 20); }, start: function (elementId, lineMD, e) { if (jm.Mouse.GetButton(e) != "left") return; var line = jm.el('scrollLine_' + elementId + '_div'), selLine = jm.el('scrollLineSel_' + elementId + '_div'), pointer = jm.el('scrollPointer_' + elementId + '_div'), val = jm.el('scrollVal_' + elementId + '_div'), data = _scroll.Data[elementId]; if (!line || !selLine || !pointer || !data || line.offsetWidth <= 0 || selLine.offsetWidth <= 0) return; pointer.className = "pointer pointer_acive"; selLine.className = "lineSel lineSel_acive"; jm.preventDefault(e); var pointerWidth = pointer.offsetWidth - 1; if (lineMD) data.scrollStartX = Math.round(jm.Mouse.X - jm.gDim(line).Left - pointerWidth / 2); else data.scrollStartX = Math.round(selLine.offsetWidth - pointerWidth); data.mouseStartX = jm.Mouse.X; data.pointerStartX = Math.round(e.target.className.indexOf("pointer") >= 0 ? e.layerX : (pointer.offsetWidth / 2)); jm.Mouse.Subscribe.SetMouseDown('scroll', true); data.scrolling = true; _scroll.updatePosition(elementId); }, updatePosition: function (elementId) { var data = _scroll.Data[elementId], line = jm.el('scrollLine_' + elementId + '_div'), selLine = jm.el('scrollLineSel_' + elementId + '_div'), pointer = jm.el('scrollPointer_' + elementId + '_div'), val = jm.el('scrollVal_' + elementId + '_div'); if (!data || !line || !selLine || !pointer || line.offsetWidth <= 0 || selLine.offsetWidth <= 0) return; var pointerWidth = pointer.offsetWidth - 1, pos = (jm.Mouse.X - data.mouseStartX) + data.scrollStartX + pointerWidth; if (pos < pointerWidth - 1) pos = pointerWidth - 1; if (pos > line.offsetWidth) pos = line.offsetWidth; var oldVal = data.value; data.value = data.min + Math.round((pos - pointerWidth) / (line.offsetWidth - pointerWidth) * (data.max - data.min)); data.value = Math.round(data.value / data.step) * data.step; if (oldVal != data.value && data.onscroll) data.onscroll(data.value); selLine.style.width = Math.round(pos) + "px"; pointer.style.marginLeft = (Math.round(pos) - pointerWidth) + "px"; val.style.marginLeft = Math.round((pointerWidth - Math.round(pos)) / (line.offsetWidth - pointerWidth) * 60 - 15) + "px"; val.childNodes[0].innerHTML = data.valWrite ? data.valWrite(data.value) : data.value; }, progress: function () { for (var elId in _scroll.Data) { var data = _scroll.Data[elId]; if (data && data.scrolling) { _scroll.updatePosition(elId); break; } } }, end: function () { for (var elId in _scroll.Data) { var data = _scroll.Data[elId]; if (data && data.scrolling) { var pointer = jm.el('scrollPointer_' + elId + '_div'), selLine = jm.el('scrollLineSel_' + elId + '_div'); if (pointer && selLine) { pointer.className = "pointer anim100l"; selLine.className = "lineSel anim100l"; } _scroll.updatePosition(elId); data.scrolling = false; break; } } }, setValue: function (elementId, value) { var data = _scroll.Data[elementId], pointer = jm.el('scrollPointer_' + elementId + '_div'), line = jm.el('scrollLine_' + elementId + '_div'), selLine = jm.el('scrollLineSel_' + elementId + '_div'), val = jm.el('scrollVal_' + elementId + '_div'); if (!data || !line || !selLine || !pointer || data.value == value || data.min > value) return; data.value = value; if (data.onscroll) data.onscroll(data.value); var pointerWidth = pointer.offsetWidth - 1, pos = (data.value - data.min) / (data.max - data.min) * (line.offsetWidth - pointerWidth) + pointerWidth; if (pos < pointerWidth - 1) pos = pointerWidth - 1; if (pos > line.offsetWidth) pos = line.offsetWidth; selLine.style.width = Math.round(pos) + "px"; pointer.style.marginLeft = (Math.round(pos) - pointerWidth) + "px"; val.style.marginLeft = Math.round((pointerWidth - Math.round(pos)) / (line.offsetWidth - pointerWidth) * 60 - 15) + "px"; val.childNodes[0].innerHTML = data.valWrite ? data.valWrite(data.value) : data.value; } }; jm.Mouse.Subscribe.Add("scroll", [["MouseDownMovie", _scroll.progress], ["MouseUp", _scroll.end]]); var _checkbox = { _data: [], add: function (id, text, checked, change) { var el = jm.el(id); if (!el) return; el.innerHTML = '
' + text + '
'; _checkbox._data[id] = change; }, click: function (id) { var div = jm.el("checkbox_" + id + "_inDiv"), checked = _checkbox.checked(id); if (!div) return; div.className = "in anim100l" + (checked ? " no" : ""); if (_checkbox._data[id]) _checkbox._data[id](!checked); }, checked: function (id) { var div = jm.el("checkbox_" + id + "_inDiv"); return div && div.className.indexOf("no") < 0; }, set: function (id, checked) { var div = jm.el("checkbox_" + id + "_inDiv"); div.className = "in anim100l" + (checked ? "" : " no"); } }; var _calculate = function (obj, conf) { var result = { price: 0, trial: false, commonDiv: {}, periodDiv: {}, promoDiv: {}, promoSpan: {}, installPaymentDiv: {} }, vramSteps = [0, 64, 128, 256, 512, 1024], cpAS = obj.getControlPanelAS(conf.controlPanel, conf.os), kaspAS = conf.kaspAV ? obj.kaspAvAS : null, dc = obj ? obj.getDC(conf.dc) : null, tariff = conf.premium ? obj.tariffP : obj.tariffR, ddosPrice = conf.ddos.on && dc ? (_ddosProtectionFreeMonthPromo && (!_auth.user || !_auth.user.hasDDoS) && conf.ddos.value == 1 ? 0 : ((conf.premium ? dc.premium.ddos.price : dc.regular.ddos.price) * conf.ddos.value) ) : 0, price = conf.cpu * tariff.cpu + conf.ram * tariff.ram + vramSteps[conf.vram] * tariff.vram + conf.drive * (conf.ssd ? tariff.drive.ssd : tariff.drive.hdd) + (conf.ip - 1) * tariff.ip + ddosPrice + (cpAS ? cpAS.price : 0) + (kaspAS ? kaspAS.price : 0), trial = conf.premium ? (dc && dc.premium ? dc.premium.trial : null) : (dc && dc.regular ? dc.regular.trial : null); result.price = price; var promo = obj._promo, promoSC = null; if (promo && promo.specConf && promo.specConf.length > 0) { for (var n in promo.specConf) { hasPromo = true; var sc = promo.specConf[n]; if (sc && sc.ram == conf.ram && sc.drive == conf.drive && (sc.driveType == 0 || sc.driveType == 1 && !conf.ssd || sc.driveType == 3 && conf.ssd) && (sc.serverType == 0 || sc.serverType == 1 && !conf.premium || sc.serverType == 2 && conf.premium) && (!sc.os || sc.os.length == 0 || sc.os.indexOf(conf.os) >= 0) && (sc.ip == 0 || sc.ip == conf.ip) && (sc.cpu == 0 || sc.cpu == conf.cpu) && (sc.vram < 0 || sc.vram == vramSteps[conf.vram]) ) { result.promoSC = promoSC = sc; break; } } } var trialType = trial ? (conf.ssd ? trial.typeSSD : trial.type) : 7; result.trialHTML = '{0} для теста сервера предоставляется бесплатно!'.Format( trialType == 1 ? _words.Week.Print(1) : trialType == 2 ? "3 " + _words.Day.Print(3) : trialType == 3 ? "1 " + _words.Day.Print(1) : trialType == 4 ? "6 " + _words.Hour.Print(6) : trialType == 5 ? "3 " + _words.Hour.Print(3) : trialType == 6 ? "1 " + _words.Hour.Print(1) : "" ).CapitalizeFirstLetter(); result.trial = conf.usageType == 1 && !cpAS && (!kaspAS || kaspAS.trialAvailable) && tariff && trialType >= 1 && trialType <= 6 && price <= trial.price && conf.cpu <= trial.cpu && conf.ip <= trial.ip && (!promoSC || promoSC.trial); result.promoPrice = 0; result.priceYear = ((promoSC ? (promoSC.price + ddosPrice + (cpAS && cpAS.applyDiscount ? cpAS.price : 0) + (kaspAS && kaspAS.applyDiscount ? kaspAS.price : 0)) : (price - (cpAS && !cpAS.applyDiscount ? cpAS.price : 0) - (kaspAS && !kaspAS.applyDiscount ? kaspAS.price : 0)))) * (1 - (!promoSC || promoSC.applyDiscount ? _getPeriodDiscount(obj._promo, 5) : 0)) + (cpAS && !cpAS.applyDiscount ? cpAS.price : 0) + (kaspAS && !kaspAS.applyDiscount ? kaspAS.price : 0); var price2strSpanned = _state.locale.getCurrency().PrintValue(Math.round(_state.locale.getCurrency().ConvertFromRub(result.priceYear)), '', ''); result.periodDiv.display = conf.usageType == 1; if (promoSC) { result.promoPrice = (promoSC.price + ddosPrice + (cpAS ? cpAS.price : 0) + (kaspAS ? kaspAS.price : 0)); if (promoSC.showCrossedRegularPrice) { result.promoSpan.innerHTML = _state.locale.getCurrency().PrintValue(_state.locale.getCurrency().ConvertFromRub(result.promoPrice).toString().Replace(",", "."), '', '', '', '', true); result.promoDiv.display = true; result.commonDiv.className = "price1 crossedPrice"; } else { result.promoDiv.display = false; result.commonDiv.className = "price1"; } result.periodDiv.innerHTML = (!promoSC.payPerMonth && promoSC.applyDiscount ? price2strSpanned + ' при оплате за год!
' : '') + (promoSC.url ? 'Подробное описание тарифа' : 'Срок действия тарифа ограничен' ); _nav.updatePageLinks(); } else { result.promoDiv.display = false; result.commonDiv.className = "price1"; result.periodDiv.innerHTML = price2strSpanned + ' при оплате за год!'; } result.price1 = promoSC && !promoSC.showCrossedRegularPrice ? result.promoPrice : price; if (conf.usageType == 2 && obj.tariffResource) { result.price1 = 60 * 24 * 30.4375 * ( obj.tariffResource.ram_mb * 1024 + (conf.ssd ? obj.tariffResource.drive.ssd_mb : obj.tariffResource.drive.hdd_mb) * conf.drive * 1024 + conf.ip * obj.tariffResource.ip) + (kaspAS ? kaspAS.price : 0); result.installPaymentDiv.display = obj.tariffResource.installPayment > 0; result.installPaymentDiv.priceHTML = "+" + _state.locale.getCurrency().PrintValue(_state.locale.getCurrency().ConvertFromRub(obj.tariffResource.installPayment).toString().Replace(",", "."), '', ' ', '', ''); } else result.installPaymentDiv.display = false; result.priceHTML = _state.locale.getCurrency().PrintValue(_state.locale.getCurrency().ConvertFromRub(result.price1).toString().Replace(",", "."), '', '', '', '', true); if (conf.usageType == 2) result.commonDiv.className += " res"; result.payForResourceDisplay = conf.usageType == 2; return result; }; var Controls = function () { } Controls.Obj = Controls.prototype = { subscribe: function () { var el = document.body ? document.body : document; jm.Events.Add(el, "mousedown", function (e) { _controls.cb.bodyMD(e, false, null, false); }); jm.Events.Add(el, "mouseup", function (e) { _controls.cb.bodyMU(e); }); jm.Events.Add(el, "mousemove", function (e) { if (e != null) { _controls.cb._mouseX = e.clientX; _controls.cb._mouseY = e.clientY; } }); jm.Events.Add(el, "keydown", function (e) { if (e != null && (e.keyCode == 27 || e.keyCode == 13)) _controls.cb.bodyMD(null, e.keyCode == 13, null, true); }); }, tb:{ help: { data: [], create: function (id, params) { var el = jm.el(id), prefixSize = params.prefix ? jm.Text.Measure(params.prefix, "font-size:16px") : null; if (!el || !params || !params.helpValue) return; var w = params.width - (prefixSize ? (prefixSize.Width + 5) : 0); el.className += " helpText"; params.tbStyle = (params.center ? 'text-align:center;' : '') + (params.fontSize > 0 ? 'font-size:' + params.fontSize + 'px;' : '') + 'width:' + w + 'px;' + (params.height > 0 ? 'height:' + params.height + 'px;' : '') + (prefixSize ? (params.prefixRight ? 'padding-right:' : 'padding-left:') + (prefixSize.Width + 19) + 'px;' : ''); el.innerHTML = '
0 || params.center || params.helpAddStyle ? 'style="' + (params.helpAddStyle ? params.helpAddStyle : "") + (params.fontSize > 0 ? 'font-size:' + params.fontSize + 'px;' : '') + (params.center ? 'width:' + w + 'px;text-align:center;' : '') + '"' : '')) + ' class="anim200l ' + (params.value ? "opacity0" : "opacity100") + '">' + params.helpValue.ToHTML() + '
' + (prefixSize ? '
0 ? ' style="margin-left:' + (params.width - (prefixSize ? prefixSize.Width : 0)) + 'px;"' : '') + '>' + params.prefix.ToHTML() + '
' : '') + (params.multiline ? ' 0 ? (' maxlength="' + params.maxLength + '"') : '') + (params.autocomplete ? (' autocomplete="' + params.autocomplete + '"') : '') + ' onfocus="_controls.tb.help.focus(\'' + id + '\');" onblur="_controls.tb.help.blur(\'' + id + '\');" onkeypress="_controls.tb.help.update(\'' + id + '\');" onkeyup="_controls.tb.help.update(\'' + id + '\');" onchange="_controls.tb.help.update(\'' + id + '\');" ' + (params.width > 0 ? ('style="' + params.tbStyle + (params.addStyle ? params.addStyle : '') + '" ') : '') + ' class="anim200l" ' + (params.multiline ? '>' + (params.value ? params.value.ToHTML() : '') + '' : '/>'); if (params.padding) { var tb = jm.el(id + '_tb'); tb.style.padding = params.padding; jm.el(id + '_help_div').style.padding = (tb.style.paddingTop.ToNumeric() + 3) + "px 0px " + (tb.style.paddingBottom.ToNumeric() + 3) + "px " + (tb.style.paddingLeft.ToNumeric() + 1) + "px"; } _controls.tb.help.data[id] = params; }, update: function (id) { var value = jm.el(id + "_tb").value, div = jm.el(id + "_help_div"), params = _controls.tb.help.data[id]; div.className = "anim200l " + (value.length == 0 ? "opacity100" : "opacity0"); if (params && params.onChange) params.onChange(); }, focus: function (id) { var params = _controls.tb.help.data[id]; if (params) { var el = jm.el(id + '_tb'); if (!el) return; if (params.activeStyle) if (params.keepAnim) el.style.cssText = params.tbStyle + params.activeStyle; else setTimeout(function () { el.className = ""; setTimeout(function () { el.style.cssText = params.tbStyle + params.activeStyle; setTimeout(function () { el.className = "anim200l"; }, 20); }, 20); }, 200); if (params.onFocus) params.onFocus(); } }, blur: function (id) { var params = _controls.tb.help.data[id]; if (params) { var el = jm.el(id + '_tb'); if (!el) return; if (params.activeStyle) if (params.keepAnim) el.style.cssText = params.tbStyle + (params.addStyle ? params.addStyle : ''); else setTimeout(function () { el.className = ""; setTimeout(function () { el.style.cssText = params.tbStyle + (params.addStyle ? params.addStyle : ''); setTimeout(function () { el.className = "anim200l"; }, 20); }, 20); }, 200); if (params.onBlur) params.onBlur(); } }, }, err: function (element, justLight, endClass){ var el = jm.el(element); if (!el) return; el.style.backgroundColor = "rgba(255,23,23,.5)"; if (!justLight) el.focus(); setTimeout(function () { el.className = (endClass ? endClass + " " : "") + "anim1000l"; setTimeout(function () { el.style.backgroundColor = ""; setTimeout(function () { el.className = endClass ? endClass : "anim200l"; }, 20); }, 20); }, 100); } }, iSelect: { data: [], create: function (id, items, sprite, selected, onStateChange) { var el = jm.el(id); if (!el || !sprite || !items || typeof (selected) == 'undefined') return; var itemsHeight = parseInt(el.getAttribute("itemsHeight")), addStyle = ""; if (itemsHeight > 0) addStyle = 'height:' + itemsHeight + 'px;' _controls.iSelect.data[id] = { id: id, sprite: sprite, onStateChange: onStateChange, exp: false, sel: selected, itemsHeight: itemsHeight > 0 ? itemsHeight : 0, items: items }; el.className = 'rsLayout'; el.innerHTML += '
'; el.innerHTML += '
'; el.style.height = (itemsHeight > 0 ? itemsHeight : 94) + 'px'; var optId, prev; items.forEach(function (item, i) { optId = id+i; if (i == selected && item) { el.innerHTML += '
'; el.setAttribute('data-sid', optId); } else if (item) el.innerHTML += '
'; }); }, toggle: function (id) { var d = _controls.iSelect.data[id]; if (!d) return; if (!d.exp) _controls.iSelect._expand(id); else _controls.iSelect._compact(id); }, select: function (id, i) { var optId = id + i, el = jm.el(optId), cel = jm.el(id), crEl = jm.el(id + '_c'), pel = jm.el(cel.getAttribute('data-sid')); if (!el || !cel || !crEl || !pel) return; var ocn = pel.className.replace('saE', 'sE'), ncn = el.className.replace('sE', 'saE'), ccn = ncn.replace('saE', 'scE'); if (ocn && ncn && ccn) pel.className = ocn, el.className = ncn, crEl.className = ccn; cel.setAttribute('data-sid', optId); _controls.iSelect.toggle(id); _controls.iSelect.data[id].sel = i; _controls.iSelect.data[id].onStateChange(id, i); }, getSelected: function(id) { return _controls.iSelect.data[id].sel; }, _compact: function (id) { var lt = jm.el(id), arEl = jm.el(id + '_a'), crEl = jm.el(id + '_c'), osEl = jm.el(id + '_o'), d = _controls.iSelect.data[id]; if (!lt || !arEl || !crEl || !osEl || !d) return; d.exp = false; arEl.className = 'a1'; crEl.style.display = 'block'; crEl.style.opacity = '1'; lt.style.boxShadow = 'none'; lt.style.transition = 'none'; lt.style.height = (d.itemsHeight > 0 ? d.itemsHeight : 94) + 'px'; osEl.style.opacity = '1'; osEl.style.transform = 'scale(1.3)'; setTimeout(function () { lt.style.transition = 'height .2s linear'; osEl.style.transform = 'scale(1)'; }, 10); }, _compactOthers: function (id) { for (var key in _controls.iSelect.data) if (key != id) _controls.iSelect._compact(key); }, _expand: function (id) { _controls.iSelect._compactOthers(id); var lt = jm.el(id), arEl = jm.el(id + '_a'), crEl = jm.el(id + '_c'), osEl = jm.el(id + '_o'), d = _controls.iSelect.data[id]; if (!lt || !arEl || !crEl || !osEl || !d) return; d.exp = true; arEl.className = 'a1a'; lt.style.height = ((d.itemsHeight > 0 ? d.itemsHeight : 94) * d.items.length) + "px"; lt.style.boxShadow = '0 0 4px 0 rgba(0,0,0,0.3)'; crEl.style.opacity = '0'; crEl.style.display = 'none'; osEl.style.opacity = '0'; } }, iSwitch: { data: [], create: function (id, state, change, params) { var el = jm.el(id); if (!el) return; _controls.iSwitch.data[id] = { id: id, change: change, state: state ? true : false, params: params, disabled: false }; var bgColor = params.bgColor ? 'background-color:' + params.bgColor + ';' : '', stateClass = state ? ('switch' + (params.small ? 'S' : '') + '_on') : ('switch' + (params.small ? 'S' : '')); if (params && params.nameOff && params.nameOn) el.innerHTML = '
' + (params.nameOff.indexOf(" 0 ? params.nameOff : ('' + params.nameOff + '')) + '
' + (params.nameOn.indexOf(" 0 ? params.nameOn : ('' + params.nameOn + '')) + '
'; else el.innerHTML = '
'; }, getState: function (id) { var d = _controls.iSwitch.data[id]; return d && d.state; }, setState: function (id, value, force) { var d = _controls.iSwitch.data[id]; if (d && d.state != value) _controls.iSwitch._click(id, false, force); }, _click: function (id, refreshOnly, force) { var d = _controls.iSwitch.data[id], div = jm.el(id + '_iSwitch_div'), table = jm.el(id + '_iSwitch_table'); if (!d || !div || !force && !refreshOnly && d.disabled) return; if (d.params && d.params.beforeChange && !d.params.beforeChange(!d.state, d.params)) return; if (!refreshOnly) d.state = !d.state; div.className = d.state ? ('switch' + (d.params.small ? 'S' : '') + '_on anim200l') : ('switch' + (d.params.small ? 'S' : '') + ' anim200l'); div.style.backgroundColor = d.state ? (d.params.onBG ? d.params.onBG : "") : (d.params.offBG ? d.params.offBG : ""); if (table) table.className = (d.state ? "switchT_on" : "switchT") + (d.disabled ? " switchDisabled" : ""); if (!refreshOnly && d.change) d.change(d.state, d.params); }, setDisabled: function (id, disabled) { var d = _controls.iSwitch.data[id]; if (!d) return; d.disabled = disabled; _controls.iSwitch._click(id, true, false); } }, fu:{ data: [], create: function (id, params) { var el = jm.el(id); if (!el) return; _controls.fu.data[id] = params; el.innerHTML = '
' + '' + '' + '
Файл не выбран
'; }, _selected: function (id) { var upload = jm.el(id + '_fu'), text = jm.el(id + '_text'), btn = jm.el(id + '_btn'), progress = jm.el(id + '_progress'), params = _controls.fu.data[id]; if (!upload || !upload.files || upload.files.length == 0) text.innerHTML = 'Файл не выбран'; else { function getExtension(name) { if (!name || name.length == 0) return null; for (var n = name.length - 1; n >= 0; n--) if (name.substring(n, n + 1) == ".") return name.substring(n + 1, name.length).Trim().toLowerCase(); return null; } function containsExtension(name){ if (!params.extension || params.extension.length == 0) return true; for (var n in params.extension) if (params.extension[n] && params.extension[n].Trim().toLowerCase() == name.Trim().toLowerCase()) return true; return false; } var str = '', fd = new FormData(), files = []; fd.append("elementId", id); for (var n in upload.files) { var file = upload.files[n], extension = file ? getExtension(file.name) : null; if (file && extension && containsExtension(extension) && (!params.maxSize || params.maxSize <= 0 || params.maxSize * 1048576 >= file.size)) { str += file.name + "; "; files[files.length] = file; fd.append("fileToUpload", file); } } if (str.length == 0) { text.innerHTML = 'Файл не выбран'; _controls.messageBox.show("Загрузка файла", '
' + '{0} некорректного формата или размера.'.Format(upload.files.length > 1 ? 'Выбраны файлы' : 'Выбран файл') + '
Пожалуйста, попробуйте еще раз.
', _controls.messageBox.button.ok, _controls.messageBox.icon.error, 600); } else { function clear() { _controls.fu._clear(id); }; text.innerHTML = str.substring(0, str.length - 2); var xhr = new XMLHttpRequest(); if (!xhr || !xhr.upload) { _controls.messageBox.show("Загрузка файла", '
Невозможно завершить загрузку выбранных файлов.
Пожалуйста, используйте более современный браузер, либо обновите текущий.
', _controls.messageBox.button.ok, _controls.messageBox.icon.error, 600); } xhr.upload.addEventListener("progress", function (e) { progress.style.width = Math.round((params.width - 135) * e.loaded / e.total) + "px"; }, false); xhr.addEventListener("load", function (e) { clear(); if (e && e.target && e.target.responseText) jm.Script.Write("_controls.fu._load" + e.target.responseText, null, true); }, false); xhr.addEventListener("error", clear, false); xhr.addEventListener("abort", clear, false); xhr.open("POST", "/fileUpload.h"); btn.disabled = "disabled"; btn.value = "Подождите..."; upload.style.visibility = "hidden"; xhr.send(fd); } } }, _clear: function (id) { var upload = jm.el(id + '_fu'), text = jm.el(id + '_text'), btn = jm.el(id + '_btn'), progress = jm.el(id + '_progress'); if (!upload || !text || !btn || !progress) return; jm.el(id + "_form").reset(); text.innerHTML = 'Файл не выбран'; btn.disabled = ""; btn.value = "Выберите файл..."; progress.style.width = "0px"; upload.style.visibility = ""; }, _load: function (rejectReason, id, files) { var err = null; if (rejectReason == 1) err = '
Вы не авторизованы.
Попробуйте обновить страницу и повторить операцию.
'; else if (rejectReason > 0) err = '
Возникла неизвестная ошибка.
Пожалуйста, обратитесь к службе поддержки.
'; _controls.fu._clear(id); if (err) _controls.messageBox.show("Загрузка файла", err, _controls.messageBox.button.ok, _controls.messageBox.icon.error, 600); else if (files && files.length > 0) { var params = _controls.fu.data[id]; if (params && params.load) params.load(files); } }, del: function (id, fileId) { if (!id) return false; jm.AJAX({ URL: "/fileDeleteTmp.h?fName=_controls.fu._delResult&r=" + jm.Random.Int(), Type: "post", Data: { "elementId": id, "fileId": fileId, }, Async: true, IsAnswerScript: true }); }, _delResult: function (rejectReason, id, fileId) { if (rejectReason > 0) return; var params = _controls.fu.data[id]; if (params && params.del) params.del(fileId); } }, showNotification: function (el, innerHtml, scrollToTop) { var notifDiv = jm.el(el); if (!notifDiv) return; notifDiv.innerHTML = innerHtml; notifDiv.className = "notif notifBgNew"; notifDiv.style.display = ""; setTimeout(function () { if (scrollToTop) $('html, body').animate({ scrollTop: 0 }, 500); setTimeout(function () { notifDiv.className = "notif notifBg notificationAP"; }, 500); }, 20); }, inputSuccessShow: function (element, value) { if (!element) return; var el = jm.el(element); if (!el) return; el.innerHTML = value; el.className = "success anim200 opacity100 transX0"; }, inputSuccessHide: function (element) { if (!element) return; var el = jm.el(element); if (!el) return; el.className = "success anim200 opacity0 transX20"; }, inputErrShow: function (element, value) { if (!element) return; var el = jm.el(element); if (!el) return; el.innerHTML = value; el.className = "err anim200 opacity100 transX0"; }, inputErrHide:function(element) { if (!element) return; var el = jm.el(element); if (!el) return; el.className = "err anim200 opacity0 transX20"; }, scrollAndFocus: function (element, addToScroll) { if (!element) return; var el = jm.el(element); if (!el) return; var docH = jm.Window.Document.Height(), scrollTop = jm.Window.Document.ScrollTop(), scrollLeft = jm.Window.Document.ScrollLeft(), wH = jm.Window.Height(); if (docH <= wH) el.focus(); else { var location = jm.gDim(el); if (scrollTop > location.Top - 120 - addToScroll) { $('html, body').animate({ scrollTop: location.Top - addToScroll }, 200); setTimeout(function () { el.focus(); }, 200); } else if (scrollTop + wH < location.Top + location.Height + 40 + addToScroll) { $('html, body').animate({ scrollTop: location.Top + location.Height + 40 + addToScroll }, 200); setTimeout(function () { el.focus(); }, 200); } else el.focus(); } }, progress: { add: function (element, showDelay, addStyle) { if (!element || element == "") return; var el = jm.el(element); if (!el || !el.id || el.id == "" || el.id.indexOf('"') >= 0 || el.id.indexOf("'") >= 0) return; if (!jm.el(el.id + "_progress_img")) el.innerHTML = ''; if (!jm.Browser.Opera && showDelay > 0) setTimeout(function () { jm.Elements.SetOpacity(el.id + "_progress_img", 1); }, showDelay); }, create: function (element, addStyle) { if (!element || element == "") return null; var el = jm.el(element), _isProgress = true; if (!el || !el.id || el.id == "" || el.id.indexOf('"') >= 0 || el.id.indexOf("'") >= 0) return null; el.innerHTML = '
'; this.Stop = function () { _isProgress = false; }; function _movieBg(top) { if (!_isProgress) return; var progressDiv = jm.el(el.id + '_progress_div'); if (!progressDiv) return; if (isNaN(top)) top = 0; top -= 6; if (top < -30) top = 0; progressDiv.style.backgroundPosition = "0px " + (top) + "px"; _timeOut = setTimeout(function () { _movieBg(top); }, 100); } _timeOut = setTimeout(function () { _movieBg(0); }, 100); return this; } }, cb:{ "Data": [], "_maxHeight": 250, "_mouseX": -10000, "_mouseY": -10000, "_mouseLastItemOverX": -10000, "_mouseLastItemOverY": -10000, "isDisabled": function (id) { var selEl = jm.el(id); return !selEl || selEl.disabled == true || selEl.disabled == "disabled"; }, "Refresh": function (id) { var params = _controls.cb.Data[id]; if (!params) return; if (_controls.cb.isDisabled(id)) { _controls.cb.elMOut(id, false); if (params.Dynamic && params.Input && params.LoadUrl && params.LoadUrl.length > 0) { jm.el(id + "_cb_titleInput").disabled = "disabled"; jm.el(id + "_cb_titleTbDiv").className = "CBdisabled"; } else jm.el(id + "_cb_parent").className = "noSel CBdisabled"; jm.el(id + "_cb_td").className = "CBarrowTdDisabled anim200l"; } else { if (params.Dynamic && params.Input && params.LoadUrl && params.LoadUrl.length > 0) { jm.el(id + "_cb_titleInput").disabled = ""; jm.el(id + "_cb_titleTbDiv").className = ""; } else jm.el(id + "_cb_parent").className = "noSel"; jm.el(id + "_cb_td").className = "CBarrowTd anim200l"; } }, "elMOver": function (id, isSelect) { if (_controls.cb.isDisabled(id)) return; if (isSelect) _controls.cb.Data[id].SelectHasFocus = true; jm.el(id + "_cb_div").className = "CB CBH anim200l"; jm.el(id + "_cb_td").className = "CBarrowTd CBarrowTdH" + (_controls.cb.Data[id].style == "red" ? "_red" : "_blue") + " anim200l"; jm.el(id + "_cb_borderTd").className = "CBarrowTdBorderH anim200l"; }, "elMOut": function (id, isSelect) { if (isSelect) _controls.cb.Data[id].SelectHasFocus = false; if (jm.el(id + "_cb_itemsDiv").style.height == "0px" && _controls.cb.Data[id].SelectHasFocus == false) { jm.el(id + "_cb_div").className = "CB anim200l"; jm.el(id + "_cb_td").className = (_controls.cb.isDisabled(id) ? "CBarrowTdDisabled" : "CBarrowTd") + " anim200l"; jm.el(id + "_cb_borderTd").className = "CBarrowTdBorder anim200l"; } }, "elMDown": function (id, e) { if (_controls.cb.isDisabled(id)) return; _controls.cb.Data[id].IsSelectMD = true; _controls.cb.elMOver(id, false); if (e == null || e.button == 0 || e.button == 1) { var el = jm.el(id + "_cb_itemsDiv"), elTop = jm.el(id + "_cb_itemsTopDiv"), selEl = jm.el(id); if (el && selEl && el.style.height == "0px") { var height = jm.el(id + "_cb_itemsTable").offsetHeight; if (height <= 0) height = _controls.cb._maxHeight; if (height > _controls.cb._maxHeight) height = _controls.cb._maxHeight; var itemsCount = _controls.cb.overSelectedItem(id, height); if (itemsCount == 0) return; elTop.style.display = ""; elTop.style.zIndex = parseInt(el.style.zIndex) + 11; el.style.visibility = "visible"; el.style.zIndex = parseInt(el.style.zIndex) + 10; el.style.height = height + "px"; var tb = jm.el(id + "_cb_tb"); if (tb) { tb.style.display = ""; tb.value = ""; } var titleTbDiv = jm.el(id + "_cb_titleTbDiv"), tbTitle = jm.el(id + "_cb_titleInput"); if (titleTbDiv && tbTitle) { titleTbDiv.className = "OptionalTextColor"; jm.Elements.SetOpacity(tbTitle, 1); titleTbDiv.innerHTML = (tbTitle.value.length > 0 ? '' + tbTitle.value.ToHTML().Replace(" ", " ") + ' ' : '') + _controls.cb.selectedHtml(id, true); } else { _controls.cb.Data[id].TypedText = ""; _controls.cb.focusKeyCapture(id); } } else _controls.cb.hideItems(id, false, false); } }, "overSelectedItem": function (id, height) { //mark item, corresponds the selectedValue of real control var el = jm.el(id + "_cb_itemsDiv"), selEl = jm.el(id), params = _controls.cb.Data[id]; if (!el || !selEl || !params) return; var itemsCount = 0; for (var n = 0; n < selEl.options.length; n++) { var item = selEl.options[n]; if (_controls.cb.validOption(item)) { itemsCount++; var itemTd = jm.el(selEl.id + "_item_" + n + "_cb_td"); if (!itemTd) continue; if (item.value == selEl.value) { if (el.style.overflowY != "hidden") { var st = itemTd.offsetTop - (height - itemTd.offsetHeight) / 2; if (st < 0) st = 0; jm.el(id + "_cb_itemsDiv").scrollTop = st; } itemTd.className = item.value == params.EmptyId ? "" : ("CBItemSel_" + (params.style == "red" ? "red" : "blue") + " CBitemHover"); } else itemTd.className = ""; } } return itemsCount; }, "selectLeave": function (id) { var selEl = jm.el(id); if (!selEl) return; var newSelItem = selEl.selectedIndex + "_" + (selEl.value ? selEl.value : ""), params = _controls.cb.Data[id]; if (params) { if (params.SelectedItem != newSelItem && params.OnChange != null) params.OnChange(params.Tag); params.SelectedItem = newSelItem; } }, "focusKeyCapture": function (id) { setTimeout(function () { var tb = jm.el(id + "_cb_tb"); if (tb && tb.style.display != "none") tb.focus(); }, 10); return false; }, "elChange": function (id, isSelect) { var el = jm.el(id), params = _controls.cb.Data[id]; if (!params || !el || el.selectedIndex == undefined || el.selectedIndex < 0) return; if (params.Dynamic && params.Input && params.LoadUrl && params.LoadUrl.length > 0) jm.el(id + "_cb_titleTbDiv").value = _controls.cb.selectedHtml(id, true); else jm.el(id + "_cb_titleDiv").innerHTML = "" + _controls.cb.selectedHtml(id) + ""; if (isSelect) _controls.cb.elMOver(id, true); }, "itemsShowed": function (id) { var el = jm.el(id + "_cb_itemsDiv"); return el && el.style.height != "0px"; }, "hideItems": function (id, isOut, setSelectedItem) { var itemsShowed = _controls.cb.itemsShowed(id); if (itemsShowed) { var tb = jm.el(id + "_cb_tb"), el = jm.el(id + "_cb_itemsDiv"), elTop = jm.el(id + "_cb_itemsTopDiv"); if (tb) tb.style.display = "none"; el.style.height = "0px"; el.style.visibility = "hidden"; el.className = "CBItems anim200"; setTimeout(function () { elTop.style.display = "none"; el.className = "CBItems CBItemsH anim200"; }, 200); var zIndex = parseInt(el.style.zIndex) - 10 el.style.zIndex = zIndex > 0 ? zIndex : 0; if (setSelectedItem) { var si = _controls.cb.divSelectedIndex(id); if (si >= 0) { jm.el(id).selectedIndex = si; _controls.cb.elChange(id, false); } } var titleTbDiv = jm.el(id + "_cb_titleTbDiv"), tbTitle = jm.el(id + "_cb_titleInput"); if (titleTbDiv && tbTitle) { titleTbDiv.className = ""; jm.Elements.SetOpacity(tbTitle, 0); titleTbDiv.innerHTML = _controls.cb.selectedHtml(id, false); } } if (isOut) { if (itemsShowed || setSelectedItem) _controls.cb.selectLeave(id); _controls.cb.elMOut(id, true); } }, "divSelectedIndex": function (id) { var selEl = jm.el(id); if (!selEl) return -1; for (var n = 0; n < selEl.options.length; n++) { var item = selEl.options[n]; if (_controls.cb.validOption(item)) { var itemTd = jm.el(selEl.id + "_item_" + n + "_cb_td"); if (!itemTd) continue; if (itemTd.className == "CBItemSel_" + (_controls.cb.Data[id].style == "red" ? "red" : "blue") + " CBitemHover") return n; } } return -1; }, "itemMouseOver": function (id, itemIndex, mouseEvent) { if (mouseEvent != null) { _controls.cb._mouseX = mouseEvent.clientX; _controls.cb._mouseY = mouseEvent.clientY; if (_controls.cb._mouseX == _controls.cb._mouseLastItemOverX && _controls.cb._mouseY == _controls.cb._mouseLastItemOverY) return; } _controls.cb._mouseLastItemOverX = _controls.cb._mouseX; _controls.cb._mouseLastItemOverY = _controls.cb._mouseY; jm.el(id + "_item_" + itemIndex + "_cb_td").className = "CBItemSel_" + (_controls.cb.Data[id].style == "red" ? "red" : "blue") + " CBitemHover"; var selEl = jm.el(id); if (!selEl) return; for (var n = 0; n < selEl.options.length; n++) { if (n == itemIndex) continue; var item = selEl.options[n]; if (_controls.cb.validOption(item)) { var itemTd = jm.el(selEl.id + "_item_" + n + "_cb_td"); if (!itemTd || itemTd.className == "") continue; itemTd.className = ""; } } }, "itemMouseUp": function (id, itemIndex, e) { if (e == null || e.button == 0 || e.button == 1) { jm.el(id).selectedIndex = itemIndex; _controls.cb.hideItems(id, true, false); _controls.cb.elChange(id, false); } }, "tbBlur": function (id) { if (!_controls.cb.Data[id].IsItemsMD) _controls.cb.hideItems(id, true, false); }, "keyDown": function (id, e) { if (e != null && (e.keyCode == 38 || e.keyCode == 40)) { var tb = jm.el(id + "_cb_tb"); if (!tb) tb = jm.el(id + "_cb_titleInput"); if (tb && tb.style.display != "none") { _controls.cb.selectNext(id, e.keyCode == 38); return false; } } return true; }, "keyUp": function (id, e) { var tb = jm.el(id + "_cb_tb"); if (tb) { var value = tb.value; if (value && value != undefined && value.length > 0) { if (tb) tb.value = ""; var dt = new Date(); if (dt - _controls.cb.Data[id].LastTypeDT > 1000) _controls.cb.Data[id].TypedText = value.toLowerCase(); else _controls.cb.Data[id].TypedText += value.toLowerCase(); _controls.cb.Data[id].LastTypeDT = dt; var selEl = jm.el(id), typedText = _controls.cb.Data[id].TypedText; for (var n = 0; n < selEl.options.length; n++) { var item = selEl.options[n], itemHtml = item.innerHTML.Replace("{{{", "<").Replace("}}}", ">").Trim(); if (_controls.cb.validOption(item) && itemHtml.length >= typedText.length && itemHtml.substring(0, typedText.length).toLowerCase() == typedText) { if (selEl.selectedIndex != n) { var oldN = selEl.selectedIndex; selEl.selectedIndex = n; _controls.cb.setSelectedIndex(id, oldN > n, n); } break; } } } } else { var tbTitle = jm.el(id + "_cb_titleInput"), tbTitleDiv = jm.el(id + "_cb_titleTbDiv"); if (tbTitle && tbTitleDiv) { tbTitleDiv.innerHTML = (tbTitle.value.length > 0 ? '' + tbTitle.value.ToHTML().Replace(" ", " ") + ' ' : '') + _controls.cb.selectedHtml(id, true); var params = _controls.cb.Data[id]; if (!params) return; var value = tbTitle.value.Trim().toLowerCase(); if (params.TypedText != value) { params.TypedText = value; var data = params.LoadedList[value]; if (!data) _controls.cb.sendLoadRequest(id, 0, 30); else { _controls.cb.ClearItems(id); if (data.List && data.List.length > 0) for (var n in data.List) _controls.cb.AddItem(id, params.GetIdByLoadedItem(data.List[n]), params.GetNameByLoadedItem(data.List[n], true), params.GetNameByLoadedItem(data.List[n], false)); else _controls.cb.AddItem(id, params.EmptyId, params.NotFoundText, params.NotFoundHtml); var height = _controls.cb.RefreshItemsListHeight(id); jm.el(id + '_cb_itemsDiv').scrollTop = 0; _controls.cb.overSelectedItem(id, height); tbTitleDiv.innerHTML = (tbTitle.value.length > 0 ? '' + tbTitle.value.ToHTML().Replace(" ", " ") + ' ' : '') + _controls.cb.selectedHtml(id, true); } } } } }, "selectNext": function (id, up) { var selEl = jm.el(id); if (!selEl) return; var updated = false; var si = _controls.cb.divSelectedIndex(id); if (si < 0) si = selEl.selectedIndex; if (!up && si < selEl.options.length - 1) { selEl.selectedIndex = si + 1; updated = true; } else if (up && si > 0) { selEl.selectedIndex = si - 1; updated = true; } if (updated) _controls.cb.setSelectedIndex(id, up, selEl.selectedIndex); return updated; }, "setSelectedIndex": function (id, up, n) { _controls.cb.itemMouseOver(id, n, null); var itemTd = jm.el(id + "_item_" + n + "_cb_td"), itemsDiv = jm.el(id + "_cb_itemsDiv"); if (itemTd && itemsDiv) { if (up) { if (itemsDiv.scrollTop > itemTd.offsetTop) itemsDiv.scrollTop = itemTd.offsetTop; else if (itemsDiv.scrollTop < itemTd.offsetTop - itemsDiv.offsetHeight) itemsDiv.scrollTop = itemTd.offsetTop - (itemsDiv.offsetHeight - itemTd.offsetHeight); } else { var compareVal = itemTd.offsetTop - (itemsDiv.offsetHeight - itemTd.offsetHeight); if (itemsDiv.scrollTop < compareVal) itemsDiv.scrollTop = compareVal; else if (itemsDiv.scrollTop > compareVal + itemsDiv.offsetHeight) itemsDiv.scrollTop = itemTd.offsetTop; } } _controls.cb.elChange(id, false); }, "bodyMD": function (e, setSelectedItem, exceptionId, forceHide) { for (var id in _controls.cb.Data) if (exceptionId != id && _controls.cb.Data[id] != null) { var el = jm.el(id); if (!el) _controls.cb.Data[id] = null; else{ _controls.cb.Data[id].IsItemsMU = false; if (_controls.cb.Data[id].IsSelectMD) { _controls.cb.Data[id].IsSelectMD = false; if (!forceHide) continue; } _controls.cb.hideItems(id, true, setSelectedItem); var tbTitle = jm.el(id + "_cb_titleInput"); if (tbTitle) tbTitle.blur(); } } }, "bodyMU": function (e) { for (var id in _controls.cb.Data) if (_controls.cb.Data[id] != null) { var el = jm.el(id); if (!el) _controls.cb.Data[id] = null; else { if (_controls.cb.Data[id].IsItemsMD && !_controls.cb.Data[id].IsItemsMU) _controls.cb.focusKeyCapture(id); _controls.cb.Data[id].IsItemsMD = false; } } }, "validOption": function (item) { return item && item.tagName && item.tagName != undefined && item.tagName.toLowerCase() == "option" && item.value && item.value != undefined && item.value != "" && item.innerHTML && item.innerHTML != undefined && item.innerHTML != "" && item.value.indexOf('"') < 0 && item.value.indexOf("'") < 0; }, "selectedHtml": function (id, emptyIfNothing) { var el = jm.el(id), params = _controls.cb.Data[id]; if (!el || el.selectedIndex == undefined || el.selectedIndex < 0 || !params) return emptyIfNothing ? "" : _controls.cb.Data[id].DefText; var listItem = el.options[el.selectedIndex]; if (params.Dynamic && params.Input && params.LoadUrl && params.LoadUrl.length > 0 && params.GetNameByLoadedItem && params.GetLoadedItemById) { var tbTitle = jm.el(id + "_cb_titleInput"); function tryGet(key) { var data = params.LoadedList[key]; if (data && data.List && data.List.length > 0) { var item = params.GetLoadedItemById(data.List, listItem.value); if (item) return params.GetNameByLoadedItem(item, false); } return null; } if (tbTitle) { var val = tryGet(tbTitle.value.Trim().toLowerCase()); if (val) return val; } for (var searchKey in params.LoadedList) { var val = tryGet(searchKey); if (val) return val; } } if (!_controls.cb.validOption(listItem) || listItem.value == params.EmptyId) return emptyIfNothing ? "" : _controls.cb.Data[id].DefText; return listItem.innerHTML.Replace("{{{", "<").Replace("}}}", ">"); }, "Create": function (selectControl, params, onChange) {/*params:DefaultText,Width,ItemsHeight,ItemsPadding,ItemInControlPadding*/ if (!selectControl) return; var itemsPadding = { "Top": 0, "Right": 0, "Bottom": 0, "Left": 0 }, itemInControlPadding = { "Top": 0, "Right": 0, "Bottom": 0, "Left": 0 }; if (params && params.ItemsPadding) { itemsPadding = params.ItemsPadding; itemInControlPadding = params.ItemsPadding } if (params && params.ItemInControlPadding) itemInControlPadding = params.ItemInControlPadding; var defaultText = params && params.DefaultText && params.DefaultText.length > 0 ? params.DefaultText : ""; var itemsHeight = params && params.ItemsHeight && params.ItemsHeight > 0 ? params.ItemsHeight : 18; var width = params && params.Width && params.Width > 0 ? params.Width : 100; var selEl = jm.el(selectControl); if (!selEl || !selEl.options || !selEl.id || selEl.id == "" || selEl.id.indexOf('"') >= 0 || selEl.id.indexOf("'") >= 0) return; _controls.cb.Data[selEl.id] = { "Tag": params.Tag, "IsSelectMD": false, "IsItemsMD": false, "IsItemsMU": false, "SelectHasFocus": false, "DefText": defaultText, "TypedText": params.SearchText && params.SearchText.length > 0 ? params.SearchText : "", "LastTypeDT": new Date(), "SelectedItem": selEl.selectedIndex + "_" + (selEl.value ? selEl.value : ""), "ItemInControlPadding": itemInControlPadding, "itemsHeight": itemsHeight, "OnChange": onChange, "itemsPadding": itemsPadding, "itemInControlPadding": itemInControlPadding, "Dynamic": params.Dynamic, "Input": params.Input, "LoadUrl": params.LoadUrl, "LoadRequestParams": params.LoadRequestParams, "UpdateList": params.UpdateList, "LoadedList": [], // lists of loaded results for text queries "_loadResult": function (userId, searchText, audioCount, list) { if (searchText == null || searchText == undefined) searchText = ""; var p = _controls.cb.Data[selEl.id]; if (!p) return; var sText = searchText.Trim().toLowerCase(); var searchList = p.LoadedList[sText], clearControl = true, newItems = []; if (!searchList) { searchList = { "TotalCount": audioCount, "List": list }; p.LoadedList[sText] = searchList; newItems = list; } else { searchList.TotalCount = audioCount; if (!p.UpdateList) searchList.List = newItems = list; else { newItems = p.UpdateList(searchList.List, list, null); clearControl = false; } } if (clearControl) _controls.cb.ClearItems(selEl.id); if (newItems && newItems.length > 0) for (var n in newItems) _controls.cb.AddItem(selEl.id, p.GetIdByLoadedItem(newItems[n]), p.GetNameByLoadedItem(newItems[n], true), p.GetNameByLoadedItem(newItems[n], false)); else if (clearControl) _controls.cb.AddItem(selEl.id, params.EmptyId, params.NotFoundText, params.NotFoundHtml); if (params.OnLoadItemId) { _controls.cb.SetValue(selEl.id, params.OnLoadItemId); params.OnLoadItemId = null; } var height = _controls.cb.RefreshItemsListHeight(selEl.id); if (clearControl) { jm.el(selEl.id + '_cb_itemsDiv').scrollTop = 0; _controls.cb.overSelectedItem(selEl.id, height); } var tbTitleDiv = jm.el(selEl.id + "_cb_titleTbDiv"); if (tbTitleDiv) tbTitleDiv.innerHTML = (searchText && searchText.length > 0 && _controls.cb.itemsShowed(selEl.id) ? '' + searchText.ToHTML().Replace(" ", " ") + ' ' : '') + _controls.cb.selectedHtml(selEl.id, true); }, "GetLoadedItemById": params.GetLoadedItemById, "GetIdByLoadedItem": params.GetIdByLoadedItem, "GetNameByLoadedItem": params.GetNameByLoadedItem, "EmptyId": params.EmptyId, "NotFoundText": params.NotFoundText, "NotFoundHtml": params.NotFoundHtml, style: params.style }; var dynamicInput = params.Dynamic && params.Input && params.LoadUrl && params.LoadUrl.length > 0, headPadding = 'padding:0px;', headWidth = 'width:' + (width - itemInControlPadding.Right - itemInControlPadding.Left - 26) + 'px;'; jm.Elements.AddAttribute(selEl, "onmousedown", "return false;"); if (dynamicInput) { jm.Elements.AddAttribute(selEl, "onfocus", "jm.el('" + selEl.id + "_cb_titleInput').focus();"); } else { jm.Elements.AddAttribute(selEl, "onfocus", "_controls.cb.elMOver('" + selEl.id + "', true);"); jm.Elements.AddAttribute(selEl, "onblur", "_controls.cb.elMOut('" + selEl.id + "', true); _controls.cb.selectLeave('" + selEl.id + "');"); } jm.Elements.AddAttribute(selEl, "onchange", "_controls.cb.elChange('" + selEl.id + "', true);"); jm.Elements.AddAttribute(selEl, "onkeypress", "_controls.cb.elChange('" + selEl.id + "', true);"); jm.Elements.AddAttribute(selEl, "onkeyup", "_controls.cb.elChange('" + selEl.id + "', true);"); var popupWidth = width + 2 + (params.addItemsWidth > 0 || params.addItemsWidth < 0 ? params.addItemsWidth : 0); var html = '
' + '' + '' + '' + '
' + ( dynamicInput ? ('
' + '') : ('
' + _controls.cb.selectedHtml(selEl.id) + '
') ) + '
' + (dynamicInput ? '' : ('
')) + '
' + '' + ''; selEl.parentElement.appendChild(div); selEl.style.position = "absolute"; selEl.style.left = "-30000px"; selEl.style.width = "1px"; selEl.style.height = "1px"; jm.Elements.SetOpacity(selEl, 0); var itemsTotalHeight = itemsCount * (itemsHeight + itemsPadding.Top + itemsPadding.Bottom); if (itemsTotalHeight < _controls.cb._maxHeight) jm.el(selEl.id + "_cb_itemsDiv").style.overflowY = "hidden"; jm.el(selEl.id + "_cb_itemsDiv").style.zIndex = (selEl.style.zIndex == "" ? 0 : parseInt(selEl.style.zIndex)) + 1; jm.el(selEl.id + "_cb_itemsTopDiv").style.zIndex = (selEl.style.zIndex == "" ? 0 : parseInt(selEl.style.zIndex)) + 2; _controls.cb.Refresh(selEl.id); if (dynamicInput) { var titleTb = jm.el(selEl.id + '_cb_titleInput'); if (titleTb) { jm.Elements.SetOpacity(titleTb, 0); if (params.SearchText && params.SearchText.length > 0) titleTb.value = params.SearchText; var loadCount = params.FirstLoadCount && params.FirstLoadCount > 0 ? params.FirstLoadCount : 30; if (params.SearchTextItems && params.SearchTextItems.List.length >= loadCount && params.SearchTextItems.TotalCount > 0) _controls.cb.Data[selEl.id]._loadResult(null, titleTb.value, params.SearchTextItems.TotalCount, params.SearchTextItems.List); else _controls.cb.sendLoadRequest(selEl.id, 0, loadCount); } } if (params.Dynamic) jm.Events.Add(jm.el(selEl.id + "_cb_itemsDiv"), "scroll", function (yOffset) { if (yOffset.target) yOffset = yOffset.target.scrollTop; var params = _controls.cb.Data[selEl.id], listDiv = jm.el(selEl.id + "_cb_itemsDiv"), listTable = jm.el(selEl.id + "_cb_itemsTable"); if (!params || !params.LoadUrl || params.LoadUrl.length == 0 || !listDiv || !listTable) return; var docHeight = listTable.offsetHeight, windowHeight = listDiv.offsetHeight; if (docHeight && windowHeight && yOffset + windowHeight + windowHeight / 2 >= docHeight) { var tb = jm.el(selEl.id + "_cb_titleInput"); if (tb) { var data = params.LoadedList[tb.value.Trim().toLowerCase()]; if (data && data.List && data.List.length < data.TotalCount) _controls.cb.sendLoadRequest(selEl.id, data.List.length, data.TotalCount - data.List.length < 30 ? data.TotalCount - data.List.length : 30); } } }); return div; }, "sendLoadRequest": function (id, indexFrom, count) { var params = _controls.cb.Data[id], tb = jm.el(id + '_cb_titleInput'); if (!params || !params.LoadUrl || params.LoadUrl.length == 0 || !tb) return; var data = { "searchText": tb.value, "indexFrom": indexFrom, "count": count }; if (params.LoadRequestParams) for (var n in params.LoadRequestParams) { var p = params.LoadRequestParams[n]; data[p.Key] = p.Value; } jm.AJAX({ URL: params.LoadUrl.Replace("{0}", encodeURI('_controls.cb.Data["' + id + '"].') + "_loadResult") + "&r=" + jm.Random.Int(), Type: "post", Data: data, Async: true, IsAnswerScript: true }); }, "CreateOrUpdate": function (selectControl, params, onChange) {/*params:DefaultText,Width,ItemsHeight,ItemsPadding,ItemInControlPadding*/ if (!selectControl) return; var selEl = jm.el(selectControl); if (!selEl || !selEl.options || !selEl.id || selEl.id == "" || selEl.id.indexOf('"') >= 0 || selEl.id.indexOf("'") >= 0) return; var itemsPadding = { "Top": 0, "Right": 0, "Bottom": 0, "Left": 0 }; if (params && params.ItemsPadding) itemsPadding = params.ItemsPadding; var itemsHeight = params && params.ItemsHeight && params.ItemsHeight > 0 ? params.ItemsHeight : 18; var parent = jm.el(selEl.id + "_cb_parent"), itemsDiv = jm.el(selEl.id + "_cb_itemsDiv"); if (_controls.cb.Data[selEl.id] == null || !parent || !itemsDiv) _controls.cb.Create(selectControl, params, onChange); else{ var width = params && params.Width && params.Width > 0 ? params.Width : 100; if (!itemsPadding) itemsPadding = { "Top": 0, "Right": 0, "Bottom": 0, "Left": 0 }; var itemsCount = 0, html = ''; for (var n = 0; n < selEl.options.length; n++) { var item = selEl.options[n]; if (_controls.cb.validOption(item)) { itemsCount++; html += ''; } } itemsDiv.innerHTML = html + '
' + (params.keepSpaces ? item.innerHTML : item.innerHTML.Replace(" ", " ")).Replace("{{{", "<").Replace("}}}", ">") + '
'; var itemsTotalHeight = itemsCount * (itemsHeight + itemsPadding.Top + itemsPadding.Bottom); itemsDiv.style.overflowY = itemsTotalHeight < _controls.cb._maxHeight ? "hidden" : "scroll"; itemsDiv.innerHTML = itemsDiv.innerHTML; if (itemsDiv.style.height != "0px") { var height = itemsTotalHeight; if (height <= 0) height = _controls.cb._maxHeight; if (height > _controls.cb._maxHeight) height = _controls.cb._maxHeight; itemsDiv.style.height = height + "px"; _controls.cb.overSelectedItem(selEl.id, height); } jm.el(selEl.id + "_cb_titleDiv").innerHTML = "" + _controls.cb.selectedHtml(selEl.id) + ""; if (params && params.Width && params.Width > 0) _controls.cb.SetWidth(selEl.id, params.Width); if (onChange != null && onChange != undefined) { _controls.cb.Data[selEl.id].OnChange = onChange; _controls.cb.Data[selEl.id].SelectedItem = selEl.selectedIndex + "_" + (selEl.value ? selEl.value : ""); } } }, "SetValue": function (id, value) { var sel = jm.el(id), result = false; if (sel && sel.length > 0) { var selIndex = sel.selectedIndex; sel.value = value; if (!sel.value || sel.value == "") sel.selectedIndex = selIndex; else result = true; _controls.cb.elChange(id, false); _controls.cb.selectLeave(id); } return result; }, "SetWidth": function (id, value) { if (value < 30) return; var data = _controls.cb.Data[id], cbDiv = jm.el(id + '_cb_div'), titleParentDiv = jm.el(id + '_cb_titleParentDiv'), titleTB = jm.el(id + '_cb_titleInput'), titleDiv = jm.el(id + '_cb_titleDiv'), itemsDiv = jm.el(id + '_cb_itemsDiv'); if (!data) return; if (cbDiv) cbDiv.style.width = (value - 10) + "px"; if (titleParentDiv) titleParentDiv.style.width = (value - data.ItemInControlPadding.Right - data.ItemInControlPadding.Left - 26) + "px"; if (titleTB) titleTB.style.width = (value - data.ItemInControlPadding.Right - data.ItemInControlPadding.Left - 26) + "px"; if (titleDiv) titleDiv.style.width = (value - data.ItemInControlPadding.Right - data.ItemInControlPadding.Left - 26) + "px"; if (itemsDiv) itemsDiv.style.width = (value + 4) + "px"; }, "GetFitWidth": function (id) { var data = _controls.cb.Data[id], selEl = jm.el(id), maxWidth = 0; if (data && selEl) { for (var n = 0; n < selEl.options.length; n++) { var item = jm.el(selEl.id + '_item_' + n + '_cb_div'); if (item && item.offsetWidth > maxWidth) maxWidth = item.offsetWidth; } maxWidth += (data.ItemInControlPadding.Right + data.ItemInControlPadding.Right + 26); } return maxWidth > 100 ? maxWidth : 100; }, "GetSearchText": function (id) { var titleTB = jm.el(id + '_cb_titleInput'); return titleTB ? titleTB.value : ""; }, "GetLoadedItems": function (id, searchText) { var data = _controls.cb.Data[id]; if (!data || !data.LoadedList) return null; return data.LoadedList[searchText && searchText.length > 0 ? searchText.Trim().toLowerCase() : ""]; }, "ClearItems": function (id) { var data = _controls.cb.Data[id], selEl = jm.el(id) if (!data || !selEl) return; selEl.options.length = 0; var itemsDiv = jm.el(selEl.id + '_cb_itemsDiv'); if (itemsDiv) itemsDiv.innerHTML = '
'; //_controls.cb.hideItems(id, false, false); }, "AddItem": function (id, value, text, html) { var params = _controls.cb.Data[id], selEl = jm.el(id); if (!params || !selEl) return; var item = new Option(text, value); selEl.options[selEl.options.length] = item; var itemsTable = jm.el(id + '_cb_itemsTable'), itemsDiv = jm.el(selEl.id + '_cb_itemsDiv'); var n = selEl.options.length - 1; if (!html || html.length == 0) html = (params.keepSpaces ? item.innerHTML : item.innerHTML.Replace(" ", " ")).Replace("{{{", "<").Replace("}}}", ">"); var itemHtml = '
' + html + '
'; if (itemsTable) { var tr = document.createElement('tr'); var td = document.createElement('td'); td.id = selEl.id + '_item_' + n + '_cb_td'; td.innerHTML = itemHtml; if (value != params.EmptyId) { td.onmouseover = function (e) { _controls.cb.itemMouseOver(selEl.id, n, e); } td.onmouseup = function (e) { _controls.cb.itemMouseUp(selEl.id, n, e); } } tr.appendChild(td); itemsTable.appendChild(tr); } else if (itemsDiv) itemsDiv.innerHTML = '
' + itemHtml + '
'; var itemsTotalHeight = selEl.options.length * (params.itemsHeight + params.itemsPadding.Top + params.itemsPadding.Bottom); itemsDiv.style.overflowY = itemsTotalHeight < _controls.cb._maxHeight ? "hidden" : "scroll"; }, "RefreshItemsListHeight": function (id) { var params = _controls.cb.Data[id], selEl = jm.el(id), itemsTable = jm.el(id + "_cb_itemsTable"), itemsDiv = jm.el(selEl.id + '_cb_itemsDiv'); if (!params || !selEl) return; //if (!itemsTable || selEl.options.length == 0) _controls.cb.hideItems(id, false, false); if (itemsDiv && itemsDiv.style.height != "0px") { var height = itemsTable.offsetHeight; if (height <= 0 || height > _controls.cb._maxHeight) height = _controls.cb._maxHeight; itemsDiv.style.height = height + "px"; return height; } return 0; } }, windows: { count: 0, data: [], actionSource: { bgClick: 1, esc: 2, cancelBtn: 3, closeIcon: 4 }, create: function (uniqueId, params) { if (!uniqueId || !params || params.changedBgTo != uniqueId && jm.el(uniqueId + "_bg_div")) return; var bg = document.createElement("div"), wnd = document.createElement("div"), topWndId = _controls.windows.getTopWindowId(); bg.id = uniqueId + "_bg_div"; bg.className = "window_lock anim200 opacity0"; _controls.windows.data[uniqueId] = params; _controls.windows.count++; params.index = _controls.windows.count; if (_controls.windows.count == 1) { document.body.style.overflowY = "hidden"; document.body.style.padding = "0px " + (params.overflowY != "none" && params.overflowY != "auto" ? 17 : 0) + "px 0px 0px"; var headerTd = jm.el("main_Header_td"), headerMenuTd = jm.el("main_HeaderMenu_td"); if (headerTd && headerMenuTd) headerMenuTd.style.display = headerTd.style.display = ""; } else if (topWndId) { var t = jm.el(topWndId + "_wnd_table"); if (t) { t.parentElement.style.overflowY = "hidden"; t.parentElement.style.margin = '0px 0px 0px -' + (jm.Browser.IE || jm.Browser.Firefox || jm.Browser.Opera ? 8 : 9) + 'px'; } } bg.style.zIndex = _controls.windows.count * 10; wnd.innerHTML = '
 ' + '
' + '
' + /*'
' + params.title + '
' + */params.body + '
' + '
 
'; if (!params.withoutBG) document.body.appendChild(bg); document.body.appendChild(wnd.childNodes[0]); if (params.onCreate) params.onCreate(); var wndDiv = jm.el(uniqueId + "_wnd_div"); if (wndDiv && params.fromTop) wndDiv.style.transform = 'translateY(-' + wndDiv.offsetHeight + 'px)'; setTimeout(function () { wndDiv.className += " anim500"; }, 10); }, show: function (uniqueId) { var bg = jm.el(uniqueId + "_bg_div"), wnd = jm.el(uniqueId + "_wnd_table"), params = _controls.windows.data[uniqueId]; if (!wnd || !params) return; if (!params.withoutBG) bg.className = "window_lock anim200 opacity50"; wnd.className = "c opacity100 " + (params.fromTop ? "anim500" : "anim300"); if (params.fromTop) { var wndDiv = jm.el(uniqueId + "_wnd_div"); if (wndDiv) wndDiv.style.transform = 'translateY(' + (params.fromTopY >= 0 ? params.fromTopY : 120) + 'px)'; } _ttText.Update(); }, close: function (uniqueId, leaveBgWithId, actionSource) { var body = jm.el(uniqueId + "_body_div"), bg = jm.el(uniqueId + "_bg_div"), wnd = jm.el(uniqueId + "_wnd_table"), params = _controls.windows.data[uniqueId]; if (!wnd || !params) return; if (params.onClose && !params.onClose(actionSource)) return; _controls.windows.data[uniqueId] = null; _controls.windows.count--; if (!leaveBgWithId && bg) bg.className = "window_lock anim200 opacity0"; if (leaveBgWithId && bg) bg.id = leaveBgWithId + "_bg_div"; wnd.parentElement.style.overflowY = wnd.parentElement.style.overflow = "hidden"; wnd.parentElement.style.margin = '0px 0px 0px -' + (jm.Browser.IE || jm.Browser.Firefox || jm.Browser.Opera ? 8 : 9) + 'px'; wnd.className = "c opacity0 " + (params.fromTop ? "anim500" : "anim300 hide"); if (params.fromTop) { var wndDiv = jm.el(uniqueId + "_wnd_div"); if (wndDiv) wndDiv.style.transform = 'translateY(-' + wndDiv.offsetHeight + 'px)'; } setTimeout(function (t_bg, t_wnd, t_leaveBgWithId) { if (!t_leaveBgWithId && t_bg) t_bg.parentElement.removeChild(t_bg); t_wnd.parentElement.parentElement.removeChild(t_wnd.parentElement); var topWndId = _controls.windows.getTopWindowId() if (_controls.windows.count == 0) { document.body.style.overflowY = params.overflowY == "none" || params.overflowY == "auto" ? params.overflowY : "scroll"; document.body.style.padding = "0px"; var headerTd = jm.el("main_Header_td"), headerMenuTd = jm.el("main_HeaderMenu_td"); if (headerTd && headerMenuTd) headerMenuTd.style.display = headerTd.style.display = "none"; } else if (topWndId) { var t = jm.el(topWndId + "_wnd_table"); if (t) { t.parentElement.style.overflowY = params.overflowY == "none" || params.overflowY == "auto" ? params.overflowY : "scroll"; t.parentElement.style.margin = '0px'; } } }, params.fromTop ? 500 : 300, bg, wnd, leaveBgWithId); }, _bgClick: function (uniqueId, e) { var p = _controls.windows.data[uniqueId]; if (!p || jm.Mouse.GetButton(e) != "left") return; if (p.md) p.md = false; else _controls.windows.close(uniqueId, null, _controls.windows.actionSource.bgClick); }, _bodyMAct: function (uniqueId, e) { if (jm.Mouse.GetButton(e) != "left") return; var p = _controls.windows.data[uniqueId]; if (p) p.md = true; }, getTopWindowId: function () { var maxIndex = -1, uId = null; for (var uniqueId in _controls.windows.data) { var p = _controls.windows.data[uniqueId]; if (p && p.index > maxIndex) { maxIndex = p.index; uId = uniqueId; } } return uId; }, closeTop: function (mbOkSelect, actionSource) { var uId = _controls.windows.getTopWindowId(); if (uId && (!mbOkSelect || uId.length > "messageBox".length && uId.substring(0, "messageBox".length) == "messageBox")) { if (mbOkSelect) _controls.messageBox._okClick(uId); else _controls.windows.close(uId, null, actionSource); return true; } return false; }, closeAll: function () { while (true) if (!_controls.windows.closeTop()) break; } }, calendar: { "Data": [], "Create": function (id, params) { if (!id || !params || !params.date) return; var el = jm.el(id); if (!el) return; _controls.calendar.Data[id] = params; var day = params.date.getDate(), month = (params.date.getMonth() + 1); if (day < 10) day = "0" + day; if (month < 10) month = "0" + month; var html = '
' + day + '.' + month + '.' + params.date.getFullYear() + '
' + ''; el.innerHTML = html; }, "SetDate": function (id, date) { var div = jm.el('calendar_' + id + '_div'), titleDiv = jm.el('calendarTitle_' + id + '_div'), params = _controls.calendar.Data[id]; if (!div || !titleDiv || !date || !params) return; params.date = date; var day = date.getDate(), month = (date.getMonth() + 1); if (day < 10) day = "0" + day; if (month < 10) month = "0" + month; titleDiv.innerHTML = day + '.' + month + '.' + params.date.getFullYear(); div.style.display = "none"; titleDiv.className = "DatePicker anim100l"; }, "GetDate": function (id) { var params = _controls.calendar.Data[id]; return params ? params.date : null; }, "_md": function (id, titleClick) { var div = jm.el('calendar_' + id + '_div'), titleDiv = jm.el('calendarTitle_' + id + '_div'), params = _controls.calendar.Data[id]; if (!div || !titleDiv || !params) return; params.md = true; if (titleClick) if (div.style.display == "none") { titleDiv.className = "DatePicker DatePickerH anim100l"; _controls.calendar._buildCalendar(id, params.date); div.style.display = ""; } else { div.style.display = "none"; titleDiv.className = "DatePicker anim100l"; } }, "_bmd": function () { for (var id in _controls.calendar.Data) { var p = _controls.calendar.Data[id]; if (!p) continue; if (p.md) p.md = false; else { var div = jm.el('calendar_' + id + '_div'), titleDiv = jm.el('calendarTitle_' + id + '_div') if (div) div.style.display = "none"; if (titleDiv) titleDiv.className = "DatePicker anim100l"; } } }, "_buildCalendar": function (id, month) { var div = jm.el('calendarBody_' + id + '_div'), html = '', p = _controls.calendar.Data[id]; if (!div || !month || !p) return false; month = new Date(month.getFullYear(), month.getMonth(), 1); var d = month.getDay(), m = month.getMonth(); if (d == 0) d = 7; html = '' + '' + '' + '
' + (m == 0 ? 'Январь' : m == 1 ? 'Февраль' : m == 2 ? 'Март' : m == 3 ? 'Апрель' : m == 4 ? 'Май' : m == 5 ? 'Июнь' : m == 6 ? 'Июль' : m == 7 ? 'Август' : m == 8 ? 'Сентябрь' : m == 9 ? 'Октябрь' : m == 10 ? 'Ноябрь' : m == 11 ? 'Декабрь' : '') + ' ' + month.getFullYear() + '
' + '
ПнВтСрЧтПтСбВс
'; var table = '', n = 0, r = 1; function equal(d1, d2) { return d1.getFullYear() == d2.getFullYear() && d1.getMonth() == d2.getMonth() && d1.getDate() == d2.getDate(); } function toStr(date) { return "new Date(" + date.getFullYear() + "," + date.getMonth() + "," + date.getDate() + ")"; } if (d > 1) for (var a = d - 1; a >= 1; a--) { var tmpDate = new Date(month.getFullYear(), month.getMonth(), 1); tmpDate.setDate(tmpDate.getDate() - a); n++; table += ''; } while (m == month.getMonth()) { n++; table += ''; if (n % 7 == 0) { table += ''; r++; } month.setDate(month.getDate() + 1); } d = month.getDay(); if (d == 0) d = 7; if (d > 1) for (var a = 0; a <= 7 - d; a++) { var tmpDate = new Date(month.getFullYear(), month.getMonth(), 1); tmpDate.setDate(tmpDate.getDate() + a); table += ''; } if (table.substring(table.length - 4, table.length) == '') { table = table.substring(0, table.length - 4); r -= 1; } div.innerHTML = html + '
' + table + '
' + tmpDate.getDate() + '
' + month.getDate() + '
' + tmpDate.getDate() + '
'; return false; } }, messageBox: { button: { ok: 1, ok_cancel: 2, yes_no: 3 }, icon: { info: 1, question: 2, warning: 3, error: 4 }, dialogResult: { ok: 1, cancel: 2, yes: 3, no: 4 }, _data: [], show: function (title, body, buttons, icon, width, onmousedown, resultAction, overflowY, extraStyle) { var uniqueId = "messageBox" + jm.Random.Int(); _controls.messageBox._data[uniqueId] = { resultAction: resultAction, buttons: buttons }; _controls.windows.create(uniqueId, { width: width, title: title, overflowY: overflowY, titleStyle: icon == _controls.messageBox.icon.error ? "error" : "", body: (extraStyle ? '

' + title + '

' : '') + "
" + body.Replace("{uid}", uniqueId) + '
' + (extraStyle ? '' : ( '
' + (buttons == _controls.messageBox.button.ok ? '' : (buttons == _controls.messageBox.button.ok_cancel ? '' : '')) + '
')) + (extraStyle ? '
' : ''), onClose: function () { var data = _controls.messageBox._data[uniqueId]; if (data && data.resultAction) data.resultAction(data.buttons == _controls.messageBox.button.ok ? _controls.messageBox.dialogResult.ok : (data.buttons == _controls.messageBox.button.ok_cancel ? _controls.messageBox.dialogResult.cancel : _controls.messageBox.dialogResult.no)); _controls.messageBox._data[uniqueId] = null; return true; } }); setTimeout(function () { var ok = jm.el(uniqueId + '_OKbtn'); if (ok) ok.focus(); _controls.windows.show(uniqueId); }, 20); }, _okClick: function (uniqueId) { var data = _controls.messageBox._data[uniqueId]; if (data && data.resultAction) data.resultAction(data.buttons == _controls.messageBox.button.ok || data.buttons == _controls.messageBox.button.ok_cancel ? _controls.messageBox.dialogResult.ok : _controls.messageBox.dialogResult.yes); _controls.messageBox._data[uniqueId] = null; _controls.windows.close(uniqueId); } }, authConfirmation:{ _pwdHash: null, _clearPwd: null, _result: null, _lastPassword: null, show: function (title, useHashPassword, result, overflowY) { if (useHashPassword && _controls.authConfirmation._pwdHash) { if (result) result(_controls.authConfirmation._pwdHash); return; } _controls.authConfirmation._result = result; _controls.windows.create("authConfirmation", { width: 380, title: title, overflowY: overflowY, body: '
Для выполнения этой операции требуется подтверждение
Наберите пароль от Вашего аккаунта
' + '
' + '
', onClose: function () { return true; }, }); _controls.tb.help.create("confirm_Password_div", { width: 250, helpValue: "••••••••••", password: true, maxLength: 50 }); setTimeout(function () { _controls.windows.show("authConfirmation"); jm.el('confirm_Password_div_tb').focus(); }, 20); }, apply: function () { var pwd = jm.el('confirm_Password_div_tb').value.Trim(); if (pwd.length < 6) { _controls.tb.err("confirm_Password_div_tb"); return; } _controls.windows.close("authConfirmation"); if (_controls.authConfirmation._result) _controls.authConfirmation._result(pwd); _controls.authConfirmation._result = null; }, setPasswordHash: function (password) { _controls.authConfirmation._pwdHash = password; if (_controls.authConfirmation._clearPwd) window.clearTimeout(_controls.authConfirmation._clearPwd); _controls.authConfirmation._clearPwd = window.setTimeout(function () { _controls.authConfirmation._pwdHash = null; _controls.authConfirmation._clearPwd = null; }, 300000); } }, payment:{ _params: null, getAttachedCardsHTML: function () { var result = '', hasAttachedCards = false if (!_autoPayments.isEnabled() || jm.Data["PayPage"] || !_auth.user) return ''; for (var n in _auth.user.paymentAccounts.sort(function (a, b) { return a.priority > b.priority ? 1 : -1; })) { var pa = _auth.user.paymentAccounts[n]; if (!pa || pa.removed) continue; var exp = ""; if (pa.additionalInfo && pa.additionalInfo.exp) { var m = pa.additionalInfo.exp.getMonth() + 1, y = pa.additionalInfo.exp.getFullYear(); if (y > 2000) y -= 2000; if (m.toString().length == 1) m = "0" + m; if (y.toString().length == 1) y = "0" + y; exp = m + "/" + y; } hasAttachedCards = true; result += '
' + _formatCardNumer(pa.paymentSource) + '' + exp + '
' + (pa.additionalInfo ? pa.additionalInfo.holder : '') + '
Выбрать для оплаты
'; } if (result != '') result = '
Привязанные карты
' + result; return '
' + result + '
' + '
ПРИВЯЗАТЬ КАРТУ
' + '
' + (hasAttachedCards ? 'Добавить новую карту' : _autoPayments.moneyBack > 0 ? 'Привяжи карту и получи на счет
{0}{2}%{1} от суммы платежа'.Format('', '', _autoPayments.moneyBack) : 'Привяжи карту для удобства
дальнейших платежей') + '
'; }, _showPM: function () { var div = jm.el("payment_Methods_div"); if (!div) return; if (div.offsetHeight > 0) { div.style.height = "0px"; div.style.opacity = 0; } else { div.style.height = (div.scrollHeight > 0 ? div.scrollHeight : 450) + "px"; div.style.opacity = 1; setTimeout(function () { var div = jm.el("payment_Methods_div"), body = jm.el("payment_body_div"); if (!div || div.style.opacity != 1 || !body || body.scrollHeight - body.clientHeight <= 100) return; $(body).animate({ scrollTop: body.scrollHeight - body.clientHeight }, 300); }, 500); } }, _setBody: function (includeBalance, hideLegalTransfer, clearObj){ var div = jm.el("payment_Body_div"), p = _controls.payment._params, hasAttachedCards = _autoPayments.isEnabled() && !jm.Data["PayPage"] && _auth.user && _auth.user.paymentAccounts && _auth.user.paymentAccounts.length > 0 && _auth.user.paymentAccounts.some(function (a) { return a && !a.removed; }) > 0; if (!div) return; var currency = _state.locale.getCurrency(); div.innerHTML = '

Сумма' + (p && (p.objectId > 0 || p.staticAmount) && p.amountRub > 0 ? ' к оплате' : '') + '

' + '
' + '
' + _controls.payment.getAttachedCardsHTML() + '
' + '

' + (hasAttachedCards ? '' : '') + '{0} платежную систему'.Format(_autoPayments.isEnabled() && !jm.Data["PayPage"] ? 'Или выберите' : 'Выберите') + (hasAttachedCards ? '' : '') + '

' + '
 
' + (!currency.SupportsPM(_cardPaymentMethod) ? '' : ('
Банковская
карта VISA
')) + (!currency.SupportsPM(_cardPaymentMethod) ? '' : ('
Банковская
карта MC
')) + (!currency.SupportsPM(PaymentMethod.Card_Skrill) ? '' : ('
Банковская
карта VISA
')) + (!currency.SupportsPM(PaymentMethod.Card_Skrill) ? '' : ('
Банковская
карта MC
')) + (!currency.SupportsPM(PaymentMethod.Card_PayPal) ? '' : ('
Банковская
карта VISA
')) + (!currency.SupportsPM(PaymentMethod.Card_PayPal) ? '' : ('
Банковская
карта MC
')) + (!currency.SupportsPM(PaymentMethod.Qiwi) ? '' : ('
QIWI
кошелек
')) + (!currency.SupportsPM(PaymentMethod.WebMoney) ? '' : ('
WEB
MONEY
')) + (!currency.SupportsPM(PaymentMethod.YandexMoney) ? '' : ('
ЯНДЕКС
Деньги
')) + (!currency.SupportsPM(PaymentMethod.SberbankOnline) ? '' : ('
СБЕРБАНК
ОНЛАЙН
')) + (!currency.SupportsPM(PaymentMethod.Skrill) ? '' : ('
Skrill
')) + (!currency.SupportsPM(PaymentMethod.PayPal) ? '' : ('
PayPal
')) + (!currency.SupportsPM(PaymentMethod.Transfer) || hideLegalTransfer ? '' : ('
Счет для
юр. лиц
')) + (!currency.SupportsPM(PaymentMethod.Balance) || !includeBalance ? '' : ('
Мой
баланс
')) + '
 
'; if (clearObj && _controls.payment._params) { _controls.payment._params.objectId = _controls.payment._params.objectType = null; var titleDiv = jm.el('payment_title_div'); if (titleDiv) titleDiv.innerHTML = 'Пополнение баланса'; } _controls.payment._updateMethod(); }, create: function (amountRub, currencyStr, title, objectType, objectId, staticAmount) { var currency = _state.locale.getCurrency(); amountRub = amountRub.toString().ToNumeric(); var amount = jm.Math.Round(currency.ConvertFromRub(amountRub), 2); var err = null; if (err) { _controls.messageBox.show("Формирование платежа", err, _controls.messageBox.button.ok, _controls.messageBox.icon.warning, 500); return; } _controls.windows.create("payment", { width: 650, title: title ? title : "НОВЫЙ ПЛАТЕЖ", body: '
' + '' + '

' + (title ? title : "НОВЫЙ ПЛАТЕЖ") + '

' + '
', }); _controls.payment._params = { currencyStr: currencyStr, objectType: objectType, objectId: objectId, amountRub: amountRub, staticAmount: staticAmount }; _controls.payment._setBody(title && _auth.user.balance > 0.5 && objectId > 0); _controls.tb.help.create("payment_Amount_div", { width: 300, value: isNaN(amountRub) || amountRub > 500000 || amountRub < 10 ? "" : amount.toString(), helpValue: "Введите сумму пополнения", maxLength: 10, prefix: currency._symbol }); if ((staticAmount || objectId > 0) && amountRub > 0) { jm.el("payment_Amount_div").style.display = "none"; jm.el("payment_AmountStatic_div").style.display = ""; jm.el("payment_AmountStatic_div").innerHTML = currency.PrintValue(amount, '', ''); } setTimeout(function () { _controls.windows.show("payment"); }, 20); }, _updateMethod: function () { var btn = jm.el("payment_OK_btn"), legalCB = jm.el("payment_Method5_input"), balanceCB = jm.el("payment_Method20_input"); if (!btn || btn.disabled) return; btn.value = legalCB && legalCB.checked ? "Получить счет" : (balanceCB && balanceCB.checked ? "Завершить" : "Перейти к оплате"); }, _payClick: function (pm, attachedId) { var p = _controls.payment._params, progress = jm.el("payment_Progress_div"), payUserEmail = jm.Data["PayPage"] && jm.el('payment_Email_div_tb') ? jm.el('payment_Email_div_tb').value.Trim() : null; if (pm <= 0 || !progress) return; var amountRub = p && p.amountRub && p.amountRub != 0 ? p.amountRub // Pre-defined virtual server cost : jm.Math.Round(_state.locale.getCurrency().ConvertToRub(jm.el('payment_Amount_div_tb').value.ToNumeric()), 2); // Entered amount in current currency if (payUserEmail != null && !payUserEmail.ValidateEMail()) _controls.tb.err("payment_Email_div_tb"); else if (amountRub <= 0) _controls.tb.err("payment_Amount_div_tb"); else if (amountRub < 10) _controls.messageBox.show("Формирование платежа", "Минимальная сумма для оплаты - {0}".Format(_state.locale.getCurrency().PrintValue(_state.locale.getCurrency().ConvertFromRub(10))), _controls.messageBox.button.ok, _controls.messageBox.icon.error, 500); else if (amountRub < 300 && (pm == 4 || pm == 14)) _controls.messageBox.show("Формирование платежа", (pm == 4 ? "Минимальная сумма для оплаты через PayPal - {0}" : "Минимальная сумма для оплаты банковской картой через PayPal - {0}").Format(_state.locale.getCurrency().PrintValue(_state.locale.getCurrency().ConvertFromRub(300))), _controls.messageBox.button.ok, _controls.messageBox.icon.error, 500); else if (amountRub < 500 && pm == 5) _controls.messageBox.show("Формирование платежа", "Минимальная сумма для оплаты банковским переводом - {0}".Format(_state.locale.getCurrency().PrintValue(_state.locale.getCurrency().ConvertFromRub(500))), _controls.messageBox.button.ok, _controls.messageBox.icon.error, 700); else if (pm == 5 && !_auth.user.hasOrg) _auth.org.show(); else { progress.style.display = ""; progress.className = "payProgress anim200"; setTimeout(function () { progress.style.opacity = 1; setTimeout(function () { _controls.payment.createRequest( pm, amountRub, jm.Data["PayPage"] ? jm.Data["PayPage"].payForUserId : null, payUserEmail, p ? p.objectType : null, p ? p.objectId : null, "attachedId:" + attachedId ); }, 300); }, 20); } }, createRequest: function (pm, amountRub, payForUserId, payUserEmail, objectType, objectId, additionalData) { _actCounter('pay_order'); jm.AJAX({ URL: "/payment_Create.h?fName=_controls.payment._createResult&r=" + jm.Random.Int(), Type: "post", Data: { userId: _auth.user ? _auth.user.hash : null, paymentMethod: pm, amount: jm.Math.Round(amountRub, 2), forUserId: payForUserId, email: payUserEmail, objectType: objectType, objectId: objectId, orderPage: jm.Data["OrderPage"] ? 1 : 0, additionalData: additionalData }, Async: true, IsAnswerScript: true }); }, _createResult: function (rr, userId, pm, result) { var div = document.createElement('div'), tmpId = 'btn' + jm.Random.Int(), err = null, progress = jm.el("payment_Progress_div"); function goSrv() { if (jm.Data["OrderPage"]) jm.Data["OrderPage"].paySuccess(false); else if (jm.Data["BalancePage"]) { _controls.windows.close('payment'); jm.Data["BalancePage"].rebuild(); } else { _controls.windows.close('addServer'); _controls.windows.close('payment'); var objSrv = jm.Data["ServersPage"]; if (objSrv && objSrv.updateSrv) objSrv.updateSrv(); else _nav.go("/my/servers/last"); } } if (rr == 1) err = "
Вы не авторизованы.
Попробуйте обновить страницу и повторить операцию.
"; else if (rr == 2) err = pm == 30 ? "
Не удалось найти привязанную банковскую карту для совершения платежа.
Попробуйте обновить страницу и повторить операцию.
" : "
Сервер для оплаты не найден в системе.
Попробуйте обновить страницу и повторить операцию.
"; else if (rr == 3) { goSrv(); return; } else if (rr == 4) err = "
Неверная конфигурация сервера.
Попробуйте обновить страницу и повторить операцию.
"; else if (rr == 5) err = "
Не удалось рассчитать стоимость сервера.
Пожалуйста, обратитесь к службе поддержки.
"; else if (rr == 6) err = "
Возникла неизвестная ошибка при сохранении данных.
Пожалуйста, обратитесь к службе поддержки.
"; else if (rr == 7) err = "
На Вашем балансе недостаточно средств.
Пожалуйста, предварительно пополните его или выберите другой способ платежа.
"; else if (rr == 8) err = userId ? "Адрес email клиента не подтвержден" : '
Ваш адрес email не подтвержден.
' + '
Перейдите к {0}Личным данным аккаунта{1} для исправления ошибки.
'.Format('', ''); else if (rr == 9) err = userId ? "Возможность приобретения новых услуг и продления уже существующих отключена для {0}, оплата невозможна.".Format('данного аккаунта') : "
" + "Возможность приобретения новых услуг и продления уже существующих отключена для {0}, оплата невозможна.".Format('Вашего аккаунта') + "
Пожалуйста, обратитесь к службе поддержки.
"; else if (rr == 10) err = "Карточка организации не заполнена или заполнена не полностью"; else if (rr == 11) err = "
Произошла неизвестная ошибка при формировании документа.
Пожалуйста, обратитесь к службе поддержки.
"; else if (rr == 12) err = "Сумма для пополнения задана некорректно"; else if (rr == 13) err = "Данные переданы некорректно."; else if (rr == 18) err = "Транзакция была отклонена процессинговым центром."; else if (rr == 19) err = "Вы сможете продлить данный сервер не ранее, чем за 1 неделю до окончания его текущего расчетного периода"; else if (rr > 0) err = "
Возникла неизвестная ошибка.
Пожалуйста, обратитесь к службе поддержки.
"; if (err) { _controls.messageBox.show("Формирование платежа", err, _controls.messageBox.button.ok, _controls.messageBox.icon.error, err.length <= 50 ? 500 : 700); if (progress) { progress.style.opacity = 0; setTimeout(function () { progress.className = "payProgress"; progress.style.display = "none"; }, 300); } } if (rr == 0 && pm > 0 && _controls.payment.fill(div, tmpId, pm, result)) { if (pm == 5) { if (jm.el("srv_OK_btn") && jm.Data["MainPage"]) _nav.go("/my/servers/last"); _controls.windows.close('addServer'); _controls.windows.close('payment'); if (jm.Data["OrderPage"]) jm.Data["OrderPage"].paySuccess(true); else setTimeout(function (){ _controls.messageBox.show( "Формирование счета", '
Счет на оплату сформирован и доступен в загрузках Вашего браузера.
' + '
После оплаты, пожалуйста, отправьте копию платёжного поручения на support@ruvds.com для ускорения процесса зачисления средств.
' + '
Если Вы еще не подписали или не отправили Договор, обязательно сделайте это, загрузив его со страницы {0}Личных данных аккаунта{1}.
'.Format('', ''), _controls.messageBox.button.ok, _controls.messageBox.icon.info, 700); }, 500); var btn = jm.el('balance_Pay_btn'); if (btn) { btn.disabled = ""; btn.value = "Оплатить"; } } else if (pm != 4 && pm != 14) { document.body.appendChild(div.childNodes[0]); jm.el(tmpId).click(); } } else if (rr == 0 && (pm == 20 || pm == 30)) { if (pm == 30 && result && result.length >= 3) { if (jm.Data["BalancePage"]) { jm.Data["BalancePage"].addNewRow(result[0]);//payment jm.Data["BalancePage"].addNewRow(result[1]);//money back jm.Data["BalancePage"].showSuccess(result[0].amount, result[0].cur); var totalInSpan = jm.el("balance_TotalIn_span"); if (totalInSpan) totalInSpan.innerHTML = result[2]; } else if (jm.Data["ServersPage"]) _controls.messageBox.show( "Оплата", '
Ваш платёж на {0} успешно получен.
'.Format(_state.locale.getCurrency().PrintValue(_state.locale.getCurrency().ConvertFromRub(result[0].amount).toString().Replace(".", ","))) + '
Cпасибо!
', _controls.messageBox.button.ok, _controls.messageBox.icon.info, 400); } _auth.updateBalance(); goSrv(); } }, fill: function (el, tmpId, pm, params) { if (pm == 1 && params && params.length >= 8) { el.innerHTML = '
'; return true; } else if (pm == 2 && params && params.length >= 8) { el.innerHTML = '
'; return true; } else if (pm == 3 && params && params.length >= 8) { el.innerHTML = '
'; return true; } else if ((pm == 4 || pm == 14) && params && params.length >= 1) { window.location = params[0]; return true; } else if (pm == 5 && params && params.length >= 1) { window.location = "/document_Get.h?id=" + params[0]; return true; } else if (pm == 6 && params && params.length >= 2 && params[0] && params[1] && params[0].length > 0 && params[1].length > 0) { el.innerHTML = '
'; return true; } else if (pm == 7 && params && params.length >= 8) { el.innerHTML = '
'; return true; } else if ((pm == 8 || pm == 13) && params) { el.innerHTML = '\
\ \ \ \ \ \ \ \ \ \ \ \
'; return true; } else if (pm == 11 && params && params.length >= 8) { el.innerHTML = '
'; return true; } return false; }, showMsgResult: function (success, amount, currency) { _controls.windows.create("paymentSuccess", { width: 600, title: success ? "Успешная операция" : "Неуспешная операция", body: '

' + (success ? 'УСПЕШНАЯ ОПЕРАЦИЯ' : 'НЕУСПЕШНАЯ ОПЕРАЦИЯ') + '

' + (success ? '
Оплата прошла успешно.
В течение 30 минут платёж будет обработан (обычно моментально).
' : '
Оплата не была успешно завершена.
Пожалуйста, попробуйте повторить операцию через несколько минут, либо выберите другой способ оплаты.
') + '
', }); setTimeout(function () { _controls.windows.show("paymentSuccess"); }, 20); }, attachCard: { _3DSecurityCloseConfirmed: false, _check3DSecureResult: window.setInterval(function () { var iframe = jm.el("payment_CardAuth_iframe"); if (!iframe) return; try { if (iframe.contentWindow.location.href.toLowerCase().indexOf("/card_3dsecure/result") >= 0) { var payDataId = iframe.getAttribute("payDataId"); if (payDataId && payDataId.length > 0) { iframe.setAttribute("payDataId", ""); _controls.windows.close("payment_3dsecure"); setTimeout(function (pdId) { jm.AJAX({ URL: "/payment_AttachAction.h?fName=_controls.payment.attachCard._result&r=" + jm.Random.Int(), Type: "post", Data: { action: "3ds_result", payDataId: pdId }, Async: true, IsAnswerScript: true }); }, 1000, payDataId); } } } catch (ex) { } }, 1000), show: function () { if (_auth.user && _auth.user.currency > 0 && !jm.Data.DbCache.Currency.GetById(_auth.user.currency).SupportsPM(PaymentMethod.Autopayment)) { _controls.messageBox.show("Ошибка", "Выбранная вами валюта аккаунта не поддерживает привязку банковских карт", _controls.messageBox.button.ok, _controls.messageBox.icon.error, 600); return; } _controls.windows.create("payment_addCard", { width: 400, title: "ДОБАВЛЕНИЕ КАРТЫ", body: '
' + '' + '

Добавление карты

' + '
' + '
' + '
Номер карты
' + '
Владелец карты
' + '
Срок действия CVV
' + '' + '' + '' + '' + '' + '
 / 
' + '
' + '
', onClose: function (actionSource) { return actionSource != _controls.windows.actionSource.bgClick; } }); var addStyle = "border-top:none;border-left:none;border-right:none;border-bottom:1px solid #999999;border-radius:0px;"; _controls.tb.help.create("payment_CardNumber_div", { width: 293, helpValue: "XXXX-XXXX-XXXX-XXXX", maxLength: 30, autocomplete: "off", center: true, addStyle: addStyle }); _controls.tb.help.create("payment_HolderName_div", { width: 293, value: _auth.user.engName ? _auth.user.engName.toUpperCase() : null, helpValue: "IVAN IVANOV", maxLength: 50, autocomplete: "off", center: true, addStyle: addStyle }); _controls.tb.help.create("payment_Code_div", { width: 50, helpValue: "XXX", maxLength: 4, autocomplete: "off", center: true, addStyle: addStyle }); _controls.cb.Create("payment_ExpMonth_select", { DefaultText: "Месяц", Width: 90, ItemsHeight: 24, ItemsPadding: { Top: 6, Right: 6, Bottom: 6, Left: 9 }, IsFirstHeader: true, addStyle: addStyle }); var yearSelect = jm.el("payment_ExpYear_select"), nowYear = jm.DateTime.UTC().getUTCFullYear(); for (var n = nowYear; n <= 2030; n++) yearSelect.options[n - nowYear + 1] = new Option(n, n); var birthYearCbDiv = _controls.cb.Create("payment_ExpYear_select", { DefaultText: "Год", Width: 80, ItemsHeight: 24, ItemsPadding: { Top: 6, Right: 6, Bottom: 6, Left: 9 }, IsFirstHeader: true, addStyle: addStyle }); setTimeout(function () { _controls.windows.show("payment_addCard"); }, 20); }, click: function () { var cardNumber = jm.el("payment_CardNumber_div_tb").value.ExtractDigits(), holderName = jm.el("payment_HolderName_div_tb").value.Trim().ExtractLatinLetters(), code = jm.el("payment_Code_div_tb").value.ExtractDigits(), expMonth = parseInt(jm.el("payment_ExpMonth_select").value), expYear = parseInt(jm.el("payment_ExpYear_select").value), err = false, nowDT = jm.DateTime.UTC(), btn = jm.el("payment_AddCard_btn"), progress = jm.el("payment_AddCardProgress_div"); while (holderName.indexOf(" ") >= 0) holderName = holderName.Replace(" ", " "); if (!code || code.length < 3) { err = true; _controls.tb.err("payment_Code_div_tb"); } if (!holderName || holderName.indexOf(" ") < 0) { err = true; _controls.tb.err("payment_HolderName_div_tb"); } if (!cardNumber.ValidateCreditCardNumber()) { err = true; _controls.tb.err("payment_CardNumber_div_tb"); } if (expMonth <= 0) { err = true; _controls.tb.err("payment_ExpMonth_select_cb_div", true, "CB anim200l"); } if (expYear <= 0) { err = true; _controls.tb.err("payment_ExpYear_select_cb_div", true, "CB anim200l"); } if (expMonth > 0 && expYear > 0 && (expYear < nowDT.getFullYear() || expYear == nowDT.getFullYear() && expMonth < nowDT.getMonth() + 1)) { err = true; _controls.tb.err("payment_ExpMonth_select_cb_div", true, "CB anim200l"); _controls.tb.err("payment_ExpYear_select_cb_div", true, "CB anim200l"); } if (err) return; btn.disabled = "disabled"; btn.value = "Подождите..."; progress.style.display = ""; progress.className = "payProgress anim200"; setTimeout(function () { progress.style.opacity = 1; jm.AJAX({ URL: "/payment_AttachAction.h?fName=_controls.payment.attachCard._result&r=" + jm.Random.Int(), Type: "post", Data: { action: "new", paymentMethod: _cardPaymentMethod, number: cardNumber, holder: holderName, exp: expMonth + "-" + expYear, code: code }, Async: true, IsAnswerScript: true }); }, 20); }, _result: function (rr, paymentAccount, paymentDataHashId) { var err = null; function setEnableAndSetDefaut() { var btn = jm.el("payment_AddCard_btn"), progress = jm.el("payment_AddCardProgress_div"); if (btn) { btn.disabled = ""; btn.value = "Привязать"; } if (progress) { progress.style.opacity = 0; setTimeout(function () { progress.className = "payProgress"; progress.style.display = "none"; }, 300); } } if (rr == 1) err = "
Вы не авторизованы.
Попробуйте обновить страницу и повторить операцию.
"; else if (rr == 9) err = "
Транзакция была отклонена процессинговым центром.
Пожалуйста, перепроверьте введенные данные и повторите попытку.
В случае если ошибка сохранится попробуйте обратиться в Ваш банк для уточнения причин отклонения транзакции.
"; else if (rr == 11) err = "
Процессинговый центр временно недоступен.
Пожалуйста, попробуйте повторить операцию позднее.
"; else if (rr == 13) err = "Платежные данные переданы некорректно"; else if (rr == 15) err = "Данная карта уже привязана к Вашему аккаунту"; else if (rr == 17) err = "
Карта не поддерживает безопасную авторизацию 3-D Secure.
Пожалуйста, попробуйте привязать другую карту, либо воспользуйтесь обычным разовым пополнением баланса.
"; else if (rr > 0 && rr != 14 && rr != 16) err = "
Произошла ошибка во время сохранения данных.
Пожалуйста, обратитесь к службе поддержки.
"; if (err) { _controls.messageBox.show("Привязка банковской карты", err, _controls.messageBox.button.ok, _controls.messageBox.icon.error, err.length <= 50 ? 500 : 700); setEnableAndSetDefaut(); } else if (rr == 0 && paymentAccount && _auth.user) { if (!_auth.user.paymentAccounts) _auth.user.paymentAccounts = []; _auth.user.paymentAccounts[_auth.user.paymentAccounts.length] = paymentAccount; var div = jm.el("payment_AttachedCards_div"); if (div) div.innerHTML = _controls.payment.getAttachedCardsHTML(); if (jm.Data["AttachedCardsPage"]) jm.Data["AttachedCardsPage"].rebuild(); _controls.windows.close('payment_addCard'); } else if (rr == 14 && paymentDataHashId) { _controls.payment.attachCard._3DSecurityCloseConfirmed = false; _controls.windows.create("payment_3dsecure", { width: 650, title: "Авторизация банковской карты", body: '
' + '
Ваш банк требует дополнительную аутентификацию по стандарту 3-D Secure
При этом с карты будет списан и сразу же возвращен 1 рубль
' + '
' + '
', onClose: function (actionSource) { if (_controls.payment.attachCard._3DSecurityCloseConfirmed || actionSource != _controls.windows.actionSource.bgClick && actionSource != _controls.windows.actionSource.esc) { if (actionSource != undefined) setEnableAndSetDefaut(); return true; } _controls.messageBox.show("Подтверждение", "Вы действительно хотите закрыть окно подтверждения привязки банковской карты?", _controls.messageBox.button.yes_no, _controls.messageBox.icon.question, 600, null, function (r) { _controls.payment.attachCard._3DSecurityCloseConfirmed = r == _controls.messageBox.dialogResult.yes; if (_controls.payment.attachCard._3DSecurityCloseConfirmed) { _controls.windows.close("payment_3dsecure"); setEnableAndSetDefaut(); } }); } }); setTimeout(function () { _controls.windows.show("payment_3dsecure"); }, 20); } else if (rr == 16 && paymentDataHashId) { setTimeout(function (pdId) { jm.AJAX({ URL: "/payment_AttachAction.h?fName=_controls.payment.attachCard._result&r=" + jm.Random.Int(), Type: "post", Data: { action: "3ds_result", payDataId: pdId }, Async: true, IsAnswerScript: true }); }, 2000, paymentDataHashId); } } } } }; var _controls = new Controls(); jm.Events.Add(document, "keydown", function (e) { if (!e) return; if (e.keyCode == 27 || e.keyCode == 13) _controls.windows.closeTop(e.keyCode == 13, _controls.windows.actionSource.esc); }); jm.Mouse.Subscribe.Add("calendar", [["MouseDown", _controls.calendar._bmd]]); function _getPeriodDiscount(promoInf, period) { if (promoInf && promoInf.periodDiscount && promoInf.periodDiscount.length > 0) for (var n in promoInf.periodDiscount) { var discount = promoInf.periodDiscount[n]; if (discount && discount.length == 2 && discount[0] == period) return discount[1] / 100; } return period == 3 ? 0.05 : (period == 4 ? 0.1 : (period == 5 ? 0.2 : 0)); } function _getSelectedCountry(elementId) { var select = jm.el(elementId); if (!select) return null; var countryId = parseInt(select.value); for (var n = 0; n < _countries.length; n++) if (_countries[n][0] == countryId) return _countries[n]; return null; } function _getCountryById(id) { if (_countries && _countries.length > 0 && id > 0) for (var a = 0; a < _countries.length; a++) if (_countries[a][0] == id) return _countries[a]; return null; } function _formatCardNumer(value) { if (!value || value.length <= 4) return value; return value.length >= 16 ? value.substring(0, 4) + " " + value.substring(4, 8) + " " + value.substring(8, 12) + " " + value.substring(12, value.length) : (value.length >= 12 ? value.substring(0, 4) + " " + value.substring(4, 8) + " " + value.substring(8, value.length) : value); } //# sourceURL=/controls.js