var ASC; (function (ASC) { ASC.langasc = {}; ASC.ttlangasc = {}; ASC.loadedJSLibs = []; function windowOpenINP(url) { var a = $j("").attr('href', url).text(url); a.appendTo(document.body); a[0].click(); a.remove(); return; } ASC.windowOpenINP = windowOpenINP; function createChild(container, tag, css, style) { var i = document.createElement(tag); container.appendChild(i); if (css) setClass(i, css); if (style) i.style.cssText = style; return i; } ASC.createChild = createChild; function createDiv(container, css, style) { return ASC.createChild(container, 'div', css, style); } ASC.createDiv = createDiv; function createSpan(container, css, style) { return ASC.createChild(container, 'span', css, style); } ASC.createSpan = createSpan; function createText(container, text) { var i = document.createTextNode(text); container.appendChild(i); return i; } ASC.createText = createText; function createSpanText(container, text, css, style) { var el = ASC.createSpan(container, css, style); ASC.createText(el, text); return el; } ASC.createSpanText = createSpanText; function createAnchor(container, text, onclick, obj, css, style) { var $el = $j("").appendTo(container).text(text).css({ cursor: 'pointer', textDecoration: 'underline' }) .click(obj, function (e) { onclick(e, e.data); }); if (css) $el.addClass(css); if (style) $el.get(0).style.cssText += style; return $el.get(0); } ASC.createAnchor = createAnchor; function createTable(container, columns, rows, cssClass, style) { var res = { table: ASC.createChild(container, 'table', cssClass, style), tbody: null, rows: [], cells: [] }; res.tbody = ASC.createChild(res.table, 'tbody'); for (var y = 0; y < rows; y++) { res.cells[y] = []; var tr = ASC.createChild(res.tbody, 'tr'); res.rows[y] = tr; for (var x = 0; x < columns; x++) { res.cells[y][x] = ASC.createChild(tr, 'td'); } } return res; } ASC.createTable = createTable; function createMiniIcon(container, fn, options) { if (options === void 0) { options = {}; } options = $j.extend({ type: 'edit', }, options); var $el = $j('
').addClass('mini ' + options.type) .css(options.right ? 'right' : 'left', '0') .hide(); $j(container).addClass('miniContainer') .mouseover(function (e) { $el.show(); }) .mouseout(function (e) { $el.hide(); }) .click(function (e) { fn(e); }) .append($el); return $el; } ASC.createMiniIcon = createMiniIcon; function createUploadFile(container, saveUrl, options) { var $form = $j('
').appendTo(container).attr({ id: 'form_' + ASC_newId(), method: 'post', enctype: 'multipart/form-data', }).css('display', 'inline'); $form.append(''); var send = function (e) { var formData = new FormData($form.get(0)); ASC_action(saveUrl, formData, $j.extend({ timeout: 2 * 3600000, cache: false, global: false, contentType: false, processData: false }, options)); }; send['form'] = $form; send['input'] = $form.find("input"); $form.find(":file").on('change submit', send); return send; } ASC.createUploadFile = createUploadFile; function setClass(el, c, b) { if (b === void 0) { b = true; } $j(el).toggleClass(c, !!b); } ASC.setClass = setClass; function type(o) { var TYPES = { 'undefined': 'undefined', 'number': 'number', 'boolean': 'boolean', 'string': 'string', '[object Function]': 'function', '[object RegExp]': 'regexp', '[object Array]': 'array', '[object Date]': 'date', '[object Error]': 'error' }; return TYPES[typeof o] || TYPES[Object.prototype.toString.call(o)] || (o ? 'object' : null); } ASC.type = type; function isArray(o) { return (o) ? ASC.type(o) === 'array' : false; } ASC.isArray = isArray; function isString(o) { return ASC.type(o) === 'string'; } ASC.isString = isString; function isJQuery(o) { return (o.get && o.on && o.off) ? true : false; } ASC.isJQuery = isJQuery; function assert(b, msg) { if (msg === void 0) { msg = "Assertion failed"; } if (!b) { throw msg; } } ASC.assert = assert; function strippedBackground(el, colors, w, h, light) { if (light === void 0) { light = false; } var uni_light = ''; if (light) { var lh = 5; if (h) lh = Math.min(h, lh); uni_light = 'linear-gradient(rgba(255,255,255,0.5),rgba(0,0,0,0) ' + lh + 'px)'; } if (colors.length > 0) { if (uni_light) el.style.cssText = el.style.cssText + ";background:" + uni_light + "," + colors[0]; else el.style.backgroundColor = colors[0]; } if (colors.length > 1) { color = colors[0]; var angle = 45; if (w >= 3 && h >= 3) { angle = Math.atan2(h, w / (colors.length - 1)) / Math.PI * 180; } var moz = '-moz-linear-gradient(0% 0% -' + angle + 'deg,' + color; var webkit = '-webkit-gradient(linear, 0% 0%, 100% 100%, from(' + color + '), to(' + colors[colors.length - 1] + ')'; var uni = 'linear-gradient(' + (180 - angle) + 'deg,' + color; for (var color_i = 1; color_i < colors.length; color_i++) { var p = 1 / colors.length * (color_i); moz += ',' + color + ' ' + (p * 100) + '%'; webkit += ',color-stop(' + p + ',' + color + ')'; uni += ',' + color + ' ' + (p * 100) + '%'; var color = colors[color_i]; moz += ',' + color + ' ' + (p * 100) + '%'; webkit += ',color-stop(' + p + ',' + color + ')'; uni += ',' + color + ' ' + (p * 100) + '%'; } moz += ')'; webkit += ')'; uni += ')'; if (uni_light) uni = uni_light + ',' + uni; el.style.cssText = el.style.cssText + ";background:" + uni; } } ASC.strippedBackground = strippedBackground; function json_dc(data) { var encoded = data[0], values = data[1], ekeys = [], i = 0; var decode = function () { var t = encoded[i++]; switch (t) { case -1: var length = encoded[i++], rows = []; for (var j = 0; j < length; j++) { rows.push(decode()); } return rows; case -2: var length = encoded[i++], res = {}, keys = []; for (var j = 0; j < length; j++) { keys.push(decode()); } ekeys.push(keys); for (var j = 0; j < length; j++) { res[keys[j]] = decode(); } return res; case -3: return []; case -4: return [decode()]; case -5: return [decode(), decode()]; } if (t < 0) { var keys = ekeys[-t - 10], res = {}; for (var j = 0; j < keys.length; j++) { res[keys[j]] = decode(); } return res; } else { var v = values[t]; if (ASC.isArray(v)) v = v.slice(0); return v; } }; return decode(); } ASC.json_dc = json_dc; var timer_last = 0; function timer_start() { timer_last = Date.now(); } ASC.timer_start = timer_start; function timer_dump(t, d) { var time = Date.now(); console.log(t + "=" + (time - timer_last)); if (d) d.append("
" + t + "=" + (time - timer_last)); timer_last = time; } ASC.timer_dump = timer_dump; var todo_read_buffer = []; var todo_write_buffer = []; function todo(f) { todo_read_buffer.push(f); } ASC.todo = todo; function todo_read(f) { todo_read_buffer.push(f); } ASC.todo_read = todo_read; function todo_write(f) { todo_write_buffer.push(f); } ASC.todo_write = todo_write; function todo_finish() { if (todo_read_buffer.length == 0 && todo_write_buffer.length == 0) return; var old = todo_read_buffer; todo_read_buffer = []; for (var i = 0; i < old.length; i++) { old[i](); } var old = todo_write_buffer; todo_write_buffer = []; for (var i = 0; i < old.length; i++) { old[i](); } todo_finish(); } ASC.todo_finish = todo_finish; function todo_flipText(d, text, width, center) { if (ASC.isArray(d)) { for (var i = 0; i < d.length; i++) ASC.flipText(d[i], text, width, center); return; } todo_read(function () { var pw = d.clientWidth; if (width === 'get') width = d.clientHeight; if (!width) width = 90; todo_write(function () { if (!text) { text = ASC.textContent(d); d.innerHTML = ''; } todo_write(function () { var d0 = ASC.createDiv(d, '', 'width:' + width + 'px;'); var d1 = ASC.createDiv(d0, 'flip-text' + (center ? ' center' : ''), ''); ASC.createText(d1, text); todo_read(function () { var rw = d1.clientHeight; todo_write(function () { d1.style.height = width + 'px'; if (isIE(9)) { d1.style.cssText += ';-ms-writing-mode:tb-lr;padding-top:1px;padding-left:0;'; } if (window.getComputedStyle) { todo_read(function () { var cs = window.getComputedStyle(d); var pl = ASC.getStyleValuePixels(cs.paddingLeft); var pr = ASC.getStyleValuePixels(cs.paddingRight); if (rw > pw - pl - pr) { todo_write(function () { if (rw > pw) { d1.style.lineHeight = '85%'; rw = rw * 0.85; } var nw = Math.round(Math.min(pw, rw)); var npl = Math.round((pw - nw) / 2); var npr = pw - nw - npl; if (npl == 3 && (npr == 3 || npr == 2) && nw == 15) { $j(d).addClass('fix315'); } else { d.style.paddingLeft = npl + 'px'; d.style.paddingRight = npr + 'px'; d.style.width = nw + 'px'; } }); } }); } }); }); }); }); }); } ASC.todo_flipText = todo_flipText; ; function flipText(el, text, width, center) { todo_flipText(el, text, width, center); todo_finish(); } ASC.flipText = flipText; function ls_skcz(sk, cz) { return ASC.lang == 'cz' ? cz : sk; } ASC.ls_skcz = ls_skcz; function ls_skczen(sk, cz, en) { return ASC.lang == 'cz' ? cz : (ASC.lang == 'sk' ? sk : en); } ASC.ls_skczen = ls_skczen; function lang_getLocale(country) { country = country || ASC.school_country || 'en'; var base = country.toLowerCase(); switch (country) { case 'cz': base = 'cs'; break; case 'at': base = 'de'; break; case 'us': base = 'en'; break; } return base + "-" + country.toUpperCase(); } ASC.lang_getLocale = lang_getLocale; function fit_width(d_o, d_i, d_f) { var ow = d_o.clientWidth; if (d_i.clientWidth <= ow) return; var $d_f = $j(d_f); var min_size = 3; var max_size = parseInt($d_f.css('font-size')); var ok_size = min_size; while (min_size + 1 < max_size) { var size = Math.floor((min_size + max_size) / 2); $d_f.css('font-size', size); if (d_i.clientWidth <= ow) { ok_size = size; min_size = size; } else { max_size = size; } } $d_f.css('font-size', ok_size); } ASC.fit_width = fit_width; function vertical_align(d_o, d_i, a) { if (a == 0) d_i.style.top = ((d_o.clientHeight - d_i.clientHeight) / 2) + 'px'; else if (a > 0) d_i.style.top = ((d_o.clientHeight - d_i.clientHeight) / 1) + 'px'; } ASC.vertical_align = vertical_align; function vyskrtni(el, typ, width) { if (typ === void 0) { typ = '/'; } if (width === void 0) { width = 1; } var $el = $j(el); $el.html(''); $el.css('vertical-align', 'top'); $el.css('overflow', 'hidden'); $el.css('padding', '0px'); var angle = 1; var w = el.offsetWidth; var h = el.offsetHeight; if (w > 0) { angle = Math.atan2(h, w); if (typ == '\\') angle = -angle; if (typ == '-') angle = 0; } $j('
').appendTo(el).css({ borderTop: width + 'px solid black', margin: (($el.height() - width) / 2) + 'px -100% 0% -100%', height: width + 'px', transform: 'rotate(-' + angle + 'rad)' }); } ASC.vyskrtni = vyskrtni; function getCssCrossBrowser(property, value, enabled) { var css = {}; css[property] = enabled ? value : ''; css['-webkit-' + property] = css[property]; css['-moz-' + property] = css[property]; css['-ms-' + property] = css[property]; css['-o-' + property] = css[property]; return css; } ASC.getCssCrossBrowser = getCssCrossBrowser; var showContextMenu_menu = null; function showContextMenu(items, e, options) { if (options === void 0) { options = {}; } hideContextMenu(); if (options instanceof HTMLElement || ASC.isJQuery(options)) options = { cd: options }; var cd = options.cd; if (options.handler) { function addHandler(item) { if (ASC.isArray(item)) { for (var i = 0; i < item.length; i++) { addHandler(item[i]); } } else { if (item.cmd) { if (!item.onclick) { item.onclick = function () { options.handler(item); }; } } if (item.submenu) addHandler(item.submenu); } } addHandler(items); } var $dlg = $j(cd).parents('.ui-front'); showContextMenu_menu = new ASC.ui.ContextMenu(items, { container: $dlg.length ? $dlg : document.body }); if (options.header) showContextMenu_menu.cfg.setProperty('header', options.header); $j(document.body).click(hideContextMenu); showContextMenu_menu.show(cd || e); e.stopPropagation(); } ASC.showContextMenu = showContextMenu; function showContextMenuOpened(el) { return showContextMenu_menu && showContextMenu_menu.$menu.is(":visible") && (!el || showContextMenu_menu.$trigger.is(el)); } ASC.showContextMenuOpened = showContextMenuOpened; function hideContextMenu() { if (showContextMenu_menu) { showContextMenu_menu.hide(); showContextMenu_menu.destroy(); showContextMenu_menu = null; } } ASC.hideContextMenu = hideContextMenu; function dieError(errNumber, msg) { console.log('Error', errNumber, msg); alert('ErrorJS: ' + errNumber); throw errNumber; } ASC.dieError = dieError; function checkRequiredFields(jsc, fields, markField) { var getBorderEl = function ($el) { var borderEl = $el[0]['ASC_uiElement']; if (!borderEl) borderEl = $el.is(":hidden") ? $el.parent().get(0) : $el.get(0); return borderEl; }; for (var i in fields) { var $el = $j(jsc[fields[i]]); if ($el.hasClass('required') && !$el.val()) { if (markField === undefined || markField) { if (ASC.ascdebug) { console.log(fields[i], $el); } ASC.flashMessage(ASC.ls(2724), { border_error: getBorderEl($el) }); } return false; } } return true; } ASC.checkRequiredFields = checkRequiredFields; function removeDiacritics(text) { var remove = /[áÁäčČďĎéÉíÍĺĹľĽňŇóÓôÔŕŔšŠťŤúÚýÝžŽąĄćĆęĘłŁńŃóÓśŚżŻźŹüßöřŘ]/g; var def = "á=a,Á=a,ä=a,č=c,Č=C,ď=d,Ď=D,é=e,É=E,í=i,Í=I,ĺ=l,Ĺ=L,ľ=l,Ľ=L,ň=n,Ň=N,ó=o,Ó=O,ô=o,Ô=O,ŕ=r,Ŕ=R,š=s,Š=S,ť=t,Ť=T,ú=u,Ú=U,ý=y,Ý=Y,ž=z,Ž=Z"; def += ",ą=a,Ą=a,ć=c,Ć=C,ę=e,Ę=E,ł=l,Ł=L,ń=n,Ń=N,ó=o,Ó=O,ś=s,Ś=S,ż=z,Ż=Z,ź=z,Ź=Z"; def += ",ü=u,ß=ss,ö=o"; def += ",ř=r,Ř=R"; return text.replace(remove, function (match) { var i = def.search(match); return def.substr(i + 2, def.indexOf(",", i + 2) - i - 2); }); } ASC.removeDiacritics = removeDiacritics; ; function setFieldValidator(e, func) { function up() { ASC.setClass(e, 'asc-badfieldvalue', !func(e.value)); } up(); $j(e).change(up); $j(e).keyup(up); } ASC.setFieldValidator = setFieldValidator; function validatorRC(nin) { if (nin == '') return true; var re = /^[0-9]{6}\/[0-9]{3,4}$/i; if (!re.test(nin)) return false; if (parseInt(nin.replace('/', '')) % 11 != 0) return false; return true; } ASC.validatorRC = validatorRC; function validatorEmail(email) { if (email == '') return true; var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; return re.test(email); } ASC.validatorEmail = validatorEmail; function validatorRequire(o) { if (typeof o !== "string" && o.call) { return function (str) { if (str == '') return false; return o(str); }; } return o != ''; } ASC.validatorRequire = validatorRequire; function isIE(upToVersion) { if (ASC.browser && ASC.browser.substr(0, 2) == 'ie') { if (upToVersion > 6) { return parseInt(ASC.browser.substr(2)) <= upToVersion; } return true; } var i = navigator.appVersion.indexOf("MSIE"); if (i != -1) { if (upToVersion > 6) { var version = navigator.appVersion.substr(i + 4, 5); return parseInt(version) <= upToVersion; } return true; } return false; } ASC.isIE = isIE; function reloadPage() { window.location.reload(); } ASC.reloadPage = reloadPage; function date_today() { return date_js2sql(new Date()); } ASC.date_today = date_today; function date_delta(date, smer) { var d = date_sql2js(date); return date_js2sql(new Date(d.getTime() + 1000 * 3600 * 24 * smer)); } ASC.date_delta = date_delta; function date_diff(date1, date2) { var d = date_sql2js(date1).getTime() - date_sql2js(date2).getTime(); return Math.round(d / (1000 * 60 * 60 * 24)); } ASC.date_diff = date_diff; function date_js2sql(date) { var d = date.getDate(), m = date.getMonth() + 1, y = date.getFullYear(); return '' + y + '-' + (m < 10 ? '0' : '') + m + '-' + (d < 10 ? '0' : '') + d; } ASC.date_js2sql = date_js2sql; function date_sql2js(date) { if (date instanceof Date) return date; return new Date(parseInt(date.substr(0, 4), 10), parseInt(date.substr(5, 2), 10) - 1, parseInt(date.substr(8, 2), 10), 11); } ASC.date_sql2js = date_sql2js; function ASC_date2str(date, ajRok) { if (ajRok === void 0) { ajRok = true; } if (!date || date == '') return ''; date = '' + date; if (date.length < 10) return date; var d = parseInt(date.substr(8, 2), 10); var m = parseInt(date.substr(5, 2), 10); var y = parseInt(date.substr(0, 4), 10); var dp = (d < 10 ? '0' : '') + d; var mp = (m < 10 ? '0' : '') + m; switch (ASC.lang) { case 'sk': case 'cz': return d + '. ' + m + '.' + (ajRok ? ' ' + y : ''); case 'de': return dp + '.' + mp + '.' + (ajRok ? y : ''); case 'pl': return d + '.' + m + '.' + (ajRok ? y : ''); case 'hu': return (ajRok ? y + '.' : '') + ' ' + m + '. ' + d; default: if (ASC.school_country == 'us') return m + '/' + d + (ajRok ? '/' + y : ''); else return dp + '/' + mp + (ajRok ? '/' + y : ''); } } ASC.ASC_date2str = ASC_date2str; function ASC_date2str_day(date) { if (!date || date == '') return ''; var d = parseInt(date.substr(8, 2), 10); var m = parseInt(date.substr(5, 2), 10); var r = parseInt(date.substr(0, 4), 10); return ASC.ui.DatePicker.getDayNamesShort()[new Date(r, m - 1, d).getDay()]; } ASC.ASC_date2str_day = ASC_date2str_day; function ASC_time2str(timestamp, options) { if (options === void 0) { options = {}; } if (!timestamp || timestamp == '') return ''; var short = !!options.short; var ajSekundy = options.ajSekundy === undefined ? !short : options.ajSekundy; var h = parseInt(timestamp.substr(0, 2), 10), m = parseInt(timestamp.substr(3, 2), 10), s = parseInt(timestamp.substr(6, 2), 10); var hp = (h < 10 ? '0' : '') + h, mp = (m < 10 ? '0' : '') + m, sp = (s < 10 ? '0' : '') + s; switch (ASC.lang) { case 'de': return hp + ':' + mp + (ajSekundy ? ':' + sp : ''); case 'en': var a = ':' + mp + (ajSekundy ? ':' + sp : ''); if (h == 0) return '12' + a + (short ? '' : ' AM'); else if (h < 12) return h + a + (short ? '' : ' AM'); else if (h == 12) return '12' + a + (short ? '' : ' PM'); else return (h - 12) + a + (short ? '' : ' PM'); default: return h + ':' + mp + (ajSekundy ? ':' + sp : ''); } } ASC.ASC_time2str = ASC_time2str; function ASC_str2time(timestamp) { var parts = timestamp.split(":"), res = ['00', '00', '00']; if (timestamp) { var am = parts[parts.length - 1] + '', part = 0; for (var i in parts) { part = parseInt(parts[i].length > 2 ? parts[i].substr(0, 2) : parts[i], 10); if (!isNaN(part)) { res[i] = (part < 10 ? '0' : '') + part; } } if (am.toLowerCase().indexOf('pm') >= 0 && parseInt(res[0]) < 12) { res[0] = "" + (parseInt(res[0]) + 12) % 24; } if (am.toLowerCase().indexOf('am') >= 0 && parseInt(res[0]) == 12) { res[0] = '00'; } } return res.join(":"); } ASC.ASC_str2time = ASC_str2time; function currentTimeMillis() { return new Date().getTime(); } ASC.currentTimeMillis = currentTimeMillis; function date_week_end(date) { return date_delta(date_week_start(date), 6); } ASC.date_week_end = date_week_end; function date_week_start(date) { var firstDay = ASC.ui.DatePicker.getSettings().firstDay, oDate = date_sql2js(date); for (var i = 6; i > 0; i--) { if (oDate.getDay() == firstDay) break; oDate.setDate(oDate.getDate() - 1); } return ASC.date_js2sql(oDate); } ASC.date_week_start = date_week_start; function ASC_monthName(n) { if (n >= 0 && n < ASC.ui.DatePicker.monthNames.length) return ls(ASC.ui.DatePicker.monthNames[n]); return n; } ASC.ASC_monthName = ASC_monthName; function ASC_dayName(n) { if (n >= 0 && n < ASC.ui.DatePicker.dayNames.length) return ls(ASC.ui.DatePicker.dayNames[n]); return n; } ASC.ASC_dayName = ASC_dayName; function date_firstDayOfWeek(date, firstDayOfWeek) { if (firstDayOfWeek === undefined) firstDayOfWeek = 1; var d; var isDateObj = false; if (ASC.type(date) == 'date') { d = date; isDateObj = true; } else d = new Date(ASC.date_sql2js(date)); var i = d.getDay(); if (i != firstDayOfWeek) { if (i < firstDayOfWeek) i = d.getDate() - (6 - i); else i = d.getDate() - (i - firstDayOfWeek); d.setDate(i); } return isDateObj ? d : ASC.date_js2sql(d); } ASC.date_firstDayOfWeek = date_firstDayOfWeek; function date_week_getNumber(dateStr) { var date = ASC.date_sql2js(dateStr); date.setHours(0, 0, 0, 0); date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); var week1 = new Date(date.getFullYear(), 0, 4); return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7); } ASC.date_week_getNumber = date_week_getNumber; function indexOf(a, elt, from) { if (from === void 0) { from = 0; } var len = a.length; for (; from < len; from++) { if (from in a && a[from] === elt) return from; } return -1; } ASC.indexOf = indexOf; function indexOf2(a, elt, from) { if (from === void 0) { from = 0; } var len = a.length; for (; from < len; from++) { if (from in a && a[from] == elt) return from; } return -1; } ASC.indexOf2 = indexOf2; function remove(a, e) { var i = ASC.indexOf(a, e); if (i >= 0) a.splice(i, 1); } ASC.remove = remove; function trim(str) { if (str.trim) return str.trim(); return str.replace(/^\s+|\s+$/g, ''); } ASC.trim = trim; function length(o) { if (o.length) return parseInt(o.length); return ASC.count(o); } ASC.length = length; function count(o) { var c = 0; if (o) { for (var i in o) { c++; } } return c; } ASC.count = count; function strEquals(a, b) { return '' + a == '' + b; } ASC.strEquals = strEquals; function emailIsValid(email) { email += ''; if (email.length < 5 || email.indexOf('@') < 0) return false; var r = /^[a-zA-Z0-9]+[a-zA-Z0-9\._\-\+]*@([a-zA-Z0-9_\-]+\.)+[a-zA-Z]+$/i; return r.test(email); } ASC.emailIsValid = emailIsValid; function ttls(i) { if (ASC.ttlangasc[i]) return ASC.ttlangasc[i]; return '' + i; } ASC.ttls = ttls; function ls(i) { if (Langs && Langs[i]) return Langs[i]; return '' + i; } ASC.ls = ls; function lsf(i, replace) { var t = parseInt(i) ? ls(parseInt(i)) : i; if (replace) { for (var ri in replace) { var value = replace[ri]; t = t.replace('{' + ri + '}', value); while (true) { var i0 = t.indexOf('{' + ri + ':'); if (i0 >= 0) { var i1 = i0 + 2 + ri.length, i2 = t.indexOf('}', i1); var ts = t.substring(i1, i2).split('|'), tvar = 1; switch (ASC.lang) { case 'sk': case 'cz': if (value == 1) tvar = 1; else if (value >= 2 && value < 5) tvar = 2; else tvar = 3; break; default: if (value == 1) tvar = 1; else tvar = 2; case 'hr': var v = Math.abs(value); if (v % 10 == 1 && v % 100 != 11) tvar = 1; else if (v % 10 >= 2 && v % 10 < 5 && (v % 100 < 10 || v % 100 >= 20)) tvar = 2; else tvar = 3; break; } if (ts.length == 1) ts = ['', ts[0], ts[0]]; if (ts.length == 2) ts = [ts[0], ts[1], ts[1]]; t = t.substr(0, i0) + ts[tvar - 1] + t.substr(i2 + 1); } else { break; } } } } return t; } ASC.lsf = lsf; function clone(o) { return JSON.parse(JSON.stringify(o)); } ASC.clone = clone; function cloneArray(a) { var r = []; for (var i = 0; i < a.length; i++) r.push(a[i]); return r; } ASC.cloneArray = cloneArray; function ToString(data) { if (data === undefined || data === null) return ''; var res = '' + data; switch (ASC.type(data)) { case 'object': res = '{'; for (var param in data) { if (res != '{') res += ', '; res += param + ': ' + ASC.ToString(data[param]); } res += '}'; break; case 'array': res = ''; for (var i = 0; i < data.length; i++) { if (i > 0) res += ', '; res += ASC.ToString(data[i]); } break; } return res; } ASC.ToString = ToString; function textContent(el) { return $j(el).text(); } ASC.textContent = textContent; function getStyleValuePixels(style) { var l = style.length; if (l > 2 && style.substr(l - 2) == 'px') { return parseInt(style.substr(0, l - 2)); } return 0; } ASC.getStyleValuePixels = getStyleValuePixels; var ASC_nextId = 1; function ASC_newId() { return 'ASC_ID_' + (ASC_nextId++); } ASC.ASC_newId = ASC_newId; function ASC_response(response, options) { if (options === void 0) { options = {}; } if (response != "OK") { if (response.substr(0, 3) == 'JS:') { var cmd = '' + response.substr(3); try { eval(cmd); } catch (e) { var msg = '???'; var i = -1; function setMinIndex(index) { if (index >= 0) { if (i >= 0) i = Math.min(i, index); else i = index; } } setMinIndex(cmd.indexOf('Warning')); setMinIndex(cmd.indexOf('Fatal error')); setMinIndex(cmd.indexOf('Catchable fatal error')); if (i < 0) { msg = ASC_getTemporaryErrorMsg(cmd); if (!msg) { setMinIndex(cmd.indexOf('Error')); } else { e = msg; } } if (i >= 0) { msg = e + "\n\n" + cmd.substr(i, 200); } else { msg = '' + e; } if (!options.silent) ASC.ASC_messageBox(msg); if (options.failure) options.failure(msg); } } else { if (!options.silent) ASC.ASC_messageBox(response); } } } ASC.ASC_response = ASC_response; function ASC_getTemporaryErrorMsg(cmd) { var errors = cmd.match(/Error[0-9]+/); var temporaryErrors = { 1569: ['8759147973'] }; if (errors && errors.length) { for (var lsIndex in temporaryErrors) { for (var i = 0; i < errors.length; i++) { var errNum = errors[i].substr(5); if (ASC.indexOf2(temporaryErrors[lsIndex], errNum) >= 0) { return ASC.ls(parseInt(lsIndex)) + ' Error' + errNum; } } } } return ''; } ASC.ASC_getTemporaryErrorMsg = ASC_getTemporaryErrorMsg; function ASC_action(savephp, param, options) { if (options === void 0) { options = {}; } var mask = null; if (ASC.type(options) != 'object') { options = { modal: !!options }; } options = $j.extend({ modal: true, }, options); if (options.modal) { mask = new ASC.ui.Dialog({ resizable: false, draggable: false, width: '150px', title: ASC.ls(2568) + "...", show: true, dialogClass: 'asc-dialog-mask', open: function (e) { $j(this).parent().hide(); $j(this).parent().prev(".ui-widget-overlay").attr('style', 'opacity:0 !important;'); } }); setTimeout(function () { if (mask) { mask.$div.parent().fadeIn(); mask.$div.parent().prev(".ui-widget-overlay").attr('style', ''); } }, 1000); } var hideMask = function () { if (mask) { mask.$div.parent().fadeOut(); mask.$div.dialog("destroy"); mask = null; } }; if (ASC.isString(param)) { param += '&_LJSL=' + ASC.loadedJSLibs; } var o_success = options.success; delete options.success; var request = $j.ajax($j.extend({ url: savephp, type: 'POST', data: param, timeout: 60000, global: false, success: function (data, status, xhr) { hideMask(); if (o_success) o_success(); ASC_response(data, { failure: options.failure, silent: options.silent }); }, error: function (xhr, status, error) { hideMask(); if (options.retry && options.retry > 0) { options.retry--; var r2 = ASC_action(savephp, param, options); request['ASC_abort'] = r2['ASC_abort']; return; } if (options.failure) { options.failure(xhr); } else { alert('Error connecting to: ' + savephp + '\n' + status); } } }, options)); request['ASC_abort'] = function () { request.abort(); hideMask(); }; return request; } ASC.ASC_action = ASC_action; function alertMSG(message, header) { if (header === void 0) { header = "Edupage"; } var dlg = new ASC.ui.Dialog({ width: '1000px', title: header, autoOpen: false }); var $div = $j('
').css({ 'maxHeight': '500px', 'overflow': 'auto', 'whiteSpace': 'pre' }).html(message); dlg.setBody($div); dlg.center(); dlg.show(); return dlg; } ASC.alertMSG = alertMSG; function ASC_messageBox(message) { if (!ASC.ui || !ASC.ui.Dialog) { alert(message); } else { new ASC.ui.Dialog({ title: 'Edupage', width: 300, buttons: ["OK"] }) .setBody(escapeHTML(message).replace(/\n/g, "
")); } } ASC.ASC_messageBox = ASC_messageBox; function messageBox(container, html, options) { if (options === void 0) { options = {}; } if (!options.type || ASC.indexOf(['warning', 'succes', 'info', 'error', 'customize'], options.type) < 0) options.type = 'succes'; var $div = $j('
').addClass('messageBox ' + options.type).appendTo(container).html(html); if (options.style) { $div.get(0).style.cssText = options.style; } $j('
').appendTo($div).addClass('close').click(function (e) { $div.hide(); if (options.fn && ASC.type(options.fn) == 'function') { options.fn(e); } }).attr('title', (options.fn) ? ASC.ls(1038) : ASC.ls(1567)); return $div.get(0); } ASC.messageBox = messageBox; var flashDiv; function flashMessage(text, options) { if (options === void 0) { options = {}; } if (!flashDiv) { flashDiv = ASC.createDiv(document.body, 'flash-message-container'); } var timeout = 5 * 1000; if (text.length > 40) timeout = 7 * 1000; if (text.length > 80) timeout = 10 * 1000; if (options.timeout >= 1) timeout = options.timeout; var s = ASC.createSpan(flashDiv); var t = ASC.createDiv(s, 'flash-message'); ASC.createChild(s, 'br'); t.innerHTML = text; var $el = $j(options.border_error); if (options.border_error) { if ($el.is(":hidden")) { var $search = $el.next(":visible").first(); if (!$search.length || $search.is(":hidden")) { $search = $el.prev(":visible").first(); } $el = $search; } $el.addClass('border_error'); } setTimeout(function () { if ($el.length) { $el.removeClass('border_error'); } s.parentNode.removeChild(s); }, timeout); } ASC.flashMessage = flashMessage; var Mask = (function () { function Mask() { var _this = this; this.mask = new ASC.ui.Dialog({ autoOpen: false, resizable: false, draggable: false, width: '150px', title: ASC.ls(2568) + "...", show: true, dialogClass: 'asc-dialog-mask' }); setTimeout(function () { if (_this.mask) { _this.mask.$div.dialog("open"); $j(".ui-widget-overlay.ui-front").css({ opacity: 0 }); } }, 500); } Mask.prototype.hide = function () { this.mask.hide(); this.mask = null; }; return Mask; }()); ASC.Mask = Mask; var PaginatedDiv = (function () { function PaginatedDiv(div, options) { this.options = options; this.maxY = 0; this.result = { pages: [], format: 'a4-portrait', html: '', html_begin: '', html_pages: '', html_end: '', map: [], height: 0, width: 0, px2mm: 0 }; this.$div = $j(div); if (options.pageHeight == 'auto') this.computePageHeight(); else this.pageHeight = options.pageHeight; if (options.watermark) this.createWatermark(); if (options.minify) { this.pattern = /<[a-zA-Z]+ ([^>]+)>/g; this.replace = /<[a-zA-Z]+ ([^>]+)>/; } PaginatedDiv.fixInputValues(this.$div); } PaginatedDiv.prototype.paginate = function () { this.stack = []; this.result.pages = []; this.result.map = []; this.maxY = this.$div.offset().top + this.pageHeight; if (this.$div.is('[class*="-landscape"]')) { this.result.format = 'a4-landscape'; } if (this.pageHeight > 0) { this.paginateNormal(); } else if (this.$div.hasClass('print-sheet')) { this.result.pages.push(ASC.outerHTML(this.$div.get(0))); } else { this.paginateManual(); } this.createHTMLResult(); return this.result; }; PaginatedDiv.prototype.paginateNormal = function () { var sel = this.addStackItem(this.$div); if (this.watermark) { sel.content += this.nodeHTML(this.watermark.get(0)); sel.headers = sel.headers.add(this.watermark); } try { this.traverse(sel); } catch (e) { alert(e); } if (sel.needed) { this.emitPage(); } }; PaginatedDiv.prototype.paginateManual = function () { var _this = this; var p = this.$div.html(); if (this.options.addprintsheet) { p = ""; } this.result.pages.push(p); this.$div.children(".print-sheet-manual").each(function (index, el) { _this.result.format = 'custom'; var $el = $j(el); _this.result.height = $el.height(); _this.result.width = $el.width(); var px2mm = el['ASC_px2mm']; if (px2mm) { _this.result.px2mm = px2mm; } }); }; PaginatedDiv.prototype.createHTMLResult = function () { var _this = this; var html = ""; var manualPages = this.result.format == 'custom'; var landscape = this.result.format.indexOf('-landscape') > 0; html += '\n'; html += ""; html += ""; var sss = []; function getSS(el) { return el.sheet || el.styleSheet; } $j("LINK").each(function (index, link) { if (getSS(link)) { if (_this.options.css_inline) { sss.push(link); } else { var href = link.getAttribute('href'); html += ""; } } }); $j('STYLE').each(function (index, style) { sss.push(style); }); for (var ssi in sss) { var ss = sss[ssi]; var sheet = getSS(ss); html += ""; } if (landscape) html += ""; if (manualPages) html += ""; html += "" + escapeHTML(ASC.school_name) + ""; html += ""; html += "" + "
"; this.result.html_begin = html; this.result.html_pages = this.result.pages.join(''); this.result.html_end = "
"; this.result.html = this.result.html_begin + this.result.html_pages + this.result.html_end; }; PaginatedDiv.prototype.computePageHeight = function () { this.pageHeight = 0; if (this.$div.hasClass('print-sheet')) { this.pageHeight = parseInt(this.$div.css('min-height')); if (this.pageHeight < 400 || this.pageHeight > 2000) this.pageHeight = 1000; } }; PaginatedDiv.prototype.createWatermark = function () { this.watermark = $j('
').css({ position: 'absolute', right: '50px', bottom: '50px', width: '300px', height: '100px', padding: '10px', color: '#000', backgroundColor: '#fff', fontSize: '30px' }) .addClass('print-header') .text('Unregistered version of Timetables Online'); }; PaginatedDiv.fixInputValues = function (node) { node.find("INPUT").each(function (index, input) { input.setAttribute('value', input.value); }); }; PaginatedDiv.prototype.addStackItem = function (el) { var item = { el: el, content: '', headers: $j(), needed: true }; this.stack.push(item); return item; }; PaginatedDiv.prototype.getHeaderHeight = function () { var height = 0; for (var i = 0; i < this.stack.length; i++) { this.stack[i].headers.filter("DIV,TABLE,TR,THEAD").each(function (index, el) { var h = $j(el).height(); if (h > 0 && el.parentNode) height += h; }); } return height; }; PaginatedDiv.prototype.nodeHTML = function (nodeOrString) { if (nodeOrString instanceof HTMLElement) { var content = ASC.outerHTML(nodeOrString); return (this.options.minify) ? this.minify(content) : content; } else { return nodeOrString.textContent || nodeOrString + ''; } }; PaginatedDiv.prototype.minify = function (nodeString) { var match = nodeString.match(this.pattern); if (match) { for (var i = 0; i < match.length; i++) { var m = match[i].match(this.replace); var key = ASC.indexOf2(this.result.map, m[1]); if (key < 0) { key = this.result.map.length; this.result.map.push(m[1]); } nodeString = nodeString.replace(m[1], "*" + key); } } return nodeString; }; PaginatedDiv.prototype.emitPage = function () { var _this = this; var start = ''; var end = ''; for (var i = 0; i < this.stack.length; i++) { var item = this.stack[i]; var tag = tagHTML(item.el.get(0)); start += tag[0] + item.content; end = tag[1] + end; item.needed = false; item.content = ''; item.headers.each(function (index, headerEl) { item.content += _this.nodeHTML(headerEl); }); } this.result.pages.push(start + end); }; PaginatedDiv.prototype.getElementType = function (el) { if (el.nodeType != 1) return 0; switch (el['tagName'].toLowerCase()) { case 'div': var $el = $j(el); if ($el.is(':hidden')) return -1; if ($el.hasClass('print-nobreak')) return 1; if ($el.hasClass('print-header')) return 3; if ($el.hasClass('print-pagebreak')) return 4; if ($el.hasClass('print-nobreakafter')) return 5; if ($el.hasClass('print-pagebreak-even')) return 6; if ($el.children().length > 0) return 2; return 1; case 'table': case 'tbody': return 2; case 'thead': case 'colgroup': return 3; case 'tr': var $el = $j(el); if ($el.hasClass('print-pagebreak')) return 4; if ($el.hasClass('print-nobreakafter')) return 5; return 1; } return 1; }; PaginatedDiv.prototype.traverse = function (stackItem) { for (var el = stackItem.el.get(0).firstChild; el; el = el.nextSibling) { switch (this.getElementType(el)) { case -1: break; case 0: stackItem.content += this.nodeHTML(el); stackItem.needed = true; break; case 1: var $el = $j(el); if (this.isItemOverflowed($el) && (this.stack.length > 1 || stackItem.content != '')) { var offset = $el.offset(); var h = this.getHeaderHeight(); this.emitPage(); this.maxY = offset.top - h + this.pageHeight; } stackItem.content += this.nodeHTML(el); stackItem.needed = true; break; case 2: var item = this.addStackItem($j(el)); this.traverse(item); if (item.needed) { var th = ASC.tagHTML(item.el.get(0)); stackItem.content += th[0] + item.content + th[1]; stackItem.needed = true; } this.stack.pop(); break; case 3: stackItem.content += this.nodeHTML(el); stackItem.headers = stackItem.headers.add(el); stackItem.needed = true; break; case 4: var $el = $j(el); var offset = $el.offset(); var hh = this.getHeaderHeight(); this.emitPage(); this.maxY = offset.top + $el.height() - hh + this.pageHeight; break; case 5: var offset = $j(el).offset(); var cn = this.nodeHTML(el); var e2 = el; while (e2.nextSibling) { var next = e2.nextSibling; var et2 = this.getElementType(next); if (et2 == 5) { e2 = next; cn += this.nodeHTML(e2); continue; } else if (et2 == 1) { e2 = next; cn += this.nodeHTML(e2); break; } else { e2 = el; cn = this.nodeHTML(el); if (ASC.edupage == 'roz3000') { alert('Error6257088380'); return; } break; } } if (this.isItemOverflowed($j(e2))) { var hh = this.getHeaderHeight(); this.emitPage(); this.maxY = offset.top - hh + this.pageHeight; } stackItem.content += cn; stackItem.needed = true; el = e2; break; case 6: var $el = $j(el); var offset = $el.offset(); var hh = this.getHeaderHeight(); this.emitPage(); if (this.result.pages.length % 2) this.emitPage(); this.maxY = offset.top + $el.height() - hh + this.pageHeight; break; } } }; PaginatedDiv.prototype.isItemOverflowed = function ($el) { var h = $el.height(); var offset = $el.offset(); return h > 0 && offset.top + h > this.maxY; }; PaginatedDiv.convertToA3 = function (container) { var tmpDiv = "