/* 01.settings.js */ //4.7 /* Contains all global script settings, constants and variables */ var debug = 0; var d = document; var w = window; var voidLink = "javascript:void(0);"; var voidHref = "href=\"" + voidLink + "\""; var imagesPath = "/img/"; var servicesPath = "/services/"; var userPhotosPath = "/img/photos/"; var avatarsPath = "/img/avatars/"; var skinsPreviewPath = "/img/journals/"; var adminRights = 75; var keeperRights = 20; var topicRights = 10; var LoadingIndicator = "
"; var SeverityCss = ["Warning", "Error"]; var ReplaceTags = new RegExp("\<[\/a-z][^\>]*\>", "gim"); /* Service methods */ function $(id) { if (d.getElementById) { return d.getElementById(id); } else if (d.all) { return d.all[id]; } else if (d.layers) { return d.layers[id]; } return false; }; function DisplayElement(el, state) { if (!el.style) { el = $(el); } if (el) { el.style.display = state ? "" : "none"; } } var empty_pass = "**********"; function ClearInput(el) { if (el.value == empty_pass) { el.value = ""; } else { el.previousValue = el.value; } }; function RestoreInput(el, relatedBlockId) { if (el.value != el.previousValue) { var el2 = $(relatedBlockId); if (el2) { DisplayElement(el2, el.value); } } if (!el.value) { el.value = empty_pass; } }; /* Workaround the IE bug with assigning names to dynamically created elements Upd.: Opera has document.all property Upd.: Mozilla doesn't know try-catch */ function CreateElement(tag, name) { var result; if (d.all) { try { result = d.createElement("<" + tag + " name=\"" + name + "\" id=\"" + name + "\">"); } catch(e) { } } if (!result) { result = d.createElement(tag); result.name = name; result.id = name; } return result; }; function CreateBitInput(name, checked, is_radio) { var result; var type = (is_radio ? "radio" : "checkbox"); if (d.all) { try { result = d.createElement(""); } catch(e) { } } if (!result) { result = d.createElement("input"); result.type = type; result.name = name; if (checked) { result.setAttribute("checked", "true"); } } return result; }; function CreateRadio(name, checked) { return CreateBitInput(name, checked, 1); }; function CreateCheckBox(name, checked) { return CreateBitInput(name, checked, 0); }; function CreateBooleanImage(state) { var img = new Image(); img.src = state ? "/img/icons/done.gif" : "/img/delete_icon.gif"; return img; }; function MakeButtonLink(target, text, obj, css, alt) { var a = d.createElement("a"); a.href = voidLink; a.className = css; a.obj = obj; if (text) { a.innerHTML = text; } if (!alt || alt == "undefined") { alt = ""; } a.alt = alt; a.title = alt; eval("a.onclick=function(){" + target + "}"); return a; }; function MakeButton(target, src, obj, css, alt) { if (!alt || alt == "undefined") { alt = ""; } var a = MakeButtonLink(target, "", obj, css, alt); a.className = "Button " + css; a.innerHTML = "" + alt + ""; return a; }; function MakeDiv(text, tag) { var div = d.createElement(tag ? tag : "div"); div.innerHTML = text; return div; }; function IndexElementChildElements(el, hash) { if (!hash) { hash = new Array(); } if (el) { if (el.id) { hash[el.id] = el; } for (var i = 0, l = el.childNodes.length; i < l; i++) { // Recursion IndexElementChildElements(el.childNodes[i], hash); } } return hash; }; function insertAfter(new_node, existing_node) { if (existing_node.nextSibling) { existing_node.parentNode.insertBefore(new_node, existing_node.nextSibling); } else { existing_node.parentNode.appendChild(new_node); } }; function BindList(list, holder, obj, empty_message) { var l = list.length; if (l) { for (var i = 0; i < l; i++) { holder.appendChild(list[i].ToString(i, obj)); } } else { holder.innerHTML = empty_message; } }; /* Methods to set/get value of group of radios in holder element */ function RenameRadioGroup(holder, name) { if (!name) { name = "group" + Math.random(9999); } for (var i = 0, l = holder.childNodes.length; i < l; i++) { var el = holder.childNodes[i]; if (el && el.type == "radio") { el.name = name; } } }; // Recursive methods function SetRadioValue(holder, value) { for (var i = 0, l = holder.childNodes.length; i < l; i++) { var el = holder.childNodes[i]; if (el.hasChildNodes()) { SetRadioValue(el, value); } else if (el && el.type == "radio") { el.checked = (el.value == "" + value); } } }; function GetRadioValue(holder) { for (var i = 0, l = holder.childNodes.length; i < l; i++) { var el = holder.childNodes[i]; if (el.hasChildNodes()) { var v = GetRadioValue(el); if (v) { return v; } } else if (el && el.type == "radio") { if (el.checked) { return el.value; } } } return ""; }; // Bubbling function CancelBubbling(e) { if (!e) { var e = window.event; } e.cancelBubble = true; if (e.stopPropagation) { e.stopPropagation(); } }; // Create Pop & Push methods For Array if not supported function ArrayPop(a) { var o = a[a.length - 1]; a.length--; return o; }; function ArrayPush(a, p) { a[a.length] = p; return a.length; }; function ArrayInsertFirst(a, p, len) { if (!a) { return false; } for (var i = a.length - 1; i >= 0; i--) { a[i + 1] = a[i]; } a[0] = p; if (a.length > len) { a.length = len; } }; // DOM Helper methods function AddSelectOption(select, name, value, selected) { var opt = d.createElement("option"); opt.value = value; opt.text = name; opt.selected = selected ? true : false; try { select.add(opt, null); // standards compliant; doesn't work in IE } catch (ex) { select.add(opt); // IE only } }; function Random(n, not_null) { return (not_null ? 1 : 0) + Math.round(n * Math.random()); }; /* 02.debug.helper.js */ //1.1 /* Helps in JS code debugging. Displays debugging information in pop-up window. */ var debugWin; function DebugLine(line) { if (!debug) { return; } if (!debugWin || !debugWin.document) { debugWin = window.open('','debug'); debugWin.document.open(); debugWin.document.writeln(''); } debugWin.document.writeln('

' + line); }; function PropertiesOf(o) { var s = ""; var l = 0; for (p in o) { s += p + "=" + o[p] + " "; if (l++ == 3) { l = 0; s += "\n"; } } return s; }; /* 03.string.helper.js */ //1.3 /* Contains misc string-related functions. */ var chars = "абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"; var ascii = new Array(); for (var i = 0; i < chars.length; i++) { var ch = chars.charAt(i); ascii[ch] = i + 1; }; function CheckSum(source) { source = "" + source; var sum = 0; if (source != "undefined" && source != "") { source = " " + source; var i; if (source && source.length) { var code; for (i = 1; i < source.length; i++) { code = ascii[source.charAt(i)]; if (!code) { code = source.charCodeAt(i); if (code > 255) { code = 1; } } sum += code; //DebugLine(source.charAt(i) + " = " + code + " -> " + sum); } } } DebugLine(source + " = " + sum + "


"); return sum; }; function MakeParametersPair(name, value) { if (value == "undefined") { return ""; } var param = encodeURIComponent(name); param += "="; param += encodeURIComponent(value); param += "&"; return param; }; function TwoDigits(d) { if (d > 9) { return d; } return "0" + d; }; var tagsRegex = new RegExp("\<[\/]{0,1}[a-z]+[^\>]*\>", "ig"); function StripTags(text) { text = text.replace(tagsRegex, ""); return text; }; /* 04.ajax.helper.js */ //1.5 function sendRequest(url, callback, postData, obj) { var req = createXMLHTTPObject(); if (!req) { return; } var method = postData ? "POST" : "GET"; req.open(method,url,true); req.setRequestHeader('User-Agent','XMLHTTP/1.0'); if (postData) { req.setRequestHeader('Content-type','application/x-www-form-urlencoded'); }; req.onreadystatechange = function () { if (req.readyState != 4) { return; } try { if (req.status != 200 && req.status != 304) { return; } if (callback) { // Callback passed as parameter callback(req, obj); } else if (obj && obj.TemplateLoaded) { // Template render callback obj.TemplateLoaded(req); } } catch (e) { DebugLine("Exception: " + e.Description); } }; if (req.readyState == 4) { return; } req.send(postData); return req; }; var XMLHttpFactories = [ function () {return new XMLHttpRequest()}, function () {return new ActiveXObject("Msxml2.XMLHTTP")}, function () {return new ActiveXObject("Msxml3.XMLHTTP")}, function () {return new ActiveXObject("Microsoft.XMLHTTP")} ]; function createXMLHTTPObject() { var xmlhttp = false; for (var i = 0; i < XMLHttpFactories.length; i++) { try { xmlhttp = XMLHttpFactories[i](); } catch (e) { continue; } break; } return xmlhttp; }; function handleRequest(req) { try { eval(req.responseText); return; } catch(e) { return; } eval(req.responseText); }; /* 05.collection.class.js */ //2.5 /* Collection of entities (users, rooms etc.) */ function Collection() { this.Base = new Array(); this.LastId = 0; }; Collection.prototype.Get = function(id) { if (this.Base['_'+id]) { return this.Base['_'+id]; } return false; }; Collection.prototype.Add = function(e) { this.Base['_'+e.Id] = e; this.LastId = e.Id; }; Collection.prototype.Delete = function(id) { id = '_'+id; if (this.Base[id]) { var a = new Array(); for (var cid in this.Base) { if (cid != id) { a[cid] = this.Base[cid]; } } this.Base = a; } }; Collection.prototype.Clear = function() { this.Base = new Array(); }; Collection.prototype.Count = function() { var l = 0; for (var k in this.Base) { l += k ? 1 : 0; } return l; }; Collection.prototype.ToString = function(holder) { var i = 0; var s = ''; for (var id in this.Base) { if (id && this.Base[id].ToString) { if (holder) { this.Base[id].ToString(holder, i++); } else { s += this.Base[id].ToString(i++); } } } return s; }; Collection.prototype.Gather = function(holder) { var i = 0; var s = ''; for (var id in this.Base) { if (id && this.Base[id].Gather) { if (holder) { this.Base[id].Gather(holder); } else { s += this.Base[id].Gather(i++); } } } return s; }; /* 06.dto.class.js */ //3.6 /* DTOs with edit functionality */ /* Vase DTO */ function DTO() { this.fields = []; }; DTO.prototype.Init = function(args) { if (!args || !this.fields || args.length != this.fields.length) { return; } for (var i = 0, l = this.fields.length; i < l; i++) { this[this.fields[i]] = args[i]; } }; DTO.prototype.ToString = function(index, grid) { return this.ToShowView(index, grid); }; DTO.prototype.ToShowView = function() { // To override return ""; }; /* Editable DTO */ function EditableDTO() { this.EditView = false; }; EditableDTO.prototype = new DTO(); EditableDTO.prototype.ToString = function(index, grid) { if (this.EditView) { return this.ToEditView(index, grid); } else { return this.ToShowView(index, grid); } }; EditableDTO.prototype.ToEditView = function() { // To override return ""; }; EditableDTO.prototype.Gather = function() { for (var i = 0, l = this.fields.length; i < l; i++) { var input = this[this.fields[i] + "Input"]; if (input) { if (input.type == "checkbox" || input.type == "radio") { this[this.fields[i]] = input.checked ? 1 : ""; } else { this[this.fields[i]] = input.value; } } } }; /* Buttons events */ EditableDTO.prototype.CancelEditing = function() { if (this.Grid) { this.Grid.CancelEditing(); } }; EditableDTO.prototype.Edit = function() { if (this.Grid) { this.Grid.Edit(this.Id); } }; EditableDTO.prototype.Save = function() { if (this.Grid) { this.Gather(); if (this.Grid.GatherDTO(this)) { this.Grid.Save(); } } }; EditableDTO.prototype.Delete = function() { if (this.Grid) { this.Gather(); if (this.Grid.GatherDTO(this)) { this.Grid.Delete(); } } }; /* ---------------------------- */ EditableDTO.prototype.MakeButtonsCell = function(hideEdit) { var td = d.createElement("td"); td.className = "Middle Centered"; if (this.EditView) { td.appendChild(MakeButton("this.obj.Save()", "icons/done.gif", this, "", "Сохранить")); td.appendChild(MakeButton("this.obj.CancelEditing()", "icons/cancel.gif", this, "", "Отмена")); } else { if (!hideEdit) { td.appendChild(MakeButton("this.obj.Edit()", "icons/edit.gif", this, "", "Править")); } td.appendChild(MakeButton("this.obj.Delete()", "delete_icon.gif", this, "", "Удалить")); } return td; }; /* 06.options.class.js */ //7.6 /* User options UI and helper methods */ // Options base class function OptionsBase() { this.defaultValues = []; }; // Loading Template OptionsBase.prototype.LoadTemplate = function(tab, user_id, login) { // To be overriden this.LoadBaseTemplate(tab, user_id, login); }; OptionsBase.prototype.LoadBaseTemplate = function(tab, user_id, login) { this.USER_ID = Math.round(user_id); this.LOGIN = login; tab[this.ClassName] = this; tab.Alerts = new Alerts(tab.TopicDiv); this.Tab = tab; if (this.Template) { RequestContent(this); } }; // Template Callbacks OptionsBase.prototype.TemplateLoaded = function(req) { // To be overriden this.TemplateBaseLoaded(req); }; OptionsBase.prototype.TemplateBaseLoaded = function(req) { text = req; if (req.responseText) { text = req.responseText; KeepRequestedContent(this.Template, text); } this.Tab.RelatedDiv.innerHTML = text; this.Tab.InitUploadFrame(); this.Request(); }; /* Gathering object properties from UI controls */ OptionsBase.prototype.GatherOne = function(name, property) { el = this.Inputs ? this.Inputs[name] : ""; var prop = property ? property : name; if (el) { if (el.type == "text" || el.type == "password" || el.type == "hidden" || el.type == "select-one" || el.type == "textarea") { this[prop] = el.value; return MakeParametersPair(name, el.value); } else if (el.type == "checkbox" || el.type == "radio") { this[prop] = el.checked; return MakeParametersPair(name, el.checked ? 1 : 0); } if (el.className == "Radios") { var value = GetRadioValue(el); this[prop] = value; return MakeParametersPair(name, value); } } else if (this[name] != "undefined") { return MakeParametersPair(name, this[name]); // In case if no real controls relate to object } return ""; }; OptionsBase.prototype.GatherFields = function(fields) { this.FindRelatedControls(); if (!fields) { if (!this.properties) { this.properties = this.fields; // In case if properties differs from elements ids } fields = this.fields; properties = this.properties; } else { properties = fields; } var el; var result = ""; for (var i = 0,l = fields.length; i < l; i++) { result += this.GatherOne(fields[i], properties[i]); } return result; }; OptionsBase.prototype.BaseGather = function() { var result = this.GatherFields(); if (this.alt_fields) { result += this.GatherFields(this.alt_fields); } return result; }; OptionsBase.prototype.Gather = function() { // Method to override return this.BaseGather(); }; /* Filling object properties with values from source array */ OptionsBase.prototype.FillBase = function(source, fields) { if (!fields) { fields = this.fields; } else { this.alt_fields = fields; } var doClear = 0; if (!source || !source.length) { source = this.defaultValues; // Do reset fields to default values } if (source.length != fields.length) { doClear = 1; } var el; for (var i = 0,l = fields.length; i < l; i++) { this[fields[i]] = doClear ? "" : source[i]; } }; OptionsBase.prototype.FillFrom = function(source, fields) { // Method to override this.FillBase(source, fields); }; /* Binding tba controls with object's properties */ OptionsBase.prototype.FindRelatedControls = function(force) { if ((force || !this.Inputs) && this.Tab) { this.Inputs = IndexElementChildElements(this.Tab.RelatedDiv); } }; OptionsBase.prototype.BindFields = function(fields) { this.FindRelatedControls(); var el; for (var i = 0, l = fields.length; i < l; i++) { var field = fields[i]; var value = this[field]; if (value == "undefined") { value = ""; } this.SetTabElementValue(field, value); } }; OptionsBase.prototype.BaseBind = function() { this.BindFields(this.fields); if (this.alt_fields) { this.BindFields(this.alt_fields); } }; OptionsBase.prototype.Bind = function() { // Method to override return this.BaseBind(); }; OptionsBase.prototype.AssignObjectTo = function(id, obj, name) { this.FindRelatedControls(); var el = this.Inputs[id]; if (el) { el[name] = obj; } }; OptionsBase.prototype.AssignTabTo = function(id) { this.AssignObjectTo(id, this.Tab, "Tab"); }; OptionsBase.prototype.AssignSelfTo = function(id) { this.AssignObjectTo(id, this, "obj"); }; OptionsBase.prototype.SetTabElementValue = function(element, value) { this.FindRelatedControls(); var el = this.Inputs[element]; if (el) { if (el.type == "text" || el.type == "hidden" || el.type == "select-one" || el.type == "textarea") { el.value = value; return; } else if (el.type == "checkbox" || el.type == "radio") { el.checked = value; return; } if (el.className == "Radios") { SetRadioValue(el, value); } else { el.innerHTML = value; } } }; OptionsBase.prototype.DisplayTabElement = function(element, state) { var el = this.Inputs[element]; if (el) { DisplayElement(el, state); } }; OptionsBase.prototype.Clear = function() { this.FindRelatedControls(); for (var i = 0,l = this.fields.length; i < l; i++) { this[this.fields[i]] = ""; } }; OptionsBase.prototype.Reset = function() { if (!this.defaultValues || this.defaultValues.length < this.fields.length) { return; } this.FindRelatedControls(); for (var i = 0,l = this.fields.length; i < l; i++) { this.SetTabElementValue(this.fields[i], this.defaultValues[i]); } }; /* Request methods */ OptionsBase.prototype.BaseRequest = function(params, callback) { if (!params) { params = ""; } params += MakeParametersPair("USER_ID", this.USER_ID); sendRequest(this.ServicePath, callback ? callback : this.RequestCallback, params, this); }; OptionsBase.prototype.Request = function(params, callback) { /* Method to override */ this.BaseRequest(params, callback); }; OptionsBase.prototype.Save = function(callback) { var params = this.Gather(); params += MakeParametersPair("go", "save"); this.Request(params, callback); }; OptionsBase.prototype.Delete = function(callback) { var params = this.Gather(); params += MakeParametersPair("go", "delete"); this.Request(params, callback); }; /* Common callback */ OptionsBase.prototype.RequestBaseCallback = function(req, obj) { this.data = []; this.Total = 0; if (obj) { var tabObject = obj.Tab; tabObject.Alerts.Clear(); eval(req.responseText); } }; // Reaction method to be overriden OptionsBase.prototype.React = function(value) {alert("Reaction handler is unset.");}; OptionsBase.prototype.GroupAssign = function(method, items) { if (this[method]) { for (var i = 0, l = items.length; i < l; i++) { this[method](items[i]); } } }; OptionsBase.prototype.GroupSelfAssign = function(items) { this.GroupAssign("AssignSelfTo", items); }; OptionsBase.prototype.GroupTabAssign = function(items) { this.GroupAssign("AssignTabTo", items); }; OptionsBase.prototype.UpdateToPrintableDate = function(field) { this.SetTabElementValue(field, ParseDate(this[field]).ToPrintableString(1)); }; /* Helper methods */ var optionsWindow; function ShowOptions() { if (!optionsWindow || optionsWindow.closed) { optionsWindow = open("options", "options", "width=600,height=400,toolbar=0,location=0,directories=0,status=1,menubar=0,resizable=1"); } optionsWindow.focus(); }; /* Static content requestor */ var cachedContent = new Array(); function RequestContent(obj) { var req; if (cachedContent[obj.Template] && obj.TemplateLoaded) { var req = new Object(); req.responseText = cachedContent[obj.Template]; obj.TemplateLoaded(req); } else { // No callback passed as parameter. Supposed to be taken from Obj. req = sendRequest("/options/" + obj.Template + ".php", "", "", obj); } return req; }; function KeepRequestedContent(name, value) { cachedContent[name] = value; }; /* Load template template_name with data for user_id into tab */ function LoadAndBindObjectToTab(tab, user_id, obj, obj_class, callback, login) { obj.USER_ID = Math.round(user_id); obj.LOGIN = login; tab[obj_class] = obj; tab.Alerts = new Alerts(tab.TopicDiv); obj.Tab = tab; if (obj.Template) { RequestContent(obj); } }; function CreateUserTab(id, login, obj, prefix, parameter, tab_id) { if (!tab_id) { tab_id = tabs.tabsCollection.LastId + 1; } var tab = tabs.tabsCollection.Get(tab_id); if (!tab) { tab = new Tab(tab_id, (prefix ? prefix : "") + (prefix && login ? " " : "") + login); tabs.Add(tab); SwitchToTab(tab_id); tabs.Print(); var tab = tabs.tabsCollection.Get(tab_id); tab.PARAMETER = parameter; obj.LoadTemplate(tab, id, login); } else { SwitchToTab(tab_id); tabs.Print(); } return tab; }; /* Common methods */ function SaveObject(a) { if (a && a.obj) { if (a.obj.Tab & a.obj.Tab.Alerts) { a.obj.Tab.Alerts.Clear(); } a.obj.Save(); } }; function ReRequestData(a) { if (a.obj) { a.obj.Tab.Alerts.Clear(); a.obj.Request(); } }; function ResetFilter(a) { if (a.obj) { var ac = a.obj; ac.SetTabElementValue("DATE", ""); ac.SetTabElementValue("SEARCH", ""); if (ac.CustomReset) { ac.CustomReset(); } ac.Request(); } }; /* 06.validator.class.js */ //2.5 /* Validation of controls against rules given. */ function ValidatorsCollection() { this.Clear(); }; ValidatorsCollection.prototype = new Collection(); ValidatorsCollection.prototype.Init = function(summary_control, summary_text) { this.Summary = summary_control; this.SummaryText = summary_text ? summary_text : ""; this.InitSummary(); for (var id in this.Base) { if (id && this.Base[id].Init) { this.Base[id].Init(); } } }; ValidatorsCollection.prototype.InitSummary = function() { if (this.Summary) { this.Summary.innerHTML = this.SummaryText; this.Summary.className = "Hidden"; } }; ValidatorsCollection.prototype.AreValid = function() { this.InitSummary(); var result = true; for (var id in this.Base) { if (id && this.Base[id].Validate) { if (!this.Base[id].Validate(this.Summary)) { result = false; } } } return result; }; var PageValidators = new ValidatorsCollection(); function ValueHasChanged() { return PageValidators.AreValid(); }; /* --------------- Single Validator --------------- */ function Validator(control, rule, message, summarize, on_the_fly) { this.Control = control; this.Rule = rule; this.Message = message; this.ShowInSummary = summarize; this.OnTheFly = on_the_fly; this.Id = Random(1000, 1); this.Enabled = true; }; Validator.prototype.Init = function() { if (this.OnTheFly) { this.Control.onchange = ValueHasChanged; } this.ErrorContainer = d.createElement("div"); if (!this.ShowInSummary) { this.Display(false); this.ErrorContainer.innerHTML = this.Message; insertAfter(this.ErrorContainer, this.Control); } }; Validator.prototype.Validate = function(summary_control) { if (this.Control && this.Rule.Check(this.Control.value, this.Control)) { this.Display(false); return true; } this.Control.focus(); this.Display(true, summary_control); return false; }; Validator.prototype.Display = function(state, summary_control) { if (summary_control && this.ShowInSummary) { summary_control.innerHTML += "
  • " + this.Message; summary_control.className = ""; } else { this.ErrorContainer.className = "Validator" + (state ? "" : " Hidden"); } }; /* -------------------- Validation Rules -------------------- */ // Required Field function RequiredField() { }; RequiredField.prototype.Check = function(value) { return (value.length > 0); }; // Field Length function LengthRange(min_length, max_length) { this.MinLength = min_length; this.MaxLength = max_length; }; LengthRange.prototype.Check = function(value) { var l = value.length; return (l >= this.MinLength && l <= this.MaxLength); }; // Equal To function EqualTo(control) { this.Control = control; }; EqualTo.prototype.Check = function(value) { return (this.Control && this.Control.value == value); }; // Match the pattern var emailPattern = new RegExp("^[0-9a-zA-Z\!\#\$\'\*\+\-\/\=\?\^_\.\`\{\|\}\~]+\@[0-9a-zA-Z\!\#\$\'\*\+\-\/\=\?\^_\`\{\|\}\~]{2,50}([\.][0-9a-zA-Z\!\#\$\'\*\+\-\/\=\?\^_\`\{\|\}\~]{2,50})+$"); function MatchPattern(pattern) { this.Pattern = pattern; }; MatchPattern.prototype.Check = function(value) { return value.match(this.Pattern); }; // Is Checked function IsChecked() { }; IsChecked.prototype.Check = function(x, control) { return control.checked; }; /* 07.myframe.class.js */ //1.1 /* MyFrame class Handles window resize and update object's properties correspondingly */ function MyFrame(obj, min_width, min_height) { this.x = 0; this.y = 0; this.width = 0; this.height = 0; this.minWidth = min_width ? parseInt(min_width) : 0; this.minHeight = min_height ? parseInt(min_height) : 0; this.element = 0; this.GetPosAndSize = function() { if (this.element == window) { return this.GetWindowSize(); } this.width = parseInt(this.element.clientWidth); this.height = parseInt(this.element.clientHeight); var obj = this.element; if (obj.offsetParent) { this.x = obj.offsetLeft; this.y = obj.offsetTop; while (obj = obj.offsetParent) { this.x += obj.offsetLeft; this.y += obj.offsetTop; } } }; this.GetWindowSize = function() { this.x = 0; this.y = 0; if (self.innerWidth) { this.width = self.innerWidth; this.height = self.innerHeight; } else if (document.documentElement && document.documentElement.clientWidth) { this.width = document.documentElement.clientWidth; this.height = document.documentElement.clientHeight; } else if (document.body) { this.width = document.body.clientWidth; this.height = document.body.clientHeight; } }; this.Replace = function(x, y, w, h) { if (this.element == window || !this.element.style) { return; } if (x >= 0) { this.element.style.left = x + 'px'; } if (y >= 0) { this.element.style.top = y + 'px'; } if (w >= 0) { if (w < this.minWidth) { w = this.minWidth; } this.element.style.width = w + 'px'; } if (h >= 0) { if (h < this.minHeight) { h = this.minHeight; } this.element.style.height = h + 'px'; } this.GetPosAndSize(); }; this.Info = function() { var s = 'x=' + this.x + ', '; s += 'y='+ this.y + ', '; s += 'width='+ this.width + ', '; s += 'height='+ this.height; return s; }; if (obj) { this.element = obj; this.GetPosAndSize(); } } /* 08.panel.class.js */ //3.8 /* Sliding panel class */ var panels = new Array(); function Panel() { this.IsOpened = 1; this.Step = 20; this.MinPosition = 10; this.BaseLinkClass = "Panel"; }; Panel.prototype.Init = function(id, size) { this.Id = id; this.Holder = $(id); this.Position = size; this.CurrentSize = size; this.CreateLink(); if (this.Holder) { this.Resize(this.Position); if (this.SwitchLink) { this.SwitchLink.href = voidLink; this.SwitchLink.Panel = this; this.SwitchLink.onclick = function(){Slide(this.Panel)}; this.LinkSwitcher(); } panels[id] = this; } }; Panel.prototype.CreateLink = function () { this.SwitchLink = d.createElement("a"); this.SwitchLink.onfocus = function(){this.blur()}; if (this.Holder.hasChildNodes()) { this.Holder.insertBefore(this.SwitchLink, this.Holder.firstChild); } else { this.Holder.appendChild(this.SwitchLink); } }; Panel.prototype.LinkSwitcher = function () { this.SwitchLink.className = this.BaseLinkClass + " " + (this.IsOpened ? "Opened" : "Closed"); if (AdjustDivs) { AdjustDivs(); } }; Panel.prototype.ResizeBy = function (to) { var result = true; var size = this.CurrentSize + to; if (size < this.MinPosition) { size = this.MinPosition; this.IsOpened = false; result = false; } if (size > this.Position) { size = this.Position; this.IsOpened = true; result = false; } if (!result) { this.LinkSwitcher(); } this.Resize(size); return result; }; Panel.prototype.Resize = function (size) { // Method to override }; function Slide(panel) { if (panel.ResizeBy(panel.IsOpened ? -panel.Step : panel.Step)) { setTimeout(function() {Slide(panel)}, 1); } }; /* Left Panel derived class */ function LeftPanel(id, size) { this.BaseLinkClass = "PanelLeft"; this.Init(id, size); }; LeftPanel.prototype = new Panel(); LeftPanel.prototype.Resize = function (size) { // this.Holder.style.width = size + "px"; this.Holder.style.left = (size - this.Position) + "px"; this.CurrentSize = size; }; /* Right Panel derived class */ function RightPanel(id, size) { this.BaseLinkClass = "PanelRight"; this.MinPosition = 10; this.Init(id, size); }; RightPanel.prototype = new Panel(); RightPanel.prototype.Resize = function (size) { this.Holder.style.width = size + "px"; this.Holder.style.right = "10px"; this.CurrentSize = size; }; /* 09.room.class.js */ //2.9 /* Represents room entity on client-side. */ function Room(id, title, topic, topic_lock, topic_author_id, topic_author_name, is_locked, is_by_invitation, owner_id) { // Properties this.Id = id; this.Title = title; this.Topic = topic; this.TopicLock = topic_lock; this.TopicAuthorId = topic_author_id; this.TopicAuthorName = topic_author_name; this.IsLocked = is_locked; this.IsInvitationRequired = is_by_invitation; this.OwnerId = owner_id; }; // Methods Room.prototype.IsCurrent = function() { if (this.Id == CurrentRoomId) { CurrentRoom = this; return true; } return false; }; Room.prototype.Enter = function() { CurrentRoomId = this.Id; }; Room.prototype.ToString = function() { var s = "
  • "; var title = this.Title.length < 16 ? this.Title : this.Title.substr(0, 16) + "..."; if (this.IsCurrent()) { s += "" + title + ""; } else { s += "" + title + ""; } var inside = 0; var t = '
  • "; s = s + (inside ? (" (" + inside + ")") : "") + (inside || requestors ? t : ""); return s; }; Room.prototype.Gather = function(sel) { var opt = d.createElement("option"); opt.value = this.Id; opt.text = this.Title; try { sel.add(opt, null); // standards compliant; doesn't work in IE } catch (ex) { sel.add(opt); // IE only } }; Room.prototype.MakeCSS = function() { var cl = (this.IsInvitationRequired ? "Private" : "Usual"); cl += (this.IsCurrent() ? " Current" : ""); cl += (this.IsLocked ? " Locked " : ""); return cl; }; Room.prototype.CheckSum = function() { var cs = CheckSum(this.OwnerId); cs+= CheckSum(this.Title); cs+= CheckSum(this.Topic); cs+= CheckSum(this.TopicLock); cs+= CheckSum(this.TopicAuthorId); cs+= CheckSum(this.IsLocked); cs+= CheckSum(this.IsInvitationRequired); DebugLine("Room: " + this.Id + " sum: "+cs); return cs; }; var CurrentRoom; function ChangeRoom(id) { if (rooms && rooms.Get) { var room = rooms.Get(id); if (room && room.Enter) { room.Enter(); if (MoveToRoom) { MoveToRoom(id); } if (PrintRooms) { PrintRooms(); } } else { return false; } } }; /* Room DTO class */ function RoomLightweight() { this.fields = new Array("NEW_ROOM", "IS_PRIVATE", "IS_LOCKED"); this.ServicePath = servicesPath + "room.service.php"; this.Template = "add_room"; this.ClassName = "AddRoom"; }; RoomLightweight.prototype = new OptionsBase(); RoomLightweight.prototype.RequestCallback = function(req, obj) { if (req.responseText) { obj.SetRoomStatus(req.responseText); } else { obj.SetRoomStatus(""); obj.Clear(); obj.Bind(); obj.Tab.Display(false); PrintRooms(); } }; RoomLightweight.prototype.Request = function(params, callback) {}; RoomLightweight.prototype.Save = function(callback) { var params = this.Gather(); if (this.NEW_ROOM) { this.BaseRequest(params, callback); } else { this.SetRoomStatus("Введите название"); } }; RoomLightweight.prototype.SetRoomStatus = function(text) { this.FindRelatedControls(); var st = this.Inputs["RoomStatus"]; if (st) { st.innerHTML = text; } }; RoomLightweight.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); DisplayElement("AdminOnly", me && me.Rights >= adminRights); this.AssignTabTo("linkAdd"); BindEnterTo(this.Inputs["NEW_ROOM"], this.Inputs["linkAdd"]); }; /* Room lightweight link actions */ function AddRoom(a) { if (a.Tab) { a.Tab.AddRoom.Save(); } }; /* 10.status.class.js */ //1.0 /* Represents status entity on client-side. */ function Status(rights, title, color) { // Properties this.Rights = rights; this.Title = title; this.Color = color; }; // Methods Status.prototype.MakeCSS = function() { return "color:" + this.Color + ";"; }; Status.prototype.CheckSum = function() { var cs = CheckSum(this.Rights); cs+= CheckSum(this.Title); cs+= CheckSum(this.Color); return cs; }; /* 11.font.class.js */ //2.5 /* Represents font settings */ function Font(color, size, face, is_bold, is_italic, is_underlined) { this.Color = color; this.Size = size; this.Face = face; this.IsBold = is_bold; this.IsItalic = is_italic; this.IsUnderlined = is_underlined; this.fields = new Array("FONT_COLOR", "FONT_SIZE", "FONT_FACE", "FONT_BOLD", "FONT_ITALIC", "FONT_UNDERLINED"); this.properties = new Array("Color", "Size", "Face", "IsBold", "IsItalic", "IsUnderlined"); }; Font.prototype = new OptionsBase(); // Methods Font.prototype.ToCSS = function(observer) { var s = (observer && observer.Settings) ? observer.Settings : new Settings('', 0, 0, 0, 0); var style = ''; if (this.Color && !s.IgnoreColors) { style += "color:" + this.Color + ";"; } if (this.Face && !s.IgnoreFonts) { style += "font-family:\"" + this.Face + "\";"; } if (this.Size && !s.IgnoreSizes) { style += "font-size:" + (5 + 2 * this.Size) + "pt;"; } if (!s.IgnoreStyles) { if (1 * this.IsBold) { style += "font-weight:bold;"; } if (1 * this.IsItalic) { style += "font-style:italic;"; } if (1 * this.IsUnderlined) { style += "text-decoration:underline;"; } } return style; }; Font.prototype.ApplyTo = function(element) { if (element) { var result = (this.IsItalic ? "italic" : "normal") + " normal "; result += (this.IsBold ? "bold " : "normal "); result += (5 + 2 * this.Size) + "pt "; result += "'" + this.Face + "'"; element.style.font = result; element.style.textDecoration = this.IsUnderlined ? "underline" : "none"; element.style.color = this.Color; }; }; Font.prototype.CheckSum = function() { var cs = CheckSum(this.Color); cs+= CheckSum(this.Size); cs+= CheckSum(this.Face); cs+= CheckSum(this.IsBold); cs+= CheckSum(this.IsItalic); cs+= CheckSum(this.IsUnderlined); return cs; }; /* 12.user.class.js */ //5.0 /* Represents user entity on client-side. */ var IsIgnoredDefault = "", IgnoresYouDefault = ""; function User(id, login, room_id, room_is_permitted, ip, away_message, ban_reason, banned_by, nickname, settings, rights, status_title, status_color, is_ignored, ignores_you) { // Properties this.Id = id; this.Login = login; this.RoomId = room_id; this.RoomIsPermitted = room_is_permitted; this.SessionAddress = ip; this.AwayMessage = away_message; this.BanReason = ban_reason; this.BannedBy = banned_by; this.Nickname = nickname; this.Settings = settings; this.Rights = rights; this.StatusTitle = status_title; this.StatusColor = status_color; this.IsIgnored = 1 * is_ignored; this.IgnoresYou = 1 * ignores_you; }; User.prototype.CheckSum = function() { var cs = 0; cs += CheckSum(this.RoomId); cs += CheckSum(this.RoomIsPermitted); cs += CheckSum(this.AwayMessage); cs += CheckSum(this.BanReason); cs += CheckSum(this.BannedBy); cs += this.Settings.CheckSum(); cs += CheckSum(this.Nickname); cs += CheckSum(this.Rights); cs += CheckSum(this.StatusTitle); cs += CheckSum(this.StatusColor); // cs += CheckSum(this.IsIgnored); // cs += CheckSum(this.IgnoresYou); cs += "" + this.IsIgnored + "" + this.IgnoresYou; // DebugLine('User: '+this.Id+' sum: '+cs); return cs; }; User.prototype.IsAdmin = function() { return this.Rights >= adminRights; }; User.prototype.IsSuperAdmin = function() { return this.Rights > adminRights; }; User.prototype.ToString = function(room) { var name = (this.Nickname ? this.Nickname : this.Login); var has_access = this.HasAccessTo(room); var s = this.NameToString(name, has_access); s += ''; return s; }; User.prototype.NameToString = function(name, has_access) { var color = this.StatusColor; var className = ""; var cl = 1; if (this.BannedBy > 0) { className = "Banned"; cl = 0; } else if (this.AwayMessage) { className = "Away"; cl = 0; } if (!has_access && me.RoomId == this.RoomId) { className = "Requestor"; } if (this.IgnoresYou) { className += " IgnoresMe"; } var title = name + (this.AwayMessage ? " отсутствует «" + this.AwayMessage + "»" : ""); var s = '
  • ' + name + '
    '; return s; }; User.prototype.DisplayedName = function() { return this.Nickname ? this.Nickname : this.Login; }; User.prototype.HasAccessTo = function(room) { if (!room.IsInvitationRequired || room.OwnerId == this.Id) { return true; } if (this.RoomId == room.Id && this.RoomIsPermitted != 0) { return true; } return false; }; function SetVisibility(id, state) { var e = id.style ? id : $(id); if (e) { e.style.display = state ? '' : 'none'; } }; function SwitchVisibility(id) { var e = id.style ? id : $(id); if (e.style.display == 'none') { Show(e); } else { HideDelayed(); } }; /* Helper methods */ var shownElement; var hideTimer; function Show(id) { if (shownElement) { if (shownElement != id) { HideDelayed(); } else if (hideTimer) { clearTimeout(hideTimer); return; } } SetVisibility(id, true); shownElement = id; }; function Hide() { hideTimer = setTimeout("HideDelayed()", 1000); }; function HideDelayed() { SetVisibility(shownElement, false); shownElement = ''; }; /* 13.confirm.class.js */ //2.8 /* Displays inline confirmation window blocking all content behind and handling callback. */ function Confirm() { var Cover; var Holder; var CallbackObject; var AlertType = false; }; Confirm.prototype.Init = function(coverId, holderId) { this.Cover = $(coverId); this.Holder = $(holderId); this.Holder.className = "ConfirmContainer"; }; Confirm.prototype.Display = function(state) { DisplayElement(this.Holder, state); DisplayElement(this.Cover, state); }; Confirm.prototype.Show = function(callback, title, message, customContent, keep_opened) { if (!this.Holder) { return false; } else { this.Holder.innerHTML = ""; } title = title ? title : 'Confirmation'; this.CallbackObject = callback; this.KeepOpened = keep_opened; var h1 = d.createElement("h1"); h1.innerHTML = title; this.Holder.appendChild(h1); var m = d.createElement("div"); m.innerHTML = message; this.Holder.appendChild(m); if (customContent && customContent.CreateControls) { customContent.CreateControls(this.Holder); if (customContent.RequestData) { customContent.RequestData(); } } var m1 = d.createElement("div"); m1.className = "ConfirmButtons"; if (this.AlertType) { m1.appendChild(MakeButton("ConfirmObject.Ok()", "ok_button.gif")); } else { m1.appendChild(MakeButton("ConfirmObject.Ok()", "yes_button.gif")); m1.appendChild(MakeButton("ConfirmObject.Cancel()", "no_button.gif")); } this.Holder.appendChild(m1); this.Display(true); window.ConfirmObject = this; return false; }; Confirm.prototype.Hide = function() { if (!this.Holder) { return; } this.Display(false); this.Holder.innerHTML = ""; }; Confirm.prototype.Cancel = function() { if (!this.Holder) { return; } this.Hide(); this.CallbackObject = null; }; Confirm.prototype.Ok = function() { if (!this.Holder) { return; } if (!this.KeepOpened) { this.Hide(); } if (this.CallbackObject) { if (typeof(this.CallbackObject) == 'function') { this.CallbackObject(); } else { if (this.CallbackObject.click) { this.CallbackObject.click(); } else { location.href = this.CallbackObject; } } } }; /* 14.tabs.class.js */ //4.1 /* Tab class. Entity of Tabs one. */ /* Base tab class */ function TabBase() { }; TabBase.prototype.InitUploadFrame = function(property) { if (!property) { property = "UploadFrame"; } if (!this[property]) { this[property] = CreateElement("iframe", "UploadFrame" + Math.round(100000*Math.random())); this[property].className = "UploadFrame"; if (this.RelatedDiv) { this.RelatedDiv.appendChild(this[property]); } } }; /* obj - object to be assigned as a.obj (Tab by default) */ TabBase.prototype.AddSubmitButton = function(method, holder, obj) { var m1 = d.createElement("div"); m1.className = "ConfirmButtons"; this.SubmitButton = MakeButton(method, "ok_button.gif", obj ? obj : this, "", "Сохранить изменения"); m1.appendChild(this.SubmitButton); // alert(holder ? holder : "RelatedDiv"); this[holder ? holder : "RelatedDiv"].appendChild(m1); }; /* Tab object reaction by outside call */ TabBase.prototype.React = function(value) { if (this.Reactor) { this.Reactor.React(value); } }; /* Sets additional className to RelatedDiv */ TabBase.prototype.SetAdditionalClass = function(className) { this.RelatedDiv.className = "TabContainer" + (className ? " " + className : ""); }; /* Tab class */ Tab.prototype = new TabBase(); function Tab(id, title, is_locked, is_private, on_select) { this.Id = id; this.Title = title; this.IsLocked = is_locked; this.IsPrivate = is_private; this.onSelect = on_select; this.UnreadMessages = 0; this.lastMessageId = -1; this.Alt = ""; this.recepients = new Collection(); if (this.IsPrivate) { this.recepients.Add(new Recepient(id, title, 1)); } }; Tab.prototype.ToString = function(index) { var isSelected = CurrentTab.Id == this.Id; if (isSelected) { CurrentTab = this; } this.DisplayDiv(isSelected); var s = "
  • "; if (isSelected) { s += "" + this.Title + ""; } else { var action = "SwitchToTab(\"" + this.Id + "\")"; s += "" + this.Title; if (this.UnreadMessages) { s += "(" + this.UnreadMessages + ")"; } s += ""; } if (!this.IsLocked) { s += "x"; } s += "
  • "; return s; }; Tab.prototype.DisplayDiv = function(state) { DisplayElement(this.RelatedDiv, state); DisplayElement(this.TopicDiv, state); }; Tab.prototype.Clear = function() { this.TopicDiv.innerHTML = ''; this.RelatedDiv.innerHTML = ''; this.lastMessageId = -1; }; /* Tabs collection class. */ var CurrentTab; function Tabs(tabsContainer, contentContainer) { this.TabsContainer = tabsContainer; this.ContentContainer = contentContainer; this.tabsCollection = new Collection(); this.tabsList = document.createElement("ul"); this.tabsList.className = "Tabs"; this.TabsContainer.appendChild(this.tabsList); }; Tabs.prototype.Print = function() { this.tabsList.innerHTML = this.tabsCollection.ToString(); }; Tabs.prototype.Add = function(tab, existing_container) { var topic = document.createElement("div"); topic.className = "TabTopic"; this.ContentContainer.appendChild(topic); tab.TopicDiv = topic; if (!existing_container) { existing_container = document.createElement("div"); existing_container.className = "TabContainer"; this.ContentContainer.appendChild(existing_container); } tab.RelatedDiv = existing_container; this.tabsCollection.Add(tab); tab.DisplayDiv(false); }; Tabs.prototype.Delete = function(id) { var tab = this.tabsCollection.Get(id); if (tab) { this.ContentContainer.removeChild(tab.TopicDiv); this.ContentContainer.removeChild(tab.RelatedDiv); this.tabsCollection.Delete(id); } }; Tabs.prototype.PrintTo = function(id, text) { var tab = this.tabsCollection.Get(id); if (tab && tab.RelatedDiv) { tab.RelatedDiv.innerHTML = text; } }; /* Service functions */ function SwitchToTab(id) { var tab = tabs.tabsCollection.Get(id); if (tab) { CurrentTab = tab; tab.UnreadMessages = 0; tabs.Print(); recepients = tab.recepients; if (window.ShowRecepients) { ShowRecepients(); } if (tab.onSelect) { tab.RelatedDiv.innerHTML = LoadingIndicator; tab.onSelect(tab); tab.onSelect = ""; /* TODO: Treat failure */ } } if (AdjustDivs) { AdjustDivs(); } } function CloseTab(id) { var tab = tabs.tabsCollection.Get(id); if (tab) { tabs.Delete(id); SwitchToTab(MainTab.Id); tabs.Print(); } } /* 15.recepient.class.js */ //1.5 /* Recepient class. */ function Recepient(id, title, is_locked) { this.Id = id; this.Title = title; this.IsLocked = is_locked; }; Recepient.prototype.ToString = function(index) { var s = (index ? ", " : "") + this.Title; if (!this.IsLocked) { s += "x"; } return s; }; Recepient.prototype.Gather = function(index) { return (index ? "," : "") + this.Id; }; /* 16.message.formatter.js */ //1.3 /* Replaces #pvt#, #info# and #add# chunks with proper links */ function MakePrivateLink(id, name) { return "#"; }; function MakeLink(name) { return "" + name + ""; }; function MakeInfoLink(id, name) { return "" + name + ""; }; function GetUserStyle(id) { if (users) { var user = users.Get(id); if (user && user.Settings.Font && user.Settings.Font.ToCSS) { return "style='" + user.Settings.Font.ToCSS(me) + "'"; } } return ""; } function Format(text, person_id, person_name) { text = text.replace("#style#", GetUserStyle(person_id)); text = text.replace("#info#", MakeInfoLink(person_id, person_name)); text = text.replace("#pvt#", MakePrivateLink(person_id, person_name)); text = text.replace("#add#", MakeLink(person_name)); return text; }; /* 17.wakeup.helper.js */ //2.0 /* Opens pop-up wakeup windows with messages. */ var wakeups = new Collection(); var WakeupsHolder; var MaxShownWakeups = 10; var ReceivedWakeups = 0; function Wakeup(id, sender, reset) { if (!me) { return; } if (me.Settings.ReceiveWakeups) { ShowWakeup(id); } else { wakeups.Add(new WakeupMessage(id, sender)); } }; function ShowWakeup(id, remove) { var wakeupWindow = window.open("wakeup.php?id=" + id, "wakeup" + id, "width=500,height=300,toolbar=0,location=0,directories=0,status=1,menubar=0,resizable=1"); if (remove) { wakeups.Delete(id); PrintWakeups(); } }; function PrintWakeups() { if (!WakeupsHolder) { WakeupsHolder = $("Wakeups"); } if (WakeupsHolder) { ReceivedWakeups = wakeups.Count(); if (ReceivedWakeups > 0) { WakeupsHolder.innerHTML = "

    Вейкапы (" + ReceivedWakeups + "):

    "; wakeups.ToString(WakeupsHolder); DisplayElement(WakeupsHolder, true); } else { DisplayElement(WakeupsHolder, false); } } }; function WakeupMessage(id, sender) { this.Id = id; this.Sender = sender; }; WakeupMessage.prototype.ToString = function(holder, i) { if (i == MaxShownWakeups) { holder.appendChild(d.createTextNode(", и ещё " + (ReceivedWakeups - MaxShownWakeups))); return; } else if (i > MaxShownWakeups) { return; } var a = d.createElement("a"); a.innerHTML = this.Sender; a.href = voidLink; a.wId = this.Id; a.onclick = function(){ShowWakeup(this.wId,1)}; if (i) { holder.appendChild(d.createTextNode(", ")); } holder.appendChild(a); }; /* 18.info.helper.js */ //1.1 /* Info PopUp helper */ var infoPopUp; function Info(id) { infoPopUp = open("/user/" + id + ".html", "info", "width=550,height=600,toolbar=0,location=0,directories=0,status=1,menubar=0,resizable=1"); } /* 19.menu.class.js */ //2.2 /* Menu items */ var menuItemWidth = 100; var menuItemHeight = 20; function MenuItem(id, title, action, is_locked) { this.Id = id; this.Title = title; this.Action = action; this.IsLocked = is_locked; this.SubItems = new MenuItemsCollection(); }; MenuItem.prototype.Gather = function(holder) { var a = d.createElement('a'); a.innerHTML = this.Title; a.href = voidLink; if (this.Action) { eval("a.onclick = function() {" + this.Action + ";}"); } var li = document.createElement("li"); li.RelatedItem = this; li.onmouseover = function() {DisplaySubmenu(this, true);}; li.onmouseout = function() {DisplaySubmenu(this, false);}; li.onclick = li.onmouseout; if (this.SubItems.Items.Count() > 0) { this.SubItems.Create(li); } li.appendChild(a); holder.appendChild(li); }; function MenuItemsCollection(shown) { this.Items = new Collection(); this.Container = document.createElement("ul"); if (!shown) { DisplayElement(this.Container, false); } }; MenuItemsCollection.prototype.Create = function(where) { this.Container.innerHTML = ""; if (this.Items.Count() > 0) { this.Items.Gather(this.Container); where.appendChild(this.Container); } }; MenuItemsCollection.prototype.Display = function(state) { DisplayElement(this.Container, state); }; function DisplaySubmenu(el, state, force) { if (el.RelatedItem && el.RelatedItem.SubItems) { el.RelatedItem.SubItems.Display(state); el.className = state ? "Selected" : ""; } }; /* 20.alerts.class.js */ //1.3 /* Displays messages on given container. */ function Alerts(container) { this.Holder = container; this.Holder.className = "AlertsHolder"; this.Container = RoundCorners(container, "corners_med.gif", 3); this.Clear(); }; Alerts.prototype.Add = function(message, isError) { DisplayElement(this.Holder, true); this.Container.innerHTML += "

    " + message + "

    "; this.HasErrors = this.HasErrors || isError; this.IsEmpty = 0; }; Alerts.prototype.Clear = function() { DisplayElement(this.Holder, false); this.Container.innerHTML = ""; this.HasErrors = 0; this.IsEmpty = 1; }; /* 21.nickname.class.js */ //2.7 /* Custom confirm contents. */ /* Nickname class */ var nicknames = new Collection(); var nicknames1; var max_names = 5; var name_length = 20; function Nickname(index, id, name) { this.Index = index; this.Id = id; this.OldName = name; this.Name = name; this.Mode = "show"; }; Nickname.prototype.IsEmpty = function() { return (this.Name == ""); }; Nickname.prototype.HasChanged = function() { return (this.OldName != this.Name); }; Nickname.prototype.CreateButton = function(src, action) { var button = d.createElement("input"); button.type = "image"; button.RelatedItem = this; eval("button.onclick = function(){" + action + "}"); button.className = "Button"; button.style.width = "15px"; button.style.height = "15px"; button.src = imagesPath + src; return button; }; Nickname.prototype.CreateViewControls = function() { this.Div.innerHTML = ""; if (this.Mode == "show") { this.Div.innerHTML += (this.Name ? this.Name + (this.Name == me.Login ? " (ваш логин)" : "") : "<не задано>") + " "; if (this.Id) { this.Div.appendChild(this.CreateButton("edit_icon.gif", "Edit(this)")); if (this.Name) { this.Div.appendChild(this.CreateButton("delete_icon.gif", "Clear(this)")); } } } else { this.Input = d.createElement("input"); this.Input.className = "NewNick"; this.Input.value = this.Name; this.Input.setAttribute("maxlength", name_length); this.Div.appendChild(this.Input); if (this.Id) { this.Div.appendChild(this.CreateButton("icons/done.gif", "StopEditing(true)")); this.Div.appendChild(this.CreateButton("icons/cancel.gif", "StopEditing(false)")); } } }; Nickname.prototype.ToString = function(holder) { if (!this.Li) { this.Li = d.createElement("li"); } else { this.Li.innerHTML = ""; } this.Radio = CreateRadio("nickname", ((!me.Nickname && this.Name == me.Login) || (me.Nickname && this.Name == me.Nickname))); this.Radio.RelatedItem = this; eval("this.Radio.onclick = function(){Select(this)}"); this.Li.appendChild(this.Radio); this.Div = d.createElement("span"); this.CreateViewControls(); this.Li.appendChild(this.Div); holder.appendChild(this.Li); }; Nickname.prototype.Gather = function(index) { var s = ""; s += MakeParametersPair("id" + index, this.Id > 0 ? this.Id : ""); s += MakeParametersPair("name" + index, this.Name); if (this.Radio.checked) { s += MakeParametersPair("selected", index); } return s; }; /* Change Nickname class */ function ChangeNickname() { }; ChangeNickname.prototype.CreateControls = function(container) { this.Holder = d.createElement("ul"); this.Holder.className = "NamesList"; this.Holder.innerHTML = LoadingIndicator; container.appendChild(this.Holder); this.Status = d.createElement("div"); this.Status.className = "Status"; container.appendChild(this.Status); nicknames1 = this; }; ChangeNickname.prototype.RequestData = function() { sendRequest(servicesPath + "nickname.service.php", NamesResponse, ""); }; function NamesResponse(req) { if (nicknames1.Holder) { nicknames.Clear(); nicknames.Add(new Nickname(0, 0, me.Login)); try { eval(req.responseText); } catch (e) { } for (var i = nicknames.Count(); i <= max_names; i++) { nicknames.Add(new Nickname(i + 1, - (i + 1), "")); } if (NewNickname != "-1") { me.Nickname = NewNickname; if (PrintRooms) { PrintRooms(); } } nicknames1.Holder.innerHTML = ""; nicknames.ToString(nicknames1.Holder); } }; var activeItem; function Select(e) { if (e.RelatedItem) { StopEditing(true); var item = e.RelatedItem; if (item.IsEmpty()) { Edit(e); } } }; function Edit(e) { if (e.RelatedItem) { StopEditing(true); var item = e.RelatedItem; item.Mode = "edit"; item.CreateViewControls(); item.Input.focus(); activeItem = item; } }; function Clear(e) { if (e.RelatedItem) { var item = e.RelatedItem; item.Name = ""; item.CreateViewControls(); } }; function StopEditing(acceptChanges) { if (activeItem) { activeItem.Mode = "show"; if (acceptChanges) { activeItem.Name = activeItem.Input.value; } activeItem.CreateViewControls(); } }; var nicknameSaving = 0; function SaveNicknameChanges() { if (nicknameSaving) { return; } StopEditing(true); nicknameSaving = 1; setTimeout("UnLockSaving()", 10000); sendRequest(servicesPath + "nickname.service.php", SavingResults, nicknames.Gather()); }; function UnLockSaving() { nicknameSaving = 0; }; function SavingResults(req) { UnLockSaving(); status = ""; NamesResponse(req); if (!status) { SetStatus("Изменения сохранены."); setTimeout("co.Hide()", 2000); } ForcePing(); }; var status; function SetStatus(text) { nicknames1.Status.innerHTML = text; status = text; }; /* 22.profile.class.js */ //6.6 /* User profile data & helper methods */ function Profile() { this.fields = new Array("LOGIN", "EMAIL", "NAME", "GENDER", "BIRTHDAY", "CITY", "ICQ", "URL", "PHOTO", "AVATAR", "ABOUT", "REGISTERED", "LAST_VISIT"); this.ServicePath = servicesPath + "profile.service.php"; this.Template = "userdata"; this.ClassName = "Profile"; // Optimize? }; Profile.prototype = new OptionsBase(); Profile.prototype.Gather = function() { var result = this.BaseGather(); result += this.GatherOne("PASSWORD"); result += this.GatherOne("PASSWORD_CONFIRM"); result += this.GatherOne("BANNED"); return result; }; Profile.prototype.Bind = function() { this.BaseBind(); /* Bind images */ DisplayElement(this.Inputs["liDeletePhoto"], this.PHOTO); DisplayElement(this.Inputs["liDeleteAvatar"], this.AVATAR); this.BindImage(this.Photo1); this.BindImage(this.Avatar1); /* Ban Status */ this.SetTabElementValue("BANNED", this.BANNED_BY > 0); this.DisplayTabElement("BanDetails", !this.ADMIN && this.BANNED_BY > 0); var ban_status = ""; if (this.ADMIN) { ban_status += "Пользователь забанен администратором " + this.ADMIN + ""; ban_status += " " + (this.BANNED_TILL ? "до " + this.BANNED_TILL : "бессрочно"); if (this.BAN_REASON) { ban_status += " по причине «" + this.BAN_REASON + "»"; } } this.SetTabElementValue("BanStatus", ban_status); // Correct dates this.UpdateToPrintableDate("REGISTERED"); this.UpdateToPrintableDate("LAST_VISIT"); }; Profile.prototype.BindImage = function(img) { if (this[img.Field]) { this.ReloadImage(img); } else { img.ImageObject = ""; this.PrintLoadedImage(img); } }; Profile.prototype.CheckPhoto = function(img) { if (!img.HasImage()) { img.ImageObject = d.createElement("img"); img.ImageObject.Profile = this; img.ImageObject.Img = img; img.ImageObject.onload = function(){ImageLoaded(this)}; } }; Profile.prototype.ReloadImage = function(img) { if (!this.Tab.Alerts.HasErrors) { this.SetTabElementValue(img.Container, LoadingIndicator); this.CheckPhoto(img); img.ImageObject.src = img.Path + this[img.Field] + "?" + Math.random(100); if (this.Inputs[img.UploadForm]) { this.Inputs[img.UploadForm].reset(); } } }; Profile.prototype.PrintLoadedImage = function(img) { var p = this.Inputs[img.Container], result = "не загружено"; if (p) { if (img.ImageObject) { var dim = "width='" + img.MaxWidth + "'"; if (img.ImageObject.width < img.MaxWidth) { dim = "width='" + img.ImageObject.width + "' height='" + img.ImageObject.height + "'"; } result = ""; } p.innerHTML = result; } }; Profile.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(); obj.Initialized = false; } }; function ImageLoaded(e) { e.Profile.PrintLoadedImage(e.Img); }; // Loading template Profile.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); /* Init images (photo & avatar) */ this.Tab.InitUploadFrame("AvatarUploadFrame"); /* Assign Tab to links */ this.Photo1 = new Img("PHOTO", "Photo", "uploadForm", this.Tab.UploadFrame, userPhotosPath, 300); this.Avatar1 = new Img("AVATAR", "Avatar", "avatarUploadForm", this.Tab.AvatarUploadFrame, avatarsPath, 120); this.GroupTabAssign(["linkDeletePhoto", "linkDeleteAvatar", "BANNED", "PASSWORD"]); this.GroupSelfAssign(["linkRefresh", "linkLockIP"]); /* Viewing my profile hide Status & Ban sections */ if (this.USER_ID == me.Id) { this.DisplayTabElement("NotForMe", false); } /* Date pickers */ new DatePicker(this.Inputs["BIRTHDAY"]); new DatePicker(this.Inputs["BANNED_TILL"], 1); /* Admin comments spoiler */ if (me.IsAdmin()) { var acs = new Spoiler(1, "Комментарии администраторов & логи", 0, 0, function(tab) {new AdminComments().LoadTemplate(tab, this.USER_ID)}); acs.USER_ID = this.USER_ID; acs.ToString(this.Inputs["AdminComments"]); } /* Submit button */ this.Tab.AddSubmitButton("SaveProfile(this)", "", this); }; /* Save profile */ function UploadImage(profile, img) { var form = profile.Inputs[img.UploadForm]; if (form) { var p = form["PHOTO1"]; if (p && p.value) { form["tab_id"].value = profile.Tab.Id; form["USER_ID"].value = profile.USER_ID; form.target = img.Frame.name; form.submit(); } } }; function SaveProfile(a) { if (a.obj) { a.obj.Tab.Alerts.Clear(); /* Saving Photo & Avatar */ UploadImage(a.obj, a.obj.Photo1); UploadImage(a.obj, a.obj.Avatar1); /* Saving profile */ a.obj.Save(ProfileSaved); } }; function ProfileSaved(req, obj) { if (obj && req.responseText) { var tabObject = obj.Tab; obj.RequestCallback(req, obj); // Refresh admin comments obj.FindRelatedControls(true); DoClick(obj.Inputs["RefreshAdminComments"]); } }; /* Links actions */ function DeletePhotoConfirmed(a, image) { if (a.Tab) { a.Tab.Alerts.Clear(); a.Tab.Profile.Request(MakeParametersPair("go", "delete_" + image)); } }; function ShowBanDetails(cb) { if (cb.Tab) { cb.Tab.Profile.DisplayTabElement("BanDetails", !cb.Tab.Profile.ADMIN && cb.checked); } }; function RestoreInput(el, relatedBlockId) { var tab = el.Tab; if (!tab) { return; } if (el.value != el.previousValue) { tab.Profile.DisplayTabElement(relatedBlockId, el.value); } if (!el.value) { el.value = empty_pass; } }; /* Profile Image helper class */ function Img(field, container, form, frame, path, max_width) { this.Field = field; this.Container = container; this.UploadForm = form; this.Frame = frame; this.Path = path; this.MaxWidth = max_width; }; Img.prototype.HasImage = function() { return this.ImageObject; }; /* Confirms */ function DeletePhoto(a) { co.Show(function() {DeletePhotoConfirmed(a,"photo")}, "Удалить фотографию?", "Фотография пользователя будет удалена из профиля.
    Вы уверены?"); }; function DeleteAvatar(a) { co.Show(function() {DeletePhotoConfirmed(a,"avatar")}, "Удалить аватар?", "Автар будет удален из профиля.
    Вы уверены?"); }; /* 23.settings.class.js */ //3.6 /* Represents settings entity on client-side. */ function Settings(status, ignore_colors, ignore_sizes, ignore_fonts, ignore_styles, receive_wakes, frameset, font) { // Properties this.Status = status; this.IgnoreColors = ignore_colors; this.IgnoreSizes = ignore_sizes; this.IgnoreFonts = ignore_fonts; this.IgnoreStyles = ignore_styles; this.ReceiveWakeups = receive_wakes; this.Frameset = frameset; this.Font = font; this.fields = new Array("LOGIN", "STATUS", "IGNORE_COLORS", "IGNORE_FONT_SIZE", "IGNORE_FONTS", "IGNORE_FONT_STYLE", "RECEIVE_WAKEUPS", "FRAMESET", "ENTER_MESSAGE", "QUIT_MESSAGE", "FONT_COLOR", "FONT_SIZE", "FONT_FACE", "FONT_BOLD", "FONT_ITALIC", "FONT_UNDERLINED"); this.ServicePath = servicesPath + "settings.service.php"; this.Template = "usersettings"; this.ClassName = "Settings"; }; Settings.prototype = new OptionsBase(); // Methods Settings.prototype.CheckSum = function() { var cs = CheckSum(this.Status); cs += CheckSum(this.IgnoreColors); cs += CheckSum(this.IgnoreSizes); cs += CheckSum(this.IgnoreFonts); cs += CheckSum(this.IgnoreStyles); cs += CheckSum(this.ReceiveWakeups); cs += CheckSum(this.Frameset); if (this.Font && this.Font.CheckSum) { cs += this.Font.CheckSum(); } return cs; }; Settings.prototype.Bind = function() { this.BaseBind(); UpdateFontView(); }; Settings.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(); } }; Settings.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.AssignSelfTo("linkRefresh"); // Create Font object font = new Font(); font.Inputs = this.Inputs; setTimeout("UpdateFontView()", 1000); // Set delay for IE // Init ColorPicker // var cp = new ColorPicker("FONT_COLOR"); new ColorPicker("FONT_COLOR"); /* Submit button */ this.Tab.AddSubmitButton("SaveObject(this)", "", this); }; /* Links actions */ function RefreshSettings(a) { if (a.Tab) { a.Tab.Alerts.Clear(); a.Tab.Settings.Request(); } }; var font; function UpdateFontView() { if (font && font.Inputs) { var el = font.Inputs["fontExample"]; if (el) { font.Gather(); font.ApplyTo(el); } } }; /* 24.rounded.corners.helper.js */ //2.2 /* Rounded div corners based on Alessandro Fulciniti's functionality */ function RoundCorners(el, bk, h){ if (!el.tagName) { el = $(id); } if (!el) { return; } // Create 3-cell table row var t = d.createElement("table"); var tr = d.createElement("tr"); var mainCell; for (var i = 0; i < 3; i++) { var td = d.createElement("td"); if (i == 1) { td.className = "AlertsContainer"; mainCell = td; } else { td.style.width = "50%"; } tr.appendChild(td); } var c = new Array(4); for (var i = 0; i < 4; i++) { c[i] = d.createElement("b"); c[i].style.display = "block"; c[i].style.height = h + "px"; c[i].style.fontSize = "1px"; c[i].style.background = "url(" + imagesPath + bk + ") no-repeat " + (i%2 ? "right" : "left") + " " + (-i * h) + "px"; } c[0].appendChild(c[1]); c[2].appendChild(c[3]); mainCell.style.padding = "0"; mainCell.insertBefore(c[0], mainCell.firstChild); var div = d.createElement("div"); mainCell.appendChild(div); mainCell.appendChild(c[2]); if (d.all) { // IE hack var tb = d.createElement("tbody"); tb.appendChild(tr); t.appendChild(tb); } else { t.appendChild(tr); } el.appendChild(t); return div; }; /* 25.colorpicker.class.js */ //2.3 /* Allows color selection with mouse click */ var bw = new Array("0","2","4","6","8","A","C","D","E","F"); var ones = new Array("19","33","4C","66","99", "99", "99","B2","CC","E5"); var twos = new Array("33","66","99","CC","E5", "FF", "33","66","99","CC"); var line = new Array("_002","_012","_022","_021","_020","_120","_220","_210","_200","_201","_202","_102"); function ColorPicker(input) { this.Visible = false; if (input.tagName) { this.Input = input; } else { this.Input = $(input); } if (this.Input) { this.Input.className = "Color"; this.Table = d.createElement("table"); DisplayElement(this.Table, false); var t = d.createElement("tbody"); this.Table.appendChild(t); this.Table.className = "ColorPicker"; this.Table.obj = this; this.Table.onclick = function() {this.obj.ColorSelected()}; //this.Table.onmouseout = function() {this.obj.SwitchVisibility()}; for (var i = 0, l = bw.length; i < l; i++) { this.MakeRow(i); } insertAfter(this.Table, this.Input); insertAfter(MakeButton("SwitchPicker(this)", "icons/palette.gif", this, "PickerButton", "Выбрать цвет"), this.Input); } }; ColorPicker.prototype.MakeCell = function(row, i, color) { var cell = row.insertCell(i); cell.style.backgroundColor = color; cell.Color = color; cell.onclick = function() {pc(this)}; }; ColorPicker.prototype.MakeRow = function(index) { var row = this.Table.insertRow(index); this.MakeCell(row, 0, "#" + bw[index] + bw[index] + bw[index] + bw[index] + bw[index] + bw[index]); var zero = "00"; if (index > 5) { zero = "FF"; } for (var i = 0, l = line.length; i < l; i++) { var color = "#"; var rgb = line[i]; for (var j = 1; j <=3; j++) { var comp = (zero == "FF" ? 2 - 1 * rgb.charAt(j) : 1 * rgb.charAt(j)); color += (comp ? (comp == 1 ? ones[index] : twos[index]) : zero); } this.MakeCell(row, i + 1, color); } }; ColorPicker.prototype.SwitchVisibility = function() { this.Visible = !this.Visible; DisplayElement(this.Table, this.Visible); }; ColorPicker.prototype.ColorSelected = function() { this.Input.value = this.Table.SelectedColor; this.SwitchVisibility(); if (top.UpdateFontView) { UpdateFontView(); } }; function SwitchPicker(a) { if (a && a.obj) { a.obj.SwitchVisibility(); } }; function pc(td) { var table = td.parentNode.parentNode.parentNode; table.SelectedColor = td.Color; }; /* 26.grid.class.js */ //6.3 /* Base class for grids with[out] pager. */ /* Grid class */ function Grid() { this.GridId = "Grid"; this.Columns = 3; this.CurrentContent = []; this.HasEmptyRow = false; }; Grid.prototype = new OptionsBase(); Grid.prototype.GatherDTO = function(dto) { var l = this.fields.length; if (dto.fields.length < l) { l = dto.fields.length; } for (var i = 0; i < l; i++) { this[this.fields[i]] = dto[dto.fields[i]]; } return true; }; Grid.prototype.FindTableBase = function() { if (this.Tbody) { return true; } this.FindRelatedControls(); if (!this.Inputs) { return false; } var el = this.Inputs[this.GridId]; if (el) { this.Tbody = el.firstChild; } return false; }; Grid.prototype.FindTable = function() { // Method to override return this.FindTableBase(); }; Grid.prototype.AddItem = function(dto) { this.CurrentContent[this.CurrentContent.length] = dto; }; Grid.prototype.ClearRecords = function(show_indicator) { this.FindTable(); if (!this.Tbody) { return false; } for (var i = 1, l = this.Tbody.childNodes.length; i < l; i++) { var e = this.Tbody.childNodes[l - i]; this.Tbody.removeChild(e); } if (show_indicator) { var tr = d.createElement("tr"); var td = d.createElement("td"); td.colSpan = this.Columns; td.innerHTML = LoadingIndicator; tr.appendChild(td); this.Tbody.appendChild(td); } this.CurrentContent = []; this.HasEmptyRow = false; }; Grid.prototype.Request = function(params, callback) { this.ClearRecords(true); this.BaseRequest(params, callback); this.HasEmptyRow = false; }; Grid.prototype.DoBind = function(content) { if (!this.Tbody) { return false; } this.BaseBind(); this.ClearRecords(); for (var i = 0, l = content.length; i < l; i++) { this.Tbody.appendChild(content[i].ToString(i, this, this.Tbody)); content[i].Grid = this; } this.CurrentContent = content; }; Grid.prototype.Bind = function(content) { return this.DoBind(content); }; Grid.prototype.Refresh = function() { var content = this.CurrentContent; return this.DoBind(content); }; /* --------------- Paged Grid class --------------- */ function PagedGrid() { this.PerPage = 10; this.PagerId = "Pager"; }; PagedGrid.prototype = new Grid(); PagedGrid.prototype.InitPager = function() { // Method to override this.Pager = new Pager(this.Inputs[this.PagerId], function(){}, this.PerPage); this.Tab.Pager = this.Pager; }; PagedGrid.prototype.FindTable = function() { if (!this.FindTableBase()) { this.InitPager(); this.Pager.Tab = this.Tab; } }; PagedGrid.prototype.Bind = function(content, total) { this.Pager.Total = total; this.DoBind(content); this.Pager.Print(); }; PagedGrid.prototype.Request = function(params, callback) { this.ClearRecords(true); if (!params) { params = ""; } params += this.Gather(); params += MakeParametersPair("from", this.Pager.Offset()); params += MakeParametersPair("amount", this.Pager.PerPage); this.BaseRequest(params, callback); }; PagedGrid.prototype.SwitchPage = function() { this.Request(); }; /* --------------- Editable Grid class --------------- */ function EditableGrid() { }; EditableGrid.prototype = new Grid(); EditableGrid.prototype.Edit = __edit; EditableGrid.prototype.CancelEditing = __cancelEditing; EditableGrid.prototype.AddRow = __addRow; /* --------------- Editable Paged Grid class --------------- */ function EditablePagedGrid() { }; EditablePagedGrid.prototype = new PagedGrid(); EditablePagedGrid.prototype.Edit = __edit; EditablePagedGrid.prototype.CancelEditing = __cancelEditing; EditablePagedGrid.prototype.AddRow = __addRow; /* Editable grid helper methods */ function __edit(id) { if (!this.CurrentContent) { return; } for (var i = 0,l = this.CurrentContent.length; i < l; i++) { this.CurrentContent[i].EditView = (this.CurrentContent[i].Id == id) ? 1 : 0; } this.Refresh(); }; function __cancelEditing() { if (this.CurrentContent && this.CurrentContent.length && this.CurrentContent[this.CurrentContent.length - 1].Id == 0) { this.CurrentContent.pop(); } this.Edit(""); }; function __addRow(dto) { if (!this.HasEmptyRow) { this.AddItem(dto); this.DoBind(this.CurrentContent); this.Edit(0); this.HasEmptyRow = true; } }; /* Helper methods */ function MakeGridRow(index) { var tr = d.createElement("tr"); if (index%2) { tr.className = " Dark"; } if (this.IsHidden) { tr.className += " Hidden"; } return tr; }; function MakeGridSubHeader(index, cols, text) { var trd = MakeGridRow(index); trd.className = "Sub"; var td0 = d.createElement("th"); td0.colSpan = cols; td0.innerHTML = text; trd.appendChild(td0); return trd; }; /* 27.userman.class.js */ //5.2 /* User Manager admin functionality */ function Userman() { this.fields = ["BY_NAME", "BY_ROOM", "FILTER_BANNED", "FILTER_EXPIRED", "FILTER_TODAY", "FILTER_YESTERDAY"]; this.ServicePath = servicesPath + "users.service.php"; this.Template = "userman"; this.ClassName = "Userman"; this.GridId = "UsersContainer"; this.Columns = 2; }; Userman.prototype = new Grid(); Userman.prototype.BaseBind = function() {}; Userman.prototype.RequestCallback = function(req, obj) { if (obj) { obj.more = 0; obj.RequestBaseCallback(req, obj); obj.Bind(obj.data); if (obj.more) { obj.Tab.Alerts.Add("Более 20 результатов - уточните критерий поиска.", 1); } else { if ((!obj.data || !obj.data.length) && userSearched) { obj.Tab.Alerts.Add("Пользователи не найдены."); } } } }; Userman.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); var assignee = ["BY_NAME", "BY_ROOM", "FILTER_BANNED", "FILTER_EXPIRED", "FILTER_TODAY", "FILTER_YESTERDAY"]; for (var i = 0, l = assignee.length; i Продолжить?"); }; /* 31.pager.class.js */ //1.6 /* Paged view of the long content. */ function Pager(holder, callback, per_page, total, current) { this.Holder = holder; this.Callback = callback; this.PerPage = per_page ? per_page : 20; this.Total = total; this.Current = current ? current : 0; this.VisiblePages = 10; this.Holder.className += " Pager"; }; Pager.prototype.AddLink = function(i, prefix, postfix) { if (prefix) { this.Holder.appendChild(d.createTextNode(prefix)); } var page; if (i == this.Current) { page = d.createElement("span"); } else { page = d.createElement("a"); page.href = voidLink; page.Pager = this; page.onclick = function(){this.Pager.SwitchTo(this)}; } page.innerHTML = i + 1; this.Holder.appendChild(page); if (postfix) { this.Holder.appendChild(d.createTextNode(postfix)); } }; Pager.prototype.Offset = function() { return this.Current * this.PerPage; }; Pager.prototype.Pages = function() { return Math.ceil(this.Total / this.PerPage); }; Pager.prototype.Print = function() { var pages = this.Pages(); this.Holder.innerHTML = ""; var from = this.Current - Math.floor(this.VisiblePages / 2); if (from < 0 ) { from = 0; } var till = from + this.VisiblePages; if (till > pages) { from = pages - this.VisiblePages; till = pages; if (from < 0 ) { from = 0; } } if (from > 0) { this.AddLink(0, "", ".."); } for (var i = from; i < till; i++) { this.AddLink(i); } if (till < pages) { this.AddLink(pages - 1, ".."); } }; Pager.prototype.SwitchToPage = function(num) { this.Current = num; this.Print(); if (this.Callback) { this.Callback(this.Current); } }; Pager.prototype.SwitchTo = function(a) { this.SwitchToPage((1 * a.innerHTML) - 1); }; function SwitchPage(el) { if (el && el.obj && el.obj.Pager) { el.obj.Pager.SwitchToPage(0); } }; /* 32.event.helper.js */ //2.5 /* Help with binding events to controls. */ function EnterHandler(e, el) { var keynum = 0; if(window.event) { // IE keynum = e.keyCode; } else if (e.which) { // Netscape/Firefox/Opera keynum = e.which; } if (keynum == 13 && el.Submitter) { DoClick(el.Submitter); return true; } return false; }; function BindEnterTo(el, click_to) { if (el) { el.Submitter = click_to; el.onkeypress = function(e) {EnterHandler(e,this)}; } }; function DoClick(el) { if (el) { if (el.click) { el.click(); } else if (el.onclick) { el.onclick(); } } }; /* 33.journal.templates.class.js */ //2.7 /* Journal templates: Global markup, single message & stylesheets. */ function JournalTemplates() { this.fields = new Array("BODY", "MESSAGE", "CSS"); this.ServicePath = servicesPath + "journal.templates.service.php"; this.Template = "journal_templates"; this.ClassName = "JournalTemplates"; this.Forum = new fldto(); }; JournalTemplates.prototype = new OptionsBase(); JournalTemplates.prototype.Bind = function() { if (this["SKIN_TEMPLATE_ID"]) { var select = this.Inputs["SKIN_TEMPLATE_ID"]; if (this["SKIN_TEMPLATE_ID"] > 0) { select.value = this["SKIN_TEMPLATE_ID"]; } PreviewSkin(select); } this.BaseBind(); }; JournalTemplates.prototype.Gather = function() { var params = this.BaseGather(); params += MakeParametersPair("SKIN_TEMPLATE_ID", this.Inputs["SKIN_TEMPLATE_ID"].value); return params; }; JournalTemplates.prototype.Request = function(params, callback) { if (!params) { params = ""; } params += MakeParametersPair("FORUM_ID", this.Forum.FORUM_ID); this.BaseRequest(params, callback); }; JournalTemplates.prototype.RequestCallback = function(req, obj) { if (obj) { obj.skinTemplateId = ""; obj.RequestBaseCallback(req, obj); obj["SKIN_TEMPLATE_ID"] = obj.skinTemplateId; if (obj.data) { obj.FillFrom(obj.data); obj.Bind(); } } if (obj.Forum) { obj.SetTabElementValue("TITLE", obj.Forum.MakeTitle()); } }; JournalTemplates.prototype.TemplateLoaded = function(req) { // Bind tab react this.Tab.Reactor = this; this.Forum = this.Tab.Forum; this.FORUM_ID = this.Tab.FORUM_ID; this.TemplateBaseLoaded(req); this.AssignTabTo("SKIN_TEMPLATE_ID"); this.Tab.AddSubmitButton("SaveObject(this)", "", this); }; JournalTemplates.prototype.React = function() { this.Forum = this.Tab.Forum; this.FORUM_ID = this.Forum.FORUM_ID; this.Request(); }; /* Actions */ function Maximize(el) { el.className = "Maximized"; }; function ShowSkinPreview(jt, background) { var url = "url(".length; var bg = background.substr(url, background.length - url -1); if (bg.indexOf("/") > 0) { bg = bg.substr(bg.lastIndexOf("/")); } jt.DisplayTabElement("previewCell", bg); if (bg) { jt.Inputs["skinPreview"].innerHTML = ""; } }; function PreviewSkin(select) { var jt = select.Tab.JournalTemplates; if (jt) { jt.FindRelatedControls(); if (jt.Inputs["templates"]) { jt.DisplayTabElement("templates", !select.value); ShowSkinPreview(jt, select.options[select.selectedIndex].style.backgroundImage); } } }; /* Confirms */ function DeleteRecord(a, id) { co.Show(function() {DeleteRecordConfirmed(a.obj, id)}, "Удалить запись?", "Запись в блоге и все комментарии к ней будут удалены.
    Продолжить?"); }; /* 34.calendar.class.js */ //3.7 /* Date picker fuctionality. */ function Calendar(holder, date, with_time) { this.Holder = holder; this.WithTime = with_time; this.Callback = ""; this.Date = date ? date : new Date(); this.SelectDate(); }; Calendar.prototype.SelectDate = function() { this.SelectedDate = new Date(this.Date.getFullYear(), this.Date.getMonth(), this.Date.getDate()); }; Calendar.prototype.MakeHeaderLink = function(is_selectable, holder) { if (holder.hasChildNodes()) { holder.removeChild(holder.firstChild); } var result; if (is_selectable) { var select = d.createElement("select"); select.Calendar = this; result = select; } else { var a = d.createElement("a"); a.href = voidLink; a.Calendar = this; result = a; } holder.appendChild(result); return result; }; Calendar.prototype.MakeMonth = function(is_selectable) { var el = this.MakeHeaderLink(is_selectable, this.MonthHolder); this.MonthSelect = is_selectable ? el : ""; if (is_selectable) { el.onchange = function(){this.Calendar.UpdateMonth()}; el.onblur = el.onchange; el.className = "Right"; var month = this.Date.getMonth(); for (var i = 0, l = months.length; i < l; i++) { var o = d.createElement("option"); o.text = months[i]; o.value = i; if (i == month) { o.selected = true; } el.options.add(o, i); } el.focus(); } else { el.innerHTML = months[this.Date.getMonth()]; el.onclick = function(){this.Calendar.MakeMonth(true)} } }; Calendar.prototype.MakeYear = function(is_selectable) { var el = this.MakeHeaderLink(is_selectable, this.YearHolder); this.YearSelect = is_selectable ? el : ""; var year = this.Date.getFullYear(); if (is_selectable) { el.onchange = function(){this.Calendar.UpdateYear()}; el.onblur = el.onchange; var k = 0; for (var i = year - 20; i < year + 20; i++) { var o = d.createElement("option"); o.text = i; o.value = i; if (i == year) { o.selected = true; } el.options.add(o, k++); } el.focus(); } else { el.innerHTML = year; el.onclick = function(){this.Calendar.MakeYear(true)} } }; Calendar.prototype.MakeHours = function(is_selectable) { var el = this.MakeHeaderLink(is_selectable, this.HoursHolder); this.HoursSelect = is_selectable ? el : ""; var hours = this.Date.getHours(); if (is_selectable) { el.onchange = function(){this.Calendar.UpdateTime()}; el.onblur = el.onchange; var k = 0; for (var i = 0; i < 24; i++) { var o = d.createElement("option"); o.text = TwoDigits(i); o.value = i; if (i == hours) { o.selected = true; } el.options.add(o, k++); } el.focus(); } else { el.innerHTML = TwoDigits(hours); el.onclick = function(){this.Calendar.MakeHours(true)} } }; Calendar.prototype.MakeMinutes = function(is_selectable) { var el = this.MakeHeaderLink(is_selectable, this.MinutesHolder); this.MinutesSelect = is_selectable ? el : ""; var minutes = this.Date.getMinutes(); if (is_selectable) { el.onchange = function(){this.Calendar.UpdateTime()}; el.onblur = el.onchange; var k = 0; for (var i = 0; i < 60; i++) { var o = d.createElement("option"); o.text = TwoDigits(i); o.value = i; if (i == minutes) { o.selected = true; } el.options.add(o, k++); } el.focus(); } else { el.innerHTML = TwoDigits(minutes); el.onclick = function(){this.Calendar.MakeMinutes(true)} } }; Calendar.prototype.UpdateMonth = function() { if (this.MonthSelect) { this.Date.setMonth(this.MonthSelect.value); this.Print(); } else { this.MakeMonth(false); } }; Calendar.prototype.UpdateYear = function() { if (this.YearSelect) { this.Date.setYear(this.YearSelect.value); this.Print(); } else { this.MakeYear(false); } }; Calendar.prototype.UpdateTime = function(flag) { if (this.HoursSelect) { this.Date.setHours(this.HoursSelect.value); this.Print(); } else if (this.MinutesSelect) { this.Date.setMinutes(this.MinutesSelect.value); this.Print(); } }; Calendar.prototype.MakeHeader = function() { var tr = d.createElement("tr"); var th = d.createElement("th"); th.colSpan = 7; this.MonthHolder = d.createElement("span"); this.MakeMonth(false); th.appendChild(this.MonthHolder); th.appendChild(d.createTextNode(" ")); this.YearHolder = d.createElement("span"); this.MakeYear(false); th.appendChild(this.YearHolder); tr.appendChild(th); return tr; }; Calendar.prototype.MakeTimePicker = function() { var tr = d.createElement("tr"); var th = d.createElement("th"); th.colSpan = 7; th.appendChild(d.createTextNode("Время: ")); this.HoursHolder = d.createElement("span"); this.MakeHours(false); th.appendChild(this.HoursHolder); th.appendChild(d.createTextNode(":")); this.MinutesHolder = d.createElement("span"); this.MakeMinutes(false); th.appendChild(this.MinutesHolder); tr.appendChild(th); return tr; }; Calendar.prototype.Clear = function() { this.Holder.innerHTML = ""; }; Calendar.prototype.MakeLink = function(day, check_day) { var a = d.createElement("a"); a.href = voidLink; a.innerHTML = day; a.Calendar = this; a.onclick = function(){this.Calendar.Select(this)}; if (day == check_day) { a.className = "Selected"; } return a; }; Calendar.prototype.Print = function() { /* Date calculations */ var a = new Date(this.Date.getFullYear(), this.Date.getMonth(), 1); var offset = a.getDay() - 1; if (offset < 0) { offset = 6; } var days = 31; if (this.Date.getMonth() != 11) { var b = new Date(this.Date.getFullYear(), this.Date.getMonth() + 1, 1); days = Math.round((b.getTime() - a.getTime()) / dayMsec); } var t = d.createElement("table"); var tb = d.createElement("tbody"); /* Header */ tb.appendChild(this.MakeHeader()); /* Body */ var i = 0; var day = 1; var check_day = 0; if (this.Date.getMonth() == this.SelectedDate.getMonth() && this.Date.getYear() == this.SelectedDate.getYear()) { check_day = this.SelectedDate.getDate(); } while (day <= days) { var tr = d.createElement("tr"); for (var k = 0; k < 7; k++) { var td = d.createElement("td"); if (i >= offset && day <= days) { td.appendChild(this.MakeLink(day, check_day)); day++; } else { td.innerHTML = " "; } i++; tr.appendChild(td); } tb.appendChild(tr); } /* Time */ if (this.WithTime) { tb.appendChild(this.MakeTimePicker()); } this.Holder.innerHTML = ""; t.appendChild(tb); t.className = "Calendar"; this.Holder.appendChild(t); }; Calendar.prototype.Select = function(a) { this.Date.setDate(a.innerHTML); this.SelectDate(); this.Print(); if (this.Callback) { this.Callback(); } }; /*-------------------------------------------------*/ function DatePicker(input, with_time) { if (!input) { return; } this.Visible = true; this.WithTime = with_time; this.Input = input; if (!input.type) { this.Input = $(input); } if (this.Input) { this.Input.className = (with_time ? "DateTime" : "Date"); this.Holder = d.createElement("div"); this.Holder.className = "DatePicker"; this.SwitchVisibility(false); this.Calendar = new Calendar(this.Holder, "", this.WithTime); this.Calendar.Picker = this; this.Calendar.Callback = function() {this.Picker.Selected()}; insertAfter(this.Holder, this.Input); insertAfter(MakeButton("SwitchDatePicker(this)", "icons/calendar.gif", this, "PickerButton", "Выбрать дату"), this.Input); } }; DatePicker.prototype.Init = function() { this.Calendar.Date = ParseDate(this.Input.value); this.Calendar.SelectDate(); this.Calendar.Print(); }; DatePicker.prototype.SwitchVisibility = function() { this.Visible = !this.Visible; DisplayElement(this.Holder, this.Visible); if (this.Visible) { this.Init(); } }; DatePicker.prototype.Selected = function() { this.Visible = true; this.SwitchVisibility(); var date = this.Calendar.Date; this.Input.value = date.ToString(this.WithTime); }; function SwitchDatePicker(a) { if (a && a.obj) { a.obj.SwitchVisibility(); } }; /* 35.date.helper.js */ //2.0 /* Helper methods to work with dates. */ var dayMsec = 1000 * 60 * 60 * 24; var months = new Array("Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"); var monthsNames = new Array("января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"); function ParseDate(str) { var datePat = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})(\s(\d{1,2}):(\d{1,2})){0,1}/; var matchArray = str.match(datePat); var date = new Date(); date.IsEmpty = false; if (matchArray == null) { date.IsEmpty = true; return date; } var year = matchArray[1]; var month = matchArray[3]; var day = matchArray[5]; var hours = date.getHours(); var minutes = date.getMinutes(); if (matchArray[6]) { hours = matchArray[7]; minutes = matchArray[8]; } return new Date(year, month - 1, day, hours, minutes, 0); }; Date.prototype.ToString = function(add_time) { var result = this.getFullYear() + "-" + TwoDigits(1 + this.getMonth()) + "-" + TwoDigits(this.getDate()); if (add_time) { result += " " + TwoDigits(this.getHours()) + ":" + TwoDigits(this.getMinutes()); } return result; }; Date.prototype.ToPrintableString = function(add_time) { var result = this.getDate() + " " + monthsNames[this.getMonth()] + " " + this.getFullYear(); if (add_time) { result += ", " + this.Time(); } return result; }; Date.prototype.Time = function() { return TwoDigits(this.getHours()) + ":" + TwoDigits(this.getMinutes()); }; /* 36.journal.post.class.js */ //3.3 /* Create/edit blog post in separate tab. */ var post_service = servicesPath + "journal.post.service.php"; function JournalPost(forum) { this.fields = new Array("RECORD_ID", "TITLE", "CONTENT", "DATE", "TYPE", "IS_COMMENTABLE", "FORUM_ID"); this.defaultValues = new Array("-1", "", "", new Date().ToString(true), "0", "1", ""); this.ServicePath = post_service; this.ClassName = "JournalPost"; this.Template = "journal_post"; this.Forum = forum; mceInitialized = 0; }; JournalPost.prototype = new OptionsBase(); JournalPost.prototype.EditorIsShown = function() { return (!this.Forum || this.Forum.TYPE == "j"); }; JournalPost.prototype.Gather = function() { var editor = tinyMCE.get(this.ContentField.id); if (editor) { this.CONTENT = editor.save(); } else { this.CONTENT = this.ContentField.value; } return this.BaseGather(); }; JournalPost.prototype.Bind = function() { this.BaseBind(); this.ContentField.value = this.CONTENT; /* Update tab title */ if (this.TITLE) { this.Tab.Title = "«" + this.TITLE.substr(0, 10) + "...»"; this.Tab.Alt = this.TITLE; tabs.Print(); } }; JournalPost.prototype.Request = function(params, callback) { if (!params) { params = ""; } params += MakeParametersPair("RECORD_ID", this.RECORD_ID); if (this.Forum) { params += MakeParametersPair("FORUM_ID", this.Forum.FORUM_ID); } if (this.TagsSpoiler && this.TagsSpoiler.AddedTags) { params += MakeParametersPair("TAGS", this.TagsSpoiler.AddedTags.Gather()); } this.BaseRequest(params, callback); }; JournalPost.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); if (obj.data && obj.data != "") { // "" comparison makes sense obj.FillFrom(obj.data); obj.Bind(); if (journalMessagesObj) { journalMessagesObj.Request(); } } if (!mceInitialized && obj.EditorIsShown && obj.EditorIsShown()) { InitMCE(); mceInitialized = 1; } } if (obj.Forum) { obj.SetTabElementValue("TITLE1", obj.Forum.MakeTitle()); obj.Tab.SetAdditionalClass(obj.Forum.TYPE); } }; JournalPost.prototype.TemplateLoaded = function(req) { this.RECORD_ID = 1 * this.Tab.PARAMETER; this.TemplateBaseLoaded(req); this.SetTabElementValue("LOGIN", this.LOGIN); // Create content field this.ContentField = CreateElement("textarea", "CONTENT" + Math.random(10000)); if (this.EditorIsShown()) { this.ContentField.className = "Editable"; } this.ContentField.rows = 30; if (this.Inputs["ContentHolder"]) { this.Inputs["ContentHolder"].appendChild(this.ContentField); } // Radios group rename RenameRadioGroup(this.Inputs["TYPE"]); // DatePicker this.Inputs["DATE"].value = new Date().ToString(1); var a = new DatePicker(this.Inputs["DATE"], 1); // Tags (labels) spoiler var tagsContainer = this.Inputs["TagsContainer"]; if (tagsContainer) { this.TagsSpoiler = new Spoiler(1, "Теги (метки)", 0, 0, function(tab) {new Tags().LoadTemplate(tab, me.Id, me.Login)}); this.TagsSpoiler.ToString(tagsContainer); this.TagsSpoiler.RECORD_ID = this.RECORD_ID; } // Submit button this.Tab.AddSubmitButton("SaveObject(this)", "", this); }; /* Helper methods */ function EditJournalPost(obj, post_id) { if (obj) { // var login = obj.LOGIN ? obj.LOGIN : ""; var login = ""; var tab_id = "post" + post_id; CreateUserTab(obj.USER_ID, login, new JournalPost(obj.Forum), "Пост в журнал", post_id, tab_id); } }; /* 37.journal.settings.class.js */ //2.2 /* Journal settings of user menu. */ function JournalSettings() { this.fields = ["ALIAS", "REQUESTED_ALIAS", "TITLE", "DESCRIPTION", "IS_PROTECTED"]; this.ServicePath = servicesPath + "journal.settings.service.php"; this.Template = "journal_settings"; this.ClassName = "JournalSettings"; this.Forum = new fldto(); }; JournalSettings.prototype = new OptionsBase(); JournalSettings.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.FillFrom(obj.data); obj.Bind(obj.data); } if (obj.Forum) { obj.SetTabElementValue("TITLE1", obj.Forum.MakeTitle()); } }; JournalSettings.prototype.TemplateLoaded = function(req) { // Bind tab react this.Tab.Reactor = this; this.Forum = this.Tab.Forum; if (this.Forum && this.Forum.FORUM_ID) { this.FORUM_ID = this.Forum.FORUM_ID; } this.TemplateBaseLoaded(req); this.AssignTabTo("linkRefresh"); this.FindRelatedControls(); this.Tab.AddSubmitButton("SaveObject(this)", "", this); }; JournalSettings.prototype.Request = function(params, callback) { if (!params) { params = ""; } params += MakeParametersPair("FORUM_ID", this.FORUM_ID); this.BaseRequest(params, callback); }; JournalSettings.prototype.React = function() { this.Forum = this.Tab.Forum; this.FORUM_ID = this.Forum.FORUM_ID; this.Request(); }; /* 38.comments.class.js */ //1.1 /* Comments base class */ function Comments() { this.fields = new Array("SEARCH", "LOGIN", "TITLE"); this.GridId = "CommentsGrid"; }; Comments.prototype = new PagedGrid(); /* 39.journal.comments.class.js */ //3.5 /* Journal comments grid. Edit & delete buttons. */ function JournalComments(forum) { this.ServicePath = servicesPath + "journal.comments.service.php"; this.Template = "journal_comments"; this.ClassName = "JournalComments"; this.Columns = 3; this.Forum = forum; }; JournalComments.prototype = new Comments(); JournalComments.prototype.Gather = function() { return MakeParametersPair("RECORD_ID", this.jrdto.Id) + this.BaseGather(); }; JournalComments.prototype.InitPager = function() { this.Pager = new Pager(this.Inputs[this.PagerId], function(){this.Tab.JournalComments.SwitchPage()}, this.PerPage); }; JournalComments.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(obj.data, obj.Total); } if (obj.Forum) { obj.SetTabElementValue("FORUM", obj.Forum.MakeTitle()); } }; JournalComments.prototype.LoadTemplate = function(tab, user_id, login) { // Important! this.jrdto = tab.PARAMETER; this.TITLE = this.jrdto.Title; /* Update tab title */ tab.Title = "Комментарии к «" + this.jrdto.Title.substr(0, 10) + "...»"; tab.Alt = this.jrdto.Title; tabs.Print(); this.LoadBaseTemplate(tab, user_id, login); }; JournalComments.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.AssignSelfTo("buttonSearch"); BindEnterTo(this.Inputs["SEARCH"], this.Inputs["buttonSearch"]); }; /* Journal Record Data Transfer Object */ function jcdto(id, user_id, name, title, content, date, is_hidden, is_deleted) { this.fields = ["Id", "UserId", "Name", "Title", "Content", "Date", "IsHidden", "IsDeleted"]; this.Init(arguments); }; jcdto.prototype = new DTO(); jcdto.prototype.ToString = function(index, obj) { var tr = MakeGridRow(index); if (this.IsHidden) { tr.className += " Hidden"; } if (this.IsDeleted) { tr.className += " Deleted"; } var td1 = d.createElement("td"); var h2 = d.createElement("h2"); h2.innerHTML = "«" + this.Title + "»"; td1.appendChild(h2); var span = d.createElement("span"); span.innerHTML = this.Content; td1.appendChild(span); var div = d.createElement("div"); div.innerHTML = (this.UserId ? "" : "") + this.Name + (this.UserId ? "" : "") + ", " + this.Date; td1.appendChild(div); tr.appendChild(td1); var td3 = d.createElement("td"); td3.className = "Centered"; td3.appendChild(MakeButton("EditRecord(this,"+this.Id+")", "icons/edit.gif", obj, "", "Править")); td3.appendChild(MakeButton("DeleteComment(this,"+this.Id+")", "delete_icon.gif", obj, "", "Удалить")); tr.appendChild(td3); return tr; }; /* Actions */ function DeleteCommentConfirmed(obj, id) { var params = MakeParametersPair("go", "delete"); params += MakeParametersPair("id", id); obj.Request(params); }; function ShowMessageComments(a) { var tab_id = "c" + a.jrdto.Id; CreateUserTab(a.obj.USER_ID, a.obj.LOGIN, new JournalComments(a.obj.Forum), "Комментарии в журнале", a.jrdto, tab_id); }; /* Confirms */ function DeleteComment(a, id) { co.Show(function() {DeleteCommentConfirmed(a.obj, id)}, "Удалить комментарий?", "Комментарий будет удалён.
    Продолжить?"); }; /* 40.requestor.class.js */ //4.0 /* Performs single async request with given set of parameters */ function Requestor(service, obj) { this.ServicePath = service; this.obj = obj; }; Requestor.prototype.Request = function(names, values) { var params = MakeParametersPair("no-cache", Math.random(1000)); for (var i = 0, l = names.length; i < l; i++) { params += MakeParametersPair(names[i], values[i]); } sendRequest(this.ServicePath, this.RequestCallback, params, this); }; Requestor.prototype.Callback = function() {}; Requestor.prototype.BaseCallback = function(req) { var obj = this.obj; var tabObject = this.obj.Tab; tabObject.Alerts.Clear(); eval(req.responseText); this.req = req; this.Callback(this); }; Requestor.prototype.RequestCallback = function(req, sender) { sender.BaseCallback(req); }; /* Delayed Requestor class. Performs delayed async request by reaction to user-entered "needle" */ function DelayedRequestor(obj, input, request_method) { this.Timer = ""; this.LastValue = ""; this.obj = obj; input.DelayedRequestor = this; this.Input = input; this.RequestMethod = request_method; this.Submitter = ""; // Treating enter button input.onkeypress = function(e){GetData(this,e)}; input.onchange = function(){GetData(this)}; }; DelayedRequestor.prototype.Request = function() { var obj = this.obj; if (obj) { params = this.GetParams(); if (params == this.LastValue) { return; } this.LastValue = params; if (this.RequestMethod) { this.RequestMethod(this.Input); } else { obj.Request(params); } } }; // To be overridden DelayedRequestor.prototype.GetParams = function() {return MakeParametersPair(this.Input.name, this.Input.value);}; function GetData(input, e) { if (!input || !input.DelayedRequestor) { return; } if (e && input.DelayedRequestor.Submitter && EnterHandler(e, input.DelayedRequestor)) { return; } if (input.DelayedRequestor.Timer) { clearTimeout(input.DelayedRequestor.Timer); } input.DelayedRequestor.Timer = setTimeout(function(){input.DelayedRequestor.Request()}, 500); }; /* 41.forum_access.class.js */ //6.7 /* Forum access functionality. Allows to manage users access to forums/journals/galleries. */ var NO_ACCESS = 0; var READ_ONLY_ACCESS = 1; var FRIENDLY_ACCESS = 1; var READ_ADD_ACCESS = 2; var FULL_ACCESS = 3; var accesses = ["доступ закрыт", "только чтение", "чтение/запись", "полный доступ"]; function ForumAccess(user_id, tab) { this.UserId = user_id; this.Tab = tab; this.fields = ["WHITE_LIST", "BLACK_LIST", "FRIENDS_LIST"]; this.Template = "forum_access"; this.ClassName = "ForumAccess"; this.ServicePath = servicesPath + "forum_access.service.php"; this.Forum = new fldto(); }; ForumAccess.prototype = new OptionsBase(); ForumAccess.prototype.TemplateLoaded = function(req) { // Bind tab react this.Tab.Reactor = this; this.Forum = this.Tab.Forum; this.FORUM_ID = this.Tab.FORUM_ID; this.TemplateBaseLoaded(req); this.FindRelatedControls(); this.BlackListGrid = new UserList("BLACK_LIST", this, new fadto()); this.WhiteListGrid = new UserList("WHITE_LIST", this, new fadto()); this.FriendsListGrid = new UserList("FRIENDS_LIST", this, new fjdto()); this.AssignSelfTo("RefreshForumAccess"); var a = new DelayedRequestor(this, this.Inputs["ADD_USER"], GetJournalUsers); // a.GetParams = function() {}; }; ForumAccess.prototype.BaseBind = function() { this.BlackListGrid.ClearRecords(); this.WhiteListGrid.ClearRecords(); this.FriendsListGrid.ClearRecords(); for (var i = 0, l = this.data.length; i < l; i++) { var dtoItem = this.data[i]; switch (dtoItem.ACCESS) { case FULL_ACCESS: case READ_ADD_ACCESS: case FRIENDLY_ACCESS: case READ_ONLY_ACCESS: this.WhiteListGrid.AddItem(dtoItem); break; case NO_ACCESS: this.BlackListGrid.AddItem(dtoItem); break; } } for (var i = 0, l = this.friends.length; i < l; i++) { var dtoItem = this.friends[i]; this.FriendsListGrid.AddItem(dtoItem); } this.BlackListGrid.Refresh(); this.WhiteListGrid.Refresh(); this.FriendsListGrid.Refresh(); }; ForumAccess.prototype.Request = function(params, callback) { if (!params) { params = ""; } params += MakeParametersPair("FORUM_ID", this.Forum.FORUM_ID); this.BaseRequest(params, callback); }; ForumAccess.prototype.RequestCallback = function(req, obj) { if (obj) { obj.friends = []; obj.RequestBaseCallback(req, obj); obj.Bind(obj.data); } if (obj.Forum) { obj.SetTabElementValue("TITLE", obj.Forum.MakeTitle()); } }; ForumAccess.prototype.React = function() { this.Forum = this.Tab.Forum; this.FORUM_ID = this.Tab.FORUM_ID; this.Request(); }; /* Data Transfer Object */ function fadto(forum_id, target_user_id, login, access) { this.fields = ["FORUM_ID", "TARGET_USER_ID", "LOGIN", "ACCESS"]; this.Init(arguments); this.Id = this.FORUM_ID + "_" + this.TARGET_USER_ID; }; fadto.prototype = new EditableDTO(); fadto.prototype.ToShowView = function(index, obj) { var tr = MakeGridRow(index); tr.className = (index % 2 ? "Dark" : ""); var a = accesses[this.ACCESS]; var td1 = d.createElement("td"); td1.innerHTML = this.LOGIN + (a ? " (" + a + ")" : ""); if (this.ACCESS == FULL_ACCESS) { td1.className = "Bold"; } tr.appendChild(td1); tr.appendChild(this.MakeButtonsCell(1)); return tr; }; fadto.prototype.ToEditView = function() {}; /* Journal user DTO */ function judto($id, $login, $nick, $journal_id, $title) { this.fields = ["USER_ID", "LOGIN", "NICKNAME", "JOURNAL_ID", "TITLE"]; this.Init(arguments); }; judto.prototype = new DTO(); judto.prototype.ToString = function(index, obj, prev_id, holder, className) { if (prev_id != this.USER_ID) { var li = d.createElement("li"); li.className = className; li.appendChild(MakeButton("AddForumAccess('" + this.USER_ID + "',''," + FULL_ACCESS + ", this.obj)", "icons/add_gold.gif", obj, "", "Добавить как администратора")); li.appendChild(MakeButton("AddForumAccess('" + this.USER_ID + "',''," + READ_ADD_ACCESS + ", this.obj)", "icons/add_white.gif", obj, "", "Добавить в белый список")); li.appendChild(MakeButton("AddForumAccess('" + this.USER_ID + "',''," + NO_ACCESS + ", this.obj)", "icons/add_black.gif", obj, "", "Добавить в чёрный список")); li.appendChild(MakeDiv(this.LOGIN + (this.NICKNAME ? " (" + this.NICKNAME + ")" : ""), "span")); holder.appendChild(li); } if (this.JOURNAL_ID) { li = d.createElement("li"); li.className = className + " Journal"; li.appendChild(MakeButton("AddForumAccess('','" + this.JOURNAL_ID + "', " + FRIENDLY_ACCESS + ", this.obj)", "icons/add_green.gif", obj, "", "Добавить дружественный журнал")); li.appendChild(MakeDiv("Журнал «" + this.TITLE + "» (" + this.LOGIN + ")", "span")); holder.appendChild(li); } }; /* Friendly Journal DTO */ function fjdto(forum_id, title, login, target_forum_id) { this.fields = ["FORUM_ID", "TITLE", "LOGIN", "TARGET_FORUM_ID"]; this.Init(arguments); this.Id = this.TARGET_FORUM_ID; }; fjdto.prototype = new EditableDTO(); fjdto.prototype.ToShowView = function(index, obj) { var tr = MakeGridRow(index); tr.className = (index % 2 ? "Dark" : ""); var td1 = d.createElement("td"); td1.innerHTML = "«" + this.TITLE + "» (" + this.LOGIN + ")"; tr.appendChild(td1); tr.appendChild(this.MakeButtonsCell(1)); return tr; }; fjdto.prototype.ToEditView = function() {}; /* Userlist Grid */ function UserList(id, relatedObject, dtObject) { var dt = dtObject; this.fields = dt.fields; this.ServicePath = servicesPath + "forum_access.service.php"; this.GridId = id; this.Columns = 2; this.USER_ID = relatedObject.USER_ID; this.Tab = relatedObject.Tab; this.FindTable(); this.ClearRecords(); this.obj = relatedObject; }; UserList.prototype = new EditableGrid(); UserList.prototype.BaseBind = function(){}; UserList.prototype.RequestCallback = function(req, obj) { if (obj.obj) { obj.obj.RequestBaseCallback(req, obj); obj.obj.Bind(obj.data); } }; /* Helper methods */ function AddForumAccess(user_id, target_forum_id, access, obj) { var req = new Requestor(servicesPath + "forum_access.service.php", obj); req.Callback = RefreshList; req.Request(["go", "FORUM_ID", "TARGET_USER_ID", "TARGET_FORUM_ID", "ACCESS"], ["add", obj.Forum.FORUM_ID, user_id, target_forum_id, access]); }; function RefreshList(sender) { sender.obj.RequestCallback(sender.req, sender.obj); }; function GetJournalUsers(input) { input.DelayedRequestor.obj.SetTabElementValue("FOUND_USERS", LoadingIndicator); var juRequest = new Requestor(servicesPath + "journal_users.service.php", input.DelayedRequestor.obj); juRequest.Callback = DrawUsers; juRequest.Request(["value"], [input.value]); }; function DrawUsers(sender) { var el = sender.obj.Inputs["FOUND_USERS"]; if (el) { el.innerHTML = ""; var ul = d.createElement("ul"); var prev_id = 0; var className = ""; for (var i = 0, l = sender.data.length; i < l; i++) { var item = sender.data[i]; className = ((prev_id == item.USER_ID) ? className : (className ? "" : "Dark")); item.ToString(i, sender.obj, prev_id, ul, className); prev_id = item.USER_ID; } el.appendChild(ul); sender.obj.Tab.Alerts.Clear(); if (sender.more) { sender.obj.Tab.Alerts.Add("Более 20 результатов - уточните критерий поиска.", 1); } } }; /* 42.admin.options.class.js */ //1.7 /* Admin options */ var MessagesSpoiler, TemplatesSpoiler, SettingsSpoiler; function AdminOptions() { this.Template = "admin_options"; this.ClassName = "AdminOptions"; }; AdminOptions.prototype = new OptionsBase(); AdminOptions.prototype.Request = function() { }; AdminOptions.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.FindRelatedControls(); var spoilers = this.Inputs["Spoilers"]; if (spoilers) { for (var i = 0, l = spoilerInits.length; i < l; i++) { var s = new Spoiler(i + 1, spoilerNames[i], 0, 0, spoilerInits[i]); s.ToString(spoilers); } } }; /* 43.admin.comments.class.js */ //5.2 /* List of admin comments to user (ban, rights changes etc.) */ function AdminComments() { this.fields = ["ADMIN_COMMENT", "DATE", "SEARCH", "SEVERITY_NORMAL", "SEVERITY_WARNING", "SEVERITY_ERROR"]; this.ServicePath = servicesPath + "admin.comments.service.php"; this.ClassName = "AdminComments"; this.Template = "admin_comments"; this.GridId = "AdminCommentsGrid"; this.Columns = 2; }; AdminComments.prototype = new PagedGrid(); AdminComments.prototype.BaseBind = function() {}; AdminComments.prototype.InitPager = function() { this.Pager = new Pager(this.Inputs[this.PagerId], function(){this.Tab.AdminComments.SwitchPage()}, this.PerPage); }; AdminComments.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(obj.data, obj.Total); } }; // Template loading AdminComments.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.AssignTabTo("AddComment"); this.GroupSelfAssign(["RefreshAdminComments", "ResetFilter"]); new DatePicker(this.Inputs["DATE"]); BindEnterTo(this.Inputs["ADMIN_COMMENT"], this.Inputs["AddComment"]); BindEnterTo(this.Inputs["DATE"], this.Inputs["RefreshAdminComments"]); BindEnterTo(this.Inputs["SEARCH"], this.Inputs["RefreshAdminComments"]); // System log checkboxes BindEnterTo(this.Inputs["SEVERITY_NORMAL"], this.Inputs["RefreshAdminComments"]); BindEnterTo(this.Inputs["SEVERITY_WARNING"], this.Inputs["RefreshAdminComments"]); BindEnterTo(this.Inputs["SEVERITY_ERROR"], this.Inputs["RefreshAdminComments"]); if (this.Init) { this.Init(); } }; AdminComments.prototype.CustomReset = function() { this.SetTabElementValue("SEVERITY_NORMAL", 1); this.SetTabElementValue("SEVERITY_WARNING", 1); this.SetTabElementValue("SEVERITY_ERROR", 1); }; /* Admin comment Data Transfer Object */ var lastCommentDate; function acdto(date, content, login, severity, user) { this.fields = ["Date", "Content", "Login", "Severity", "User"]; this.Init(arguments); }; acdto.prototype = new DTO(); acdto.prototype.ToString = function(index, obj, holder) { if (!index) { lastCommentDate = ""; } var date = ParseDate(this.Date); var dateString = date.ToPrintableString(); if (date && dateString && dateString != lastCommentDate && holder) { lastCommentDate = dateString; holder.appendChild(MakeGridSubHeader(index, obj.Columns, dateString)); } var tr = MakeGridRow(index); if (this.Severity) { tr.className += " " + SeverityCss[this.Severity - 1]; } var td1 = d.createElement("td"); td1.className = "Centered"; td1.innerHTML = date.Time() + "
    " + this.Login + ""; tr.appendChild(td1); var td2 = d.createElement("td"); td2.innerHTML = (this.User ? "Пользователь " + this.User + ":
    " : "") + this.Content; tr.appendChild(td2); return tr; }; /* Helper methods */ function AddComment(img) { if (img && img.Tab && img.Tab.AdminComments) { img.Tab.AdminComments.Save(AdminCommentSaved); } }; function AdminCommentSaved(req, obj) { if (obj) { obj.SetTabElementValue("ADMIN_COMMENT", ""); obj.RequestCallback(req, obj); } }; /* 44.system.log.class.js */ //2.4 /* System log */ function SystemLog() { this.fields = ["DATE", "SEARCH", "SEVERITY_NORMAL", "SEVERITY_WARNING", "SEVERITY_ERROR"]; this.Template = "system_log"; this.ClassName = "SystemLog"; this.GridId = "AdminCommentsGrid"; this.Columns = 2; this.PerPage = 50; }; SystemLog.prototype = new AdminComments(); SystemLog.prototype.Init = function() { this.FindRelatedControls(); }; SystemLog.prototype.InitPager = function() { this.Pager = new Pager(this.Inputs[this.PagerId], function(){this.Tab.SystemLog.SwitchPage()}, this.PerPage); }; /* 45.banned.addresses.class.js */ //6.5 /* List of forbidden addresses */ var BannedAddrsList; function BannedAddresses() { this.fields = ["BAN_ID", "BAN_CHAT", "BAN_FORUM", "BAN_JOURNAL", "TYPE", "CONTENT", "COMMENT", "TILL"]; this.defaultValues = ["", "1", "1", "1", "ip", "", "", ""]; this.ServicePath = servicesPath + "banned.addresses.service.php"; this.Template = "banned_addresses"; this.GridId = "BannedAddresses"; this.ClassName = this.GridId; this.Columns = 3; }; BannedAddresses.prototype = new Grid(); BannedAddresses.prototype.BaseBind = function() {}; BannedAddresses.prototype.RequestCallback = function(req, obj) { if (obj) { if (BannedAddrsList) { BannedAddrsList.Tab.Alerts.Clear(); } obj.banData = []; obj.RequestBaseCallback(req, obj); if (BannedAddrsList) { // Adding entry from bans tab BannedAddrsList.Bind(obj.data); if (obj.banData.length) { BannedAddrsList.FillFrom(obj.banData); BannedAddrsList.BindFields(BannedAddrsList.fields); BannedAddrsList.SetFormName("Редактировать запрет " + BannedAddrsList["CONTENT"] + ":"); } } else { // Adding entry from user profile obj.Bind(obj.data); } if (BannedAddrsList && !BannedAddrsList.Tab.Alerts.HasErrors && !BannedAddrsList.Tab.Alerts.IsEmpty) { BannedAddrsList.Reset(); BannedAddrsList.SetFormName(""); } } }; BannedAddresses.prototype.SetFormName = function(name) { if (!name) { name = "Добавить запрет:"; } this.SetTabElementValue("FORM_TITLE", name); }; BannedAddresses.prototype.TemplateLoaded = function(req) { BannedAddrsList = this; this.TemplateBaseLoaded(req); this.GroupSelfAssign(["RefreshBannedAddresses", "ResetBannedAddresses"]); new DatePicker(this.Inputs["TILL"]); /* Submit button */ this.Tab.AddSubmitButton("SaveObject(this)", "", this); BindEnterTo(this.Inputs["CONTENT"], this.Tab.SubmitButton); BindEnterTo(this.Inputs["TILL"], this.Tab.SubmitButton); }; /* Banned Address Data Transfer Object */ function badto(id, content, type, comment, admin, date, till, chat, forum, journal) { this.fields = ["Id", "Content", "Type", "Comment", "Admin", "Date", "Till", "Chat", "Forum", "Journal"]; this.Init(arguments); this.Date = ParseDate(this.Date); this.Till = ParseDate(this.Till); this.BanNames = ["чат", "форум", "журналы"]; this.Bans = [this.Chat, this.Forum, this.Journal]; }; badto.prototype = new DTO(); badto.prototype.ToString = function(index, obj) { var tr = MakeGridRow(index); var td1 = d.createElement("td"); var h2 = d.createElement("h2"); h2.innerHTML = this.Content; td1.appendChild(h2); td1.appendChild(d.createTextNode("(" + this.Type + ")")); tr.appendChild(td1); var td2 = d.createElement("td"); td2.appendChild(MakeDiv((this.Comment ? "«" + this.Comment + "»" + (this.Admin ? ", " : "") : "") + (this.Admin ? this.Admin : ""), "h2")); td2.appendChild(MakeDiv("c " + this.Date.ToPrintableString() + (!this.Till.IsEmpty ? " по " + this.Till.ToPrintableString() : ""))); result = ""; var comma = false; for (var i = 0; i < 3; i++) { if (this.Bans[i]) { result += (comma ? ", " : "") + this.BanNames[i]; comma = true; } } td2.appendChild(MakeDiv("Запрет: " + result + "")); tr.appendChild(td2); var td3 = d.createElement("td"); td3.className = "Centered"; td3.appendChild(MakeButton("EditBan(this," + this.Id + ")", "icons/edit.gif", obj)); td3.appendChild(MakeButton("DeleteBan(this," + this.Id + ")", "delete_icon.gif", obj)); tr.appendChild(td3); return tr; }; /* Client events methods */ function SendItemRequest(a, id, go) { var params = MakeParametersPair("go", go); params += MakeParametersPair("id", id); a.obj.Request(params); }; function DeleteBan(a, id) { SendItemRequest(a, id, "delete"); }; function EditBan(a, id) { SendItemRequest(a, id, "edit"); }; function ResetBanForm(a) { var jc = a.obj; if (jc) { jc.Reset(); jc.SetFormName(""); } }; /* Helper method */ var ipPattern = new RegExp("^([0-9]{1,3}\.){3}[0-9]{1,3}$"); function LockIP(a) { if (a.obj) { var profile = a.obj; var addr = profile["SESSION_ADDRESS"]; if (addr) { var pos = addr.indexOf("["); if (pos > 0) { addr = addr.substr(0, pos - 1); } var obj = new BannedAddresses(); obj.Tab = profile.Tab; profile.Tab.BannedAddresses = obj; var comment = "Доступ к чату для пользователя " + profile["LOGIN"]; obj.FillFrom([-1, 1, 0, 0, (addr.match(ipPattern) ? "ip" : "host"), addr, comment, ""]); obj.USER_ID = profile["USER_ID"]; obj.Save(); } } }; /* 47.cookie.helper.js */ //1.0 /* Cookie helper hethods */ /* setCookie("foo", "bar", "Mon, 01-Jan-2001 00:00:00 GMT", "/"); */ function setCookie (name, value, expires, path, domain, secure) { document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); }; function getCookie(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = null; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset); if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return(setStr); }; /* 48.statuses.class.js */ //3.9 /* Special statuses management */ function Statuses() { this.fields = ["STATUS_ID", "RIGHTS", "COLOR", "TITLE"]; this.ServicePath = servicesPath + "statuses.service.php"; this.Template = "statuses"; this.ClassName = "Statuses"; this.GridId = "StatusesGrid"; this.Columns = 4; }; Statuses.prototype = new EditableGrid(); Statuses.prototype.BaseBind = function() {}; Statuses.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(obj.data); } }; Statuses.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.GroupSelfAssign(["AddStatus", "RefreshStatuses"]); }; /* Status Data Transfer Object */ function sdto(id, rights, color, title) { this.fields = ["Id", "Rights", "Color", "Title"]; this.Init(arguments); }; sdto.prototype = new EditableDTO(); sdto.prototype.ToShowView = function(index, obj) { var tr = MakeGridRow(index); // Rights var td1 = d.createElement("td"); td1.className = "Centered"; td1.innerHTML = this.Rights; tr.appendChild(td1); var td2 = d.createElement("td"); td2.colSpan = 2; var div = MakeDiv(" "); div.className = "StatusColor"; div.style.backgroundColor = this.Color; td2.appendChild(div); td2.appendChild(MakeDiv(this.Title)); tr.appendChild(td2); tr.appendChild(this.MakeButtonsCell()); return tr; }; sdto.prototype.ToEditView = function(index, obj) { var tr = MakeGridRow(index); // Rights var td1 = d.createElement("td"); this.RightsInput = d.createElement("input"); this.RightsInput.value = this.Rights; this.RightsInput.style.width = "30px"; td1.appendChild(this.RightsInput); tr.appendChild(td1); var td2 = d.createElement("td"); td2.style.width = "50px"; td2.className = "Nowrap"; this.ColorInput = d.createElement("input"); this.ColorInput.value = this.Color; td2.appendChild(this.ColorInput); new ColorPicker(this.ColorInput); tr.appendChild(td2); var td22 = d.createElement("td"); td22.style.width = "100%"; this.TitleInput = d.createElement("input"); this.TitleInput.value = this.Title; this.TitleInput.className = "Wide"; td22.appendChild(this.TitleInput); tr.appendChild(td22); tr.appendChild(this.MakeButtonsCell()); return tr; }; /* Helper methods */ function AddStatus(a) { if (a.obj) { a.obj.AddRow(new sdto(0, 1, "White", "Новый статус")); } }; /* 49.news.class.js */ //2.3 /* Displaying/managing news sections */ function News() { this.fields = ["OWNER_ID", "TITLE", "DESCRIPTION"]; this.ServicePath = servicesPath + "news.service.php"; this.ClassName = "News"; this.Template = "news"; this.GridId = "NewsGrid"; this.Columns = 2; }; News.prototype = new EditableGrid(); News.prototype.BaseBind = function() {}; News.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(obj.data); } }; News.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.GroupSelfAssign(["AddNews", "RefreshNews"]); this.Tab.NewsItems = this.Inputs["NewsItems"]; }; /* News Data Transfer Object */ function ndto(id, title, description) { this.fields = ["Id", "Title", "Description"]; this.Init(arguments); }; ndto.prototype = new EditableDTO(); ndto.prototype.ToShowView = function(index, obj) { var tr = MakeGridRow(index); var td1 = d.createElement("td"); var h2 = d.createElement("h2"); var a = MakeDiv(this.Title, "a"); a.href = voidLink; a.onclick = function() {ShowNewsRecords(this)}; a.obj = this; h2.appendChild(a); td1.appendChild(h2); td1.appendChild(MakeDiv(this.Description)); tr.appendChild(td1); tr.appendChild(this.MakeButtonsCell()); return tr; }; ndto.prototype.ToEditView = function(index, obj) { var tr = MakeGridRow(index); var td1 = d.createElement("td"); td1.appendChild(MakeDiv("Название:")); this.TitleInput = d.createElement("input"); this.TitleInput.value = this.Title; this.TitleInput.className = "Wide"; td1.appendChild(this.TitleInput); td1.appendChild(MakeDiv("Описание:")); this.DescriptionInput = d.createElement("textarea"); this.DescriptionInput.innerHTML = this.Description; this.DescriptionInput.className = "Wide NewsDecription"; td1.appendChild(this.DescriptionInput); tr.appendChild(td1); tr.appendChild(this.MakeButtonsCell()); return tr; }; /* Helper methods */ function AddNews(a) { if (a.obj) { a.obj.AddRow(new ndto(0, "Новый раздел", "")); } }; function ShowNewsRecords(a) { var tab = a.obj.Grid.Tab; if (tab.NewsItems) { tab.NewsItems.innerHTML = ""; var s = new Spoiler(0, a.obj.Title, 0, 1); s.ToString(tab.NewsItems); new NewsRecords().LoadTemplate(s, a.obj.Id); } }; /* 50.news_records.class.js */ //3.7 /* Displaying news/guestbook messages grid */ function NewsRecords() { this.fields = ["NEWS_RECORD_ID", "OWNER_ID", "TITLE", "CONTENT", "IS_HIDDEN", "SEARCH_DATE", "SEARCH"]; this.ServicePath = servicesPath + "news_records.service.php"; this.Template = "news_records"; this.ClassName = "NewsRecords"; this.GridId = "NewsRecordsGrid"; this.Columns = 2; }; NewsRecords.prototype = new EditablePagedGrid(); NewsRecords.prototype.BaseBind = function() {}; NewsRecords.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(obj.data, obj.Total); } }; // Template loaded NewsRecords.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.GroupSelfAssign(["buttonSearch", "ResetFilter", "linkRefresh", "AddNewsRecord", "RefreshNewsRecords"]); BindEnterTo(this.Inputs["SEARCH"], this.Inputs["buttonSearch"]); new DatePicker(this.Inputs["SEARCH_DATE"]); }; NewsRecords.prototype.CustomReset = function() { this.SetTabElementValue("SEARCH_DATE", ""); }; /* News Record Data Transfer Object */ function nrdto(id, owner_id, title, content, is_hidden) { this.fields = ["Id", "OwnerId", "Title", "Content", "IsHidden", "Date"]; this.Init(arguments); }; nrdto.prototype = new EditableDTO(); nrdto.prototype.ToShowView = function(index, obj) { var tr = MakeGridRow(index); var td1 = d.createElement("td"); var date = ParseDate(this.Date).ToPrintableString(); td1.appendChild(MakeDiv(date + ": " + this.Title, "h2")); td1.appendChild(MakeDiv(this.Content)); tr.appendChild(td1); tr.appendChild(this.MakeButtonsCell()); return tr; }; nrdto.prototype.ToEditView = function(index, obj) { var tr = MakeGridRow(index); var td1 = d.createElement("td"); td1.appendChild(MakeDiv("Дата:", "h4")); this.DateInput = d.createElement("input"); this.DateInput.value = this.Date; td1.appendChild(this.DateInput); new DatePicker(this.DateInput); td1.appendChild(MakeDiv("Заголовок:", "h4")); this.TitleInput = d.createElement("input"); this.TitleInput.value = this.Title; this.TitleInput.className = "Wide"; td1.appendChild(this.TitleInput); td1.appendChild(MakeDiv("Содержание:", "h4")); this.ContentInput = d.createElement("textarea"); this.ContentInput.value = this.Content; this.ContentInput.className = "Wide NewsDescription"; td1.appendChild(this.ContentInput); tr.appendChild(td1); tr.appendChild(this.MakeButtonsCell()); return tr; }; /* Helper methods */ function AddNewsRecord(a) { if (a.obj) { a.obj.AddRow(new nrdto(0, a.obj["USER_ID"], "Новое сообщение", "", 0, "")); } }; /* 51.gallery.class.js */ //1.0 /* Manage galleries and their contents */ function Galleries() { this.fields = ["OWNER_ID", "TITLE", "DESCRIPTION"]; this.ServicePath = servicesPath + "gallery.service.php"; this.Template = "gallery"; this.GridId = "GalleriesGrid"; this.Columns = 2; }; Galleries.prototype = new EditableGrid(); /* 52.wakeups.class.js */ //2.7 /* Wakeup messages grid. Edit & delete buttons. */ function Wakeups() { this.fields = new Array("SEARCH", "DATE", "IS_INCOMING", "IS_OUTGOING"); this.ServicePath = servicesPath + "wakeups.service.php"; this.Template = "wakeups"; this.ClassName = "Wakeups"; this.Columns = 3; this.GridId = "WakeupsGrid"; }; Wakeups.prototype = new PagedGrid(); Wakeups.prototype.InitPager = function() { this.Pager = new Pager(this.Inputs[this.PagerId], function(){this.Tab.Wakeups.SwitchPage()}, this.PerPage); }; Wakeups.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(obj.data, obj.Total); } }; Wakeups.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.GroupSelfAssign(["buttonSearch", "ResetFilter", "linkRefresh"]); BindEnterTo(this.Inputs["SEARCH"], this.Inputs["buttonSearch"]); BindEnterTo(this.Inputs["IS_INCOMING"], this.Inputs["buttonSearch"]); BindEnterTo(this.Inputs["IS_OUTGOING"], this.Inputs["buttonSearch"]); new DatePicker(this.Inputs["DATE"]); }; Wakeups.prototype.CustomReset = function() { this.SetTabElementValue("IS_INCOMING", 1); this.SetTabElementValue("IS_OUTGOING", 1); }; /* Wakeup Record Data Transfer Object */ var lastWakeDate; function wdto(id, user_id, user_name, is_incoming, date, content, is_read) { this.fields = ["Id", "UserId", "UserName", "IsIncoming", "Date", "Content", "IsRead"]; this.Init(arguments); }; wdto.prototype = new DTO(); wdto.prototype.ToString = function(index, obj, holder) { if (!index) { lastWakeDate = ""; } var date = ParseDate(this.Date); var dateString = date.ToPrintableString(); if (date && dateString && dateString != lastWakeDate && holder) { lastWakeDate = dateString; holder.appendChild(MakeGridSubHeader(index, obj.Columns, dateString)); } var tr = MakeGridRow(index); tr.className += this.IsRead ? "" : " Unread"; tr.className += (this.IsIncoming == "1" ? " Incoming" : " Outgoing"); var td0 = d.createElement("td"); td0.className = "Centered"; td0.innerHTML = date.Time(); tr.appendChild(td0); var td1 = d.createElement("td"); td1.className = "Centered"; var sender = "вы сами (" + this.UserName + ")"; if (!me || this.UserId != me.Id) { sender = (this.IsIncoming == "1" ? "от " : "для ") + this.UserName; } td1.innerHTML = sender; tr.appendChild(td1); var td2 = d.createElement("td"); td2.innerHTML = this.Content; tr.appendChild(td2); return tr; }; /* 53.messages.log.class.js */ //3.2 /* Display messages log with filter by date, room & keywords */ function MessagesLog() { this.fields = ["DATE", "SEARCH", "ROOM_ID"]; this.ServicePath = servicesPath + "messages.log.service.php"; this.ClassName = "MessagesLog"; this.Template = "messages_log"; this.GridId = "MessagesLogGrid"; this.Columns = 3; this.PerPage = 50; }; MessagesLog.prototype = new PagedGrid(); MessagesLog.prototype.BaseBind = function() {}; MessagesLog.prototype.InitPager = function() { this.Pager = new Pager(this.Inputs[this.PagerId], function(){this.Tab.MessagesLog.SwitchPage()}, this.PerPage); }; MessagesLog.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(obj.data, obj.Total); obj.BindRooms(obj.Rooms); } }; MessagesLog.prototype.BindRooms = function(rooms) { var select = this.Inputs["ROOM_ID"]; if (select) { select.innerHTML = ""; for (var i = 0, l = rooms.length; i < l; i++) { if (!this.ROOM_ID) { this.ROOM_ID = rooms[i].Id; } AddSelectOption(select, rooms[i].Title, rooms[i].Id, this.ROOM_ID == rooms[i].Id); } } }; // Template loading MessagesLog.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.GroupSelfAssign(["RefreshMessagesLog", "ResetFilter", "ROOM_ID"]); new DatePicker(this.Inputs["DATE"]); BindEnterTo(this.Inputs["DATE"], this.Inputs["RefreshMessagesLog"]); BindEnterTo(this.Inputs["ROOM_ID"], this.Inputs["RefreshMessagesLog"]); BindEnterTo(this.Inputs["SEARCH"], this.Inputs["RefreshMessagesLog"]); if (this.Init) { this.Init(); } }; /* Message Data Transfer Object */ var lastMessageDate; function mdto(date, name, name_to, text, color) { this.fields = ["Date", "Name", "NameTo", "Text", "Color"]; this.Init(arguments); }; mdto.prototype = new DTO(); mdto.prototype.ToString = function(index, obj, holder) { if (!index) { lastMessageDate = ""; } var date = ParseDate(this.Date); var dateString = date.ToPrintableString(); if (date && dateString && dateString != lastMessageDate && holder) { lastMessageDate = dateString; holder.appendChild(MakeGridSubHeader(index, obj.Columns, dateString)); } var tr = MakeGridRow(index); if (this.NameTo) { tr.className += " Highlight Warning"; } var td1 = d.createElement("td"); td1.className = "Centered"; td1.innerHTML = date.Time(); tr.appendChild(td1); var td3 = d.createElement("td"); if (this.Name) { var td2 = d.createElement("td"); td2.innerHTML = this.Name + (this.NameTo ? " для " + this.NameTo : " "); tr.appendChild(td2); } else { td3.colSpan = 2; } if (this.Color) { td3.style.color = this.Color; } td3.innerHTML = this.Text + " "; tr.appendChild(td3); return tr; }; /* Room Data Transfer Object */ function rdto(id, title, is_deleted) { this.fields = ["Id", "Title", "IsDeleted"]; this.Init(arguments); }; rdto.prototype = new DTO(); /* 54.lawcode.class.js */ //1.0 /* Law code text */ function LawCode() { this.Template = "law"; this.ClassName = "LawCode"; }; LawCode.prototype = new OptionsBase(); LawCode.prototype.Request = function() { }; LawCode.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); }; /* 54.static_text.class.js */ //1.0 /* Base class for those who loads template only (static text) with no user actions involved */ function StaticText() { }; StaticText.prototype = new OptionsBase(); StaticText.prototype.Request = function() { }; StaticText.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); }; /* 55.lawcode.class.js */ //1.0 /* Law code text */ function LawCode() { this.Template = "law"; this.ClassName = "LawCode"; }; LawCode.prototype = new StaticText(); /* 55.tag.class.js */ //5.0 /* Forum records tags (labels) */ var tagPattern = new RegExp("^[a-zA-Zа-я\ёА-Я\Ё0-9\-_\ ]+$", "gim"); var maxTags = 10; function Tags() { this.fields = []; this.ServicePath = servicesPath + "tags.service.php"; this.Template = "tags"; this.ClassName = "Tags"; this.IsLoaded = 0; }; Tags.prototype = new OptionsBase(); Tags.prototype.Bind = function(data, found) { if (data && data.length > 0 && !this.IsLoaded) { var s = ""; this.SetTabElementValue("TagsContainer", ""); this.Tab.AddedTags.Clear(); var holder = this.Inputs["TagsContainer"]; for (var i = 0,l = data.length; i < l; i++) { data[i].obj = this; this.Tab.AddedTags.Add(data[i]); s += data[i].ToString(holder, i); } this.IsLoaded = 1; } if (found) { var s = ""; var holder = this.Inputs["FoundTags"]; holder.innerHTML = ""; for (var i = 0,l = found.length; i < l; i++) { found[i].obj = this; found[i].ToSelect(holder); } } }; Tags.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.FillFrom(obj.data); obj.Bind(obj.data, obj.found); } }; Tags.prototype.TemplateLoaded = function(req) { this.Tab.AddedTags = new Collection(); this.RECORD_ID = this.Tab.RECORD_ID; this.TemplateBaseLoaded(req); this.FindRelatedControls(); this.AssignSelfTo("AddTag"); // Validation this.Tab.Validators = new ValidatorsCollection(); this.Tab.Validators.Add(new Validator(this.Inputs["SEARCH_TAG"], new MatchPattern(tagPattern), "Тег содержит запрешённые символы (разрешено a-z а-я 0-9 -_)", Random(10000))); this.Tab.Validators.Init(this.Inputs["Errors"]); var req = new DelayedRequestor(this, this.Inputs["SEARCH_TAG"]); req.Submitter = this.Inputs["AddTag"]; }; Tags.prototype.Request = function(params, callback) { if (!params) { params = ""; } params += MakeParametersPair("RECORD_ID", this.RECORD_ID); this.BaseRequest(params, callback); }; Tags.prototype.AddNewTag = function(input) { if (input && input.obj) { var value = input.obj.Inputs["SEARCH_TAG"].value; var tag = new tagdto(value, value); tag.obj = this; if (this.AT(tag)) { input.obj.Inputs["SEARCH_TAG"].value = ""; } } }; Tags.prototype.AT = function(tag) { if (this.Tab.AddedTags.Count() >= maxTags) { this.Inputs["Errors"].innerHTML = "
  • Можно добавить не более " + maxTags + " тегов"; return false; } this.Tab.AddedTags.Add(tag); this.ShowTags(); return true; }; Tags.prototype.DT = function(id) { this.Tab.AddedTags.Delete(id); this.ShowTags(); }; Tags.prototype.ShowTags = function() { this.SetTabElementValue("TagsContainer", this.Tab.AddedTags.Count() > 0 ? "" : "не указаны"); this.Tab.AddedTags.ToString(this.Inputs["TagsContainer"]); }; /* Tag Data Transfer Object */ function tagdto(id, title) { this.fields = ["Id", "Title"]; this.Init(arguments); }; tagdto.prototype = new DTO(); tagdto.prototype.ToString = function(holder, index) { holder.appendChild(d.createTextNode((index ? ", " : "") + this.Id)); var a = d.createElement("a"); a.href = voidLink; a.className = "CloseSign Small"; a.obj = this; a.onclick = function(){this.obj.obj.DT(this.obj.Id)}; a.innerHTML = "x"; holder.appendChild(a); }; tagdto.prototype.ToSelect = function(holder) { var li = d.createElement("li"); var a = d.createElement("a"); a.href = voidLink; a.obj = this; a.onclick = function(){this.obj.obj.AT(this.obj)}; a.innerHTML = this.Title; li.appendChild(a); holder.appendChild(li); }; tagdto.prototype.Gather = function(index) { return (index ? "|" : "") + this.Title; }; /* 56.scheduled_tasks.class.js */ //4.0 /* Scheduled Tasks management */ function ScheduledTasks() { this.fields = ["SCHEDULED_TASK_ID", "TYPE", "EXECUTION_DATE", "PERIODICITY", "IS_ACTIVE", "status", "unban", "expired_sessions"]; this.ServicePath = servicesPath + "scheduled_tasks.service.php"; this.Template = "scheduled_tasks"; this.ClassName = "ScheduledTasks"; this.GridId = "ScheduledTasksGrid"; this.Columns = 5; }; ScheduledTasks.prototype = new EditablePagedGrid(); ScheduledTasks.prototype.BaseBind = function() {}; ScheduledTasks.prototype.InitPager = function() { this.Pager = new Pager(this.Inputs[this.PagerId], function(){this.Tab.ScheduledTasks.SwitchPage()}, this.PerPage); }; ScheduledTasks.prototype.RequestCallback = function(req, obj) { if (obj) { obj.RequestBaseCallback(req, obj); obj.Bind(obj.data, obj.Total); } }; ScheduledTasks.prototype.TemplateLoaded = function(req) { this.TemplateBaseLoaded(req); this.GroupSelfAssign(["RefreshScheduledTasks"]); // System log checkboxes BindEnterTo(this.Inputs["status"], this.Inputs["RefreshScheduledTasks"]); BindEnterTo(this.Inputs["unban"], this.Inputs["RefreshScheduledTasks"]); BindEnterTo(this.Inputs["expired_sessions"], this.Inputs["RefreshScheduledTasks"]); }; /* Status Data Transfer Object */ function stdto(id, rights, color, title) { this.fields = ["Id", "Type", "ExecutionDate", "Periodicity", "IsActive"]; this.Init(arguments); }; stdto.prototype = new EditableDTO(); stdto.prototype.ToShowView = function(index, obj) { var tr = MakeGridRow(index); var td1 = d.createElement("td"); td1.className = "Centered"; td1.appendChild(CreateBooleanImage(this.IsActive)); tr.appendChild(td1); var td2 = d.createElement("td"); td2.innerHTML = this.Type; tr.appendChild(td2); var td3 = d.createElement("td"); td3.innerHTML = this.ExecutionDate; tr.appendChild(td3); var td4 = d.createElement("td"); td4.innerHTML = this.Periodicity; tr.appendChild(td4); tr.appendChild(this.MakeButtonsCell()); return tr; }; stdto.prototype.ToEditView = function(index, obj) { var tr = MakeGridRow(index); // Rights var td1 = d.createElement("td"); td1.className = "Centered"; this.IsActiveInput = CreateCheckBox("IsActive", this.IsActive); td1.appendChild(this.IsActiveInput); tr.appendChild(td1); var td2 = d.createElement("td"); td2.innerHTML = this.Type; tr.appendChild(td2); var td3 = d.createElement("td"); this.ExecutionDateInput = d.createElement("input"); this.ExecutionDateInput.value = this.ExecutionDate; td3.appendChild(this.ExecutionDateInput); new DatePicker(this.ExecutionDateInput, 1); tr.appendChild(td3); var td4 = d.createElement("td"); this.PeriodicityInput = d.createElement("input"); this.PeriodicityInput.value = this.Periodicity; this.PeriodicityInput.className = "Wide"; td4.appendChild(this.PeriodicityInput); tr.appendChild(td4); tr.appendChild(this.MakeButtonsCell()); return tr; }; /* 99.init.js */ //2.0 /* Chat properties initialization */ var users = new Collection(); var rooms = new Collection(); var recepients = new Collection(); var co = new Confirm(); // Below values to be updated with // values received from server var CurrentRoomId = 1; var me = ""; // OnLoad actions var menuInitilized = 0; function InitMenu(div) { var menu = new MenuItemsCollection(true); var main = new MenuItem(1, "Команды"); /* main.SubItems.Items.Add(new MenuItem(1, "/me сообщение", "MI('me')")); var w = new MenuItem(2, "Вейкап"); w.SubItems.Items.Add(new MenuItem(1, "Поиск...", "", 1)); main.SubItems.Items.Add(w);*/ main.SubItems.Items.Add(new MenuItem(3, "Отойти (Away)", "MI('away')")); main.SubItems.Items.Add(new MenuItem(4, "Сменить статус", "MI('status')")); main.SubItems.Items.Add(new MenuItem(5, "Сменить никнейм", "ChangeName()")); if (me.Rights >= topicRights) { var t = new MenuItem(6, "Сменить тему", "MI('topic')"); if (me.Rights >= adminRights) { t.SubItems.Items.Add(new MenuItem(1, "С блокировкой", "MI('locktopic')")); t.SubItems.Items.Add(new MenuItem(2, "Разблокировать", "MI('unlocktopic')")); } main.SubItems.Items.Add(t); } main.SubItems.Items.Add(new MenuItem(7, "Меню", "ShowOptions()")); main.SubItems.Items.Add(new MenuItem(8, "Выход из чата", "MI('quit')")); menu.Items.Add(main); menu.Create(div); menuInitilized = 1; }; function OnLoad() { DisplayElement(alerts.element, false); co.Init("AlertContainer", "AlertBlock"); if (window.Pong) { Ping(); } };