Compare commits

..

No commits in common. "master" and "v2.0-alpha1" have entirely different histories.

854 changed files with 11023 additions and 28747 deletions

29
.gitignore vendored
View File

@ -1,11 +1,6 @@
# IDE folders
.idea
src/mibew/install/package src/mibew/install/package
src/absent_* src/absent_*
src/release* src/release*
src/upload*
src/*.po
# Do not index actual configuration files # Do not index actual configuration files
src/mibew/configs/config.yml src/mibew/configs/config.yml
@ -15,11 +10,6 @@ src/tests/server_side/mibew/libs/config.php
src/mibew/files/avatar/* src/mibew/files/avatar/*
!src/mibew/files/avatar/.keep !src/mibew/files/avatar/.keep
# Do not index cache files
src/mibew/cache/*
!src/mibew/cache/.keep
!src/mibew/cache/.htaccess
# Do not index plugins # Do not index plugins
src/mibew/plugins/* src/mibew/plugins/*
!src/mibew/plugins/.keep !src/mibew/plugins/.keep
@ -34,22 +24,3 @@ src/composer.lock
# Do not index third-party libraries # Do not index third-party libraries
src/mibew/vendor src/mibew/vendor
src/mibew/js/vendor
# Do not index node.js modules that are used for building
src/node_modules
src/package-lock.json
# Do not index compiled js files of the core
src/mibew/js/compiled/*
!src/mibew/js/compiled/.keep
# Do not index compiled files of chat styles
src/mibew/styles/chats/*/templates_compiled/client_side/*
!src/mibew/styles/chats/*/templates_compiled/client_side/.keep
src/mibew/styles/chats/*/js/compiled/*
!src/mibew/styles/chats/*/js/compiled/.keep
# Do not index compiled files of page styles
src/mibew/styles/pages/*/templates_compiled/client_side/*
!src/mibew/styles/pages/*/templates_compiled/client_side/.keep

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "src/i18n"]
path = src/i18n
url = git@github.com:Mibew/i18n.git

View File

@ -1,12 +0,0 @@
### Environment
* Mibew Messenger version:
* OS:
* Web server:
* PHP:
* PHP extensions:
* MySQL:
### Expected behavior
### Actual behavior
### Steps to reproduce the behavior

View File

@ -1 +0,0 @@
./src/mibew/LICENSE.txt

View File

@ -1,8 +0,0 @@
Fixes # .
Changes proposed in this pull request:
-
-
-
@Mibew/core-developers

View File

@ -11,61 +11,16 @@ This repository contains the core of Mibew Messenger application.
## Server requirements ## Server requirements
1. A webserver or web hosting account running on any major Operating System 1. A webserver or web hosting account running on any major Operating System
2. PHP (7.2.5 and above) with PDO, pdo_mysql, cURL, mbstring and gd extensions 2. PHP (5.3.3 and above) with MySQL support
3. MySQL 5.0 and above 3. MySQL 5.0 and above
## Build from sources
There are several actions one should do before use the latest version of Mibew from the repository:
1. Obtain a copy of the repository using `git clone`, download button, or another way.
2. Install [node.js](http://nodejs.org/) and [npm](https://www.npmjs.org/).
3. Install [Gulp](http://gulpjs.com/).
4. Navigate to `src/` directory of the local copy of the repository.
5. Install npm dependencies using `npm install`.
6. Run Gulp to build Mibew using `gulp default`.
Finally `.tar.gz` and `.zip` archives of the ready-to-use Mibew will be available in `src/release` directory.
## Terms of Use ## Terms of Use
Mibew Messenger is licensed under the terms of [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). Mibew Messenger is licensed under the terms of [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
## Other repositories of the Mibew project ## Other repositories of the Mibew project
### Actual
1. [Mibew Messenger i18n repository](https://github.com/Mibew/i18n) 1. [Mibew Messenger i18n repository](https://github.com/Mibew/i18n)
2. [Mibew Messenger design repository](https://github.com/Mibew/design) 2. [Mibew Messenger design repository](https://github.com/Mibew/design)
3. [Mibew documentation repository](https://github.com/Mibew/docs.mibew.org) 3. [Mibew Java applications repository](https://github.com/Mibew/java)
4. [Mibew Tray repository](https://github.com/Mibew/tray)
### Obsolete
1. [Mibew Java applications repository](https://github.com/Mibew/java)
2. [Mibew Tray repository](https://github.com/Mibew/tray)
### Plugins
1. [Mibew Boilerplate plugin](https://github.com/Mibew/boilerplate-plugin) - a template for a real plugin
#### Ready for production use
1. [Mibew Advanced Button plugin](https://github.com/Mibew/advanced-button-plugin)
2. [Mibew Auto Invite plugin](https://github.com/Mibew/auto-invite-plugin)
3. [Mibew Auto Reply plugin](https://github.com/Mibew/auto-reply-plugin)
4. [Mibew Broadcast plugin](https://github.com/Mibew/broadcast-plugin)
5. [Mibew Bulk Logs Operations plugin](https://github.com/Mibew/bulk-logs-operations-plugin)
6. [Mibew Button Refresh plugin](https://github.com/Mibew/button-refresh-plugin)
7. [Mibew Emoji plugin](https://github.com/Mibew/emoji-plugin)
8. [Mibew Filter Visitors By Operator Code plugin](https://github.com/Mibew/filter-visitors-by-operator-code-plugin)
9. [Mibew First Message plugin](https://github.com/Mibew/first-message-plugin)
10. [Mibew Geo IP plugin](https://github.com/Mibew/geo-ip-plugin)
11. [Mibew Google Maps plugin](https://github.com/Mibew/google-maps-plugin)
12. [Mibew Open Street Map plugin](https://github.com/Mibew/open-street-map-plugin)
13. [Mibew Operator Status plugin](https://github.com/Mibew/mibew-operator-status-plugin)
14. [Mibew Purge History plugin](https://github.com/Mibew/purge-history-plugin)
15. [Mibew Real Ban plugin](https://github.com/Mibew/real-ban-plugin)
16. [Mibew Slack plugin](https://github.com/Mibew/mibew_slack)
17. [Mibew Title Notification plugin](https://github.com/Mibew/title-notification-plugin)
#### Not ready for production use (not stable, broken, obsolete, etc.)
1. [Mibew External API plugin](https://github.com/Mibew/external-api-plugin)

View File

@ -1,4 +0,0 @@
{
"directory": "./mibew/js/vendor",
"analytics": false
}

View File

@ -1,27 +0,0 @@
{
"extends": "eslint:recommended",
"rules": {
"indent": ["error", 4, {"SwitchCase": 1}],
"no-trailing-spaces": "error",
"semi": ["error", "always"],
"guard-for-in": "error",
"no-unused-vars": ["error", {"caughtErrors": "none", "args": "none"}]
},
"globals": {
"Mibew": true,
"MibewAPI": true,
"MibewAPIInteraction": true,
"MibewAPIChatInteraction": true,
"MibewAPIUsersInteraction": true,
"MibewAPIExecutionContext": true,
"Handlebars": true,
"_": true,
"Backbone": true,
"jQuery": true,
"vex": true,
"validator": true
},
"env":{
"browser": true
}
}

View File

@ -1,17 +0,0 @@
{
"name": "mibew",
"private": true,
"dependencies": {
"underscore": "1.8.2",
"json": "https://github.com/douglascrockford/JSON-js.git#c98948ae1944a28e2e8ebc3717894e580aeaaa05",
"jquery": "1.11.3",
"backbone": "1.1.2",
"marionette": "2.4.1",
"handlebars": "4.3.0",
"vex": "2.3.2",
"validator-js": "3.40.0"
},
"resolutions": {
"underscore": "1.8.2"
}
}

427
src/build.xml Normal file
View File

@ -0,0 +1,427 @@
<project name="mibew messenger" default="all">
<property name="mibew_path" value="mibew" />
<property name="closure.c" value="/opt/closure/compiler.jar" />
<property name="handlebars" value="handlebars" />
<property name="dialogs_styles_path" value="${mibew_path}/styles/dialogs" />
<property name="pages_styles_path" value="${mibew_path}/styles/pages" />
<property name="js_path" value="${mibew_path}/js" />
<!-- Compile Handlebars templates for dialogs styles -->
<target name="dialogs_handlebars" description="Compile Handlebars templates for dialogs styles">
<echo>Flatten templates directory structure</echo>
<!-- Use system 'mkdir' instead of ant 'mkdir' task because it do not
work with dirsets -->
<apply executable="mkdir" addsourcefile="false">
<targetfile />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/templates_src/client_side" />
</dirset>
<mapper type="glob" from="*/templates_src/client_side" to="*/templates_compiled/client_side_tmp" />
</apply>
<!-- Flatten templates directory structure -->
<apply executable="tools/flat_cp" force="true">
<srcfile />
<targetfile />
<arg value="client_side" />
<fileset dir=".">
<include name="${dialogs_styles_path}/*/templates_src/client_side/**/*.handlebars" />
</fileset>
<mapper type="regexp" from="^(.*)/templates_src/client_side/(.*)$$" to="\1/templates_compiled/client_side_tmp" />
</apply>
<echo>Compile templates</echo>
<!-- Compile templates -->
<apply executable="${handlebars}">
<arg value="-f"/>
<targetfile />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/templates_compiled/client_side_tmp" />
</dirset>
<mapper type="glob" from="*/client_side_tmp" to="*/client_side/templates_tmp.js" />
</apply>
<!-- Use closule compiler instead of handlebars minifyer (-m flag)
because of handlebars does not insert line breaks.
Very long lines are cutted by ant and this brings problems -->
<apply executable="java">
<arg value="-jar" />
<arg value="${closure.c}" />
<arg value="--js" />
<srcfile />
<arg value="--js_output_file" />
<targetfile />
<fileset dir=".">
<include name="${dialogs_styles_path}/*/templates_compiled/client_side/templates_tmp.js" />
</fileset>
<mapper type="glob" from="*_tmp.js" to="*_tmp.c.js" />
</apply>
<!-- Add license info. Use move because of it is the best way to append
some info to files -->
<move todir="${dialogs_styles_path}" overwrite="true">
<fileset dir="${dialogs_styles_path}"/>
<mapper type="glob" from="*/templates_compiled/client_side/templates_tmp.c.js" to="*/templates_compiled/client_side/templates.js"/>
<filterchain>
<!-- Add header -->
<concatfilter prepend="tools/compiled_templates_header.txt" />
<!-- Skip empty lines -->
<linecontainsregexp negate="true">
<regexp pattern="^\s+$$" />
</linecontainsregexp>
</filterchain>
</move>
<!-- Remove all temporary files -->
<!-- Use system 'rm' instead of ant
'delete' task because it does not work with dirsets -->
<echo>Remove temporary files</echo>
<apply executable="rm">
<arg value="-r" />
<arg value="-f" />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/templates_compiled/client_side_tmp" />
</dirset>
</apply>
<delete>
<fileset dir=".">
<include name="${dialogs_styles_path}/*/templates_compiled/client_side/templates_tmp.js" />
</fileset>
</delete>
<echo>Done</echo>
</target>
<!-- Compile Handlebars templates for pages styles -->
<target name="pages_handlebars" description="Compile Handlebars templates for pages styles">
<!-- Compile applications templates -->
<apply executable="${handlebars}">
<arg value="-f"/>
<targetfile />
<dirset dir=".">
<include name="${pages_styles_path}/*/templates_src/client_side/*" />
</dirset>
<mapper
type="regexp"
from="^(.*)/templates_src/client_side/(.*)$$"
to="\1/templates_compiled/client_side/\2_app_tmp.tpl.js"
/>
</apply>
<!-- Use closule compiler instead of handlebars minifyer (-m flag)
because of handlebars does not insert line breaks.
Very long lines are cutted by ant and this brings problems -->
<apply executable="java">
<arg value="-jar" />
<arg value="${closure.c}" />
<arg value="--js" />
<srcfile />
<arg value="--js_output_file" />
<targetfile />
<fileset dir=".">
<include name="${pages_styles_path}/*/templates_compiled/client_side/*_app_tmp.tpl.js" />
</fileset>
<mapper type="glob" from="*_app_tmp.tpl.js" to="*_app_tmp.c.tpl.js" />
</apply>
<!-- Add license info. Use move because of it is the best way to append
some info to files -->
<move todir="${pages_styles_path}" overwrite="true">
<fileset dir="${pages_styles_path}">
<include name="*/templates_compiled/client_side/*_tmp.c.tpl.js" />
</fileset>
<!--<mapper type="glob" from="*/templates_compiled/client_side/*_tmp.c.tpl.js" to="*.tpl.js"/>-->
<mapper type="glob" from="*_tmp.c.tpl.js" to="*.tpl.js"/>
<filterchain>
<!-- Add header -->
<concatfilter prepend="tools/compiled_templates_header.txt" />
<!-- Skip empty lines -->
<linecontainsregexp negate="true">
<regexp pattern="^\s+$$" />
</linecontainsregexp>
</filterchain>
</move>
<!-- Remove all temporary files. -->
<delete>
<fileset dir="${pages_styles_path}">
<include name="*/templates_compiled/client_side/*_tmp.tpl.js" />
</fileset>
</delete>
<echo>Done</echo>
</target>
<!-- Compile Handlebars templates for all styles (both dialogs and pages) -->
<target name="styles_handlebars" depends="pages_handlebars,dialogs_handlebars" description="Compile Handlebars templates for all styles">
<echo>Handlebars templates from all styles are built.</echo>
</target>
<!-- Compile and concatenate JavaScript files for dialog styles -->
<target name="styles_js" description="Compile JavaScript files for all dialogs styles">
<echo>Compile and concatenate JavaScript files for dialogs styles:</echo>
<!-- Create temporary directories for compiled JavaScript files -->
<echo>Create temporary directories</echo>
<apply executable="mkdir" addsourcefile="false">
<targetfile />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/js/source" />
</dirset>
<mapper type="glob" from="*/source" to="*/tmp" />
</apply>
<!-- Compile JavaScript files -->
<echo>Compile JavaScript files</echo>
<apply executable="java">
<arg value="-jar" />
<arg value="${closure.c}" />
<arg value="--js" />
<srcfile />
<arg value="--js_output_file" />
<targetfile />
<fileset dir=".">
<include name="${dialogs_styles_path}/*/js/source/*.js" />
</fileset>
<mapper type="regexp" from="^(.+)/source/(.+)$$" to="\1/tmp/\2" />
</apply>
<!-- Concatenate all scripts in one file. Use special script for
expanding wildcards. -->
<echo>Concatenate JavaScript files</echo>
<apply executable="tools/cat">
<srcfile suffix="/*.js"/>
<targetfile />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/js/tmp" />
</dirset>
<mapper type="glob" from="*/tmp" to="*/compiled/scripts.js" />
</apply>
<!-- Remove temporary directories -->
<echo>Remove temporary directories</echo>
<apply executable="rm">
<arg value="-r" />
<arg value="-f" />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/js/tmp" />
</dirset>
</apply>
<echo>Done</echo>
</target>
<!-- Build all stuff related to dialogs styles -->
<target name="styles_all" depends="styles_handlebars,styles_js" description="Run styles_handlebars and styles_js targets">
<echo>Styles built.</echo>
</target>
<!-- Compile all JavaScript files of the Mibew Core -->
<target name="core_js">
<echo>Compile JavaScript files of the Mibew Core</echo>
<!-- Copy directory tree from source to compiled -->
<echo>Copy directory tree</echo>
<copy todir="${js_path}/compiled">
<dirset dir="${js_path}/source">
<include name="**" />
</dirset>
</copy>
<!-- Compile JavaScript files -->
<echo>Compile JavaScript files</echo>
<apply executable="java">
<arg value="-jar" />
<arg value="${closure.c}" />
<arg value="--js" />
<srcfile />
<arg value="--js_output_file" />
<targetfile />
<fileset dir=".">
<include name="${js_path}/source/**/*.js" />
</fileset>
<mapper type="regexp" from="^(.+)/source/(.+)$$" to="\1/compiled/\2" />
</apply>
<echo>Done</echo>
</target>
<!-- Build JavaScript application -->
<target name="app_js">
<echo>Build "${app_name}" JavaScript application</echo>
<!-- Remove old application file -->
<delete file="${js_path}/compiled/${app_name}_app.js" />
<!-- Append application files to the result file -->
<concat destfile="${js_path}/compiled/${app_name}_app.js" eol="lf">
<!-- Append application static initialization code -->
<filelist dir="${js_path}/compiled/${app_name}" files="init.js" />
<!-- Include files from ${js_path}/compiled/${app_name}/ -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="*.js" />
<exclude name="init.js" />
<exclude name="app.js" />
</fileset>
<!-- Include models files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="models/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="models/**/*.js" />
<!-- Exclude base files -->
<exclude name="models/**/base*.js" />
</fileset>
<!-- Include collections files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="collections/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="collections/**/*.js" />
<!-- Exclude base files -->
<exclude name="collections/**/base*.js" />
</fileset>
<!-- Include models views files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="model_views/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="model_views/**/*.js" />
<!-- Exclude base files -->
<exclude name="model_views/**/base*.js" />
</fileset>
<!-- Include collections views files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="collection_views/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="collection_views/**/*.js" />
<!-- Exclude base files -->
<exclude name="collection_views/**/base*.js" />
</fileset>
<!-- Include regions files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="regions/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="regions/**/*.js" />
<!-- Exclude base files -->
<exclude name="regions/**/base*.js" />
</fileset>
<!-- Include layouts files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="layouts/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="layouts/**/*.js" />
<!-- Exclude base files -->
<exclude name="layouts/**/base*.js" />
</fileset>
<!-- Include all other files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="**/base*.js" />
<exclude name="models/**/base*.js" />
<exclude name="collections/**/base*.js" />
<exclude name="model_views/**/base*.js" />
<exclude name="collection_views/**/base*.js" />
<exclude name="regions/**/base*.js" />
<exclude name="layouts/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="**/*.js" />
<!-- Exclude files from ${js_path}/compiled/${app_name}/ -->
<exclude name="*.js" />
<!-- Exclude models, collections, views, regions and layouts
files -->
<exclude name="models/**/*.js" />
<exclude name="collections/**/*.js" />
<exclude name="model_views/**/*.js" />
<exclude name="collection_views/**/*.js" />
<exclude name="regions/**/*.js" />
<exclude name="layouts/**/*.js" />
<!-- Exclude base files -->
<exclude name="**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="app.js" />
</fileset>
<!-- Apply filters -->
<filterchain>
<!-- Skip empty lines -->
<linecontainsregexp negate="true">
<regexp pattern="^\s+$$" />
</linecontainsregexp>
</filterchain>
</concat>
<echo>Done</echo>
</target>
<!-- Build JavaScript files related to default application -->
<target name="default_app_js" depends="core_js" description="Build JavaScript files related to default application">
<antcall target="app_js">
<param name="app_name" value="default" />
</antcall>
<echo>Default JavaScript application built.</echo>
</target>
<!-- Compile and concatenate JavaScript files related to chat application -->
<target name="chat_app_js" depends="default_app_js" description="Build JavaScript files related to chat application">
<antcall target="app_js">
<param name="app_name" value="chat" />
</antcall>
<echo>Chat JavaScript application built.</echo>
</target>
<!-- Compile and concatenate JavaScript files related to users application -->
<target name="users_app_js" depends="default_app_js" description="Build JavaScript files related to users application">
<antcall target="app_js">
<param name="app_name" value="users" />
</antcall>
<echo>Users JavaScript application built.</echo>
</target>
<!-- Compile and concatenate JavaScript files related to thread log application -->
<target name="thread_log_app_js" depends="default_app_js" description="Build JavaScript files related to thread log application">
<antcall target="app_js">
<param name="app_name" value="thread_log" />
</antcall>
<echo>Thread log JavaScript application built.</echo>
</target>
<!-- Build all project -->
<target name="all" depends="chat_app_js,thread_log_app_js,users_app_js,styles_all" description="Build everything">
<echo>Mibew Messenger built.</echo>
</target>
</project>

3
src/check_coding_style Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
mibew/vendor/bin/phpcs --standard="PSR2" --extensions="php" --ignore="mibew/vendor/,mibew/plugins" -n mibew/

56
src/check_translation.pl Executable file
View File

@ -0,0 +1,56 @@
#!/usr/bin/perl
sub read_transl($) {
my($from) = @_;
my %translation = ();
open(IN, "mibew/locales/$from/properties");
while(<IN>) {
chomp;
if(/^([\w\.]+)=(.*)$/) {
if($1 ne "encoding" && $1 ne "output_charset" && $1 ne "output_encoding") {
$translation{$1} = $2;
}
} else {
die "wrong line in $from: $_\n";
}
}
close(IN);
return %translation;
}
%tr_en = read_transl("en");
@all_keys = keys %tr_en;
sub check_transl($%) {
my($name,%tr) = @_;
print "checking $name...\n";
my @totransl = ();
for $key (@all_keys) {
unless(exists $tr{$key}) {
push @totransl, "$key=".$tr_en{$key};
}
}
for $key(keys %tr) {
unless(exists $tr_en{$key}) {
print "unknown key in $name: $key\n";
}
}
if($#totransl >= 0) {
print "@{[$#totransl+1]} lines absent in locales/$name/properties\n";
open(OUT, "> absent_$name");
for(sort @totransl) {
print OUT "$_\n";
}
close(OUT);
}
}
check_transl("ru", read_transl("ru"));
check_transl("fr", read_transl("fr"));
check_transl("de", read_transl("de"));
check_transl("sp", read_transl("sp"));
check_transl("it", read_transl("it"));
check_transl("pl", read_transl("pl"));
check_transl("zh-tw", read_transl("zh-tw"));

View File

@ -1,49 +1,32 @@
{ {
"name": "mibew/mibew", "name": "mibew/mibew",
"version": "3.6.0", "version": "2.0-dev",
"description": "Mibew Messenger - open-source live support application", "description": "Mibew Messenger - open-source live support application",
"type": "project", "type": "project",
"homepage": "https://mibew.org", "homepage": "http://mibew.org",
"license": "Apache-2.0", "license": "Apache-2.0",
"authors": [ "authors": [
{ {
"name": "Mibew Messenger Project", "name": "Mibew Messenger Project",
"homepage": "https://mibew.org/credits" "homepage": "http://mibew.org/credits"
} }
], ],
"support": { "support": {
"email": "support@mibew.org", "email": "support@mibew.org",
"issues": "https://github.com/mibew/mibew/issues", "issues": "https://github.com/mibew/mibew/issues",
"forum": "https://mibew.org/forums", "forum": "http://mibew.org/forums",
"source": "https://github.com/mibew/mibew" "source": "https://github.com/mibew/mibew"
}, },
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mibew/handlebars.php"
},
{
"type": "vcs",
"url": "https://github.com/mibew/handlebars.php-helpers"
}
],
"require": { "require": {
"mibew/handlebars.php": "~0.10.5", "xamin/handlebars.php": "dev-master#cd8cec42a048ba0d8c7dd0bfde39b973b6a14b3f",
"mibew/handlebars.php-helpers": "1.*", "symfony/http-foundation": "2.4.*",
"symfony/http-foundation": "4.4.*", "symfony/routing": "2.4.*",
"symfony/routing": "4.4.*", "symfony/config": "2.4.*",
"symfony/config": "4.4.*", "symfony/yaml": "2.4.*",
"symfony/yaml": "^5.2", "symfony/translation": "2.4.*"
"symfony/translation": "2.6.*",
"tedivm/stash": "0.12.*",
"mibew/html5": "1.1.*",
"vierbergenlars/php-semver": "3.0.*",
"swiftmailer/swiftmailer": "~5.4.0",
"ua-parser/uap-php": "^3.9",
"true/punycode": "~1.1"
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "3.*" "squizlabs/php_codesniffer": "1.*"
}, },
"config": { "config": {
"vendor-dir": "mibew/vendor" "vendor-dir": "mibew/vendor"

245
src/compute_resources.pl Executable file
View File

@ -0,0 +1,245 @@
#!/usr/bin/perl
use Digest::MD5 qw(md5 md5_hex md5_base64);
@rules = (
["redirect(ed)?\\.tpl", 1],
["\\.tpl", 0],
["view/license.php", 0],
["view/themes.php", 2],
["view/translate.php", 2],
["view/translatelist.php", 2],
["view/settings.php", 2],
["view/updates.php", 2],
["view/features.php", 2],
["view/performance.php", 2],
["view/avatar.php", 2],
["view/permissions.php", 2],
["view/agent.php", 2],
["view/agents.php", 2],
["view/group.php", 2],
["view/groupmembers.php", 2],
["view/groups.php", 2],
["view/operator_groups.php", 2],
["view/gen_button.php", 2],
["view/install_err.php", 2],
["view/install_index.php", 2],
["view/.*\\.php", 1],
["install/.*\\.php", 2],
["operator/themes.php", 2],
["operator/translate.php", 2],
["operator/settings.php", 2],
["operator/updates.php", 2],
["operator/features.php", 2],
["operator/performance.php", 2],
["operator/avatar.php", 2],
["operator/permissions.php", 2],
["operator/operator.php", 2],
["operator/operators.php", 2],
["operator/group.php", 2],
["operator/groupmembers.php", 2],
["operator/groups.php", 2],
["operator/opgroups.php", 2],
["operator/getcode.php", 2],
["operator/.*\\.php", 1],
["mibew/client.php", 0],
["mibew/leavemessage.php", 0],
["mibew/captcha.php", 0],
["mibew/license.php", 0],
["mibew/mail.php", 0],
["libs/operator_settings.php", 2],
["mibew/libs/chat.php", 0],
["libs/pagination.php", 1],
["libs/settings.php", 2],
["libs/groups.php", 2],
["libs/demothread.php", 2],
["mibew/thread.php", 0],
["mibew/b.php", 0],
["mibew/button.php", 0],
["mibew/index.php", 0],
["mibew/libs/.*\\.php", 1],
);
%messagekeys = (
"localeid" => 0,
"output_charset" => 0,
"output_encoding" => 0,
"harderrors.header" => 0,
"errors.required" => 0,
"errors.wrong_field" => 0,
"errors.file.move.error" => 2,
"errors.invalid.file.type" => 2,
"errors.file.size.exceeded" => 2,
"permission.admin" => 1,
"permission.takeover" => 1,
"permission.viewthreads" => 1,
"chat.thread.state_chatting_with_agent" => 1,
"chat.thread.state_closed" => 1,
"chat.thread.state_loading" => 1,
"chat.thread.state_wait" => 1,
"chat.thread.state_wait_for_another_agent" => 1,
"clients.queue.chat" => 1,
"clients.queue.prio" => 1,
"clients.queue.wait" => 1,
);
$mibewPath = "mibew";
%urls = ();
%usermessages = ();
%operatormessages = ();
$current_level = 0;
sub usemsg($) {
my ($m) = @_;
$messagekeys{$m} = exists $messagekeys{$m} && $messagekeys{$m} < $current_level ? $messagekeys{$m} : $current_level;
if($current_level == -1) {
print " .. $m\n";
}
}
sub file_content($) {
my $input = $_[0];
open( IN1, "< $input" ) or die "cannot find file $input";
my $oldslash = $/;
$/ = EOI;
$content = <IN1>;
close( IN1 );
if($content =~ s/\r//g) {
open( OUT1, "> $input") or die "cannot fix $input";
print OUT1 $content;
close(OUT1);
}
$/ = $oldslash;
return $content;
}
sub process_tpl($) {
my ($filename) = @_;
my $m = file_content($filename);
while( $m =~ /\${msg:([\w\.]+)(,[\w\.]+)?}/g ) {
usemsg($1);
}
while( $m =~ /\${url:([\w\.]+)(,[\w\.]+)?}/g ) {
usemsg($1);
$urls{"%$1"} = 1;
}
}
sub process_php($) {
my ($source) = @_;
my $content = file_content($source);
$content =~ s/<\?xml version=\\"1\.0\\" encoding=\\"UTF-8\\"\?>//;
while( $content =~ s/<\?(?!xml)(.*?)\?>//s ) {
my $inner = $1;
while($inner =~ s/(getlocal|no_field)2?_?\((.*?)[,\)]//s) {
my $firstarg = $2;
if( $firstarg =~ /^["']([\w\.]+)['"]$/) {
usemsg($1);
} elsif($firstarg =~ /^\$\w+$/ || $firstarg eq '"$var.header"' || $firstarg eq '"permission.$permid"' || $firstarg eq '$threadstate_key[$thread[\'istate\']]') {
# skip
} else {
print "> unknown: $firstarg\n";
}
}
}
}
sub file_checksum($) {
my ($source) = @_;
if($source =~ /\.(png|gif|jpg|ico|wav)$/ || $source =~ /config\.php$/) {
return "-";
}
my $content = file_content($source);
return md5_hex($content);
}
@allsources = ();
sub process_one($) {
my($source) = @_;
push @allsources, $source unless $source =~ /$mibewPath\/locales/ && $source !~ /$mibewPath\/locales\/(en|names)/ || $source =~ /\/package$/;
if($source !~ /\.(php|tpl)$/) {
return;
}
$current_level = -1;
A: foreach $rule (@rules) {
my $key = $$rule[0];
if($source =~ /$key/) {
$current_level = $$rule[1];
last A;
}
}
if($current_level < 0 || $current_level > 2) {
print "not detected for: $source\n";
$current_level = 0;
}
if($source =~ /\.php$/) {
# print "$source ($current_level)\n";
process_php($source);
} elsif($source =~ /\.tpl$/) {
process_tpl($source);
} else {
#print ". $source\n";
}
}
sub process_files($) {
my($from) = @_;
opendir(DIR, $from) || die "can't opendir $from: $!";
my @content = readdir(DIR);
closedir DIR;
for(grep { -f "$from/$_" && ($_ !~ /^\./ || $_ eq ".htaccess") } @content) {
process_one("$from/$_");
}
for(grep { -d "$from/$_" && $_ !~ /^\./ } @content) {
process_files("$from/$_");
}
}
process_files($mibewPath);
# fix
$messagekeys{'page.analysis.userhistory.title'} = 1;
$messagekeys{'errors.failed.uploading.file'} = 2;
open( OUT, "> $mibewPath/locales/names/level1") or die "cannot write file, $!";
for $key(sort grep { $messagekeys{$_} == 0 } keys %messagekeys) {
print OUT "$key\n";
}
close( OUT );
open( OUT, "> $mibewPath/locales/names/level2") or die "cannot write file, $!";
for $key(sort grep { $messagekeys{$_} == 1 } keys %messagekeys) {
print OUT "$key\n";
}
close( OUT );
open( OUT, "> $mibewPath/install/package") or die "cannot write file, $!";
for $key(sort @allsources) {
$digest = file_checksum($key);
$key =~ s/$mibewPath\///;
print OUT "$key $digest\n";
}
close( OUT );

View File

@ -1,743 +0,0 @@
// Initialize requirements
var fs = require('fs'),
https = require('https'),
exec = require('child_process').exec,
eventStream = require('event-stream'),
runSequence = require('gulp4-run-sequence'),
through = require('through2'),
lodash = require('lodash'),
PoFile = require('pofile'),
strftime = require('strftime'),
del = require('del'),
bower = require('bower'),
gulp = require('gulp'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
phpcs = require('gulp-phpcs'),
order = require('gulp-order'),
handlebars = require('gulp-handlebars'),
handlebarsEngine = require('handlebars'),
defineModule = require('gulp-define-module'),
header = require('gulp-header'),
zip = require('gulp-zip'),
tar = require('gulp-tar'),
gzip = require('gulp-gzip'),
chmod = require('gulp-chmod'),
xgettext = require('gulp-xgettext'),
concatPo = require('gulp-concat-po'),
rename = require('gulp-rename'),
eslint = require('gulp-eslint'),
removeDuplicateHeaders = require('mibew-gulp-greh'),
mkdirp = require('mkdirp');
// Set global configuration
var config = {
mibewPath: 'mibew',
configsPath: 'mibew/configs',
phpVendorPath: 'mibew/vendor',
jsVendorPath: 'mibew/js/vendor',
pluginsPath: 'mibew/plugins',
avatarsPath: 'mibew/files/avatar',
cachePath: 'mibew/cache',
jsPath: 'mibew/js',
chatStylesPath: 'mibew/styles/chats',
pageStylesPath: 'mibew/styles/pages',
i18nPath: 'i18n',
i18nPrefix: 'mibew-i18n-',
releasePath: 'release',
uploadPath: 'upload',
compiledTemplatesHeader: fs.readFileSync('tools/compiled_templates_header.txt'),
getComposerUrl: 'https://getcomposer.org/installer',
phpBin: 'php -d "suhosin.executor.include.whitelist = phar" -d "memory_limit=512M"',
package: require('./composer.json'),
msginit: 'msginit',
msgcat: 'msgcat'
}
config.i18nSuffix = '-' + config.package.version + '-' + strftime('%Y%m%d');
// Tasks for cleaning //////////////////
// Cleans all built files
gulp.task('clean', function(callback) {
return del([
config.releasePath,
'composer.lock',
config.phpVendorPath,
config.jsVendorPath,
config.jsPath + '/compiled/**/*',
'!' + config.jsPath + '/compiled/.keep',
config.chatStylesPath + '/*/templates_compiled/client_side/*.js',
config.chatStylesPath + '/*/js/compiled/*.js',
config.pageStylesPath + '/*/templates_compiled/client_side/*.js'
], callback);
});
// Cleans temporary English translation in the release dir
gulp.task('clean-tmp-po', function(callback) {
return del([config.releasePath + '/translation.po'], callback);
});
// Cleans temporary files of translations in the release dir
gulp.task('clean-tmp-i18n-files', function(callback) {
return del([
config.releasePath + '/**/*',
'!' + config.releasePath + '/*.zip',
'!' + config.releasePath + '/*.tar.gz',
'!' + config.releasePath + '/*.pot'
], callback);
});
// Cleans all files prepared for uploading to CDN
gulp.task('clean-upload', function(callback) {
return del([config.uploadPath], callback);
});
// Cleans everything
gulp.task('clean-all', function(callback) {
runSequence( ['clean', 'clean-upload'],
callback );
});
// Watcher tasks ///////////////////////
// Watch styles
gulp.task('watch', function() {
gulp.watch(config.pageStylesPath + '/**/*.handlebars', gulp.series('page-styles'));
gulp.watch(config.chatStylesPath + '/**/js/source/**/*.js', gulp.series('chat-styles-js'));
gulp.watch(config.chatStylesPath + '/**/*.handlebars', gulp.series('chat-styles-handlebars'));
});
// Service tasks //////////////////
// Get and install PHP Composer
gulp.task('get-composer', function(callback) {
// Check whether Composer is already in place
if (fs.existsSync('./composer.phar')) {
callback(null);
return;
}
// Get installer from the Internet
https.get(config.getComposerUrl, function(response) {
// Run PHP to install Composer
var php = exec(config.phpBin, function(error, stdout, stderr) {
callback(error ? stderr : null);
});
// Pass installer code to PHP via STDIN
response.pipe(php.stdin);
});
});
// Install Composer dependencies excluding development ones
gulp.task('composer-install', gulp.series('get-composer', function(callback) {
exec(config.phpBin + ' composer.phar install --no-dev',
function(error, stdout, stderr) {
callback(error ? stderr : null);
});
}));
// Install all Composer dependencies
gulp.task('composer-install-dev', gulp.series('get-composer', function(callback) {
exec(config.phpBin + ' composer.phar install',
function(error, stdout, stderr) {
callback(error ? stderr : null);
});
}));
// Installs bower dependencies
gulp.task('bower-install', function(callback) {
bower.commands.install([], {}, {})
.on('error', function(error) {
callback(error);
})
.on('end', function() {
// We should manually minify JavaScript files that was not minified
// by bower packages' authors
// TODO: This is a temproary workaround and should be removed once
// the packages will be fixed
var stream = eventStream.merge(
gulp.src(config.jsVendorPath + '/backbone/backbone.js',
{base: config.jsVendorPath})
.pipe(uglify({preserveComments: 'some'}))
// There are neither "@license" tag nor "!preserve" in the
// header. Add the header manually
.pipe(header(
"// Backbone.js 1.1.2\n"
+ "// (c) 2010-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n"
+ "// Backbone may be freely distributed under the MIT license.\n"
+ "// For all details and documentation:\n"
+ "// http://backbonejs.org\n"
))
.pipe(rename('backbone/backbone-min.js')),
gulp.src(config.jsVendorPath + '/json/json2.js',
{base: config.jsVendorPath})
.pipe(uglify({preserveComments: 'some'}))
// There are neither "@license" tag nor "!preserve" in the
// header, add the header manually
.pipe(header("// json2.js. Public Domain. See http://www.JSON.org/js.html\n"))
.pipe(rename('json/json2.min.js'))
)
.pipe(gulp.dest(config.jsVendorPath));
stream
.on('error', callback)
.on('end', callback);
});
});
// Tasks for checking //////////////////
// Checks all PHP files with PHP Code Sniffer
gulp.task('phpcs', gulp.series('composer-install-dev', function() {
return gulp.src([
config.mibewPath + '/**/*.php',
'!' + config.phpVendorPath + '/**/*.*',
'!' + config.pluginsPath + '/**/*.*',
'!' + config.cachePath + '/**/*.*'
], {
// Content of the cache directory is readable only for webserver.
// Thus we must to set "strict" option to false to prevent "EACCES"
// errors. At the same we need to see all errors that take place.
strict: false,
silent: false
})
.pipe(phpcs({
bin: config.phpVendorPath + '/bin/phpcs',
standard: 'PSR2',
warningSeverity: 0
}))
.pipe(phpcs.reporter('log'))
.pipe(phpcs.reporter('fail'));
}));
// Checks all JavaScript Source files with ESLint
gulp.task('eslint', function() {
return gulp.src(config.jsPath + '/source/**/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
// Restore empty English translation in the source code
gulp.task('post-pack-cleanup', function(callback) {
gulp.src('translation.po')
.pipe(gulp.dest(config.mibewPath + '/locales/en/'));
del(['translation.po', config.releasePath + '/translation.po'], callback);
});
// Tasks of compiling //////////////////
// Compile all JavaScript files of the Mibew Messenger Core
gulp.task('js', function() {
return eventStream.merge(
getClientSideApp('default'),
getClientSideApp('chat'),
getClientSideApp('thread_log'),
getClientSideApp('users'),
gulp.src(config.jsPath + '/source/**/*.js')
)
.pipe(uglify({preserveComments: 'some'}))
.pipe(removeDuplicateHeaders())
.pipe(gulp.dest(config.jsPath + '/compiled'));
});
// Compile and concatenate Handlebars templates for all chat styles
gulp.task('chat-styles-handlebars', function() {
return getChildDirs(config.chatStylesPath)
.then(function (dirs) {
return Promise.all(dirs.map(function (dir) {
return new Promise(function(resolve, reject) {
gulp.src(config.chatStylesPath + '/' + dir
+ '/templates_src/client_side/**/*.handlebars')
.pipe(handlebars({
// Use specific version of Handlebars.js
handlebars: handlebarsEngine
}))
.pipe(wrapHandlebarsTemplate())
.pipe(concat('templates.js'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(header(config.compiledTemplatesHeader))
.pipe(gulp.dest(config.chatStylesPath + '/' + dir
+ '/templates_compiled/client_side'))
.on('end', resolve)
.on('error', reject);
});
}));
});
});
// Compile and concatenate js files for all chat styles
gulp.task('chat-styles-js', function() {
return getChildDirs(config.chatStylesPath)
.then(function (dirs) {
return Promise.all(dirs.map(function (dir) {
return new Promise(function(resolve, reject) {
gulp.src(config.chatStylesPath + '/' + dir
+ '/js/source/**/*.js')
.pipe(concat('scripts.js'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest(config.chatStylesPath + '/' + dir
+ '/js/compiled'))
.on('end', resolve)
.on('error', reject);
});
}));
});
});
// Performs all job related to pages styles
gulp.task('page-styles', function() {
return getChildDirs(config.pageStylesPath)
.then(function (dirs) {
return Promise.all(dirs.map(function (dir) {
return new Promise(function(resolve, reject){
gulp.src(config.pageStylesPath + '/' + dir
+ '/templates_src/client_side/**/*.handlebars')
.pipe(handlebars({
// Use specific version of Handlebars.js
handlebars: handlebarsEngine
}))
.pipe(wrapHandlebarsTemplate())
.pipe(concat('templates.js'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(header(config.compiledTemplatesHeader))
.pipe(gulp.dest(config.pageStylesPath + '/' + dir
+ '/templates_compiled/client_side'))
.on('end', resolve)
.on('error', reject);
});
}));
});
});
// Performs all job related to chat styles
gulp.task('chat-styles', gulp.series('chat-styles-handlebars', 'chat-styles-js'));
// Prepares ready to use development version of Mibew Messenger without
// packing or validating it
gulp.task('rebuild', function(callback) {
runSequence(
'clean',
['js', 'chat-styles', 'page-styles', 'composer-install',
'bower-install'],
callback
);
});
// Tasks for localization issues ///////
// Generate POT-file based upon the source code
gulp.task('generate-pot', function() {
return eventStream.merge(
gulp.src([
config.mibewPath + '/**/*.php',
'!' + config.phpVendorPath + '/**/*.*',
'!' + config.pluginsPath + '/**/*.*',
'!' + config.cachePath + '/**/*.*'
], {
// Content of the cache directory is readable only for
// webserver. Thus we must to set "strict" option to false
// to prevent "EACCES" errors. At the same we need to see all
// errors that take place.
strict: false,
silent: false
})
.pipe(xgettext({
language: 'PHP',
keywords: [
{name: 'getlocal'},
{name: 'no_field'},
{name: 'wrong_field'},
{name: 'failed_uploading_file', singular: 2}
]
})),
gulp.src(config.jsPath + '/source/**/*.js', {base: config.mibewPath})
.pipe(xgettext({
language: 'JavaScript',
keywords: [
{name: 'trans'}
]
})),
gulp.src([
config.chatStylesPath + '/default/templates_src/**/*.handlebars',
config.pageStylesPath + '/default/templates_src/**/*.handlebars'
], {base: config.mibewPath})
.pipe(xgettextHandlebars())
)
.pipe(concatPo(config.i18nPrefix + 'translation'
+ config.i18nSuffix + '.pot',
{
headers: {
'Project-Id-Version': 'Mibew Messenger '
+ config.package.version,
'Report-Msgid-Bugs-To': config.package.support.email,
'POT-Creation-Date': strftime('%Y-%m-%d %H:%M%z'),
'PO-Revision-Date': '',
'Last-Translator': '',
'Language-Team': '',
'Content-Type': 'text/plain; charset=UTF-8'
}
})
)
.pipe(gulp.dest(config.releasePath));
});
// Generate temporary English translation to be used in the release
gulp.task('generate-tmp-po', gulp.series('generate-pot', function(callback) {
return exec(config.msginit + ' --no-translator --no-wrap -i '
+ config.releasePath + '/' + config.i18nPrefix + 'translation'
+ config.i18nSuffix + '.pot' + ' -l en -o '
+ config.releasePath + '/translation.po',
function(error, stdout, stderr) {
callback(error ? stderr : null);
});
}));
// Generate complete translations (that includes missed strings) to be used
// in the release
gulp.task('generate-pos', gulp.series('generate-tmp-po', function(callback) {
return getChildDirs(config.i18nPath + '/translations')
.then(function (dirs) {
return Promise.all(dirs.map(function (dir) {
return new Promise(function(resolve, reject) {
mkdirp(config.releasePath + '/' + dir, function (error) {
if (error) {
reject(error);
}
});
exec(config.msgcat + ' ' + config.i18nPath + '/translations/'
+ dir + '/translation.po ' + config.releasePath
+ '/translation.po --no-location --no-wrap --use-first'
+ ' -o ' + config.releasePath + '/' + dir
+ '/translation.po',
function(error, stdout, stderr) {
if (error) {
reject(error);
}
});
var sources = [
config.i18nPath + '/translations/' + dir + '/**/*',
'!' + config.i18nPath + '/translations/' + dir
+ '/translation.po'
];
gulp.src(sources)
.pipe(gulp.dest(config.releasePath + '/' + dir))
.on('error', reject)
.on('end', resolve);
});
}));
});
}));
// Packaging tasks /////////////////////
// Pack sources for release as .zip and .tar.gz archives
gulp.task('pack-sources', gulp.series('composer-install', 'bower-install', function() {
gulp.src(config.mibewPath + '/locales/en/translation.po')
.pipe(gulp.dest('.'));
gulp.src(config.releasePath + '/translation.po')
.pipe(gulp.dest(config.mibewPath + '/locales/en/'));
var sources = [
config.mibewPath + '/**/*',
// Exclude user's config
'!' + config.configsPath + '/config.yml',
// Exclude cache files but not the ".keep" file.
'!' + config.cachePath + '/**/!(.keep)',
// Exclude avatars but not the ".keep" file.
'!' + config.avatarsPath + '/!(.keep)',
// Exclude plugins but not the ".keep" file.
'!' + config.pluginsPath + '/!(.keep)',
'!' + config.pluginsPath + '/*/**/*',
// Exclude Git repositories that can be shipped with third-party libs
'!' + config.phpVendorPath + '/**/.git',
'!' + config.phpVendorPath + '/**/.git/**/*',
// Exclude vendors binaries
'!' + config.phpVendorPath + '/bin/**/*',
// Exclude JavaScript sources
'!' + config.jsPath + '/source/**/*',
// Actually we does not need backbone.babysitter and backbone.wreqr
// dependencies because they embed into marionette.js. So we exclude
// "backbone.babysitter" and "backbone.wreqr" directories and all their
// contents.
'!' + config.jsVendorPath + '/backbone.babysitter{,/**}',
'!' + config.jsVendorPath + '/backbone.wreqr{,/**}',
// Exclude dot files within third-party JS libraries.
'!' + config.jsVendorPath + '/**/.*',
// Exclude config files of various package systems
'!' + config.jsVendorPath + '/**/{bower,component,package,composer}.json',
// Exclude config files of various build systems
'!' + config.jsVendorPath + '/**/Gruntfile.*',
'!' + config.jsVendorPath + '/**/gulpfile.*',
'!' + config.jsVendorPath + '/**/Makefile',
// Exclude HTML files from third-party JS libraries. Such files can be
// used for docs or for tests, we need none of them.
'!' + config.jsVendorPath + '/**/*.html',
// There are too many useless files in Vex.js library. Exclude them.
'!' + config.jsVendorPath + '/vex/sass{,/**}',
'!' + config.jsVendorPath + '/vex/docs{,/**}',
'!' + config.jsVendorPath + '/vex/docs{,/**}',
'!' + config.jsVendorPath + '/vex/coffee{,/**}'
];
var srcOptions = {
// Dot files (.htaccess, .keep, etc.) must be included in the package
dot: true,
// Content of the cache directory is readable only for webserver. Thus
// we must to set "strict" option to false to prevent "EACCES" errors.
// At the same we need to see all errors that take place.
strict: false,
silent: false,
// Preserve root directory name (i.e. 'mibew/')
base: '.'
}
var version = config.package.version;
return eventStream.merge(
gulp.src(sources, srcOptions)
.pipe(zip('mibew-' + version + '.zip')),
gulp.src(sources, srcOptions)
.pipe(tar('mibew-' + version + '.tar'))
.pipe(gzip())
)
.pipe(chmod(644))
.pipe(gulp.dest(config.releasePath));
}));
// Pack translations for release as .zip and .tar.gz archives
gulp.task('pack-i18n', function(callback) {
return getChildDirs(config.i18nPath + '/translations')
.then(function (dirs) {
return Promise.all(dirs.map(function (dir) {
return new Promise(function(resolve, reject) {
var srcOptions = {
base: config.releasePath
};
eventStream.merge(
gulp.src(config.releasePath + '/' + dir
+ '/**/*', srcOptions)
.pipe(zip(config.i18nPrefix + dir
+ config.i18nSuffix + '.zip')),
gulp.src(config.releasePath + '/' + dir
+ '/**/*', srcOptions)
.pipe(tar(config.i18nPrefix + dir
+ config.i18nSuffix + '.tar'))
.pipe(gzip())
)
.pipe(chmod(644))
.pipe(gulp.dest(config.releasePath))
.on('error', reject)
.on('end', resolve);
});
}));
});
});
// Tasks of releasing //////////////////
// Prepare release of Mibew Messenger
gulp.task('prepare-release', function(callback) {
runSequence(
'clean',
['phpcs', 'js', 'chat-styles', 'page-styles', 'generate-pot',
'generate-tmp-po'],
'pack-sources',
'post-pack-cleanup',
callback
);
});
// Prepare releases of translations for Mibew Messenger
gulp.task('prepare-i18n-release', function(callback) {
runSequence( 'clean-tmp-po',
'generate-pos',
'pack-i18n',
'clean-tmp-i18n-files',
callback
);
});
// Mirror prepared releases of Mibew Messenger and its translations in a form
// intended for uploading into the CDN
gulp.task('prepare-for-upload', function(callback) {
gulp.src(config.releasePath + '/mibew-' + config.package.version + '.*')
.pipe(gulp.dest(config.uploadPath + '/core/' + config.package.version + '/'));
gulp.src(config.releasePath + '/mibew-i18n-translation-' + config.package.version + '-*.pot')
.pipe(gulp.dest(config.uploadPath + '/i18n/_pot/' + config.package.version + '/'));
return getChildDirs(config.i18nPath + '/translations')
.then(function (dirs) {
return Promise.all(dirs.map(function (dir) {
return new Promise(function(resolve, reject) {
gulp.src(config.releasePath + '/mibew-i18n-' + dir + '-' + config.package.version + '-*.*')
.pipe(gulp.dest(config.uploadPath + '/i18n/' + dir + '/' + config.package.version + '/'))
.on('error', reject)
.on('end', resolve);
});
}));
});
});
// Perform all preparations before uploading the release of Mibew Messenger and
// its translations into the CDN
gulp.task('prepare-all', function(callback) {
runSequence('clean-all', 'prepare-release', 'prepare-i18n-release',
'prepare-for-upload', callback);
});
// Prepare release archives of the development version of Mibew Messenger
gulp.task('default', function(callback) {
runSequence(
'clean',
['js', 'chat-styles', 'page-styles', 'generate-tmp-po'],
'pack-sources',
['post-pack-cleanup', 'clean-tmp-po'],
callback
);
});
/**
* Loads and prepare js file for a client side application with the specified
* name.
*
* @param {String} name Application name.
* @returns A files stream that can be piped to any gulp plugin.
*/
var getClientSideApp = function(name) {
var appSource = config.jsPath + '/source/' + name;
return gulp.src(appSource + '/**/*.js')
.pipe(order(
[
appSource + '/init.js',
// The following line is equivalent to
// gulp.src([appSource + '/*.js', '!' + appSource + '/app.js']);
appSource + '/!(app).js',
appSource + '/models/**/base*.js',
appSource + '/models/**/*.js',
appSource + '/collections/**/base*.js',
appSource + '/collections/**/*.js',
appSource + '/model_views/**/base*.js',
appSource + '/model_views/**/*.js',
appSource + '/collection_views/**/base*.js',
appSource + '/collection_views/**/*.js',
appSource + '/regions/**/base*.js',
appSource + '/regions/**/*.js',
appSource + '/layouts/**/base*.js',
appSource + '/layouts/**/*.js',
appSource + '/**/base*.js',
// The following line is equivalent to
// gulp.src([appSource + '/**/*.js', '!' + appSource + '/app.js']);
'!' + appSource + '/app.js',
appSource + '/app.js'
],
{base: process.cwd()}
))
.pipe(concat(name + '_app.js'));
}
/**
* Wraps a handlebars template with a function and attach it to the
* Handlebars.templates object.
*
* @returns {Function} A function that can be used in pipe() method of a file
* stream right after gulp-handlebars plugin.
*/
var wrapHandlebarsTemplate = function() {
return defineModule('plain', {
wrapper: '(function() {\n'
+ 'var templates = Handlebars.templates = Handlebars.templates || {};\n'
+ 'Handlebars.templates["<%= relative %>"] = <%= handlebars %>;\n'
+ '})()',
context: function(context) {
return {relative: context.file.relative.replace(/\.js$/, '').replace(/\\/g, '/')};
}
});
}
/**
* Extracts gettext messages from handlebars templates.
*
* @returns {Function} A function that can be used in pipe() method of a file
* stream.
*/
var xgettextHandlebars = function() {
var helperRegExp = /\{{2}l10n\s*('|")(.*?[^\\])\1.*?\}{2}/g;
return through.obj(function (file, enc, callback) {
var po = new PoFile();
match = false,
contents = file.contents.toString();
while (match = helperRegExp.exec(contents)) {
// Try to find item in the .po file by its name
var item = lodash.find(po.items, function(item) {
return match[2] === item.msgid;
});
var line = contents.substr(0, match.index).split(/\r?\n|\r/g).length;
if (!item) {
// There is no such item, create new one
item = new PoFile.Item();
item.msgid = match[2].replace(/\\'/g, "'").replace(/\\"/g, '"');
po.items.push(item);
}
// Add new reference
item.references.push(file.relative + ':' + line);
}
// Update file contents
file.contents = Buffer.from(po.toString());
this.push(file);
callback();
});
}
/**
* Retrieves list of all dirs which are placed in the specified one.
*
* @param {String} srcDir A dir to search.
* @returns Promise A promise which will be resolved with list of child dirs or
* rejected with the occured error.
*/
var getChildDirs = function(srcDir) {
return (new Promise(function(resolve, reject) {
fs.readdir(srcDir, function (err, files) {
if (err) {
reject(err);
} else {
resolve(files);
}
});
})).then(function (files) {
// Replace all files that are not a directory with nulls.
return Promise.all(files.map(function (file) {
return new Promise(function (resolve, reject) {
fs.lstat(srcDir + '/' + file, function (err, stat) {
if (err) {
reject(err);
} else {
resolve(stat.isDirectory() ? file : null);
}
});
});
}));
}).then(function(dirs) {
// Remove all nulls from the array.
return dirs.filter(function (dir) {
return null !== dir;
});
});
}

@ -1 +0,0 @@
Subproject commit 55868d9973f531c3550575481bde4233cc625b91

View File

@ -1,14 +1,12 @@
# Set default handler for incoming requests
DirectoryIndex index.php
# Disable directory listing # Disable directory listing
Options -Indexes Options -Indexes
# Follow symbolic links in the directory # Follow symbolic links in the directory
Options +FollowSymLinks Options +FollowSymLinks
<IfModule mod_negotiation.c>
# Forbid apache to guess file extensions
Options -MultiViews
</IfModule>
# Disable mod_security for Apache 1.x # Disable mod_security for Apache 1.x
<IfModule mod_security.c> <IfModule mod_security.c>
SecFilterEngine Off SecFilterEngine Off
@ -28,15 +26,12 @@ Options +FollowSymLinks
# Redirect requests to the front controller # Redirect requests to the front controller
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
# Use the front controller as a default handler
DirectoryIndex index.php
RewriteEngine On RewriteEngine On
# Use separate front controller for the system installator # Use separate front controller for the system installator
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^install(/(.*))?$ install.php [QSA,L] RewriteRule ^install(|/(.*))$ install.php [QSA,L]
# Rewrite all other requests for files and directories that do not exist to # Rewrite all other requests for files and directories that do not exist to
# the main front controller # the main front controller
@ -45,20 +40,7 @@ Options +FollowSymLinks
RewriteRule ^(.*)$ index.php [QSA,L] RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule> </IfModule>
<IfModule !mod_rewrite.c>
# There is no mod_rewrite in the system. For the root Mibew Messenger
# directory index_fallback.php should be loaded first to activate
# old-fashioned URLs. For all other directories index.php is just a
# directory index file.
DirectoryIndex index_fallback.php index.php
</IfModule>
# Deny access to internal system files # Deny access to internal system files
<FilesMatch "\.(yml|po|ini|handlebars|keep)$"> <FilesMatch "\.(yml|po|ini|handlebars|keep)$">
Deny from all Deny from all
</FilesMatch> </FilesMatch>
# Deny access to CLI cron worker from the outside
<Files "cron.php">
Deny from all
</Files>

View File

@ -1,19 +1,17 @@
Mibew Messenger Mibew Messenger
Copyright 2005-2023 the original author or authors. Copyright 2005-2014 the original author or authors.
REQUIREMENTS REQUIREMENTS
* Apache web server 1.3.34 or above with the ability to use local .htaccess * Apache web server 1.3.34 or above
files (mod_rewrite module is optional, but recommended)
* MySQL database 5.0 or above * MySQL database 5.0 or above
* PHP 7.2.5 or above with PDO, pdo_mysql, cURL, mbstring and gd extensions * PHP 5.3.3 or above with MySQL support
INSTALLATION INSTALLATION
1. Create folder with name 'mibew' in the root of your website. 1. Create folder with name 'mibew' in the root of your website.
2. Upload all the files contained in this archive (retaining the directory 2. Upload all the files contained in this archive (retaining the directory structure) into created folder.
structure) into created folder. Be sure to chmod the mibew folder to 755.
Be sure to chmod the mibew folder to 0755.
3. Add a MySQL database with the name 'mibew' 3. Add a MySQL database with the name 'mibew'
4. Copy /mibew/configs/default_config.yml to /mibew/configs/config.yml 4. Copy /mibew/configs/default_config.yml to /mibew/configs/config.yml
5. Edit /mibew/configs/config.yml to the information needed to connect to the database 5. Edit /mibew/configs/config.yml to the information needed to connect to the database
@ -24,33 +22,10 @@ INSTALLATION
user: admin user: admin
password: <your password> password: <your password>
9. Get button code and setup it on your site. 9. Get button code and setup it on your site.
10. Configure periodically running tasks by setting up an automated 10. Change your name.
process to visit the page http://<yourdomain>/cron?cron_key=<key> 11. Wait for your visitors on 'Pending users' page.
The full URL including the secret "cron key" used to protect against
unauthorized access can be seen on the 'General' tab at the 'Settings' page.
11. Change your name.
12. Wait for your visitors on 'Pending users' page.
On unix/linux platforms change the owner of /mibew/files/avatar and
/mibew/cache folders to the user, under which the web server is running
(for instance, www). The owner should have all rights on the folders
/mibew/files/avatar and /mibew/cache
(chmod 0700 /mibew/files/avatar && chmod 0700 /mibew/cache).
UPDATE
1. Backup your actual installation (i.e. code and database).
2. Disable all plugins.
3. Delete all items in your Mibew Messenger directory on the server.
4. Unpack the archive with the official distrubition in that directory.
5. Remove install.php file.
6. Restore configuration (configs/ directory), plugins (plugins/ directory),
(maybe) custom styles (if you have any), (maybe) additional
locales (if you use any), and avatars (files/avatar/ directory) from the
backup you've made at the step 1.
7. Visit http://<yourdomain>/<path to your Mibew Messenger>/update and follow
the instructions to update the database tables (if needed).
8. Enable disabled plugins.
On unix/linux platforms change the owner of /mibew/files/avatar folder
to the user, under which the web server is running (for instance, www).
The owner should have all rights on the folder /mibew/files/avatar
(chmod 700 /mibew/files/avatar).

View File

@ -1 +1 @@
Mibew/3.6.0 Mibew/2.0

View File

View File

@ -72,7 +72,7 @@ thread:
useragent: "varchar(255)" useragent: "varchar(255)"
# Total count of user's messages related with the thread. # Total count of user's messages related with the thread.
messagecount: "varchar(16)" messagecount: "varchar(16)"
# ID of the group at Mibew Messenger side related with the thread. # ID of the group at Mibew side related with the thread.
groupid: "int references {opgroup}(groupid)" groupid: "int references {opgroup}(groupid)"
# Contains "by thread" statistics # Contains "by thread" statistics
@ -104,7 +104,7 @@ requestcallback:
fields: fields:
callbackid: "int NOT NULL auto_increment PRIMARY KEY" callbackid: "int NOT NULL auto_increment PRIMARY KEY"
token: "varchar(64) NOT NULL DEFAULT ''" token: "varchar(64) NOT NULL DEFAULT ''"
func: "varchar(64) NOT NULL" function: "varchar(64) NOT NULL"
arguments: "varchar(1024)" arguments: "varchar(1024)"
indexes: indexes:
token: [token] token: [token]
@ -129,23 +129,12 @@ translation:
# Contains locales info # Contains locales info
locale: locale:
fields: fields:
# Artificial primary key. # Artificial primary key
localeid: "int NOT NULL auto_increment PRIMARY KEY" localeid: "int NOT NULL auto_increment PRIMARY KEY"
# Locale code # Locale code
code: "varchar(5) NOT NULL" code: "varchar(5) NOT NULL"
# Human readable name of the locale. # Indicates if a locale is enabled or not.
name: "varchar(128) NOT NULL DEFAULT ''"
# Indicates if the locale is enabled or not.
enabled: "tinyint NOT NULL DEFAULT 0" enabled: "tinyint NOT NULL DEFAULT 0"
# Indicates if the locale uses RTL writing.
rtl: "tinyint NOT NULL DEFAULT 0"
# Name of the locale which is used with PHP's setlocale to format dates.
time_locale: "varchar(128) NOT NULL DEFAULT 'en_US'"
# Serialized array of various date formats.
date_format: "text"
unique_keys:
# Make sure locale code can be duplicated
code: [code]
# Contains localized mail templates # Contains localized mail templates
mailtemplate: mailtemplate:
@ -201,6 +190,7 @@ operator:
istatus: "int DEFAULT 0" istatus: "int DEFAULT 0"
idisabled: "int DEFAULT 0" idisabled: "int DEFAULT 0"
vcavatar: "varchar(255)" vcavatar: "varchar(255)"
vcjabbername: "varchar(255)"
# Operators privileges bitmask. # Operators privileges bitmask.
iperm: "int DEFAULT 0" iperm: "int DEFAULT 0"
dtmrestore: "int NOT NULL DEFAULT 0" dtmrestore: "int NOT NULL DEFAULT 0"
@ -226,7 +216,7 @@ operatorstatistics:
revision: revision:
fields: fields:
id: "INT NOT NULL PRIMARY KEY" id: "INT NOT NULL"
# Contains relations between operators and groups # Contains relations between operators and groups
operatortoopgroup: operatortoopgroup:
@ -245,6 +235,7 @@ ban:
dtmtill: "int NOT NULL DEFAULT 0" dtmtill: "int NOT NULL DEFAULT 0"
address: "varchar(255)" address: "varchar(255)"
comment: "varchar(255)" comment: "varchar(255)"
blockedcount: "int DEFAULT 0"
# Contains dynamic configs # Contains dynamic configs
config: config:
@ -300,37 +291,3 @@ visitedpagestatistics:
acceptedinvitations: "int NOT NULL DEFAULT 0" acceptedinvitations: "int NOT NULL DEFAULT 0"
rejectedinvitations: "int NOT NULL DEFAULT 0" rejectedinvitations: "int NOT NULL DEFAULT 0"
ignoredinvitations: "int NOT NULL DEFAULT 0" ignoredinvitations: "int NOT NULL DEFAULT 0"
# Contains info about installed plugins
plugin:
fields:
# Artificial ID
id: "INT NOT NULL auto_increment PRIMARY KEY"
# Plugin name in "<Vendor>:<Name>" format.
name: "varchar(255) NOT NULL"
# Installed version of the plugin.
version: "varchar(255) NOT NULL"
# Indicates if the plugin is installed or not.
installed: "tinyint NOT NULL DEFAULT 0"
# Indicates if the plugin is enabled or not.
enabled: "tinyint NOT NULL DEFAULT 0"
# Indicates if the plugin is initialized or not.
initialized: "tinyint NOT NULL DEFAULT 0"
unique_keys:
name: [name]
# Contains info about all available updates
availableupdate:
fields:
# Artificial ID
id: "INT NOT NULL auto_increment PRIMARY KEY"
# Can be either "core" or fully qualified plugin's name
target: "varchar(255) NOT NULL"
# The latest available version of the plugin
version: "varchar(255) NOT NULL"
# A URL where the new version can be downloaded
url: "text"
# Description of the update
description: "text"
unique_keys:
target: [target]

View File

@ -1,5 +1,5 @@
# IMPORTANT: Before install Mibew Messenger copy this file to config.yml and # IMPORTANT: Before install mibew copy this file to config.yml and fill it with
# fill it with your own settings! # your own settings!
# MySQL Database parameters # MySQL Database parameters
@ -12,87 +12,26 @@ database:
tables_prefix: "" tables_prefix: ""
use_persistent_connection: false use_persistent_connection: false
# Mail # Mailbox
## This value will be used as sender address in all e-mails Mibew Messenger send.
mailbox: mibew@yourdomain.com mailbox: mibew@yourdomain.com
## Mailer parameters
mailer:
# This value determines what kind of mailer will be used. Possible values
# are "mail" and "smtp".
#
# To use standard PHP mail function just set this option to "mail". No
# additional configs are required in this case.
#
# To use SMTP-based solution set this option "smtp". This approach require
# some extra configuration to be done (see below).
transport: mail
# The lines below represents default SMTP mailer configurations. They will
# be used only if the "transport" option is set to "smtp".
host: localhost
port: 25
user: user
pass: ""
# The following option determines what kind of encryption should be used.
# false means no encyption at all. Another values once can use are "ssl" and
# "tls".
encryption: false
# Cache subsystem
cache:
# This value determines where the cached data will be stored. Possible
# values are "none", "file_system" and "memcached".
#
# If "none" is used the caching will be disabled. This option should be used
# only if none of the other options works.
#
# If "file_system" is used the cached data will be stored in files within
# the "cache/" directory. Notice, that the file system storage does not work
# on NFS systems bucause exclusive file locks are not supported where.
#
# If "memcached" is used the cached data will be stored in Memcached
# storage. Before using this kind of storage make sure PHP's memcached
# extension is installed and enabled.
storage: file_system
# The lines below represents default Memcached server configurations. They
# will be used only if the "storage" option is set to "memcached".
memcached_servers:
- host: localhost
port: 11211
# The "weight" field is optional and can be omitted and it's only positive int number.
weight: 1
# Actually, one can use any number of memcached servers he wants. Just
# add servers description like the one above.
# Locales # Locales
## Native name will be used in this locale ## Native name will be used in this locale
home_locale: en home_locale: en
## If user does not provide known lang ## If user does not provide known lang
default_locale: en default_locale: en
# A timezone to use. Leave this value empty to use the default timezone from the
# system settings. For the details about available timezones see
# http://php.net/manual/en/timezones.php
timezone: ""
# List of proxy's IP Mibew Messenger should trust. You should set this option
# if you use Mibew Messenger with a load balancer or behind a proxy.
trusted_proxies: []
# Here is an example of what values this option can take:
# trusted_proxies:
# - 127.0.0.1
# - ::1
# - 10.0.0.0/8
# Plugins # Plugins
plugins: [] plugins: []
## Example of plugins configuration ## Exapmle of plugins configuration
# plugins: # plugins:
# "VendorName:PluginName": # -
# weight: 100 # name: "VendorName:PluginName"
# some_configurable_value: value # config:
# "VendorName:AnotherPluginName": # weight: 100
# very_important_value: "$3.50" # some_configurable_value: value
# -
# name: "VendorName:AnotherPluginName"
# config:
# very_important_value: "$3.50"

View File

@ -49,14 +49,6 @@ chat_user:
thread_id: \d{1,10} thread_id: \d{1,10}
token: \d{1,10} token: \d{1,10}
chat_user_check:
path: /chat/{thread_id}/{token}/check
defaults:
_controller: Mibew\Controller\Chat\UserChatController::checkAction
requirements:
thread_id: \d{1,10}
token: \d{1,10}
chat_user_invitation: chat_user_invitation:
path: /chat/invitation path: /chat/invitation
defaults: defaults:
@ -80,33 +72,11 @@ chat_user_mail_send:
token: \d{1,10} token: \d{1,10}
methods: [POST] methods: [POST]
chat_user_popup_style:
path: /chat/style/popup/{style}
defaults:
_controller: Mibew\Controller\Chat\StyleController::loadPopupStyleAction
style: ""
requirements:
style: "[0-9A-Za-z_]*"
chat_user_popup_style_force_secure:
path: /chat/style/popup/{style}/force_secure
defaults:
_controller: Mibew\Controller\Chat\StyleController::loadPopupStyleAction
style: ""
force_secure: on
requirements:
style: "[0-9A-Za-z_]*"
chat_user_start: chat_user_start:
path: /chat path: /chat
defaults: defaults:
_controller: Mibew\Controller\Chat\UserChatController::startAction _controller: Mibew\Controller\Chat\UserChatController::startAction
chat_user_cookie_set_permission:
path: /chat/cookies-set-permission
defaults:
_controller: Mibew\Controller\Chat\UserChatController::cookieSetPermissionAction
# Pages that are available for all users # Pages that are available for all users
button: button:
path: /b path: /b
@ -120,12 +90,9 @@ cron:
path: /cron path: /cron
defaults: { _controller: Mibew\Controller\CronController::runAction } defaults: { _controller: Mibew\Controller\CronController::runAction }
# A set of localization constants for the client side applications is generated license:
# dynamically path: /license
js_translation: defaults: { _controller: Mibew\Controller\LicenseController::indexAction }
path: /locales/{locale}/translation.js
defaults:
_controller: Mibew\Controller\Localization\JsTranslationController::indexAction
widget_gateway: widget_gateway:
path: /widget path: /widget
@ -133,13 +100,6 @@ widget_gateway:
# Operators' pages # Operators' pages
## About page
about:
path: /operator/about
defaults:
_controller: Mibew\Controller\AboutController::indexAction
_access_check: Mibew\AccessControl\Check\LoggedInCheck
## Banned visitors ## Banned visitors
ban_add: ban_add:
path: /operator/ban/add path: /operator/ban/add
@ -200,24 +160,21 @@ canned_message_add:
path: /operator/canned-message/add path: /operator/canned-message/add
defaults: defaults:
_controller: Mibew\Controller\CannedMessageController::showEditFormAction _controller: Mibew\Controller\CannedMessageController::showEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
_access_permissions: [CAN_ADMINISTRATE]
methods: [GET] methods: [GET]
canned_message_add_save: canned_message_add_save:
path: /operator/canned-message/add path: /operator/canned-message/add
defaults: defaults:
_controller: Mibew\Controller\CannedMessageController::submitEditFormAction _controller: Mibew\Controller\CannedMessageController::submitEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
_access_permissions: [CAN_ADMINISTRATE]
methods: [POST] methods: [POST]
canned_message_delete: canned_message_delete:
path: /operator/canned-message/{message_id}/delete path: /operator/canned-message/{message_id}/delete
defaults: defaults:
_controller: Mibew\Controller\CannedMessageController::deleteAction _controller: Mibew\Controller\CannedMessageController::deleteAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements: requirements:
message_id: \d{1,10} message_id: \d{1,10}
@ -225,8 +182,7 @@ canned_message_edit:
path: /operator/canned-message/{message_id}/edit path: /operator/canned-message/{message_id}/edit
defaults: defaults:
_controller: Mibew\Controller\CannedMessageController::showEditFormAction _controller: Mibew\Controller\CannedMessageController::showEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements: requirements:
message_id: \d{1,10} message_id: \d{1,10}
methods: [GET] methods: [GET]
@ -235,8 +191,7 @@ canned_message_edit_save:
path: /operator/canned-message/{message_id}/edit path: /operator/canned-message/{message_id}/edit
defaults: defaults:
_controller: Mibew\Controller\CannedMessageController::submitEditFormAction _controller: Mibew\Controller\CannedMessageController::submitEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements: requirements:
message_id: \d{1,10} message_id: \d{1,10}
methods: [POST] methods: [POST]
@ -245,8 +200,7 @@ canned_messages:
path: /operator/canned-message path: /operator/canned-message
defaults: defaults:
_controller: Mibew\Controller\CannedMessageController::indexAction _controller: Mibew\Controller\CannedMessageController::indexAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
_access_permissions: [CAN_ADMINISTRATE]
## Groups ## Groups
group_add: group_add:
@ -377,27 +331,7 @@ locale_disable:
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE] _access_permissions: [CAN_ADMINISTRATE]
requirements: requirements:
locale: "[a-z\\-]{2,5}" locale: "[a-z\-]{2,5}"
locale_edit:
path: /operator/locale/{locale}/edit
defaults:
_controller: Mibew\Controller\Localization\LocaleController::showEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements:
locale: "[a-z\\-]{2,5}"
methods: [GET]
locale_edit_save:
path: /operator/locale/{locale}/edit
defaults:
_controller: Mibew\Controller\Localization\LocaleController::submitEditFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
requirements:
locale: "[a-z\\-]{2,5}"
methods: [POST]
locale_enable: locale_enable:
path: /operator/locale/{locale}/enable path: /operator/locale/{locale}/enable
@ -406,7 +340,7 @@ locale_enable:
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE] _access_permissions: [CAN_ADMINISTRATE]
requirements: requirements:
locale: "[a-z\\-]{2,5}" locale: "[a-z\-]{2,5}"
locales: locales:
path: /operator/locale path: /operator/locale
@ -607,42 +541,6 @@ password_recovery_reset:
defaults: defaults:
_controller: Mibew\Controller\PasswordRecoveryController::resetAction _controller: Mibew\Controller\PasswordRecoveryController::resetAction
## Plugins
plugin_enable:
path: /operator/plugin/{plugin_name}/enable
defaults:
_controller: Mibew\Controller\PluginController::enableAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
plugin_disable:
path: /operator/plugin/{plugin_name}/disable
defaults:
_controller: Mibew\Controller\PluginController::disableAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
plugin_uninstall:
path: /operator/plugin/{plugin_name}/uninstall
defaults:
_controller: Mibew\Controller\PluginController::uninstallAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
plugin_update:
path: /operator/plugin/{plugin_name}/update
defaults:
_controller: Mibew\Controller\PluginController::updateAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
plugins:
path: /operator/plugin
defaults:
_controller: Mibew\Controller\PluginController::indexAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
## Settings ## Settings
settings_common: settings_common:
path: /operator/settings path: /operator/settings
@ -698,8 +596,7 @@ statistics:
defaults: defaults:
type: "by-date" type: "by-date"
_controller: Mibew\Controller\StatisticsController::indexAction _controller: Mibew\Controller\StatisticsController::indexAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
_access_permissions: [CAN_VIEWSTATISTICS]
requirements: requirements:
type: by-date|by-operator|by-page type: by-date|by-operator|by-page
@ -721,7 +618,7 @@ translation_edit:
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE] _access_permissions: [CAN_ADMINISTRATE]
requirements: requirements:
string_id: "\\d{1,10}" string_id: "\d{1,10}"
methods: [GET] methods: [GET]
translation_edit_save: translation_edit_save:
@ -731,23 +628,7 @@ translation_edit_save:
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE] _access_permissions: [CAN_ADMINISTRATE]
requirements: requirements:
string_id: "\\d{1,10}" string_id: "\d{1,10}"
methods: [POST]
translation_export:
path: /operator/translation/export
defaults:
_controller: Mibew\Controller\Localization\TranslationExportController::showFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
methods: [GET]
translation_export_process:
path: /operator/translation/export
defaults:
_controller: Mibew\Controller\Localization\TranslationExportController::submitFormAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
methods: [POST] methods: [POST]
translation_import: translation_import:
@ -774,26 +655,11 @@ translations:
_access_permissions: [CAN_ADMINISTRATE] _access_permissions: [CAN_ADMINISTRATE]
## Updates ## Updates
update: updates:
path: /update path: /operator/updates
defaults: defaults:
_controller: Mibew\Controller\UpdateController::indexAction _controller: Mibew\Controller\UpdatesController::indexAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
_access_permissions: [CAN_ADMINISTRATE]
update_run:
path: /update/run
defaults:
_controller: Mibew\Controller\UpdateController::runUpdateAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
update_check:
path: /update/check
defaults:
_controller: Mibew\Controller\UpdateController::checkUpdatesAction
_access_check: Mibew\AccessControl\Check\PermissionsCheck
_access_permissions: [CAN_ADMINISTRATE]
## Users (visitors avaiting page) ## Users (visitors avaiting page)
users: users:
@ -808,17 +674,7 @@ users_update:
_controller: Mibew\Controller\UsersController::updateAction _controller: Mibew\Controller\UsersController::updateAction
_access_check: Mibew\AccessControl\Check\LoggedInCheck _access_check: Mibew\AccessControl\Check\LoggedInCheck
# System routes and includes # Remove trailing slashe. This route is the last one because previous rotes can
# The following route is a fake and is used only to load plugins routes. It can
# have any unique name.
_include_pluign_routes:
# Resource name has no meaning and can be any value.
resource: .
# The type actually indicates that plugins routes should be included.
type: plugin
# Remove trailing slashes. This route is the last one because previous rotes can
# (but definitely should not) have trailing slashes. # (but definitely should not) have trailing slashes.
remove_trailing_slash: remove_trailing_slash:
path: /{url} path: /{url}

View File

@ -1,16 +1,3 @@
# The following route is a fake and is used only to load routes of the core. It
# can have any unique name.
_include_core_routes:
resource: routing.yml
type: yaml
# Override the home route to allow users use <mibew root>/install.php path to
# the installer.
home:
path: /
defaults:
_controller: Mibew\Controller\InstallController::indexAction
install: install:
path: /install path: /install
defaults: defaults:

View File

@ -1,52 +0,0 @@
<?php
/*
* This file is a part of Mibew Messenger.
*
* Copyright 2005-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Initialize libraries
require_once(dirname(__FILE__) . '/libs/init.php');
use Mibew\Cache\CacheFactory;
use Mibew\Maintenance\CronWorker;
use Mibew\Plugin\PluginManager;
$configs = load_system_configs();
// Prepare the cache. It is initialized in the same way as in index.php
$cache_factory = new CacheFactory($configs['cache']);
// For now directory for cache files cannot be changed via the configs file.
$cache_factory->setOption('path', MIBEW_FS_ROOT . '/cache/stash');
// Run plugins
if (get_maintenance_mode() === false) {
$plugin_manager = PluginManager::getInstance();
$plugin_manager->setCache($cache_factory->getCache());
$plugin_manager->loadPlugins($configs['plugins']);
}
// Do the job.
$worker = new CronWorker($cache_factory->getCache());
$success = $worker->run();
if ($success) {
echo("All cron jobs done\n");
} else {
echo("Cron job failed. Here are the errors:\n");
foreach ($worker->getErrors() as $error) {
echo(' ' . $error . "\n");
}
}

View File

@ -1,8 +1,6 @@
<?php <?php
/* /*
* This file is a part of Mibew Messenger. * Copyright 2005-2014 the original author or authors.
*
* Copyright 2005-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,53 +20,24 @@ require_once(dirname(__FILE__) . '/libs/init.php');
use Mibew\Application; use Mibew\Application;
use Mibew\Authentication\AuthenticationManager; use Mibew\Authentication\AuthenticationManager;
use Mibew\Cache\CacheFactory; use Mibew\Routing\RouteCollectionLoader;
use Mibew\Mail\MailerFactory;
use Mibew\Plugin\PluginManager;
use Mibew\Routing\Router; use Mibew\Routing\Router;
use Mibew\Routing\Loader\CacheLoader;
use Mibew\Routing\Loader\PluginLoader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Loader\YamlFileLoader; use Symfony\Component\Config\FileLocator;
$configs = load_system_configs(); $file_locator = new FileLocator(array(MIBEW_FS_ROOT));
$router = new Router(new RouteCollectionLoader($file_locator));
// Prepare the cache $router->setOption(
$cache_factory = new CacheFactory($configs['cache']); 'route_collection',
// For now directory for cache files cannot be changed via the configs file. RouteCollectionLoader::ROUTES_CORE | RouteCollectionLoader::ROUTES_PLUGINS
// TODO: Evaluate possibility of using custom cache directory. );
$cache_factory->setOption('path', MIBEW_FS_ROOT . '/cache/stash');
// Run plugins
if (get_maintenance_mode() === false) {
$plugin_manager = PluginManager::getInstance();
$plugin_manager->setCache($cache_factory->getCache());
$plugin_manager->loadPlugins($configs['plugins']);
}
// The main route loader which loads nothig but works as a cache proxy for other
// loaders.
$route_loader = new CacheLoader($cache_factory->getCache());
// Real loaders are attached via the resolver.
$loader_resolver = new LoaderResolver(array(
$route_loader,
new YamlFileLoader(new FileLocator(array(MIBEW_FS_ROOT))),
new PluginLoader(),
));
$router = new Router($route_loader, 'configs/routing.yml');
$application = new Application($router, new AuthenticationManager()); $application = new Application($router, new AuthenticationManager());
$application->setCache($cache_factory->getCache());
// Use custom config-dependent mailer factory
$application->setMailerFactory(new MailerFactory($configs['mailer']));
// Process request // Process request
$request = Request::createFromGlobals(); $request = Request::createFromGlobals();
$response = $application->handleRequest($request); $response = $application->handleRequest($request);
// Send response to the user // Send response to the user
$response->prepare($request);
$response->send(); $response->send();

View File

@ -1,23 +0,0 @@
<?php
/*
* This file is a part of Mibew Messenger.
*
* Copyright 2005-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Force the user to specify the entry point. This should be done only when
// mod_rewrite is not used by apache.
header('HTTP/1.0 301 Moved Permanently');
header('Location: index.php');

View File

@ -1,8 +1,6 @@
<?php <?php
/* /*
* This file is a part of Mibew Messenger. * Copyright 2005-2014 the original author or authors.
*
* Copyright 2005-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,28 +15,24 @@
* limitations under the License. * limitations under the License.
*/ */
define('MAINTENANCE_MODE', 'install'); define('INSTALLATION_IN_PROGRESS', true);
// Initialize libraries // Initialize libraries
require_once(dirname(__FILE__) . '/libs/init.php'); require_once(dirname(__FILE__) . '/libs/init.php');
use Mibew\Application; use Mibew\Application;
use Mibew\Authentication\DummyAuthenticationManager; use Mibew\Authentication\DummyAuthenticationManager;
use Mibew\Routing\Loader\DummyPluginLoader; use Mibew\Routing\RouteCollectionLoader;
use Mibew\Routing\Router; use Mibew\Routing\Router;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Loader\YamlFileLoader; use Symfony\Component\Config\FileLocator;
// Prepare router
$file_locator = new FileLocator(array(MIBEW_FS_ROOT)); $file_locator = new FileLocator(array(MIBEW_FS_ROOT));
$route_loader = new YamlFileLoader($file_locator); $router = new Router(new RouteCollectionLoader($file_locator));
$loader_resolver = new LoaderResolver(array( $router->setOption(
$route_loader, 'route_collection',
new DummyPluginLoader(), RouteCollectionLoader::ROUTES_CORE | RouteCollectionLoader::ROUTES_INSTALLATION
)); );
$router = new Router($route_loader, 'configs/routing_install.yml');
$application = new Application($router, new DummyAuthenticationManager()); $application = new Application($router, new DummyAuthenticationManager());
@ -47,4 +41,5 @@ $request = Request::createFromGlobals();
$response = $application->handleRequest($request); $response = $application->handleRequest($request);
// Send response to the user // Send response to the user
$response->prepare($request);
$response->send(); $response->send();

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
var myAgent="",myVer=0,myRealAgent="";function detectAgent(){for(var a="opera msie safari firefox netscape mozilla".split(" "),d=navigator.userAgent.toLowerCase(),b=0;b<a.length;b++){var c=a[b];if(-1!=d.indexOf(c)){myAgent=c;if(!window.RegExp)break;null!=RegExp(c+"[ /]?([0-9]+(.[0-9]+)?)").exec(d)&&(myVer=parseFloat(RegExp.$1));break}}myRealAgent=myAgent;"Gecko"==navigator.product&&(myAgent="moz")}detectAgent();function getEl(a){return document.getElementById(a)};

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d){var c=b.Application;c.addRegions({mainRegion:"#main-region"});c.addInitializer(function(a){b.PluginOptions=a.plugins||{};b.Objects.server=new b.Server(d.extend({interactionType:MibewAPIChatInteraction},a.server));b.Objects.Models.page=new b.Models.Page(a.page);switch(a.startFrom){case "chat":c.Chat.start(a.chatOptions);break;case "survey":c.Survey.start(a.surveyOptions);break;case "leaveMessage":c.LeaveMessage.start(a.leaveMessageOptions);break;case "invitation":c.Invitation.start(a.invitationOptions);
break;default:throw Error("Dont know how to start!");}});c.on("start",function(){b.Objects.server.runUpdater()})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Views.MessagesCollection=a.Views.CollectionBase.extend({itemView:a.Views.Message,className:"messages-collection"})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Views.StatusCollection=a.Views.CollectionBase.extend({itemView:a.Views.Status,className:"status-collection"})})(Mibew);

View File

@ -0,0 +1,10 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,j){b.Collections.Messages=d.Collection.extend({model:b.Models.Message,initialize:function(){this.periodicallyCalled=[];this.periodicallyCalled.push(b.Objects.server.callFunctionsPeriodically(j.bind(this.updateMessagesFunctionBuilder,this),j.bind(this.updateMessages,this)))},finalize:function(){for(var a=0;a<this.periodicallyCalled.length;a++)b.Objects.server.stopCallFunctionsPeriodically(this.periodicallyCalled[a])},updateMessages:function(a){a.lastId&&b.Objects.Models.thread.set({lastId:a.lastId});
for(var k=b.Models.Message.prototype.KIND_PLUGIN,g=[],c,f,e,h=0,d=a.messages.length;h<d;h++)c=a.messages[h],c.kind!=k?g.push(new b.Models.Message(c)):"object"!=typeof c.data||null===c.data||(f=c.plugin||!1,f="process:"+(!1!==f?f+":":"")+"plugin:message",e={messageData:c,model:!1},this.trigger(f,e),e.model&&(e.model.get("id")||e.model.set({id:c.id}),g.push(e.model)));0<g.length&&this.add(g)},updateMessagesFunctionBuilder:function(){var a=b.Objects.Models.thread,d=b.Objects.Models.user;return[{"function":"updateMessages",
arguments:{"return":{messages:"messages",lastId:"lastId"},references:{},threadId:a.get("id"),token:a.get("token"),lastId:a.get("lastId"),user:!d.get("isAgent")}}]},add:function(){var a=Array.prototype.slice.apply(arguments),a=d.Collection.prototype.add.apply(this,a);this.trigger("multiple:add");return a}})})(Mibew,Backbone,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Collections.Status=b.Collection.extend({comparator:function(a){return a.get("weight")}})})(Mibew,Backbone);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Regions={};a.Layouts={};a.Application=new Backbone.Marionette.Application})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,c){a.Layouts.Chat=c.Marionette.Layout.extend({template:Handlebars.templates.chat_layout,regions:{controlsRegion:"#controls-region",avatarRegion:"#avatar-region",messagesRegion:{selector:"#messages-region",regionType:a.Regions.Messages},statusRegion:"#status-region",messageFormRegion:"#message-form-region"},serializeData:function(){var b=a.Objects.Models;return{page:b.page.toJSON(),user:b.user.toJSON()}}})})(Mibew,Backbone);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Layouts.Invitation=b.Marionette.Layout.extend({template:Handlebars.templates.invitation_layout,regions:{messagesRegion:{selector:"#invitation-messages-region",regionType:a.Regions.Messages}}})})(Mibew,Backbone);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Layouts.LeaveMessage=b.Marionette.Layout.extend({template:Handlebars.templates.leave_message_layout,regions:{leaveMessageFormRegion:"#content-wrapper",descriptionRegion:"#description-region"},serializeData:function(){return{page:a.Objects.Models.page.toJSON()}}})})(Mibew,Backbone);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Layouts.Survey=b.Marionette.Layout.extend({template:Handlebars.templates.survey_layout,regions:{surveyFormRegion:"#content-wrapper"},serializeData:function(){return{page:a.Objects.Models.page.toJSON()}}})})(Mibew,Backbone);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
MibewAPIChatInteraction=function(){this.mandatoryArguments=function(){return{"*":{threadId:null,token:null,"return":{},references:{}},result:{errorCode:0}}};this.getReservedFunctionsNames=function(){return["result"]}};MibewAPIChatInteraction.prototype=new MibewAPIInteraction;

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.Avatar=b.Marionette.ItemView.extend({template:c.templates.chat_avatar,className:"avatar",modelEvents:{change:"render"}})})(Mibew,Backbone,Handlebars);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,c,d){a.Views.CloseControl=a.Views.Control.extend({template:c.templates.chat_controls_close,events:d.extend({},a.Views.Control.prototype.events,{click:"closeThread"}),closeThread:function(){var b=a.Localization.get("Are you sure want to leave chat?");(!1===b||confirm(b))&&this.model.closeThread()}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,e){b.Views.HistoryControl=b.Views.Control.extend({template:d.templates.chat_controls_history,events:e.extend({},b.Views.Control.prototype.events,{click:"showHistory"}),showHistory:function(){var c=b.Objects.Models.user,a=this.model.get("link");c.get("isAgent")&&a&&(c=this.model.get("windowParams"),a=a.replace("&amp;","&","g"),a=window.open(a,"UserHistory",c),null!==a&&(a.focus(),a.opener=window))}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,e,f){b.Views.RedirectControl=b.Views.Control.extend({template:e.templates.chat_controls_redirect,events:f.extend({},b.Views.Control.prototype.events,{click:"redirect"}),initialize:function(){b.Objects.Models.user.on("change",this.render,this)},serializeData:function(){var a=this.model.toJSON();a.user=b.Objects.Models.user.toJSON();return a},redirect:function(){var a=b.Objects.Models.user;if(a.get("isAgent")&&a.get("canPost")&&(a=this.model.get("link"))){var c=b.Objects.Models.page.get("style"),
d="";c&&(d=(-1===a.indexOf("?")?"?":"&")+"style="+c);window.location.href=a.replace(/\&amp\;/g,"&")+d}}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.RefreshControl=a.Views.Control.extend({template:b.templates.chat_controls_refresh,events:c.extend({},a.Views.Control.prototype.events,{click:"refresh"}),refresh:function(){this.model.refresh()}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,d,e){a.Views.SecureModeControl=a.Views.Control.extend({template:d.templates.chat_controls_secure_mode,events:e.extend({},a.Views.Control.prototype.events,{click:"secure"}),secure:function(){var b=this.model.get("link");if(b){var c=a.Objects.Models.page.get("style");window.location.href=b.replace(/\&amp\;/g,"&")+(c?"&style="+c:"")}}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,f){b.Views.SendMailControl=b.Views.Control.extend({template:d.templates.chat_controls_send_mail,events:f.extend({},b.Views.Control.prototype.events,{click:"sendMail"}),sendMail:function(){var a=this.model.get("link"),c=b.Objects.Models.page;if(a){var d=this.model.get("windowParams"),c=c.get("style"),e="";c&&(e=(-1===a.indexOf("?")?"?":"&")+"style="+c);a=a.replace(/\&amp\;/g,"&")+e;a=window.open(a,"ForwardMail",d);null!==a&&(a.focus(),a.opener=window)}}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.SoundControl=a.Views.Control.extend({template:b.templates.chat_controls_sound,events:c.extend({},a.Views.Control.prototype.events,{click:"toggle"}),toggle:function(){this.model.toggle()}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,c,d){b.Views.UserNameControl=b.Views.Control.extend({template:c.templates.chat_controls_user_name,events:d.extend({},b.Views.Control.prototype.events,{"click .user-name-control-set":"changeName","click .user-name-control-change":"showNameInput","keydown #user-name-control-input":"inputKeyDown"}),ui:{nameInput:"#user-name-control-input"},initialize:function(){b.Objects.Models.user.on("change:name",this.hideNameInput,this);this.nameInput=b.Objects.Models.user.get("defaultName")},serializeData:function(){var a=
this.model.toJSON();a.user=b.Objects.Models.user.toJSON();a.nameInput=this.nameInput;return a},inputKeyDown:function(a){a=a.which;(13==a||10==a)&&this.changeName()},hideNameInput:function(){this.nameInput=!1;this.render()},showNameInput:function(){this.nameInput=!0;this.render()},changeName:function(){var a=this.ui.nameInput.val();this.model.changeName(a)}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.LeaveMessageDescription=b.Marionette.ItemView.extend({template:c.templates.leave_message_description,serializeData:function(){return{page:a.Objects.Models.page.toJSON()}}})})(Mibew,Backbone,Handlebars);

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(d,e,b){var c=d.Views.BaseSurveyForm;d.Views.LeaveMessageForm=c.extend({template:e.templates.leave_message_form,events:b.extend({},c.prototype.events,{"click #send-message":"submitForm"}),ui:b.extend({},c.prototype.ui,{captcha:'input[name="captcha"]',captchaImg:"#captcha-img"}),modelEvents:b.extend({},c.prototype.modelEvents,{"submit:error":"hideAjaxLoader showError submitError"}),submitForm:function(){this.showAjaxLoader();var a={};this.model.get("groups")&&(a.groupId=this.ui.groupSelect.val());
a.name=this.ui.name.val()||"";a.email=this.ui.email.val()||"";a.message=this.ui.message.val()||"";this.model.get("showCaptcha")&&(a.captcha=this.ui.captcha.val()||"");this.model.set(a,{validate:!0});this.model.submit()},submitError:function(a,c){if(c.code==a.ERROR_WRONG_CAPTCHA&&a.get("showCaptcha")){var b=this.ui.captchaImg.attr("src"),b=b.replace(/\?d\=[0-9]+/,"");this.ui.captchaImg.attr("src",b+"?d="+(new Date).getTime())}}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.LeaveMessageSentDescription=b.Marionette.ItemView.extend({template:c.templates.leave_message_sent_description,serializeData:function(){return{page:a.Objects.Models.page.toJSON()}}})})(Mibew,Backbone,Handlebars);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Views.Message=a.Views.Message.extend({template:b.templates.chat_message})})(Mibew,Handlebars);

View File

@ -0,0 +1,11 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,e){b.Views.MessageForm=d.Marionette.ItemView.extend({template:e.templates.chat_message_form,events:{"click #send-message":"postMessage","keydown #message-input":"messageKeyDown","keyup #message-input":"checkUserTyping","change #message-input":"checkUserTyping","change #predefined":"selectPredefinedAnswer","focus #message-input":"setFocus","blur #message-input":"dropFocus"},modelEvents:{change:"render"},ui:{message:"#message-input",send:"#send-message",predefinedAnswer:"#predefined"},
initialize:function(){b.Objects.Models.user.on("change:canPost",this.render,this)},serializeData:function(){var a=this.model.toJSON();a.user=b.Objects.Models.user.toJSON();return a},postMessage:function(){var a=this.ui.message.val();""!=a&&(this.disableInput(),this.model.postMessage(a));b.Objects.Collections.messages.on("multiple:add",this.postMessageComplete,this)},messageKeyDown:function(a){var c=a.which;a=a.ctrlKey;(13==c&&(a||this.model.get("ignoreCtrl"))||10==c)&&this.postMessage()},enableInput:function(){this.ui.message.removeAttr("disabled")},
disableInput:function(){this.ui.message.attr("disabled","disabled")},clearInput:function(){this.ui.message.val("").change()},postMessageComplete:function(){this.clearInput();this.enableInput();this.focused&&this.ui.focus();b.Objects.Collections.messages.off("multiple:add",this.postMessageComplete,this)},selectPredefinedAnswer:function(){var a=this.ui.message,c=this.ui.predefinedAnswer,b=c.get(0).selectedIndex;b&&(a.val(this.model.get("predefinedAnswers")[b-1].full).change(),a.focus(),c.get(0).selectedIndex=
0)},checkUserTyping:function(){var a=b.Objects.Models.user,c=""!=this.ui.message.val();c!=a.get("typing")&&a.set({typing:c})},setFocus:function(){this.focused=!0},dropFocus:function(){this.focused=!1}})})(Mibew,Backbone,Handlebars);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.Status=b.Marionette.ItemView.extend({template:c.templates.chat_status_base,className:"status",modelEvents:{change:"render"},onBeforeRender:function(){this.model.get("visible")?this.$el.show():this.$el.hide()}})})(Mibew,Backbone,Handlebars);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Views.StatusMessage=a.Views.Status.extend({template:b.templates.chat_status_message})})(Mibew,Handlebars);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Views.StatusTyping=a.Views.Status.extend({template:b.templates.chat_status_typing})})(Mibew,Handlebars);

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(c,d){c.Views.BaseSurveyForm=d.Marionette.ItemView.extend({events:{'change select[name="group"]':"changeGroupDescription","submit form":"preventSubmit"},ui:{groupSelect:'select[name="group"]',groupDescription:"#groupDescription",name:'input[name="name"]',email:'input[name="email"]',message:'textarea[name="message"]',errors:".errors",ajaxLoader:"#ajax-loader"},modelEvents:{invalid:"hideAjaxLoader showError","submit:error":"hideAjaxLoader showError"},preventSubmit:function(a){a.preventDefault()},
changeGroupDescription:function(){var a=this.ui.groupSelect.prop("selectedIndex"),a=this.model.get("groups")[a].description||"";this.ui.groupDescription.text(a)},showError:function(a,b){this.ui.errors.html("string"==typeof b?b:b.message)},serializeData:function(){var a=this.model.toJSON();a.page=c.Objects.Models.page.toJSON();return a},showAjaxLoader:function(){this.ui.ajaxLoader.show()},hideAjaxLoader:function(){this.ui.ajaxLoader.hide()}})})(Mibew,Backbone);

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,e){var c=b.Views.BaseSurveyForm;b.Views.SurveyForm=c.extend({template:d.templates.survey_form,events:e.extend({},c.prototype.events,{"click #submit-survey":"submitForm"}),submitForm:function(){this.showAjaxLoader();var a={};this.model.get("groups")&&(a.groupId=this.ui.groupSelect.val());this.model.get("canChangeName")&&(a.name=this.ui.name.val()||"");this.model.get("showEmail")&&(a.email=this.ui.email.val()||"");this.model.get("showMessage")&&(a.message=this.ui.message.val()||"");this.model.set(a,
{validate:!0});this.model.submit()}})})(Mibew,Handlebars,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,c){b.Models.Avatar=b.Models.Base.extend({defaults:{imageLink:!1},initialize:function(){this.registeredFunctions=[];this.registeredFunctions.push(b.Objects.server.registerFunction("setupAvatar",c.bind(this.apiSetupAvatar,this)))},finalize:function(){for(var a=0;a<this.registeredFunctions.length;a++)b.Objects.server.unregisterFunction(this.registeredFunctions[a])},apiSetupAvatar:function(a){a.imageLink&&this.set({imageLink:a.imageLink})}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.ChatUser=a.Models.User.extend({defaults:b.extend({},a.Models.User.prototype.defaults,{canPost:!0,typing:!1,canChangeName:!1,dafaultName:!0})})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.CloseControl=a.Models.Control.extend({getModelType:function(){return"CloseControl"},closeThread:function(){var b=a.Objects.Models.thread,c=a.Objects.Models.user;a.Objects.server.callFunctions([{"function":"close",arguments:{references:{},"return":{closed:"closed"},threadId:b.get("id"),token:b.get("token"),lastId:b.get("lastId"),user:!c.get("isAgent")}}],function(b){b.closed?window.close():a.Objects.Models.Status.message.setMessage(b.errorMessage||"Cannot close")},!0)}})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.HistoryControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1,windowParams:""}),getModelType:function(){return"HistoryControl"}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.RedirectControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1}),getModelType:function(){return"RedirectControl"}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.RefreshControl=a.Models.Control.extend({getModelType:function(){return"RefreshControl"},refresh:function(){a.Objects.server.restartUpdater()}})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.SecureModeControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1}),getModelType:function(){return"SecureModeControl"}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.SendMailControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1,windowParams:""}),getModelType:function(){return"SendMailControl"}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,c){a.Models.SoundControl=a.Models.Control.extend({defaults:c.extend({},a.Models.Control.prototype.defaults,{enabled:!0}),toggle:function(){var b=!this.get("enabled");a.Objects.Models.soundManager.set({enabled:b});this.set({enabled:b})},getModelType:function(){return"SoundControl"}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b){b.Models.UserNameControl=b.Models.Control.extend({getModelType:function(){return"UserNameControl"},changeName:function(a){var c=b.Objects.Models.user,d=b.Objects.Models.thread,e=c.get("name");a&&e!=a&&(b.Objects.server.callFunctions([{"function":"rename",arguments:{references:{},"return":{},threadId:d.get("id"),token:d.get("token"),name:a}}],function(a){a.errorCode&&(b.Objects.Models.Status.message.setMessage(a.errorMessage||"Cannot rename"),c.set({name:e}))},!0),c.set({name:a}))}})})(Mibew);

View File

@ -0,0 +1,10 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(c,e){var d=c.Models.BaseSurveyForm;c.Models.LeaveMessageForm=d.extend({defaults:e.extend({},d.prototype.defaults,{showCaptcha:!1,captcha:""}),validate:function(a){var b=c.Localization;if("undefined"!=typeof a.email){if(!a.email)return b.get("leavemessage.error.email.required");if(!c.Utils.checkEmail(a.email))return b.get("leavemessage.error.wrong.email")}if("undefined"!=typeof a.name&&!a.name)return b.get("leavemessage.error.name.required");if("undefined"!=typeof a.message&&!a.message)return b.get("leavemessage.error.message.required");
if(this.get("showCaptcha")&&"undefined"!=typeof a.captcha&&!a.captcha)return b.get("The letters you typed don't match the letters that were shown in the picture.")},submit:function(){if(!this.validate(this.attributes)){var a=this;c.Objects.server.callFunctions([{"function":"processLeaveMessage",arguments:{references:{},"return":{},groupId:a.get("groupId"),name:a.get("name"),info:a.get("info"),email:a.get("email"),message:a.get("message"),referrer:a.get("referrer"),captcha:a.get("captcha"),threadId:null,token:null}}],function(b){0==b.errorCode?a.trigger("submit:complete",
a):a.trigger("submit:error",a,{code:b.errorCode,message:b.errorMessage||""})},!0)}},ERROR_WRONG_CAPTCHA:10})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.MessageForm=a.Models.Base.extend({defaults:{predefinedAnswers:[],ignoreCtrl:!1},postMessage:function(e){var b=a.Objects.Models.thread,c=a.Objects.Models.user;if(c.get("canPost")){this.trigger("before:post",this);var d=this;a.Objects.server.callFunctions([{"function":"post",arguments:{references:{},"return":{},message:e,threadId:b.get("id"),token:b.get("token"),user:!c.get("isAgent")}}],function(){d.trigger("after:post",d)},!0)}}})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,a){b.Models.BaseSoundManager=a.Model.extend({defaults:{enabled:!0},play:function(a){this.get("enabled")&&b.Utils.playSound(a)}})})(Mibew,Backbone);

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,c){a.Models.ChatSoundManager=a.Models.BaseSoundManager.extend({defaults:c.extend({},a.Models.BaseSoundManager.prototype.defaults,{skipNextMessageSound:!1}),initialize:function(){var b=a.Objects,c=this;b.Collections.messages.on("multiple:add",this.playNewMessageSound,this);b.Models.messageForm.on("before:post",function(){c.set({skipNextMessageSound:!0})})},playNewMessageSound:function(){if(!this.get("skipNextMessageSound")){var b=a.Objects.Models.page.get("mibewRoot");"undefined"!==typeof b&&
this.play(b+"/sounds/new_message")}this.set({skipNextMessageSound:!1})}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,c){b.Models.Status=b.Models.Base.extend({defaults:{visible:!0,weight:0,hideTimeout:4E3,title:""},initialize:function(){this.hideTimer=null},autoHide:function(a){a=a||this.get("hideTimeout");this.hideTimer&&clearTimeout(this.hideTimer);this.hideTimer=setTimeout(c.bind(function(){this.set({visible:!1})},this),a)}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.StatusMessage=a.Models.Status.extend({defaults:b.extend({},a.Models.Status.prototype.defaults,{message:"",visible:!1}),getModelType:function(){return"StatusMessage"},setMessage:function(a){this.set({message:a,visible:!0});this.autoHide()}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.StatusTyping=a.Models.Status.extend({defaults:b.extend({},a.Models.Status.prototype.defaults,{visible:!1,hideTimeout:2E3}),getModelType:function(){return"StatusTyping"},show:function(){this.set({visible:!0});this.autoHide()}})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.BaseSurveyForm=a.Models.Base.extend({defaults:{name:"",email:"",message:"",info:"",referrer:"",groupId:null,groups:null}})})(Mibew);

View File

@ -0,0 +1,10 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,e){var d=b.Models.BaseSurveyForm;b.Models.SurveyForm=d.extend({defaults:e.extend({},d.prototype.defaults,{showEmail:!1,showMessage:!1,canChangeName:!1}),validate:function(a){if(this.get("showEmail")&&"undefined"!=typeof a.email&&!b.Utils.checkEmail(a.email))return b.Localization.get("Wrong email address.")},submit:function(){if(!this.validate(this.attributes)){var a=this;b.Objects.server.callFunctions([{"function":"processSurvey",arguments:{references:{},"return":{next:"next",options:"options"},
groupId:a.get("groupId"),name:a.get("name"),info:a.get("info"),email:a.get("email"),message:a.get("message"),referrer:a.get("referrer"),threadId:null,token:null}}],function(c){if(0==c.errorCode)switch(a.trigger("submit:complete",a),b.Application.Survey.stop(),c.next){case "chat":b.Application.Chat.start(c.options);break;case "leaveMessage":b.Application.LeaveMessage.start(c.options);break;default:throw Error("Do not know how to continue!");}else a.trigger("submit:error",a,{code:c.errorCode,message:c.errorMessage||
""})},!0)}}})})(Mibew,_);

View File

@ -0,0 +1,14 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Objects.Models.Controls={};a.Objects.Models.Status={};var j=[],l=a.Application,k=l.module("Chat",{startWithParent:!1});k.addInitializer(function(b){var f=a.Objects,d=a.Objects.Models,c=a.Objects.Models.Controls,h=a.Objects.Models.Status;b.page&&d.page.set(b.page);d.thread=new a.Models.Thread(b.thread);d.user=new a.Models.ChatUser(b.user);var g=new a.Layouts.Chat;f.chatLayout=g;l.mainRegion.show(g);var e=new a.Collections.Controls;d.user.get("isAgent")||(c.userName=new a.Models.UserNameControl({weight:220}),
e.add(c.userName),c.sendMail=new a.Models.SendMailControl({weight:200,link:b.links.mail,windowParams:b.windowsParams.mail}),e.add(c.sendMail));d.user.get("isAgent")&&(c.redirect=new a.Models.RedirectControl({weight:200,link:b.links.redirect}),e.add(c.redirect),c.history=new a.Models.HistoryControl({weight:180,link:b.links.history,windowParams:b.windowsParams.history}),e.add(c.history));c.sound=new a.Models.SoundControl({weight:160});e.add(c.sound);c.refresh=new a.Models.RefreshControl({weight:140});
e.add(c.refresh);b.links.ssl&&(c.secureMode=new a.Models.SecureModeControl({weight:120,link:b.links.ssl}),e.add(c.secureMode));c.close=new a.Models.CloseControl({weight:100});e.add(c.close);f.Collections.controls=e;g.controlsRegion.show(new a.Views.ControlsCollection({collection:e}));h.message=new a.Models.StatusMessage({hideTimeout:5E3});h.typing=new a.Models.StatusTyping({hideTimeout:5E3});f.Collections.status=new a.Collections.Status([h.message,h.typing]);g.statusRegion.show(new a.Views.StatusCollection({collection:f.Collections.status}));
d.user.get("isAgent")||(d.avatar=new a.Models.Avatar,g.avatarRegion.show(new a.Views.Avatar({model:d.avatar})));f.Collections.messages=new a.Collections.Messages;d.messageForm=new a.Models.MessageForm(b.messageForm);g.messageFormRegion.show(new a.Views.MessageForm({model:d.messageForm}));g.messagesRegion.show(new a.Views.MessagesCollection({collection:f.Collections.messages}));d.soundManager=new a.Models.ChatSoundManager;j.push(f.server.callFunctionsPeriodically(function(){var b=a.Objects.Models.thread,
c=a.Objects.Models.user;return[{"function":"update",arguments:{"return":{typing:"typing",canPost:"canPost"},references:{},threadId:b.get("id"),token:b.get("token"),lastId:b.get("lastId"),typed:c.get("typing"),user:!c.get("isAgent")}}]},function(b){b.errorCode?a.Objects.Models.Status.message.setMessage(b.errorMessage||"refresh failed"):(b.typing&&a.Objects.Models.Status.typing.show(),a.Objects.Models.user.set({canPost:b.canPost||!1}))}))});k.on("start",function(){a.Objects.server.restartUpdater()});
k.addFinalizer(function(){a.Objects.chatLayout.close();for(var b=0;b<j.length;b++)a.Objects.server.stopCallFunctionsPeriodically(j[b]);"undefined"!=typeof a.Objects.Models.avatar&&a.Objects.Models.avatar.finalize();a.Objects.Collections.messages.finalize();delete a.Objects.chatLayout;delete a.Objects.Models.thread;delete a.Objects.Models.user;delete a.Objects.Models.page;delete a.Objects.Models.avatar;delete a.Objects.Models.messageForm;delete a.Objects.Models.Controls;delete a.Objects.Models.Status;
delete a.Objects.Collections.messages;delete a.Objects.Collections.controls;delete a.Objects.Collections.status})})(Mibew);

View File

@ -0,0 +1,10 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){var d=[],e=a.Application,b=e.module("Invitation",{startWithParent:!1});b.addInitializer(function(f){var c=a.Objects,b=a.Objects.Models;b.thread=new a.Models.Thread(f.thread);b.user=new a.Models.ChatUser(f.user);c.invitationLayout=new a.Layouts.Invitation;e.mainRegion.show(c.invitationLayout);c.Collections.messages=new a.Collections.Messages;c.invitationLayout.messagesRegion.show(new a.Views.MessagesCollection({collection:c.Collections.messages}));d.push(c.server.callFunctionsPeriodically(function(){var b=
a.Objects.Models.thread;return[{"function":"update",arguments:{"return":{},references:{},threadId:b.get("id"),token:b.get("token"),lastId:b.get("lastId"),typed:!1,user:!0}}]},function(){}))});b.on("start",function(){a.Objects.server.restartUpdater()});b.addFinalizer(function(){a.Objects.invitationLayout.close();for(var b=0;b<d.length;b++)a.Objects.server.stopCallFunctionsPeriodically(d[b]);a.Objects.Collections.messages.finalize();delete a.Objects.invitationLayout;delete a.Objects.Models.thread;delete a.Objects.Models.user;
delete a.Objects.Collections.messages})})(Mibew);

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){var e=a.Application,f=e.module("LeaveMessage",{startWithParent:!1});f.addInitializer(function(d){var b=a.Objects,c=a.Objects.Models;d.page&&c.page.set(d.page);b.leaveMessageLayout=new a.Layouts.LeaveMessage;e.mainRegion.show(b.leaveMessageLayout);c.leaveMessageForm=new a.Models.LeaveMessageForm(d.leaveMessageForm);b.leaveMessageLayout.leaveMessageFormRegion.show(new a.Views.LeaveMessageForm({model:c.leaveMessageForm}));b.leaveMessageLayout.descriptionRegion.show(new a.Views.LeaveMessageDescription);
c.leaveMessageForm.on("submit:complete",function(){b.leaveMessageLayout.leaveMessageFormRegion.close();b.leaveMessageLayout.descriptionRegion.close();b.leaveMessageLayout.descriptionRegion.show(new a.Views.LeaveMessageSentDescription)})});f.addFinalizer(function(){a.Objects.leaveMessageLayout.close();delete a.Objects.Models.leaveMessageForm})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){var d=a.Application,b=d.module("Survey",{startWithParent:!1});b.addInitializer(function(b){var c=a.Objects,e=a.Objects.Models;c.surveyLayout=new a.Layouts.Survey;d.mainRegion.show(c.surveyLayout);e.surveyForm=new a.Models.SurveyForm(b.surveyForm);c.surveyLayout.surveyFormRegion.show(new a.Views.SurveyForm({model:e.surveyForm}))});b.addFinalizer(function(){a.Objects.surveyLayout.close();delete a.Objects.Models.surveyForm})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Regions.Messages=b.Marionette.Region.extend({onShow:function(a){a.on("after:item:added",this.scrollToBottom,this)},scrollToBottom:function(){this.$el.scrollTop(this.$el.prop("scrollHeight"))}})})(Mibew,Backbone);

View File

@ -0,0 +1,403 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Regions={};a.Layouts={};a.Application=new Backbone.Marionette.Application})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
MibewAPIChatInteraction=function(){this.mandatoryArguments=function(){return{"*":{threadId:null,token:null,"return":{},references:{}},result:{errorCode:0}}};this.getReservedFunctionsNames=function(){return["result"]}};MibewAPIChatInteraction.prototype=new MibewAPIInteraction;
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,a){b.Models.BaseSoundManager=a.Model.extend({defaults:{enabled:!0},play:function(a){this.get("enabled")&&b.Utils.playSound(a)}})})(Mibew,Backbone);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,c){b.Models.Status=b.Models.Base.extend({defaults:{visible:!0,weight:0,hideTimeout:4E3,title:""},initialize:function(){this.hideTimer=null},autoHide:function(a){a=a||this.get("hideTimeout");this.hideTimer&&clearTimeout(this.hideTimer);this.hideTimer=setTimeout(c.bind(function(){this.set({visible:!1})},this),a)}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.BaseSurveyForm=a.Models.Base.extend({defaults:{name:"",email:"",message:"",info:"",referrer:"",groupId:null,groups:null}})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,c){b.Models.Avatar=b.Models.Base.extend({defaults:{imageLink:!1},initialize:function(){this.registeredFunctions=[];this.registeredFunctions.push(b.Objects.server.registerFunction("setupAvatar",c.bind(this.apiSetupAvatar,this)))},finalize:function(){for(var a=0;a<this.registeredFunctions.length;a++)b.Objects.server.unregisterFunction(this.registeredFunctions[a])},apiSetupAvatar:function(a){a.imageLink&&this.set({imageLink:a.imageLink})}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.ChatUser=a.Models.User.extend({defaults:b.extend({},a.Models.User.prototype.defaults,{canPost:!0,typing:!1,canChangeName:!1,dafaultName:!0})})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.CloseControl=a.Models.Control.extend({getModelType:function(){return"CloseControl"},closeThread:function(){var b=a.Objects.Models.thread,c=a.Objects.Models.user;a.Objects.server.callFunctions([{"function":"close",arguments:{references:{},"return":{closed:"closed"},threadId:b.get("id"),token:b.get("token"),lastId:b.get("lastId"),user:!c.get("isAgent")}}],function(b){b.closed?window.close():a.Objects.Models.Status.message.setMessage(b.errorMessage||"Cannot close")},!0)}})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.HistoryControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1,windowParams:""}),getModelType:function(){return"HistoryControl"}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.RedirectControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1}),getModelType:function(){return"RedirectControl"}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.RefreshControl=a.Models.Control.extend({getModelType:function(){return"RefreshControl"},refresh:function(){a.Objects.server.restartUpdater()}})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.SecureModeControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1}),getModelType:function(){return"SecureModeControl"}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.SendMailControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1,windowParams:""}),getModelType:function(){return"SendMailControl"}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,c){a.Models.SoundControl=a.Models.Control.extend({defaults:c.extend({},a.Models.Control.prototype.defaults,{enabled:!0}),toggle:function(){var b=!this.get("enabled");a.Objects.Models.soundManager.set({enabled:b});this.set({enabled:b})},getModelType:function(){return"SoundControl"}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b){b.Models.UserNameControl=b.Models.Control.extend({getModelType:function(){return"UserNameControl"},changeName:function(a){var c=b.Objects.Models.user,d=b.Objects.Models.thread,e=c.get("name");a&&e!=a&&(b.Objects.server.callFunctions([{"function":"rename",arguments:{references:{},"return":{},threadId:d.get("id"),token:d.get("token"),name:a}}],function(a){a.errorCode&&(b.Objects.Models.Status.message.setMessage(a.errorMessage||"Cannot rename"),c.set({name:e}))},!0),c.set({name:a}))}})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(c,e){var d=c.Models.BaseSurveyForm;c.Models.LeaveMessageForm=d.extend({defaults:e.extend({},d.prototype.defaults,{showCaptcha:!1,captcha:""}),validate:function(a){var b=c.Localization;if("undefined"!=typeof a.email){if(!a.email)return b.get("leavemessage.error.email.required");if(!c.Utils.checkEmail(a.email))return b.get("leavemessage.error.wrong.email")}if("undefined"!=typeof a.name&&!a.name)return b.get("leavemessage.error.name.required");if("undefined"!=typeof a.message&&!a.message)return b.get("leavemessage.error.message.required");
if(this.get("showCaptcha")&&"undefined"!=typeof a.captcha&&!a.captcha)return b.get("The letters you typed don't match the letters that were shown in the picture.")},submit:function(){if(!this.validate(this.attributes)){var a=this;c.Objects.server.callFunctions([{"function":"processLeaveMessage",arguments:{references:{},"return":{},groupId:a.get("groupId"),name:a.get("name"),info:a.get("info"),email:a.get("email"),message:a.get("message"),referrer:a.get("referrer"),captcha:a.get("captcha"),threadId:null,token:null}}],function(b){0==b.errorCode?a.trigger("submit:complete",
a):a.trigger("submit:error",a,{code:b.errorCode,message:b.errorMessage||""})},!0)}},ERROR_WRONG_CAPTCHA:10})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.MessageForm=a.Models.Base.extend({defaults:{predefinedAnswers:[],ignoreCtrl:!1},postMessage:function(e){var b=a.Objects.Models.thread,c=a.Objects.Models.user;if(c.get("canPost")){this.trigger("before:post",this);var d=this;a.Objects.server.callFunctions([{"function":"post",arguments:{references:{},"return":{},message:e,threadId:b.get("id"),token:b.get("token"),user:!c.get("isAgent")}}],function(){d.trigger("after:post",d)},!0)}}})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,c){a.Models.ChatSoundManager=a.Models.BaseSoundManager.extend({defaults:c.extend({},a.Models.BaseSoundManager.prototype.defaults,{skipNextMessageSound:!1}),initialize:function(){var b=a.Objects,c=this;b.Collections.messages.on("multiple:add",this.playNewMessageSound,this);b.Models.messageForm.on("before:post",function(){c.set({skipNextMessageSound:!0})})},playNewMessageSound:function(){if(!this.get("skipNextMessageSound")){var b=a.Objects.Models.page.get("mibewRoot");"undefined"!==typeof b&&
this.play(b+"/sounds/new_message")}this.set({skipNextMessageSound:!1})}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.StatusMessage=a.Models.Status.extend({defaults:b.extend({},a.Models.Status.prototype.defaults,{message:"",visible:!1}),getModelType:function(){return"StatusMessage"},setMessage:function(a){this.set({message:a,visible:!0});this.autoHide()}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.StatusTyping=a.Models.Status.extend({defaults:b.extend({},a.Models.Status.prototype.defaults,{visible:!1,hideTimeout:2E3}),getModelType:function(){return"StatusTyping"},show:function(){this.set({visible:!0});this.autoHide()}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,e){var d=b.Models.BaseSurveyForm;b.Models.SurveyForm=d.extend({defaults:e.extend({},d.prototype.defaults,{showEmail:!1,showMessage:!1,canChangeName:!1}),validate:function(a){if(this.get("showEmail")&&"undefined"!=typeof a.email&&!b.Utils.checkEmail(a.email))return b.Localization.get("Wrong email address.")},submit:function(){if(!this.validate(this.attributes)){var a=this;b.Objects.server.callFunctions([{"function":"processSurvey",arguments:{references:{},"return":{next:"next",options:"options"},
groupId:a.get("groupId"),name:a.get("name"),info:a.get("info"),email:a.get("email"),message:a.get("message"),referrer:a.get("referrer"),threadId:null,token:null}}],function(c){if(0==c.errorCode)switch(a.trigger("submit:complete",a),b.Application.Survey.stop(),c.next){case "chat":b.Application.Chat.start(c.options);break;case "leaveMessage":b.Application.LeaveMessage.start(c.options);break;default:throw Error("Do not know how to continue!");}else a.trigger("submit:error",a,{code:c.errorCode,message:c.errorMessage||
""})},!0)}}})})(Mibew,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,j){b.Collections.Messages=d.Collection.extend({model:b.Models.Message,initialize:function(){this.periodicallyCalled=[];this.periodicallyCalled.push(b.Objects.server.callFunctionsPeriodically(j.bind(this.updateMessagesFunctionBuilder,this),j.bind(this.updateMessages,this)))},finalize:function(){for(var a=0;a<this.periodicallyCalled.length;a++)b.Objects.server.stopCallFunctionsPeriodically(this.periodicallyCalled[a])},updateMessages:function(a){a.lastId&&b.Objects.Models.thread.set({lastId:a.lastId});
for(var k=b.Models.Message.prototype.KIND_PLUGIN,g=[],c,f,e,h=0,d=a.messages.length;h<d;h++)c=a.messages[h],c.kind!=k?g.push(new b.Models.Message(c)):"object"!=typeof c.data||null===c.data||(f=c.plugin||!1,f="process:"+(!1!==f?f+":":"")+"plugin:message",e={messageData:c,model:!1},this.trigger(f,e),e.model&&(e.model.get("id")||e.model.set({id:c.id}),g.push(e.model)));0<g.length&&this.add(g)},updateMessagesFunctionBuilder:function(){var a=b.Objects.Models.thread,d=b.Objects.Models.user;return[{"function":"updateMessages",
arguments:{"return":{messages:"messages",lastId:"lastId"},references:{},threadId:a.get("id"),token:a.get("token"),lastId:a.get("lastId"),user:!d.get("isAgent")}}]},add:function(){var a=Array.prototype.slice.apply(arguments),a=d.Collection.prototype.add.apply(this,a);this.trigger("multiple:add");return a}})})(Mibew,Backbone,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Collections.Status=b.Collection.extend({comparator:function(a){return a.get("weight")}})})(Mibew,Backbone);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.Status=b.Marionette.ItemView.extend({template:c.templates.chat_status_base,className:"status",modelEvents:{change:"render"},onBeforeRender:function(){this.model.get("visible")?this.$el.show():this.$el.hide()}})})(Mibew,Backbone,Handlebars);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(c,d){c.Views.BaseSurveyForm=d.Marionette.ItemView.extend({events:{'change select[name="group"]':"changeGroupDescription","submit form":"preventSubmit"},ui:{groupSelect:'select[name="group"]',groupDescription:"#groupDescription",name:'input[name="name"]',email:'input[name="email"]',message:'textarea[name="message"]',errors:".errors",ajaxLoader:"#ajax-loader"},modelEvents:{invalid:"hideAjaxLoader showError","submit:error":"hideAjaxLoader showError"},preventSubmit:function(a){a.preventDefault()},
changeGroupDescription:function(){var a=this.ui.groupSelect.prop("selectedIndex"),a=this.model.get("groups")[a].description||"";this.ui.groupDescription.text(a)},showError:function(a,b){this.ui.errors.html("string"==typeof b?b:b.message)},serializeData:function(){var a=this.model.toJSON();a.page=c.Objects.Models.page.toJSON();return a},showAjaxLoader:function(){this.ui.ajaxLoader.show()},hideAjaxLoader:function(){this.ui.ajaxLoader.hide()}})})(Mibew,Backbone);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.Avatar=b.Marionette.ItemView.extend({template:c.templates.chat_avatar,className:"avatar",modelEvents:{change:"render"}})})(Mibew,Backbone,Handlebars);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,c,d){a.Views.CloseControl=a.Views.Control.extend({template:c.templates.chat_controls_close,events:d.extend({},a.Views.Control.prototype.events,{click:"closeThread"}),closeThread:function(){var b=a.Localization.get("Are you sure want to leave chat?");(!1===b||confirm(b))&&this.model.closeThread()}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,e){b.Views.HistoryControl=b.Views.Control.extend({template:d.templates.chat_controls_history,events:e.extend({},b.Views.Control.prototype.events,{click:"showHistory"}),showHistory:function(){var c=b.Objects.Models.user,a=this.model.get("link");c.get("isAgent")&&a&&(c=this.model.get("windowParams"),a=a.replace("&amp;","&","g"),a=window.open(a,"UserHistory",c),null!==a&&(a.focus(),a.opener=window))}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,e,f){b.Views.RedirectControl=b.Views.Control.extend({template:e.templates.chat_controls_redirect,events:f.extend({},b.Views.Control.prototype.events,{click:"redirect"}),initialize:function(){b.Objects.Models.user.on("change",this.render,this)},serializeData:function(){var a=this.model.toJSON();a.user=b.Objects.Models.user.toJSON();return a},redirect:function(){var a=b.Objects.Models.user;if(a.get("isAgent")&&a.get("canPost")&&(a=this.model.get("link"))){var c=b.Objects.Models.page.get("style"),
d="";c&&(d=(-1===a.indexOf("?")?"?":"&")+"style="+c);window.location.href=a.replace(/\&amp\;/g,"&")+d}}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.RefreshControl=a.Views.Control.extend({template:b.templates.chat_controls_refresh,events:c.extend({},a.Views.Control.prototype.events,{click:"refresh"}),refresh:function(){this.model.refresh()}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,d,e){a.Views.SecureModeControl=a.Views.Control.extend({template:d.templates.chat_controls_secure_mode,events:e.extend({},a.Views.Control.prototype.events,{click:"secure"}),secure:function(){var b=this.model.get("link");if(b){var c=a.Objects.Models.page.get("style");window.location.href=b.replace(/\&amp\;/g,"&")+(c?"&style="+c:"")}}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,f){b.Views.SendMailControl=b.Views.Control.extend({template:d.templates.chat_controls_send_mail,events:f.extend({},b.Views.Control.prototype.events,{click:"sendMail"}),sendMail:function(){var a=this.model.get("link"),c=b.Objects.Models.page;if(a){var d=this.model.get("windowParams"),c=c.get("style"),e="";c&&(e=(-1===a.indexOf("?")?"?":"&")+"style="+c);a=a.replace(/\&amp\;/g,"&")+e;a=window.open(a,"ForwardMail",d);null!==a&&(a.focus(),a.opener=window)}}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.SoundControl=a.Views.Control.extend({template:b.templates.chat_controls_sound,events:c.extend({},a.Views.Control.prototype.events,{click:"toggle"}),toggle:function(){this.model.toggle()}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,c,d){b.Views.UserNameControl=b.Views.Control.extend({template:c.templates.chat_controls_user_name,events:d.extend({},b.Views.Control.prototype.events,{"click .user-name-control-set":"changeName","click .user-name-control-change":"showNameInput","keydown #user-name-control-input":"inputKeyDown"}),ui:{nameInput:"#user-name-control-input"},initialize:function(){b.Objects.Models.user.on("change:name",this.hideNameInput,this);this.nameInput=b.Objects.Models.user.get("defaultName")},serializeData:function(){var a=
this.model.toJSON();a.user=b.Objects.Models.user.toJSON();a.nameInput=this.nameInput;return a},inputKeyDown:function(a){a=a.which;(13==a||10==a)&&this.changeName()},hideNameInput:function(){this.nameInput=!1;this.render()},showNameInput:function(){this.nameInput=!0;this.render()},changeName:function(){var a=this.ui.nameInput.val();this.model.changeName(a)}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.LeaveMessageDescription=b.Marionette.ItemView.extend({template:c.templates.leave_message_description,serializeData:function(){return{page:a.Objects.Models.page.toJSON()}}})})(Mibew,Backbone,Handlebars);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(d,e,b){var c=d.Views.BaseSurveyForm;d.Views.LeaveMessageForm=c.extend({template:e.templates.leave_message_form,events:b.extend({},c.prototype.events,{"click #send-message":"submitForm"}),ui:b.extend({},c.prototype.ui,{captcha:'input[name="captcha"]',captchaImg:"#captcha-img"}),modelEvents:b.extend({},c.prototype.modelEvents,{"submit:error":"hideAjaxLoader showError submitError"}),submitForm:function(){this.showAjaxLoader();var a={};this.model.get("groups")&&(a.groupId=this.ui.groupSelect.val());
a.name=this.ui.name.val()||"";a.email=this.ui.email.val()||"";a.message=this.ui.message.val()||"";this.model.get("showCaptcha")&&(a.captcha=this.ui.captcha.val()||"");this.model.set(a,{validate:!0});this.model.submit()},submitError:function(a,c){if(c.code==a.ERROR_WRONG_CAPTCHA&&a.get("showCaptcha")){var b=this.ui.captchaImg.attr("src"),b=b.replace(/\?d\=[0-9]+/,"");this.ui.captchaImg.attr("src",b+"?d="+(new Date).getTime())}}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b,c){a.Views.LeaveMessageSentDescription=b.Marionette.ItemView.extend({template:c.templates.leave_message_sent_description,serializeData:function(){return{page:a.Objects.Models.page.toJSON()}}})})(Mibew,Backbone,Handlebars);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Views.Message=a.Views.Message.extend({template:b.templates.chat_message})})(Mibew,Handlebars);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,e){b.Views.MessageForm=d.Marionette.ItemView.extend({template:e.templates.chat_message_form,events:{"click #send-message":"postMessage","keydown #message-input":"messageKeyDown","keyup #message-input":"checkUserTyping","change #message-input":"checkUserTyping","change #predefined":"selectPredefinedAnswer","focus #message-input":"setFocus","blur #message-input":"dropFocus"},modelEvents:{change:"render"},ui:{message:"#message-input",send:"#send-message",predefinedAnswer:"#predefined"},
initialize:function(){b.Objects.Models.user.on("change:canPost",this.render,this)},serializeData:function(){var a=this.model.toJSON();a.user=b.Objects.Models.user.toJSON();return a},postMessage:function(){var a=this.ui.message.val();""!=a&&(this.disableInput(),this.model.postMessage(a));b.Objects.Collections.messages.on("multiple:add",this.postMessageComplete,this)},messageKeyDown:function(a){var c=a.which;a=a.ctrlKey;(13==c&&(a||this.model.get("ignoreCtrl"))||10==c)&&this.postMessage()},enableInput:function(){this.ui.message.removeAttr("disabled")},
disableInput:function(){this.ui.message.attr("disabled","disabled")},clearInput:function(){this.ui.message.val("").change()},postMessageComplete:function(){this.clearInput();this.enableInput();this.focused&&this.ui.focus();b.Objects.Collections.messages.off("multiple:add",this.postMessageComplete,this)},selectPredefinedAnswer:function(){var a=this.ui.message,c=this.ui.predefinedAnswer,b=c.get(0).selectedIndex;b&&(a.val(this.model.get("predefinedAnswers")[b-1].full).change(),a.focus(),c.get(0).selectedIndex=
0)},checkUserTyping:function(){var a=b.Objects.Models.user,c=""!=this.ui.message.val();c!=a.get("typing")&&a.set({typing:c})},setFocus:function(){this.focused=!0},dropFocus:function(){this.focused=!1}})})(Mibew,Backbone,Handlebars);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Views.StatusMessage=a.Views.Status.extend({template:b.templates.chat_status_message})})(Mibew,Handlebars);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Views.StatusTyping=a.Views.Status.extend({template:b.templates.chat_status_typing})})(Mibew,Handlebars);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d,e){var c=b.Views.BaseSurveyForm;b.Views.SurveyForm=c.extend({template:d.templates.survey_form,events:e.extend({},c.prototype.events,{"click #submit-survey":"submitForm"}),submitForm:function(){this.showAjaxLoader();var a={};this.model.get("groups")&&(a.groupId=this.ui.groupSelect.val());this.model.get("canChangeName")&&(a.name=this.ui.name.val()||"");this.model.get("showEmail")&&(a.email=this.ui.email.val()||"");this.model.get("showMessage")&&(a.message=this.ui.message.val()||"");this.model.set(a,
{validate:!0});this.model.submit()}})})(Mibew,Handlebars,_);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Views.MessagesCollection=a.Views.CollectionBase.extend({itemView:a.Views.Message,className:"messages-collection"})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Views.StatusCollection=a.Views.CollectionBase.extend({itemView:a.Views.Status,className:"status-collection"})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Regions.Messages=b.Marionette.Region.extend({onShow:function(a){a.on("after:item:added",this.scrollToBottom,this)},scrollToBottom:function(){this.$el.scrollTop(this.$el.prop("scrollHeight"))}})})(Mibew,Backbone);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,c){a.Layouts.Chat=c.Marionette.Layout.extend({template:Handlebars.templates.chat_layout,regions:{controlsRegion:"#controls-region",avatarRegion:"#avatar-region",messagesRegion:{selector:"#messages-region",regionType:a.Regions.Messages},statusRegion:"#status-region",messageFormRegion:"#message-form-region"},serializeData:function(){var b=a.Objects.Models;return{page:b.page.toJSON(),user:b.user.toJSON()}}})})(Mibew,Backbone);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Layouts.Invitation=b.Marionette.Layout.extend({template:Handlebars.templates.invitation_layout,regions:{messagesRegion:{selector:"#invitation-messages-region",regionType:a.Regions.Messages}}})})(Mibew,Backbone);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Layouts.LeaveMessage=b.Marionette.Layout.extend({template:Handlebars.templates.leave_message_layout,regions:{leaveMessageFormRegion:"#content-wrapper",descriptionRegion:"#description-region"},serializeData:function(){return{page:a.Objects.Models.page.toJSON()}}})})(Mibew,Backbone);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Layouts.Survey=b.Marionette.Layout.extend({template:Handlebars.templates.survey_layout,regions:{surveyFormRegion:"#content-wrapper"},serializeData:function(){return{page:a.Objects.Models.page.toJSON()}}})})(Mibew,Backbone);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Objects.Models.Controls={};a.Objects.Models.Status={};var j=[],l=a.Application,k=l.module("Chat",{startWithParent:!1});k.addInitializer(function(b){var f=a.Objects,d=a.Objects.Models,c=a.Objects.Models.Controls,h=a.Objects.Models.Status;b.page&&d.page.set(b.page);d.thread=new a.Models.Thread(b.thread);d.user=new a.Models.ChatUser(b.user);var g=new a.Layouts.Chat;f.chatLayout=g;l.mainRegion.show(g);var e=new a.Collections.Controls;d.user.get("isAgent")||(c.userName=new a.Models.UserNameControl({weight:220}),
e.add(c.userName),c.sendMail=new a.Models.SendMailControl({weight:200,link:b.links.mail,windowParams:b.windowsParams.mail}),e.add(c.sendMail));d.user.get("isAgent")&&(c.redirect=new a.Models.RedirectControl({weight:200,link:b.links.redirect}),e.add(c.redirect),c.history=new a.Models.HistoryControl({weight:180,link:b.links.history,windowParams:b.windowsParams.history}),e.add(c.history));c.sound=new a.Models.SoundControl({weight:160});e.add(c.sound);c.refresh=new a.Models.RefreshControl({weight:140});
e.add(c.refresh);b.links.ssl&&(c.secureMode=new a.Models.SecureModeControl({weight:120,link:b.links.ssl}),e.add(c.secureMode));c.close=new a.Models.CloseControl({weight:100});e.add(c.close);f.Collections.controls=e;g.controlsRegion.show(new a.Views.ControlsCollection({collection:e}));h.message=new a.Models.StatusMessage({hideTimeout:5E3});h.typing=new a.Models.StatusTyping({hideTimeout:5E3});f.Collections.status=new a.Collections.Status([h.message,h.typing]);g.statusRegion.show(new a.Views.StatusCollection({collection:f.Collections.status}));
d.user.get("isAgent")||(d.avatar=new a.Models.Avatar,g.avatarRegion.show(new a.Views.Avatar({model:d.avatar})));f.Collections.messages=new a.Collections.Messages;d.messageForm=new a.Models.MessageForm(b.messageForm);g.messageFormRegion.show(new a.Views.MessageForm({model:d.messageForm}));g.messagesRegion.show(new a.Views.MessagesCollection({collection:f.Collections.messages}));d.soundManager=new a.Models.ChatSoundManager;j.push(f.server.callFunctionsPeriodically(function(){var b=a.Objects.Models.thread,
c=a.Objects.Models.user;return[{"function":"update",arguments:{"return":{typing:"typing",canPost:"canPost"},references:{},threadId:b.get("id"),token:b.get("token"),lastId:b.get("lastId"),typed:c.get("typing"),user:!c.get("isAgent")}}]},function(b){b.errorCode?a.Objects.Models.Status.message.setMessage(b.errorMessage||"refresh failed"):(b.typing&&a.Objects.Models.Status.typing.show(),a.Objects.Models.user.set({canPost:b.canPost||!1}))}))});k.on("start",function(){a.Objects.server.restartUpdater()});
k.addFinalizer(function(){a.Objects.chatLayout.close();for(var b=0;b<j.length;b++)a.Objects.server.stopCallFunctionsPeriodically(j[b]);"undefined"!=typeof a.Objects.Models.avatar&&a.Objects.Models.avatar.finalize();a.Objects.Collections.messages.finalize();delete a.Objects.chatLayout;delete a.Objects.Models.thread;delete a.Objects.Models.user;delete a.Objects.Models.page;delete a.Objects.Models.avatar;delete a.Objects.Models.messageForm;delete a.Objects.Models.Controls;delete a.Objects.Models.Status;
delete a.Objects.Collections.messages;delete a.Objects.Collections.controls;delete a.Objects.Collections.status})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){var d=[],e=a.Application,b=e.module("Invitation",{startWithParent:!1});b.addInitializer(function(f){var c=a.Objects,b=a.Objects.Models;b.thread=new a.Models.Thread(f.thread);b.user=new a.Models.ChatUser(f.user);c.invitationLayout=new a.Layouts.Invitation;e.mainRegion.show(c.invitationLayout);c.Collections.messages=new a.Collections.Messages;c.invitationLayout.messagesRegion.show(new a.Views.MessagesCollection({collection:c.Collections.messages}));d.push(c.server.callFunctionsPeriodically(function(){var b=
a.Objects.Models.thread;return[{"function":"update",arguments:{"return":{},references:{},threadId:b.get("id"),token:b.get("token"),lastId:b.get("lastId"),typed:!1,user:!0}}]},function(){}))});b.on("start",function(){a.Objects.server.restartUpdater()});b.addFinalizer(function(){a.Objects.invitationLayout.close();for(var b=0;b<d.length;b++)a.Objects.server.stopCallFunctionsPeriodically(d[b]);a.Objects.Collections.messages.finalize();delete a.Objects.invitationLayout;delete a.Objects.Models.thread;delete a.Objects.Models.user;
delete a.Objects.Collections.messages})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){var e=a.Application,f=e.module("LeaveMessage",{startWithParent:!1});f.addInitializer(function(d){var b=a.Objects,c=a.Objects.Models;d.page&&c.page.set(d.page);b.leaveMessageLayout=new a.Layouts.LeaveMessage;e.mainRegion.show(b.leaveMessageLayout);c.leaveMessageForm=new a.Models.LeaveMessageForm(d.leaveMessageForm);b.leaveMessageLayout.leaveMessageFormRegion.show(new a.Views.LeaveMessageForm({model:c.leaveMessageForm}));b.leaveMessageLayout.descriptionRegion.show(new a.Views.LeaveMessageDescription);
c.leaveMessageForm.on("submit:complete",function(){b.leaveMessageLayout.leaveMessageFormRegion.close();b.leaveMessageLayout.descriptionRegion.close();b.leaveMessageLayout.descriptionRegion.show(new a.Views.LeaveMessageSentDescription)})});f.addFinalizer(function(){a.Objects.leaveMessageLayout.close();delete a.Objects.Models.leaveMessageForm})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){var d=a.Application,b=d.module("Survey",{startWithParent:!1});b.addInitializer(function(b){var c=a.Objects,e=a.Objects.Models;c.surveyLayout=new a.Layouts.Survey;d.mainRegion.show(c.surveyLayout);e.surveyForm=new a.Models.SurveyForm(b.surveyForm);c.surveyLayout.surveyFormRegion.show(new a.Views.SurveyForm({model:e.surveyForm}))});b.addFinalizer(function(){a.Objects.surveyLayout.close();delete a.Objects.Models.surveyForm})})(Mibew);
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d){var c=b.Application;c.addRegions({mainRegion:"#main-region"});c.addInitializer(function(a){b.PluginOptions=a.plugins||{};b.Objects.server=new b.Server(d.extend({interactionType:MibewAPIChatInteraction},a.server));b.Objects.Models.page=new b.Models.Page(a.page);switch(a.startFrom){case "chat":c.Chat.start(a.chatOptions);break;case "survey":c.Survey.start(a.surveyOptions);break;case "leaveMessage":c.LeaveMessage.start(a.leaveMessageOptions);break;case "invitation":c.Invitation.start(a.invitationOptions);
break;default:throw Error("Dont know how to start!");}});c.on("start",function(){b.Objects.server.runUpdater()})})(Mibew,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(d,a,f){var e=function(b,a,c){c=f.extend({model:b},c);return"function"!=typeof b.getModelType?new a(c):(b=b.getModelType())&&d.Views[b]?new d.Views[b](c):new a(c)};d.Views.CollectionBase=a.Marionette.CollectionView.extend({itemView:a.Marionette.ItemView,buildItemView:e});d.Views.CompositeBase=a.Marionette.CompositeView.extend({buildItemView:e})})(Mibew,Backbone,_);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Views.ControlsCollection=a.Views.CollectionBase.extend({itemView:a.Views.Control,className:"controls-collection"})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Collections.Controls=b.Collection.extend({comparator:function(a){return a.get("weight")}})})(Mibew,Backbone);

View File

@ -0,0 +1,10 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(e,c){c.registerHelper("apply",function(a,b){var f=a,e=/^[0-9A-z_]+$/;b=b.split(/\s*,\s*/);for(var d in b)if(b.hasOwnProperty(d)&&e.test(b[d])){if("function"!=typeof c.helpers[b[d]])throw Error("Unregistered helper '"+b[d]+"'!");f=c.helpers[b[d]](f).toString()}return new c.SafeString(f)});c.registerHelper("allowTags",function(a){a=a.replace(/&lt;(span|strong)&gt;(.*?)&lt;\/\1&gt;/g,"<$1>$2</$1>");a=a.replace(/&lt;span class=&quot;(.*?)&quot;&gt;(.*?)&lt;\/span&gt;/g,'<span class="$1">$2</span>');
return new c.SafeString(a)});c.registerHelper("formatTime",function(a){var b=new Date(1E3*a);a=b.getHours().toString();var c=b.getMinutes().toString(),b=b.getSeconds().toString();return(10>a?"0"+a:a)+":"+(10>c?"0"+c:c)+":"+(10>b?"0"+b:b)});c.registerHelper("urlReplace",function(a){return new c.SafeString(a.replace(/((?:https?|ftp):\/\/\S*)/g,'<a href="$1" target="_blank">$1</a>'))});c.registerHelper("nl2br",function(a){return new c.SafeString(a.replace(/\n/g,"<br/>"))});c.registerHelper("l10n",function(a){return e.Localization.get(a)||
""});c.registerHelper("ifEven",function(a,b){return 0===a%2?b.fn(this):b.inverse(this)});c.registerHelper("ifOdd",function(a,b){return 0!==a%2?b.fn(this):b.inverse(this)})})(Mibew,Handlebars);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
var Mibew={};(function(a,d,b){d.Marionette.TemplateCache.prototype.compileTemplate=function(a){return b.compile(a)};for(var c in b.templates)b.templates.hasOwnProperty(c)&&b.registerPartial(c,b.templates[c]);a.Models={};a.Collections={};a.Views={};a.Objects={};a.Objects.Models={};a.Objects.Collections={}})(Mibew,Backbone,Handlebars);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,d){b.Localization={};var c={};b.Localization.get=function(a){return!c.hasOwnProperty(a)?!1:c[a]};b.Localization.set=function(a){d.extend(c,a)}})(Mibew,_);

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,c,d){b.Views.Control=c.Marionette.ItemView.extend({template:d.templates.default_control,modelEvents:{change:"render"},events:{mouseover:"mouseOver",mouseleave:"mouseLeave"},attributes:function(){var a=[];a.push("control");this.className&&(a.push(this.className),this.className="");var b=this.getDashedControlType();b&&a.push(b);return{"class":a.join(" ")}},mouseOver:function(){var a=this.getDashedControlType();this.$el.addClass("active"+(a?"-"+a:""))},mouseLeave:function(){var a=this.getDashedControlType();
this.$el.removeClass("active"+(a?"-"+a:""))},getDashedControlType:function(){"undefined"==typeof this.dashedControlType&&(this.dashedControlType=b.Utils.toDashFormat(this.model.getModelType())||"");return this.dashedControlType}})})(Mibew,Backbone,Handlebars);

View File

@ -0,0 +1,9 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(c,d,e){var f={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},g=/[&<>'"`]/g;c.Views.Message=d.Marionette.ItemView.extend({template:e.templates.message,className:"message",modelEvents:{change:"render"},serializeData:function(){var a=this.model.toJSON(),b=this.model.get("kind");a.allowFormatting=b!=this.model.KIND_USER&&b!=this.model.KIND_AGENT;a.kindName=this.kindToString(b);a.message=this.escapeString(a.message);return a},kindToString:function(a){return a==this.model.KIND_USER?
"user":a==this.model.KIND_AGENT?"agent":a==this.model.KIND_FOR_AGENT?"hidden":a==this.model.KIND_INFO?"inf":a==this.model.KIND_CONN?"conn":a==this.model.KIND_EVENTS?"event":a==this.model.KIND_PLUGIN?"plugin":""},escapeString:function(a){return a.replace(g,function(a){return f[a]||"&amp;"})}})})(Mibew,Backbone,Handlebars);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.Base=b.Model.extend({getModelType:function(){return""}})})(Mibew,Backbone);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.Control=a.Models.Base.extend({defaults:{title:"",weight:0}})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.Message=a.Models.Base.extend({defaults:{kind:null,created:0,name:"",message:"",plugin:"",data:{}},KIND_USER:1,KIND_AGENT:2,KIND_FOR_AGENT:3,KIND_INFO:4,KIND_CONN:5,KIND_EVENTS:6,KIND_PLUGIN:7})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a,b){a.Models.Page=b.Model.extend()})(Mibew,Backbone);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.Thread=a.Models.Base.extend({defaults:{id:0,token:0,lastId:0,state:null},STATE_QUEUE:0,STATE_WAITING:1,STATE_CHATTING:2,STATE_CLOSED:3,STATE_LOADING:4,STATE_LEFT:5,STATE_INVITED:6})})(Mibew);

View File

@ -0,0 +1,8 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(a){a.Models.User=a.Models.Base.extend({defaults:{isAgent:!1,name:""}})})(Mibew);

View File

@ -0,0 +1,15 @@
/*
Copyright 2005-2014 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
(function(b,f,g,e){b.Server=function(a){this.updateTimer=null;this.options=e.extend({url:"",requestsFrequency:2,reconnectPause:1,onTimeout:function(){},onTransportError:function(){},onCallError:function(){},onUpdateError:function(){},onResponseError:function(){}},a);this.callbacks={};this.callPeriodically={};this.callPeriodicallyLastId=0;this.ajaxRequest=null;this.buffer=[];this.functions={};this.functionsLastId=0;this.mibewAPI=new f(new this.options.interactionType)};b.Server.prototype.callFunctions=
function(a,c,b){try{if(!(a instanceof Array))throw Error("The first arguments must be an array");for(var d=0;d<a.length;d++)this.mibewAPI.checkFunction(a[d],!1);var e=this.generateToken();this.callbacks[e]=c;this.buffer.push({token:e,functions:a});b&&this.update()}catch(f){return this.options.onCallError(f),!1}return!0};b.Server.prototype.callFunctionsPeriodically=function(a,c){this.callPeriodicallyLastId++;this.callPeriodically[this.callPeriodicallyLastId]={functionsListBuilder:a,callbackFunction:c};
return this.callPeriodicallyLastId};b.Server.prototype.stopCallFunctionsPeriodically=function(a){a in this.callPeriodically&&delete this.callPeriodically[a]};b.Server.prototype.generateToken=function(){var a;do a="wnd"+(new Date).getTime().toString()+Math.round(50*Math.random()).toString();while(a in this.callbacks);return a};b.Server.prototype.processRequest=function(a){var c=new MibewAPIExecutionContext,b=this.mibewAPI.getResultFunction(a.functions,this.callbacks.hasOwnProperty(a.token));if(null===
b)for(var d in a.functions)a.functions.hasOwnProperty(d)&&(this.processFunction(a.functions[d],c),this.buffer.push(this.mibewAPI.buildResult(c.getResults(),a.token)));else this.callbacks.hasOwnProperty(a.token)&&(this.callbacks[a.token](b.arguments),delete this.callbacks[a.token])};b.Server.prototype.processFunction=function(a,c){if(this.functions.hasOwnProperty(a["function"])){var b=c.getArgumentsList(a),d={},f;for(f in this.functions[a["function"]])this.functions[a["function"]].hasOwnProperty(f)&&
(d=e.extend(d,this.functions[a["function"]][f](b)));c.storeFunctionResults(a,d)}};b.Server.prototype.sendRequests=function(a){this.ajaxRequest=g.ajax({url:this.options.url,timeout:5E3,async:!0,cache:!1,type:"POST",dataType:"text",data:{data:this.mibewAPI.encodePackage(a)},success:e.bind(this.receiveResponse,this),error:e.bind(this.onError,this)})};b.Server.prototype.runUpdater=function(){this.update()};b.Server.prototype.updateAfter=function(a){this.updateTimer=setTimeout(e.bind(this.update,this),
1E3*a)};b.Server.prototype.restartUpdater=function(){this.updateTimer&&clearTimeout(this.updateTimer);this.ajaxRequest&&this.ajaxRequest.abort();this.updateAfter(this.options.reconnectPause)};b.Server.prototype.update=function(){this.updateTimer&&clearTimeout(this.updateTimer);for(var a in this.callPeriodically)this.callPeriodically.hasOwnProperty(a)&&this.callFunctions(this.callPeriodically[a].functionsListBuilder(),this.callPeriodically[a].callbackFunction);if(0==this.buffer.length)this.updateAfter(this.options.requestsFrequency);
else try{this.sendRequests(this.buffer),this.buffer=[]}catch(c){this.options.onUpdateError(c)}};b.Server.prototype.receiveResponse=function(a){""==a&&this.updateAfter(this.options.requestsFrequency);try{var c=this.mibewAPI.decodePackage(a),b;for(b in c.requests)this.processRequest(c.requests[b])}catch(d){this.options.onResponseError(d)}finally{this.updateAfter(this.options.requestsFrequency)}};b.Server.prototype.registerFunction=function(a,b){this.functionsLastId++;a in this.functions||(this.functions[a]=
{});this.functions[a][this.functionsLastId]=b;return this.functionsLastId};b.Server.prototype.unregisterFunction=function(a){for(var b in this.functions)this.functions.hasOwnProperty(b)&&(a in this.functions[b]&&delete this.functions[b][a],e.isEmpty(this.functions[b])&&delete this.functions[b])};b.Server.prototype.onError=function(a,b){if("abort"!=b)if(this.restartUpdater(),"timeout"==b)this.options.onTimeout();else if("error"==b)this.options.onTransportError()}})(Mibew,MibewAPI,$,_);

Some files were not shown because too many files have changed in this diff Show More