first commit
This commit is contained in:
commit
0010a5886d
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"editor.fontSize": 13,
|
||||
"terminal.integrated.fontSize": 13,
|
||||
"window.zoomLevel": 1.4,
|
||||
}
|
||||
159
README.md
Normal file
159
README.md
Normal file
@ -0,0 +1,159 @@
|
||||
# Playbooks srv-stage
|
||||
Ce playbook installe et configure un serveur pour les stages découvertes de VdG
|
||||
|
||||
## Infrastructure
|
||||
### Serveur
|
||||
* serveur virtuel avec [**Rocky Linux 9**](https://gmodocs.dyndns.org/system/rocky/installation/) (minimum)
|
||||
* hostname configuré (srv-stage)
|
||||
* adresse IP configurée avec 172.31.10.20 (home) 172.31.10.20 + proxy (vdg)
|
||||
* git installé et configuré
|
||||
* tar package installé
|
||||
* selinux disabled
|
||||
|
||||
### Réseau
|
||||
**Nom du domaine** : stage-ge.org
|
||||
|
||||
|Adresse IP|Nom|Description
|
||||
|:--|:--|:--|
|
||||
|10.10.10.1|srv-stage|serveur de stage|
|
||||
|10.10.10.21| 10.10.10.30|wpc01|wpc10| workstation des stagiaires|
|
||||
|10.10.10.40|server2016|serveur windows|
|
||||
|10.10.10.41|printer01|imprimante partagée|
|
||||
|10.10.10.50|vancouver|serveur hôte
|
||||
|
||||
### Utilisateurs
|
||||
|
||||
|Utilisateur|Nom prénom|Courriel|Mot de passe|
|
||||
|:--|:--|:--|:--
|
||||
|stagiaire1|Stagiaire Uu|stagiaire1@stage-ge.org|password|
|
||||
|stagiaire2|Stagiaire Deux|stagiaire2@stage-ge.org|password|
|
||||
|stagiaire3|Stagiaire Trois|stagiaire3@stage-ge.org|password|
|
||||
|stagiaire4|Stagiaire Quatre|stagiaire4@stage-ge.org|password|
|
||||
|stagiaire5|Stagiaire Cinq|stagiaire5@stage-ge.org|password|
|
||||
|stagiaire6|Stagiaire Six|stagiaire6@stage-ge.org|password|
|
||||
|stagiaire7|Stagiaire Sept|stagiaire7@stage-ge.org|password|
|
||||
|stagiaire8|Stagiaire Huit|stagiaire8@stage-ge.org|password|
|
||||
|stagiaire9|Stagiaire Neuf|stagiaire9@stage-ge.org|password|
|
||||
|stagiaire10|Stagiaire Dix|stagiaire10@stage-ge.org|password|
|
||||
|mailadmin|Admin Mail|mailadmin@stage-ge.org|Pa55w0rd|
|
||||
|cyrus|Admin Cyrus|-|Pa55w0rd|
|
||||
|adminldap|Admin LDAP|-|Pa55w0rd|
|
||||
|nagiosadmin| Nagios Admin|-|nagiosadmin
|
||||
|accessldap|Access LDAP|-|passw0rd|
|
||||
|root|mysql utilisateur|-|Pa55w0rd|
|
||||
|
||||
### Services installés et configurés
|
||||
|
||||
* un DNS
|
||||
* des utilisateurs locaux
|
||||
* un service httpd (apache)
|
||||
* un service php-fpm (8.2)
|
||||
* un moteur de DB (mariaDB)
|
||||
* phpmyadmin
|
||||
* un service d'annuaire (openldap)
|
||||
* LDAP Account Manager
|
||||
* un MTA (postfix)
|
||||
* saslauthd
|
||||
* un service IMAP (cyrus)
|
||||
* un webmail (roundcube)
|
||||
* un service ftpd (piure-ftpd)
|
||||
* nagios
|
||||
* docker
|
||||
* chat-box programe (via docker)
|
||||
|
||||
### Scripts
|
||||
|
||||
|Nom du script|Type|Description|
|
||||
|:--|:--|:--|
|
||||
|`instsrv.sh`|-|Installe le serveur|
|
||||
|`sendWelcomeMail.sh`|Généré par le playbook|Envoie un message de bienvenue dans la boîte des stagiaires|
|
||||
|`testSrv.sh`|Généré par le playbook|Test les services du serveur|
|
||||
|`stage-ip`|Lien symbolique sur `changeIp.sh`|Config réseau stage|
|
||||
|`vdg-ip`|Lien symbolique sur `changeIp.sh`|Config réseau VdG|
|
||||
|`home-ip`|Lien symbolique sur `changeIp.sh`|Config réseau maison|
|
||||
|`stg1` à `stg10`|Lien symbolique sur `muttStage.sh`|Affiche l'inbox du stagiaire|
|
||||
|`readAllMailbox.sh`|-|Affiche tous les messages de tous les stagiaires ou d'un stagiaire en particulier (param: 1 à 10)
|
||||
|
||||
## Installation
|
||||
```
|
||||
git clone https://gitweb.dyndns.org/scripts/srv-stage.git
|
||||
```
|
||||
```
|
||||
cd srv-stage
|
||||
chmod +x instsrv.sh
|
||||
./instsrv.sh
|
||||
```
|
||||
|
||||
## Test
|
||||
### Automatique
|
||||
./stage-ip or ./home-ip or ./vdg-ip
|
||||
./testSrv.sh
|
||||
|
||||
### Manuel
|
||||
#### LDAP
|
||||
ldapsearch -H ldap://localhost -x -D "cn=Access LDAP,dc=stage-ge,dc=org" -b "dc=stage-ge,dc=org" CN=* -W LLL
|
||||
ldapsearch -H ldap://localhost -x -D "cn=Admin LDAP,dc=stage-ge,dc=org" -b "dc=stage-ge,dc=org" CN=* -W LLL
|
||||
ldapsearch -H ldap://localhost -x -D "cn=Stagiaire Un,ou=People,dc=stage-ge,dc=org" -b "dc=stage-ge,dc=org" CN=* -W -LLL
|
||||
|
||||
#### saslauth
|
||||
testsaslauthd -u stagiaire1 -p password
|
||||
0: OK "Success."
|
||||
|
||||
#### cyrusadm
|
||||
cyradm -u cyrus localhost
|
||||
lm
|
||||
|
||||
#### chat-box
|
||||
```bash
|
||||
docker compose -f /home/chat-box/docker-compose.yml up -d
|
||||
docker exec -it apache_stage /bin/bash
|
||||
root@chat-box:/var/www# php -q socket.php
|
||||
```
|
||||
```
|
||||
http://srv-stage.stage-ge.org:8001
|
||||
```
|
||||

|
||||
|
||||
#### tcpdump
|
||||
|
||||
tcpdump port http or port ftp or port smtp or port imap or port pop3 or port telnet -l -A | egrep -i -B5 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|username:|password:|login:|pass |user '
|
||||
|
||||
tcpdump port http -i lo -l -A | grep -i "task=login?&_user=stagiaire2&_pass" --color=auto --line-buffered -B20"
|
||||
|
||||
ou
|
||||
|
||||
tcpdump -vvvv port 389 -i lo -l -A | grep dc=org
|
||||
|
||||
ou
|
||||
|
||||
tcpdump -vvvv port 389 -i lo -l -A | egrep -i 'dc=org' --color=auto --line-buffered -B20
|
||||
|
||||
ou
|
||||
|
||||
tcpdump -vvvv port 389 -i lo -l -A | egrep -i 'Access LDAP' --color=auto --line-buffered -B20
|
||||
|
||||
#### Créer une trace http pour tcpdump
|
||||
|
||||
curl --interface 127.0.0.1 "http:/webmail.stage-ge.org?task=login?&_user=stagiaire1&_pass=password"
|
||||
|
||||
## Changelog
|
||||
#### V2.2 - 2025-01-19
|
||||
##### added
|
||||
- changeIp via ansible
|
||||
##### fixed
|
||||
- DNS config when change ip
|
||||
- build chat box image for arm64
|
||||
#### V2.1 - 2023-12-26
|
||||
##### Added
|
||||
- docker
|
||||
- chat-box
|
||||
#### V2.0 - 2023-01-29
|
||||
##### Added
|
||||
- php82
|
||||
- nagios
|
||||
- vsftpd
|
||||
##### Updated
|
||||
- somes scripts files
|
||||
#### V1.0 - 2021-12-05
|
||||
##### Added
|
||||
- Initial version by [GMo](mailto:gilles.mouchet@gmail.com)
|
||||
683
ansible.cfg
Normal file
683
ansible.cfg
Normal file
@ -0,0 +1,683 @@
|
||||
[defaults]
|
||||
# (boolean) By default Ansible will issue a warning when received from a task action (module or action plugin)
|
||||
# These warnings can be silenced by adjusting this setting to False.
|
||||
;action_warnings=True
|
||||
|
||||
# (list) Accept list of cowsay templates that are 'safe' to use, set to empty list if you want to enable all installed templates.
|
||||
;cowsay_enabled_stencils=bud-frogs, bunny, cheese, daemon, default, dragon, elephant-in-snake, elephant, eyes, hellokitty, kitty, luke-koala, meow, milk, moofasa, moose, ren, sheep, small, stegosaurus, stimpy, supermilker, three-eyes, turkey, turtle, tux, udder, vader-koala, vader, www
|
||||
|
||||
# (string) Specify a custom cowsay path or swap in your cowsay implementation of choice
|
||||
;cowpath=
|
||||
|
||||
# (string) This allows you to chose a specific cowsay stencil for the banners or use 'random' to cycle through them.
|
||||
;cow_selection=default
|
||||
|
||||
# (boolean) This option forces color mode even when running without a TTY or the "nocolor" setting is True.
|
||||
;force_color=False
|
||||
|
||||
# (path) The default root path for Ansible config files on the controller.
|
||||
;home=~/.ansible
|
||||
|
||||
# (boolean) This setting allows suppressing colorizing output, which is used to give a better indication of failure and status information.
|
||||
;nocolor=False
|
||||
|
||||
# (boolean) If you have cowsay installed but want to avoid the 'cows' (why????), use this.
|
||||
;nocows=False
|
||||
|
||||
# (boolean) Sets the default value for the any_errors_fatal keyword, if True, Task failures will be considered fatal errors.
|
||||
;any_errors_fatal=False
|
||||
|
||||
# (path) The password file to use for the become plugin. --become-password-file.
|
||||
# If executable, it will be run and the resulting stdout will be used as the password.
|
||||
;become_password_file=
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Become Plugins.
|
||||
;become_plugins={{ ANSIBLE_HOME ~ "/plugins/become:/usr/share/ansible/plugins/become" }}
|
||||
|
||||
# (string) Chooses which cache plugin to use, the default 'memory' is ephemeral.
|
||||
;fact_caching=memory
|
||||
|
||||
# (string) Defines connection or path information for the cache plugin
|
||||
;fact_caching_connection=
|
||||
|
||||
# (string) Prefix to use for cache plugin files/tables
|
||||
;fact_caching_prefix=ansible_facts
|
||||
|
||||
# (integer) Expiration timeout for the cache plugin data
|
||||
;fact_caching_timeout=86400
|
||||
|
||||
# (list) List of enabled callbacks, not all callbacks need enabling, but many of those shipped with Ansible do as we don't want them activated by default.
|
||||
;callbacks_enabled=
|
||||
|
||||
# (string) When a collection is loaded that does not support the running Ansible version (with the collection metadata key `requires_ansible`).
|
||||
;collections_on_ansible_version_mismatch=warning
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for collections content. Collections must be in nested *subdirectories*, not directly in these directories. For example, if ``COLLECTIONS_PATHS`` includes ``'{{ ANSIBLE_HOME ~ "/collections" }}'``, and you want to add ``my.collection`` to that directory, it must be saved as ``'{{ ANSIBLE_HOME} ~ "/collections/ansible_collections/my/collection" }}'``.
|
||||
|
||||
;collections_path={{ ANSIBLE_HOME ~ "/collections:/usr/share/ansible/collections" }}
|
||||
|
||||
# (boolean) A boolean to enable or disable scanning the sys.path for installed collections
|
||||
;collections_scan_sys_path=True
|
||||
|
||||
# (path) The password file to use for the connection plugin. --connection-password-file.
|
||||
;connection_password_file=
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Action Plugins.
|
||||
;action_plugins={{ ANSIBLE_HOME ~ "/plugins/action:/usr/share/ansible/plugins/action" }}
|
||||
|
||||
# (boolean) When enabled, this option allows lookup plugins (whether used in variables as ``{{lookup('foo')}}`` or as a loop as with_foo) to return data that is not marked 'unsafe'.
|
||||
# By default, such data is marked as unsafe to prevent the templating engine from evaluating any jinja2 templating language, as this could represent a security risk. This option is provided to allow for backward compatibility, however users should first consider adding allow_unsafe=True to any lookups which may be expected to contain data which may be run through the templating engine late
|
||||
;allow_unsafe_lookups=True
|
||||
|
||||
# (boolean) This controls whether an Ansible playbook should prompt for a login password. If using SSH keys for authentication, you probably do not need to change this setting.
|
||||
;ask_pass=False
|
||||
|
||||
# (boolean) This controls whether an Ansible playbook should prompt for a vault password.
|
||||
;ask_vault_pass=False
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Cache Plugins.
|
||||
;cache_plugins={{ ANSIBLE_HOME ~ "/plugins/cache:/usr/share/ansible/plugins/cache" }}
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Callback Plugins.
|
||||
;callback_plugins={{ ANSIBLE_HOME ~ "/plugins/callback:/usr/share/ansible/plugins/callback" }}
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Cliconf Plugins.
|
||||
;cliconf_plugins={{ ANSIBLE_HOME ~ "/plugins/cliconf:/usr/share/ansible/plugins/cliconf" }}
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Connection Plugins.
|
||||
;connection_plugins={{ ANSIBLE_HOME ~ "/plugins/connection:/usr/share/ansible/plugins/connection" }}
|
||||
|
||||
# (boolean) Toggles debug output in Ansible. This is *very* verbose and can hinder multiprocessing. Debug output can also include secret information despite no_log settings being enabled, which means debug mode should not be used in production.
|
||||
;debug=False
|
||||
|
||||
# (string) This indicates the command to use to spawn a shell under for Ansible's execution needs on a target. Users may need to change this in rare instances when shell usage is constrained, but in most cases it may be left as is.
|
||||
;executable=/bin/sh
|
||||
|
||||
# (string) This option allows you to globally configure a custom path for 'local_facts' for the implied :ref:`ansible_collections.ansible.builtin.setup_module` task when using fact gathering.
|
||||
# If not set, it will fallback to the default from the ``ansible.builtin.setup`` module: ``/etc/ansible/facts.d``.
|
||||
# This does **not** affect user defined tasks that use the ``ansible.builtin.setup`` module.
|
||||
# The real action being created by the implicit task is currently ``ansible.legacy.gather_facts`` module, which then calls the configured fact modules, by default this will be ``ansible.builtin.setup`` for POSIX systems but other platforms might have different defaults.
|
||||
;fact_path=
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Jinja2 Filter Plugins.
|
||||
;filter_plugins={{ ANSIBLE_HOME ~ "/plugins/filter:/usr/share/ansible/plugins/filter" }}
|
||||
|
||||
# (boolean) This option controls if notified handlers run on a host even if a failure occurs on that host.
|
||||
# When false, the handlers will not run if a failure has occurred on a host.
|
||||
# This can also be set per play or on the command line. See Handlers and Failure for more details.
|
||||
;force_handlers=False
|
||||
|
||||
# (integer) Maximum number of forks Ansible will use to execute tasks on target hosts.
|
||||
;forks=5
|
||||
|
||||
# (string) This setting controls the default policy of fact gathering (facts discovered about remote systems).
|
||||
# This option can be useful for those wishing to save fact gathering time. Both 'smart' and 'explicit' will use the cache plugin.
|
||||
;gathering=implicit
|
||||
|
||||
# (list) Set the `gather_subset` option for the :ref:`ansible_collections.ansible.builtin.setup_module` task in the implicit fact gathering. See the module documentation for specifics.
|
||||
# It does **not** apply to user defined ``ansible.builtin.setup`` tasks.
|
||||
;gather_subset=
|
||||
|
||||
# (integer) Set the timeout in seconds for the implicit fact gathering, see the module documentation for specifics.
|
||||
# It does **not** apply to user defined :ref:`ansible_collections.ansible.builtin.setup_module` tasks.
|
||||
;gather_timeout=
|
||||
|
||||
# (string) This setting controls how duplicate definitions of dictionary variables (aka hash, map, associative array) are handled in Ansible.
|
||||
# This does not affect variables whose values are scalars (integers, strings) or arrays.
|
||||
# **WARNING**, changing this setting is not recommended as this is fragile and makes your content (plays, roles, collections) non portable, leading to continual confusion and misuse. Don't change this setting unless you think you have an absolute need for it.
|
||||
# We recommend avoiding reusing variable names and relying on the ``combine`` filter and ``vars`` and ``varnames`` lookups to create merged versions of the individual variables. In our experience this is rarely really needed and a sign that too much complexity has been introduced into the data structures and plays.
|
||||
# For some uses you can also look into custom vars_plugins to merge on input, even substituting the default ``host_group_vars`` that is in charge of parsing the ``host_vars/`` and ``group_vars/`` directories. Most users of this setting are only interested in inventory scope, but the setting itself affects all sources and makes debugging even harder.
|
||||
# All playbooks and roles in the official examples repos assume the default for this setting.
|
||||
# Changing the setting to ``merge`` applies across variable sources, but many sources will internally still overwrite the variables. For example ``include_vars`` will dedupe variables internally before updating Ansible, with 'last defined' overwriting previous definitions in same file.
|
||||
# The Ansible project recommends you **avoid ``merge`` for new projects.**
|
||||
# It is the intention of the Ansible developers to eventually deprecate and remove this setting, but it is being kept as some users do heavily rely on it. New projects should **avoid 'merge'**.
|
||||
;hash_behaviour=replace
|
||||
|
||||
# (pathlist) Comma separated list of Ansible inventory sources
|
||||
;inventory=/etc/ansible/hosts
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for HttpApi Plugins.
|
||||
;httpapi_plugins={{ ANSIBLE_HOME ~ "/plugins/httpapi:/usr/share/ansible/plugins/httpapi" }}
|
||||
|
||||
# (float) This sets the interval (in seconds) of Ansible internal processes polling each other. Lower values improve performance with large playbooks at the expense of extra CPU load. Higher values are more suitable for Ansible usage in automation scenarios, when UI responsiveness is not required but CPU usage might be a concern.
|
||||
# The default corresponds to the value hardcoded in Ansible <= 2.1
|
||||
;internal_poll_interval=0.001
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Inventory Plugins.
|
||||
;inventory_plugins={{ ANSIBLE_HOME ~ "/plugins/inventory:/usr/share/ansible/plugins/inventory" }}
|
||||
|
||||
# (string) This is a developer-specific feature that allows enabling additional Jinja2 extensions.
|
||||
# See the Jinja2 documentation for details. If you do not know what these do, you probably don't need to change this setting :)
|
||||
;jinja2_extensions=[]
|
||||
|
||||
# (boolean) This option preserves variable types during template operations.
|
||||
;jinja2_native=False
|
||||
|
||||
# (boolean) Enables/disables the cleaning up of the temporary files Ansible used to execute the tasks on the remote.
|
||||
# If this option is enabled it will disable ``ANSIBLE_PIPELINING``.
|
||||
;keep_remote_files=False
|
||||
|
||||
# (boolean) Controls whether callback plugins are loaded when running /usr/bin/ansible. This may be used to log activity from the command line, send notifications, and so on. Callback plugins are always loaded for ``ansible-playbook``.
|
||||
;bin_ansible_callbacks=False
|
||||
|
||||
# (tmppath) Temporary directory for Ansible to use on the controller.
|
||||
;local_tmp={{ ANSIBLE_HOME ~ "/tmp" }}
|
||||
|
||||
# (list) List of logger names to filter out of the log file
|
||||
;log_filter=
|
||||
|
||||
# (path) File to which Ansible will log on the controller. When empty logging is disabled.
|
||||
;log_path=
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Lookup Plugins.
|
||||
;lookup_plugins={{ ANSIBLE_HOME ~ "/plugins/lookup:/usr/share/ansible/plugins/lookup" }}
|
||||
|
||||
# (string) Sets the macro for the 'ansible_managed' variable available for :ref:`ansible_collections.ansible.builtin.template_module` and :ref:`ansible_collections.ansible.windows.win_template_module`. This is only relevant for those two modules.
|
||||
;ansible_managed=Ansible managed
|
||||
|
||||
# (string) This sets the default arguments to pass to the ``ansible`` adhoc binary if no ``-a`` is specified.
|
||||
;module_args=
|
||||
|
||||
# (string) Compression scheme to use when transferring Python modules to the target.
|
||||
;module_compression=ZIP_DEFLATED
|
||||
|
||||
# (string) Module to use with the ``ansible`` AdHoc command, if none is specified via ``-m``.
|
||||
;module_name=command
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Modules.
|
||||
;library={{ ANSIBLE_HOME ~ "/plugins/modules:/usr/share/ansible/plugins/modules" }}
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Module utils files, which are shared by modules.
|
||||
;module_utils={{ ANSIBLE_HOME ~ "/plugins/module_utils:/usr/share/ansible/plugins/module_utils" }}
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Netconf Plugins.
|
||||
;netconf_plugins={{ ANSIBLE_HOME ~ "/plugins/netconf:/usr/share/ansible/plugins/netconf" }}
|
||||
|
||||
# (boolean) Toggle Ansible's display and logging of task details, mainly used to avoid security disclosures.
|
||||
;no_log=False
|
||||
|
||||
# (boolean) Toggle Ansible logging to syslog on the target when it executes tasks. On Windows hosts this will disable a newer style PowerShell modules from writing to the event log.
|
||||
;no_target_syslog=False
|
||||
|
||||
# (raw) What templating should return as a 'null' value. When not set it will let Jinja2 decide.
|
||||
;null_representation=
|
||||
|
||||
# (integer) For asynchronous tasks in Ansible (covered in Asynchronous Actions and Polling), this is how often to check back on the status of those tasks when an explicit poll interval is not supplied. The default is a reasonably moderate 15 seconds which is a tradeoff between checking in frequently and providing a quick turnaround when something may have completed.
|
||||
;poll_interval=15
|
||||
|
||||
# (path) Option for connections using a certificate or key file to authenticate, rather than an agent or passwords, you can set the default value here to avoid re-specifying --private-key with every invocation.
|
||||
;private_key_file=
|
||||
|
||||
# (boolean) Makes role variables inaccessible from other roles.
|
||||
# This was introduced as a way to reset role variables to default values if a role is used more than once in a playbook.
|
||||
;private_role_vars=False
|
||||
|
||||
# (integer) Port to use in remote connections, when blank it will use the connection plugin default.
|
||||
;remote_port=
|
||||
|
||||
# (string) Sets the login user for the target machines
|
||||
# When blank it uses the connection plugin's default, normally the user currently executing Ansible.
|
||||
;remote_user=
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Roles.
|
||||
;roles_path={{ ANSIBLE_HOME ~ "/roles:/usr/share/ansible/roles:/etc/ansible/roles" }}
|
||||
|
||||
# (string) Set the main callback used to display Ansible output. You can only have one at a time.
|
||||
# You can have many other callbacks, but just one can be in charge of stdout.
|
||||
# See :ref:`callback_plugins` for a list of available options.
|
||||
;stdout_callback=default
|
||||
|
||||
# (string) Set the default strategy used for plays.
|
||||
;strategy=linear
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Strategy Plugins.
|
||||
;strategy_plugins={{ ANSIBLE_HOME ~ "/plugins/strategy:/usr/share/ansible/plugins/strategy" }}
|
||||
|
||||
# (boolean) Toggle the use of "su" for tasks.
|
||||
;su=False
|
||||
|
||||
# (string) Syslog facility to use when Ansible logs to the remote target
|
||||
;syslog_facility=LOG_USER
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Terminal Plugins.
|
||||
;terminal_plugins={{ ANSIBLE_HOME ~ "/plugins/terminal:/usr/share/ansible/plugins/terminal" }}
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Jinja2 Test Plugins.
|
||||
;test_plugins={{ ANSIBLE_HOME ~ "/plugins/test:/usr/share/ansible/plugins/test" }}
|
||||
|
||||
# (integer) This is the default timeout for connection plugins to use.
|
||||
;timeout=10
|
||||
|
||||
# (string) Default connection plugin to use, the 'smart' option will toggle between 'ssh' and 'paramiko' depending on controller OS and ssh versions
|
||||
;transport=smart
|
||||
|
||||
# (boolean) When True, this causes ansible templating to fail steps that reference variable names that are likely typoed.
|
||||
# Otherwise, any '{{ template_expression }}' that contains undefined variables will be rendered in a template or ansible action line exactly as written.
|
||||
;error_on_undefined_vars=True
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Vars Plugins.
|
||||
;vars_plugins={{ ANSIBLE_HOME ~ "/plugins/vars:/usr/share/ansible/plugins/vars" }}
|
||||
|
||||
# (string) The vault_id to use for encrypting by default. If multiple vault_ids are provided, this specifies which to use for encryption. The --encrypt-vault-id cli option overrides the configured value.
|
||||
;vault_encrypt_identity=
|
||||
|
||||
# (string) The label to use for the default vault id label in cases where a vault id label is not provided
|
||||
;vault_identity=default
|
||||
|
||||
# (list) A list of vault-ids to use by default. Equivalent to multiple --vault-id args. Vault-ids are tried in order.
|
||||
;vault_identity_list=
|
||||
|
||||
# (string) If true, decrypting vaults with a vault id will only try the password from the matching vault-id
|
||||
;vault_id_match=False
|
||||
|
||||
# (path) The vault password file to use. Equivalent to --vault-password-file or --vault-id
|
||||
# If executable, it will be run and the resulting stdout will be used as the password.
|
||||
;vault_password_file=
|
||||
|
||||
# (integer) Sets the default verbosity, equivalent to the number of ``-v`` passed in the command line.
|
||||
;verbosity=0
|
||||
|
||||
# (boolean) Toggle to control the showing of deprecation warnings
|
||||
;deprecation_warnings=True
|
||||
|
||||
# (boolean) Toggle to control showing warnings related to running devel
|
||||
;devel_warning=True
|
||||
|
||||
# (boolean) Normally ``ansible-playbook`` will print a header for each task that is run. These headers will contain the name: field from the task if you specified one. If you didn't then ``ansible-playbook`` uses the task's action to help you tell which task is presently running. Sometimes you run many of the same action and so you want more information about the task to differentiate it from others of the same action. If you set this variable to True in the config then ``ansible-playbook`` will also include the task's arguments in the header.
|
||||
# This setting defaults to False because there is a chance that you have sensitive values in your parameters and you do not want those to be printed.
|
||||
# If you set this to True you should be sure that you have secured your environment's stdout (no one can shoulder surf your screen and you aren't saving stdout to an insecure file) or made sure that all of your playbooks explicitly added the ``no_log: True`` parameter to tasks which have sensitive values See How do I keep secret data in my playbook? for more information.
|
||||
;display_args_to_stdout=False
|
||||
|
||||
# (boolean) Toggle to control displaying skipped task/host entries in a task in the default callback
|
||||
;display_skipped_hosts=True
|
||||
|
||||
# (string) Root docsite URL used to generate docs URLs in warning/error text; must be an absolute URL with valid scheme and trailing slash.
|
||||
;docsite_root_url=https://docs.ansible.com/ansible-core/
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Documentation Fragments Plugins.
|
||||
;doc_fragment_plugins={{ ANSIBLE_HOME ~ "/plugins/doc_fragments:/usr/share/ansible/plugins/doc_fragments" }}
|
||||
|
||||
# (string) By default Ansible will issue a warning when a duplicate dict key is encountered in YAML.
|
||||
# These warnings can be silenced by adjusting this setting to False.
|
||||
;duplicate_dict_key=warn
|
||||
|
||||
# (boolean) Whether or not to enable the task debugger, this previously was done as a strategy plugin.
|
||||
# Now all strategy plugins can inherit this behavior. The debugger defaults to activating when
|
||||
# a task is failed on unreachable. Use the debugger keyword for more flexibility.
|
||||
;enable_task_debugger=False
|
||||
|
||||
# (boolean) Toggle to allow missing handlers to become a warning instead of an error when notifying.
|
||||
;error_on_missing_handler=True
|
||||
|
||||
# (list) Which modules to run during a play's fact gathering stage, using the default of 'smart' will try to figure it out based on connection type.
|
||||
# If adding your own modules but you still want to use the default Ansible facts, you will want to include 'setup' or corresponding network module to the list (if you add 'smart', Ansible will also figure it out).
|
||||
# This does not affect explicit calls to the 'setup' module, but does always affect the 'gather_facts' action (implicit or explicit).
|
||||
;facts_modules=smart
|
||||
|
||||
# (boolean) Set this to "False" if you want to avoid host key checking by the underlying tools Ansible uses to connect to the host
|
||||
;host_key_checking=True
|
||||
|
||||
# (boolean) Facts are available inside the `ansible_facts` variable, this setting also pushes them as their own vars in the main namespace.
|
||||
# Unlike inside the `ansible_facts` dictionary, these will have an `ansible_` prefix.
|
||||
;inject_facts_as_vars=True
|
||||
|
||||
# (string) Path to the Python interpreter to be used for module execution on remote targets, or an automatic discovery mode. Supported discovery modes are ``auto`` (the default), ``auto_silent``, ``auto_legacy``, and ``auto_legacy_silent``. All discovery modes employ a lookup table to use the included system Python (on distributions known to include one), falling back to a fixed ordered list of well-known Python interpreter locations if a platform-specific default is not available. The fallback behavior will issue a warning that the interpreter should be set explicitly (since interpreters installed later may change which one is used). This warning behavior can be disabled by setting ``auto_silent`` or ``auto_legacy_silent``. The value of ``auto_legacy`` provides all the same behavior, but for backwards-compatibility with older Ansible releases that always defaulted to ``/usr/bin/python``, will use that interpreter if present.
|
||||
;interpreter_python=auto
|
||||
|
||||
# (boolean) If 'false', invalid attributes for a task will result in warnings instead of errors
|
||||
;invalid_task_attribute_failed=True
|
||||
|
||||
# (boolean) Toggle to control showing warnings related to running a Jinja version older than required for jinja2_native
|
||||
;jinja2_native_warning=True
|
||||
|
||||
# (boolean) By default Ansible will issue a warning when there are no hosts in the inventory.
|
||||
# These warnings can be silenced by adjusting this setting to False.
|
||||
;localhost_warning=True
|
||||
|
||||
# (int) Maximum size of files to be considered for diff display
|
||||
;max_diff_size=104448
|
||||
|
||||
# (list) List of extensions to ignore when looking for modules to load
|
||||
# This is for rejecting script and binary module fallback extensions
|
||||
;module_ignore_exts={{(REJECT_EXTS + ('.yaml', '.yml', '.ini'))}}
|
||||
|
||||
# (bool) Enables whether module responses are evaluated for containing non UTF-8 data
|
||||
# Disabling this may result in unexpected behavior
|
||||
# Only ansible-core should evaluate this configuration
|
||||
;module_strict_utf8_response=True
|
||||
|
||||
# (list) TODO: write it
|
||||
;network_group_modules=eos, nxos, ios, iosxr, junos, enos, ce, vyos, sros, dellos9, dellos10, dellos6, asa, aruba, aireos, bigip, ironware, onyx, netconf, exos, voss, slxos
|
||||
|
||||
# (boolean) Previously Ansible would only clear some of the plugin loading caches when loading new roles, this led to some behaviours in which a plugin loaded in previous plays would be unexpectedly 'sticky'. This setting allows to return to that behaviour.
|
||||
;old_plugin_cache_clear=False
|
||||
|
||||
# (path) A number of non-playbook CLIs have a ``--playbook-dir`` argument; this sets the default value for it.
|
||||
;playbook_dir=
|
||||
|
||||
# (string) This sets which playbook dirs will be used as a root to process vars plugins, which includes finding host_vars/group_vars
|
||||
;playbook_vars_root=top
|
||||
|
||||
# (path) A path to configuration for filtering which plugins installed on the system are allowed to be used.
|
||||
# See :ref:`plugin_filtering_config` for details of the filter file's format.
|
||||
# The default is /etc/ansible/plugin_filters.yml
|
||||
;plugin_filters_cfg=
|
||||
|
||||
# (string) Attempts to set RLIMIT_NOFILE soft limit to the specified value when executing Python modules (can speed up subprocess usage on Python 2.x. See https://bugs.python.org/issue11284). The value will be limited by the existing hard limit. Default value of 0 does not attempt to adjust existing system-defined limits.
|
||||
;python_module_rlimit_nofile=0
|
||||
|
||||
# (bool) This controls whether a failed Ansible playbook should create a .retry file.
|
||||
;retry_files_enabled=False
|
||||
|
||||
# (path) This sets the path in which Ansible will save .retry files when a playbook fails and retry files are enabled.
|
||||
# This file will be overwritten after each run with the list of failed hosts from all plays.
|
||||
;retry_files_save_path=
|
||||
|
||||
# (str) This setting can be used to optimize vars_plugin usage depending on user's inventory size and play selection.
|
||||
;run_vars_plugins=demand
|
||||
|
||||
# (bool) This adds the custom stats set via the set_stats plugin to the default output
|
||||
;show_custom_stats=False
|
||||
|
||||
# (string) Action to take when a module parameter value is converted to a string (this does not affect variables). For string parameters, values such as '1.00', "['a', 'b',]", and 'yes', 'y', etc. will be converted by the YAML parser unless fully quoted.
|
||||
# Valid options are 'error', 'warn', and 'ignore'.
|
||||
# Since 2.8, this option defaults to 'warn' but will change to 'error' in 2.12.
|
||||
;string_conversion_action=warn
|
||||
|
||||
# (boolean) Allows disabling of warnings related to potential issues on the system running ansible itself (not on the managed hosts)
|
||||
# These may include warnings about 3rd party packages or other conditions that should be resolved if possible.
|
||||
;system_warnings=True
|
||||
|
||||
# (boolean) This option defines whether the task debugger will be invoked on a failed task when ignore_errors=True is specified.
|
||||
# True specifies that the debugger will honor ignore_errors, False will not honor ignore_errors.
|
||||
;task_debugger_ignore_errors=True
|
||||
|
||||
# (integer) Set the maximum time (in seconds) that a task can run for.
|
||||
# If set to 0 (the default) there is no timeout.
|
||||
;task_timeout=0
|
||||
|
||||
# (string) Make ansible transform invalid characters in group names supplied by inventory sources.
|
||||
;force_valid_group_names=never
|
||||
|
||||
# (boolean) Toggles the use of persistence for connections.
|
||||
;use_persistent_connections=False
|
||||
|
||||
# (bool) A toggle to disable validating a collection's 'metadata' entry for a module_defaults action group. Metadata containing unexpected fields or value types will produce a warning when this is True.
|
||||
;validate_action_group_metadata=True
|
||||
|
||||
# (list) Accept list for variable plugins that require it.
|
||||
;vars_plugins_enabled=host_group_vars
|
||||
|
||||
# (list) Allows to change the group variable precedence merge order.
|
||||
;precedence=all_inventory, groups_inventory, all_plugins_inventory, all_plugins_play, groups_plugins_inventory, groups_plugins_play
|
||||
|
||||
# (string) The salt to use for the vault encryption. If it is not provided, a random salt will be used.
|
||||
;vault_encrypt_salt=
|
||||
|
||||
# (bool) Force 'verbose' option to use stderr instead of stdout
|
||||
;verbose_to_stderr=False
|
||||
|
||||
# (integer) For asynchronous tasks in Ansible (covered in Asynchronous Actions and Polling), this is how long, in seconds, to wait for the task spawned by Ansible to connect back to the named pipe used on Windows systems. The default is 5 seconds. This can be too low on slower systems, or systems under heavy load.
|
||||
# This is not the total time an async command can run for, but is a separate timeout to wait for an async command to start. The task will only start to be timed against its async_timeout once it has connected to the pipe, so the overall maximum duration the task can take will be extended by the amount specified here.
|
||||
;win_async_startup_timeout=5
|
||||
|
||||
# (list) Check all of these extensions when looking for 'variable' files which should be YAML or JSON or vaulted versions of these.
|
||||
# This affects vars_files, include_vars, inventory and vars plugins among others.
|
||||
;yaml_valid_extensions=.yml, .yaml, .json
|
||||
|
||||
|
||||
[privilege_escalation]
|
||||
# (boolean) Display an agnostic become prompt instead of displaying a prompt containing the command line supplied become method
|
||||
;agnostic_become_prompt=True
|
||||
|
||||
# (boolean) This setting controls if become is skipped when remote user and become user are the same. I.E root sudo to root.
|
||||
# If executable, it will be run and the resulting stdout will be used as the password.
|
||||
;become_allow_same_user=False
|
||||
|
||||
# (boolean) Toggles the use of privilege escalation, allowing you to 'become' another user after login.
|
||||
;become=False
|
||||
|
||||
# (boolean) Toggle to prompt for privilege escalation password.
|
||||
;become_ask_pass=False
|
||||
|
||||
# (string) executable to use for privilege escalation, otherwise Ansible will depend on PATH
|
||||
;become_exe=
|
||||
|
||||
# (string) Flags to pass to the privilege escalation executable.
|
||||
;become_flags=
|
||||
|
||||
# (string) Privilege escalation method to use when `become` is enabled.
|
||||
;become_method=sudo
|
||||
|
||||
# (string) The user your login/remote user 'becomes' when using privilege escalation, most systems will use 'root' when no user is specified.
|
||||
;become_user=root
|
||||
|
||||
|
||||
[persistent_connection]
|
||||
# (path) Specify where to look for the ansible-connection script. This location will be checked before searching $PATH.
|
||||
# If null, ansible will start with the same directory as the ansible script.
|
||||
;ansible_connection_path=
|
||||
|
||||
# (int) This controls the amount of time to wait for response from remote device before timing out persistent connection.
|
||||
;command_timeout=30
|
||||
|
||||
# (integer) This controls the retry timeout for persistent connection to connect to the local domain socket.
|
||||
;connect_retry_timeout=15
|
||||
|
||||
# (integer) This controls how long the persistent connection will remain idle before it is destroyed.
|
||||
;connect_timeout=30
|
||||
|
||||
# (path) Path to socket to be used by the connection persistence system.
|
||||
;control_path_dir={{ ANSIBLE_HOME ~ "/pc" }}
|
||||
|
||||
|
||||
[connection]
|
||||
# (boolean) This is a global option, each connection plugin can override either by having more specific options or not supporting pipelining at all.
|
||||
# Pipelining, if supported by the connection plugin, reduces the number of network operations required to execute a module on the remote server, by executing many Ansible modules without actual file transfer.
|
||||
# It can result in a very significant performance improvement when enabled.
|
||||
# However this conflicts with privilege escalation (become). For example, when using 'sudo:' operations you must first disable 'requiretty' in /etc/sudoers on all managed hosts, which is why it is disabled by default.
|
||||
# This setting will be disabled if ``ANSIBLE_KEEP_REMOTE_FILES`` is enabled.
|
||||
;pipelining=False
|
||||
|
||||
|
||||
[colors]
|
||||
# (string) Defines the color to use on 'Changed' task status
|
||||
;changed=yellow
|
||||
|
||||
# (string) Defines the default color to use for ansible-console
|
||||
;console_prompt=white
|
||||
|
||||
# (string) Defines the color to use when emitting debug messages
|
||||
;debug=dark gray
|
||||
|
||||
# (string) Defines the color to use when emitting deprecation messages
|
||||
;deprecate=purple
|
||||
|
||||
# (string) Defines the color to use when showing added lines in diffs
|
||||
;diff_add=green
|
||||
|
||||
# (string) Defines the color to use when showing diffs
|
||||
;diff_lines=cyan
|
||||
|
||||
# (string) Defines the color to use when showing removed lines in diffs
|
||||
;diff_remove=red
|
||||
|
||||
# (string) Defines the color to use when emitting error messages
|
||||
;error=red
|
||||
|
||||
# (string) Defines the color to use for highlighting
|
||||
;highlight=white
|
||||
|
||||
# (string) Defines the color to use when showing 'OK' task status
|
||||
;ok=green
|
||||
|
||||
# (string) Defines the color to use when showing 'Skipped' task status
|
||||
;skip=cyan
|
||||
|
||||
# (string) Defines the color to use on 'Unreachable' status
|
||||
;unreachable=bright red
|
||||
|
||||
# (string) Defines the color to use when emitting verbose messages. i.e those that show with '-v's.
|
||||
;verbose=blue
|
||||
|
||||
# (string) Defines the color to use when emitting warning messages
|
||||
;warn=bright purple
|
||||
|
||||
|
||||
[selinux]
|
||||
# (boolean) This setting causes libvirt to connect to lxc containers by passing --noseclabel to virsh. This is necessary when running on systems which do not have SELinux.
|
||||
;libvirt_lxc_noseclabel=False
|
||||
|
||||
# (list) Some filesystems do not support safe operations and/or return inconsistent errors, this setting makes Ansible 'tolerate' those in the list w/o causing fatal errors.
|
||||
# Data corruption may occur and writes are not always verified when a filesystem is in the list.
|
||||
;special_context_filesystems=fuse, nfs, vboxsf, ramfs, 9p, vfat
|
||||
|
||||
|
||||
[diff]
|
||||
# (bool) Configuration toggle to tell modules to show differences when in 'changed' status, equivalent to ``--diff``.
|
||||
;always=False
|
||||
|
||||
# (integer) How many lines of context to show when displaying the differences between files.
|
||||
;context=3
|
||||
|
||||
|
||||
[galaxy]
|
||||
# (path) The directory that stores cached responses from a Galaxy server.
|
||||
# This is only used by the ``ansible-galaxy collection install`` and ``download`` commands.
|
||||
# Cache files inside this dir will be ignored if they are world writable.
|
||||
;cache_dir={{ ANSIBLE_HOME ~ "/galaxy_cache" }}
|
||||
|
||||
# (path) Collection skeleton directory to use as a template for the ``init`` action in ``ansible-galaxy collection``, same as ``--collection-skeleton``.
|
||||
;collection_skeleton=
|
||||
|
||||
# (list) patterns of files to ignore inside a Galaxy collection skeleton directory
|
||||
;collection_skeleton_ignore=^.git$, ^.*/.git_keep$
|
||||
|
||||
# (bool) Disable GPG signature verification during collection installation.
|
||||
;disable_gpg_verify=False
|
||||
|
||||
# (bool) Some steps in ``ansible-galaxy`` display a progress wheel which can cause issues on certain displays or when outputting the stdout to a file.
|
||||
# This config option controls whether the display wheel is shown or not.
|
||||
# The default is to show the display wheel if stdout has a tty.
|
||||
;display_progress=
|
||||
|
||||
# (path) Configure the keyring used for GPG signature verification during collection installation and verification.
|
||||
;gpg_keyring=
|
||||
|
||||
# (boolean) If set to yes, ansible-galaxy will not validate TLS certificates. This can be useful for testing against a server with a self-signed certificate.
|
||||
;ignore_certs=
|
||||
|
||||
# (list) A list of GPG status codes to ignore during GPG signature verification. See L(https://github.com/gpg/gnupg/blob/master/doc/DETAILS#general-status-codes) for status code descriptions.
|
||||
# If fewer signatures successfully verify the collection than `GALAXY_REQUIRED_VALID_SIGNATURE_COUNT`, signature verification will fail even if all error codes are ignored.
|
||||
;ignore_signature_status_codes=
|
||||
|
||||
# (str) The number of signatures that must be successful during GPG signature verification while installing or verifying collections.
|
||||
# This should be a positive integer or all to indicate all signatures must successfully validate the collection.
|
||||
# Prepend + to the value to fail if no valid signatures are found for the collection.
|
||||
;required_valid_signature_count=1
|
||||
|
||||
# (path) Role skeleton directory to use as a template for the ``init`` action in ``ansible-galaxy``/``ansible-galaxy role``, same as ``--role-skeleton``.
|
||||
;role_skeleton=
|
||||
|
||||
# (list) patterns of files to ignore inside a Galaxy role or collection skeleton directory
|
||||
;role_skeleton_ignore=^.git$, ^.*/.git_keep$
|
||||
|
||||
# (string) URL to prepend when roles don't specify the full URI, assume they are referencing this server as the source.
|
||||
;server=https://galaxy.ansible.com
|
||||
|
||||
# (list) A list of Galaxy servers to use when installing a collection.
|
||||
# The value corresponds to the config ini header ``[galaxy_server.{{item}}]`` which defines the server details.
|
||||
# See :ref:`galaxy_server_config` for more details on how to define a Galaxy server.
|
||||
# The order of servers in this list is used to as the order in which a collection is resolved.
|
||||
# Setting this config option will ignore the :ref:`galaxy_server` config option.
|
||||
;server_list=
|
||||
|
||||
# (path) Local path to galaxy access token file
|
||||
;token_path={{ ANSIBLE_HOME ~ "/galaxy_token" }}
|
||||
|
||||
|
||||
[inventory]
|
||||
# (string) This setting changes the behaviour of mismatched host patterns, it allows you to force a fatal error, a warning or just ignore it
|
||||
;host_pattern_mismatch=warning
|
||||
|
||||
# (boolean) If 'true', it is a fatal error when any given inventory source cannot be successfully parsed by any available inventory plugin; otherwise, this situation only attracts a warning.
|
||||
|
||||
;any_unparsed_is_failed=False
|
||||
|
||||
# (bool) Toggle to turn on inventory caching.
|
||||
# This setting has been moved to the individual inventory plugins as a plugin option :ref:`inventory_plugins`.
|
||||
# The existing configuration settings are still accepted with the inventory plugin adding additional options from inventory configuration.
|
||||
# This message will be removed in 2.16.
|
||||
;cache=False
|
||||
|
||||
# (string) The plugin for caching inventory.
|
||||
# This setting has been moved to the individual inventory plugins as a plugin option :ref:`inventory_plugins`.
|
||||
# The existing configuration settings are still accepted with the inventory plugin adding additional options from inventory and fact cache configuration.
|
||||
# This message will be removed in 2.16.
|
||||
;cache_plugin=
|
||||
|
||||
# (string) The inventory cache connection.
|
||||
# This setting has been moved to the individual inventory plugins as a plugin option :ref:`inventory_plugins`.
|
||||
# The existing configuration settings are still accepted with the inventory plugin adding additional options from inventory and fact cache configuration.
|
||||
# This message will be removed in 2.16.
|
||||
;cache_connection=
|
||||
|
||||
# (string) The table prefix for the cache plugin.
|
||||
# This setting has been moved to the individual inventory plugins as a plugin option :ref:`inventory_plugins`.
|
||||
# The existing configuration settings are still accepted with the inventory plugin adding additional options from inventory and fact cache configuration.
|
||||
# This message will be removed in 2.16.
|
||||
;cache_prefix=ansible_inventory_
|
||||
|
||||
# (string) Expiration timeout for the inventory cache plugin data.
|
||||
# This setting has been moved to the individual inventory plugins as a plugin option :ref:`inventory_plugins`.
|
||||
# The existing configuration settings are still accepted with the inventory plugin adding additional options from inventory and fact cache configuration.
|
||||
# This message will be removed in 2.16.
|
||||
;cache_timeout=3600
|
||||
|
||||
# (list) List of enabled inventory plugins, it also determines the order in which they are used.
|
||||
;enable_plugins=host_list, script, auto, yaml, ini, toml
|
||||
|
||||
# (bool) Controls if ansible-inventory will accurately reflect Ansible's view into inventory or its optimized for exporting.
|
||||
;export=False
|
||||
|
||||
# (list) List of extensions to ignore when using a directory as an inventory source
|
||||
;ignore_extensions={{(REJECT_EXTS + ('.orig', '.ini', '.cfg', '.retry'))}}
|
||||
|
||||
# (list) List of patterns to ignore when using a directory as an inventory source
|
||||
;ignore_patterns=
|
||||
|
||||
# (bool) If 'true' it is a fatal error if every single potential inventory source fails to parse, otherwise this situation will only attract a warning.
|
||||
|
||||
;unparsed_is_failed=False
|
||||
|
||||
# (boolean) By default Ansible will issue a warning when no inventory was loaded and notes that it will use an implicit localhost-only inventory.
|
||||
# These warnings can be silenced by adjusting this setting to False.
|
||||
;inventory_unparsed_warning=True
|
||||
|
||||
|
||||
[netconf_connection]
|
||||
# (string) This variable is used to enable bastion/jump host with netconf connection. If set to True the bastion/jump host ssh settings should be present in ~/.ssh/config file, alternatively it can be set to custom ssh configuration file path to read the bastion/jump host settings.
|
||||
;ssh_config=
|
||||
|
||||
|
||||
[paramiko_connection]
|
||||
# (boolean) TODO: write it
|
||||
;host_key_auto_add=False
|
||||
|
||||
# (boolean) TODO: write it
|
||||
;look_for_keys=True
|
||||
|
||||
|
||||
[jinja2]
|
||||
# (list) This list of filters avoids 'type conversion' when templating variables
|
||||
# Useful when you want to avoid conversion into lists or dictionaries for JSON strings, for example.
|
||||
;dont_type_filters=string, to_json, to_nice_json, to_yaml, to_nice_yaml, ppretty, json
|
||||
|
||||
|
||||
[tags]
|
||||
# (list) default list of tags to run in your plays, Skip Tags has precedence.
|
||||
;run=
|
||||
|
||||
# (list) default list of tags to skip in your plays, has precedence over Run Tags
|
||||
;skip=
|
||||
|
||||
68
apache.yml
Normal file
68
apache.yml
Normal file
@ -0,0 +1,68 @@
|
||||
---
|
||||
- name: install apache
|
||||
yum:
|
||||
name:
|
||||
- httpd
|
||||
- mod_ssl
|
||||
state: installed
|
||||
|
||||
- name: config for stagiaire's site
|
||||
template:
|
||||
src: httpd/stage.conf.j2
|
||||
dest: /etc/httpd/conf.d/stage.conf
|
||||
notify: restart_httpd
|
||||
|
||||
- name: set right to home path for apache
|
||||
file:
|
||||
path: "/home/{{ item.key }}"
|
||||
group: apache
|
||||
mode: 0750
|
||||
with_dict: "{{ stagiaires }}"
|
||||
|
||||
- name: create root apache directory
|
||||
file:
|
||||
path: /home/www/
|
||||
state: directory
|
||||
owner: apache
|
||||
group: apache
|
||||
|
||||
- name: create folder in /var
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
with_items:
|
||||
- /var/www
|
||||
- /var/www/html
|
||||
- /var/www/html/intranet
|
||||
|
||||
- name: copy index.php
|
||||
template:
|
||||
src: httpd/index.php.j2
|
||||
dest: "/var/www/html/intranet/index.php"
|
||||
|
||||
- name: copy file for default page
|
||||
copy:
|
||||
src: "httpd/{{ item }}"
|
||||
dest: "/var/www/html/intranet/{{ item }}"
|
||||
owner: apache
|
||||
group: apache
|
||||
with_items:
|
||||
- vdg.css
|
||||
- wlogo.gif
|
||||
- logo_26.png
|
||||
|
||||
- name: config for sites www"
|
||||
copy:
|
||||
src: "httpd/{{ item }}"
|
||||
dest: "/etc/httpd/conf.d/{{ item }}"
|
||||
with_items:
|
||||
- http-www.conf
|
||||
- https-www.conf
|
||||
- ssl.conf
|
||||
|
||||
- name: start and enable the httpd service
|
||||
systemd_service:
|
||||
state: started
|
||||
name: httpd
|
||||
enabled: true
|
||||
|
||||
21
assert-vars.yml
Normal file
21
assert-vars.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: Assert mandatory variables
|
||||
assert:
|
||||
that: "( item ) is defined"
|
||||
msg: "( item ) is not defined"
|
||||
with_items:
|
||||
- stagiaires
|
||||
- plain_user_passwd
|
||||
- plain_ldap_passwd
|
||||
- myslql_root_passd
|
||||
- phpmyadmin_version
|
||||
- plain_admincyrus_passwd
|
||||
- plain_mailadmin_passwd
|
||||
- plain_ldapmanager_passwd
|
||||
- plain_ldapadmin_passwd
|
||||
- plain_ldapaccess_passwd
|
||||
- ldapunix_group_name
|
||||
- ldapunix_group_id
|
||||
- cyrus_admin_user
|
||||
- cyrus_admin_pass
|
||||
- certs_path
|
||||
8
build-image.yml
Normal file
8
build-image.yml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: build container image. Please wait...
|
||||
docker_image:
|
||||
name: dsic-chat-box
|
||||
build:
|
||||
path: ./files/docker-image
|
||||
source: build
|
||||
state: present
|
||||
35
certificate.yml
Normal file
35
certificate.yml
Normal file
@ -0,0 +1,35 @@
|
||||
---
|
||||
#https://milliams.com/posts/2020/ansible-certificate-authority/
|
||||
|
||||
- name: create certs folder
|
||||
file:
|
||||
path: "{{ certs_path }}"
|
||||
state: directory
|
||||
|
||||
- name: create CA key
|
||||
openssl_privatekey:
|
||||
path: "{{ certs_path }}/stageCA.key"
|
||||
register: ca_key
|
||||
|
||||
- name: create the CA csr
|
||||
openssl_csr:
|
||||
path: "{{ certs_path }}/stageCA.csr"
|
||||
privatekey_path: "{{ ca_key.filename }}"
|
||||
common_name: "my-ca"
|
||||
register: ca_csr
|
||||
|
||||
- name: sign the CA csr
|
||||
openssl_certificate:
|
||||
path: "{{ certs_path }}/stageCA.crt"
|
||||
csr_path: "{{ ca_csr.filename }}"
|
||||
privatekey_path: "{{ ca_key.filename }}"
|
||||
provider: selfsigned
|
||||
register: ca_crt
|
||||
|
||||
- name: create key and csr
|
||||
shell: "openssl req -newkey rsa:2048 -days 1095 -nodes -keyout {{ certs_path }}/stage-ge.org.key -out {{ certs_path }}/stage-ge.org.csr -config ./files/certs/ca-config -subj '/'"
|
||||
changed_when: false
|
||||
|
||||
- name: create wilcard cert
|
||||
shell: "openssl x509 -req -in {{ certs_path }}/stage-ge.org.csr -CA {{ certs_path }}/stageCA.crt -CAkey {{ certs_path }}/stageCA.key -CAcreateserial -extfile ./files/certs/wilcard.cnf -out {{ certs_path }}/stage-ge.org.crt -days 365 -sha256"
|
||||
changed_when: false
|
||||
65
changeIp.sh
Executable file
65
changeIp.sh
Executable file
@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
############################################################
|
||||
# Decription: IP change
|
||||
# Author: Gilles Mouchet (gmo@ville-ge.ch)
|
||||
# Creation Date: 20-Jun-2018
|
||||
# Version: 1.1
|
||||
# Usage: ./vdg-ip, ./stage-ip. ./home-ip
|
||||
# Changelog:
|
||||
# V2.0 - 19-Jan-2025 - GMo
|
||||
# Changed
|
||||
# - Execute script ansible to change ip
|
||||
# V1.0 - 01-Dec-2021 - GMo
|
||||
# Added
|
||||
# - Creation of script from scratch
|
||||
#
|
||||
############################################################
|
||||
|
||||
# execute this script only from consol (not from ssh connection)
|
||||
if [[ -n "$SSH_CONNECTION" ]]; then
|
||||
echo "This script cannot be run from an SSH session."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prog_name=$(basename $0)
|
||||
|
||||
case $prog_name in
|
||||
stage-ip)
|
||||
# create inventory file
|
||||
echo -e "[stage]\nlocalhost" > inventory
|
||||
ansible-playbook -l stage -i inventory changeIp.yml
|
||||
rm -f nventory
|
||||
;;
|
||||
home-ip)
|
||||
# create inventory file
|
||||
echo -e "[home]\nlocalhost" > inventory
|
||||
ansible-playbook -l home -i inventory changeIp.yml
|
||||
rm -f inventory
|
||||
;;
|
||||
vdg-ip)
|
||||
# check if you are vdg network
|
||||
ping -c2 proxy.ville-geneve.ch > /dev/null 2>&1 #2>&1 >/dev/null
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "You are not in VdG network"
|
||||
exit 1
|
||||
fi
|
||||
# create inventory file
|
||||
echo -e "[vdg]\nlocalhost" > inventory
|
||||
ansible-playbook -l vdg -i inventory changeIp.yml
|
||||
rm -f inventory
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ./vdg-ip, ./stage-ip or ./home-ip"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "****************************************"
|
||||
echo "* Le serveur est prêt! *"
|
||||
echo "* Nouveau réseau: $prog_name *"
|
||||
echo "* N'oublier pas de changer de RESEAU ! *"
|
||||
echo "* Déconnectez/reconnectez vous pour *"
|
||||
echo "* être certain que le proxy est *"
|
||||
echo "* On ou Off *"
|
||||
echo "****************************************"
|
||||
|
||||
111
changeIp.yml
Normal file
111
changeIp.yml
Normal file
@ -0,0 +1,111 @@
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
tasks:
|
||||
|
||||
- name: where
|
||||
debug:
|
||||
var: new_ip
|
||||
|
||||
# - meta: end_play
|
||||
# ip, dns, gatewy saerch actuel to delete before update
|
||||
|
||||
# - name: unset ip via nmcli
|
||||
# nmcli:
|
||||
# type: ethernet
|
||||
# conn_name: "{{ ansible_default_ipv4.interface }}"
|
||||
# state: absent
|
||||
|
||||
# - meta: end_play
|
||||
|
||||
- name: set ip via nmcli
|
||||
nmcli:
|
||||
type: ethernet
|
||||
conn_name: "{{ ansible_default_ipv4.interface }}"
|
||||
ip4: "{{ new_ip }}/24"
|
||||
gw4: "{{ new_gw }}"
|
||||
dns4: "{{ new_dns }}"
|
||||
method4: manual
|
||||
dns4_search:
|
||||
- "{{ new_search }}"
|
||||
state: present
|
||||
|
||||
- name: down interface to apply the change
|
||||
nmcli:
|
||||
conn_name: "{{ ansible_default_ipv4.interface }}"
|
||||
state: down
|
||||
|
||||
- name: up interface to apply change
|
||||
nmcli:
|
||||
conn_name: "{{ ansible_default_ipv4.interface }}"
|
||||
state: up
|
||||
|
||||
- name: config DNS
|
||||
template:
|
||||
src: named/named.conf.j2
|
||||
dest: "{{ dns_conf_file }}"
|
||||
|
||||
- name: config zone
|
||||
template:
|
||||
src: named/stage-ge.org.zone.j2
|
||||
dest: "{{ zone_file }}"
|
||||
|
||||
|
||||
- name: create reverse script
|
||||
template:
|
||||
src: scripts/createrevers.sh.j2
|
||||
dest: /tmp/createrevers.sh
|
||||
mode: 0755
|
||||
|
||||
- name: create reverse file
|
||||
shell: /tmp/createrevers.sh
|
||||
|
||||
- name: block enable proxy
|
||||
block:
|
||||
- name: copy proxy.sh to profile
|
||||
copy:
|
||||
src: os/proxy.sh
|
||||
dest: /etc/profile.d/proxy.sh
|
||||
- name: add proxy line to yum.conf
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
insertafter: EOF
|
||||
line: proxy=http://proxy.ville-geneve.ch:8080
|
||||
- name: create folder for proxy docker
|
||||
file:
|
||||
path: /etc/systemd/system/docker.service.d
|
||||
state: directory
|
||||
- name: copy proxy config for docker
|
||||
copy:
|
||||
src: os/proxy.conf
|
||||
dest: /etc/systemd/system/docker.service.d/proxy.conf
|
||||
- name: get root VDG CA
|
||||
get_url:
|
||||
url: "http://intranet.ville-ge.ch/certs/{{ item }}"
|
||||
dest: "/etc/pki/ca-trust/source/anchors/{{ item }}"
|
||||
with_items:
|
||||
- rootcavdg_ROOTVDG-CA.crt
|
||||
- adsubca.crt
|
||||
- name: update ca trust
|
||||
shell: update-ca-trust
|
||||
changed_when: fale
|
||||
when: proxy|bool
|
||||
|
||||
- name: block disabe proxy
|
||||
block:
|
||||
- name: remove proxy.sh file
|
||||
file:
|
||||
path: /etc/profile.d/proxy.sh
|
||||
state: absent
|
||||
- name: remove proxy line from yum.conf
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
regexp: '^proxy'
|
||||
state: absent
|
||||
- name: remove proxy config for docker
|
||||
file:
|
||||
dest: /etc/systemd/system/docker.service.d/proxy.conf
|
||||
state: absent
|
||||
when: not proxy|bool
|
||||
|
||||
- name: restart all service
|
||||
include_tasks: restart-services.yml
|
||||
32
chat-box-ctl.yml
Normal file
32
chat-box-ctl.yml
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: start chat-box
|
||||
community.docker.docker_compose:
|
||||
project_src: /home/chat-box
|
||||
build: false
|
||||
tags:
|
||||
- start
|
||||
|
||||
- name: run chat-socket
|
||||
community.docker.docker_container_exec:
|
||||
container: apache_stage
|
||||
command: /bin/bash -c "php -q socket.php&"
|
||||
chdir: /var/www
|
||||
register: result
|
||||
tags:
|
||||
- start
|
||||
|
||||
- name: print result
|
||||
ansible.builtin.debug:
|
||||
var: result.stdout
|
||||
tags:
|
||||
- start
|
||||
|
||||
- name: down chat-box
|
||||
community.docker.docker_compose:
|
||||
project_src: /home/chat-box
|
||||
build: false
|
||||
state: absent
|
||||
tags:
|
||||
- stop
|
||||
32
chat-box.sh
Executable file
32
chat-box.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script name
|
||||
me=`basename "$0"`
|
||||
|
||||
# env var to disable ansible warnong message
|
||||
export ANSIBLE_INVENTORY_UNPARSED_WARNING=False
|
||||
export ANSIBLE_ACTION_WARNINGS=false
|
||||
export ANSIBLE_LOCALHOST_WARNING=false
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $me start | stop | restart"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" != "start" ] && [ "$1" != "stop" ] && [ "$1" != "restart" ]; then
|
||||
echo "Usage: $me start | stop | restart"
|
||||
exit
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
ansible-playbook chat-box-ctl.yml --tags "start"
|
||||
;;
|
||||
stop)
|
||||
ansible-playbook chat-box-ctl.yml --tags "stop"
|
||||
;;
|
||||
restart)
|
||||
ansible-playbook chat-box-ctl.yml --tags "stop"
|
||||
ansible-playbook chat-box-ctl.yml --tags "start"
|
||||
;;
|
||||
esac
|
||||
39
chat-box.yml
Normal file
39
chat-box.yml
Normal file
@ -0,0 +1,39 @@
|
||||
---
|
||||
- name: create chat-box folder
|
||||
file:
|
||||
path: /home/chat-box
|
||||
state: directory
|
||||
|
||||
- name: copy file server
|
||||
copy:
|
||||
src: chat-box/server/
|
||||
dest: /home/chat-box/
|
||||
|
||||
- name: copy docker-compose.yml
|
||||
template:
|
||||
src: chat-box/server/docker-compose.yml.j2
|
||||
dest: /home/chat-box/docker-compose.yml
|
||||
|
||||
- name: run docker-compose up
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: /home/chat-box
|
||||
build: never
|
||||
|
||||
#- name: run docker compose
|
||||
# command: docker compose -f /home/chat-box/docker-compose.yml up -d
|
||||
|
||||
### NE FONCTIONNE PLUS - A EXECUTER MANUELLEMENT
|
||||
#- name: run socket
|
||||
# community.docker.docker_container_exec:
|
||||
# container: apache_stage
|
||||
# command: /bin/bash -c "php -q socket.php&"
|
||||
# chdir: /var/www
|
||||
# register: result
|
||||
|
||||
#- name: run socket
|
||||
# command: docker exec apache_stage /bin/bash -c "php -q socket.php&"
|
||||
# register: result
|
||||
|
||||
#- name: print result
|
||||
# debug:
|
||||
# var: result.stdout
|
||||
99
cyrus.yml
Normal file
99
cyrus.yml
Normal file
@ -0,0 +1,99 @@
|
||||
---
|
||||
- name: install Cyrus-Imap
|
||||
yum:
|
||||
name: cyrus-imapd
|
||||
state: installed
|
||||
|
||||
# - name: Config postfix
|
||||
#lineinfile:
|
||||
# path: "/etc/postfix/main.cf"
|
||||
# insertafter: EOF
|
||||
# line: "{{ item }}"
|
||||
# shell: "{{ item }}"
|
||||
#with_items:
|
||||
# - "mailbox_transport=cyrus"
|
||||
# - "local_recipient_maps=ldap://etc/postfix/local_recipients.cf hash:/etc/postfix/local_recipients"
|
||||
# changed_when: false
|
||||
# become: true
|
||||
|
||||
- name: config pour verif via ldap
|
||||
template:
|
||||
src: "cyrus/{{ item }}.j2"
|
||||
dest: "/etc/postfix/{{ item }}"
|
||||
with_items:
|
||||
- local_recipients.cf
|
||||
notify: restart_postfix
|
||||
|
||||
- name: config Cyrus
|
||||
copy:
|
||||
src: "cyrus/{{ item }}"
|
||||
dest: "/etc/{{ item }}"
|
||||
with_items:
|
||||
- imapd.conf
|
||||
- cyrus.conf
|
||||
|
||||
# Mdp cyrus: Pwd4Admin
|
||||
# - name: config Cyrus
|
||||
# copy:
|
||||
# src: cyrus/sasldb2
|
||||
# dest: /etc/sasldb2
|
||||
# group: mail
|
||||
# mode: 0640
|
||||
# become: true
|
||||
# - name: cyrusadmin password
|
||||
# shell: echo {{ cyrus_admin_pass }} | saslpasswd2 -p -c {{ cyrus_admin_user }}
|
||||
# changed_when: false
|
||||
|
||||
- name: start and enable cyrus
|
||||
systemd_service:
|
||||
state: started
|
||||
name: cyrus-imapd
|
||||
enabled: true
|
||||
|
||||
- name: copy perl script to create cyrus mailbox
|
||||
template:
|
||||
src: "cyrus/{{ item }}.j2"
|
||||
dest: "/root/{{ item }}"
|
||||
with_items:
|
||||
- createmailboxmailadmin.pl
|
||||
- createmailbox.pl
|
||||
|
||||
- name: create MailAdmin mailbox
|
||||
shell: perl /root/createmailboxmailadmin.pl
|
||||
changed_when: false
|
||||
|
||||
- name: create User's Mailbox
|
||||
shell: "perl /root/createmailbox.pl {{ item.key }}"
|
||||
with_dict: "{{ stagiaires }}"
|
||||
changed_when: false
|
||||
|
||||
- name: update aliases
|
||||
lineinfile:
|
||||
path: /etc/aliases
|
||||
insertafter: EOF
|
||||
line: "root: mailadmin"
|
||||
|
||||
- name: execute newalias
|
||||
shell: newaliases
|
||||
changed_when: false
|
||||
|
||||
# Les autres users vérifiés par postfix via une requête LDAP (local_recipients.cf)
|
||||
- name: add user in /etc/postfix/local_recipients
|
||||
lineinfile:
|
||||
path: /etc/postfix/local_recipients
|
||||
#insertafter: EOF
|
||||
line: "{{ item }}\t\t\t#Local"
|
||||
create: True
|
||||
with_items:
|
||||
- root
|
||||
- mailadmin
|
||||
- tous
|
||||
|
||||
- name: create hash tab
|
||||
shell: postmap /etc/postfix/local_recipients
|
||||
changed_when: false
|
||||
|
||||
- name: execute postfix_chroot
|
||||
shell: /root/postfix_chroot
|
||||
changed_when: false
|
||||
|
||||
132
defaults/main.yml
Normal file
132
defaults/main.yml
Normal file
@ -0,0 +1,132 @@
|
||||
---
|
||||
# variable
|
||||
|
||||
# user linux password (same for all user)
|
||||
plain_user_passwd: password
|
||||
plain_ldap_passwd: password
|
||||
|
||||
# Root mysql password
|
||||
myslql_root_passd: Pa55w0rd
|
||||
|
||||
# PhpMay admin version
|
||||
phpmyadmin_version: phpMyAdmin-5.2.1-english
|
||||
|
||||
# ldap manager password (Pa55w0rd)
|
||||
#ldapmanager_passwd: "{SSHA}3eleIWAg5h6mzsVgcP+rMJmnLXkq+tgN"
|
||||
plain_ldapmanager_passwd: Pwd4Admin
|
||||
|
||||
# Admin cyrus password (Pa55w0rd)
|
||||
#admincyrus_passwd: "{SSHA}rVwCFBpGJcLFwO48xnazuHSV+4U84lv1"
|
||||
plain_admincyrus_passwd: Pa55w0rd
|
||||
|
||||
# Admin mail password (password)
|
||||
#mailadmin_passwd: "{SSHA}LQRhkwuBi6FMY+CAjZ5tWEU4r1R+C5H8"
|
||||
plain_mailadmin_passwd: Pa55w0rd
|
||||
|
||||
# Admin LDAP password (Pa55w0rd)
|
||||
#ldapadmin_passwd: "{SSHA}rVwCFBpGJcLFwO48xnazuHSV+4U84lv1"
|
||||
plain_ldapadmin_passwd: Pa55w0rd
|
||||
|
||||
# Access LDAP password (password)
|
||||
#ldapaccess_passwd: "{SSHA}LQRhkwuBi6FMY+CAjZ5tWEU4r1R+C5H8"
|
||||
plain_ldapaccess_passwd: passw0rd
|
||||
|
||||
# Unix group for ldap (is not create on linux os)
|
||||
ldapunix_group_name: all-user
|
||||
ldapunix_group_id: 9000
|
||||
|
||||
# Cyrus credential
|
||||
cyrus_admin_user: cyrus
|
||||
cyrus_admin_pass: Pa55w0rd
|
||||
#
|
||||
# User stagiaire list
|
||||
# Le mot de passe pour ldap est créé avec la commande ci-dessou
|
||||
# slappasswd -v -s password
|
||||
# password = {SSHA}LQRhkwuBi6FMY+CAjZ5tWEU4r1R+C5H8
|
||||
#
|
||||
# Le mot de passe pour l'OS est créè avec la commnde ci-dessous:
|
||||
# ansible all -i localhost, -m debug -a "msg={{ 'password' | password_hash('sha512', 'mysecretsalt') }}"
|
||||
# password = "$6$mysecretsalt$MIJffjeQyfrKKrGkprGrDL/g2mCJa53koLmYQuuLmY9y37pDvGKPXU1Ov3RbMi.tpQ9cWvxAzUVtBLe7KrZoU."
|
||||
stagiaires:
|
||||
stagiaire1:
|
||||
name: Stagiaire
|
||||
firstname: Un
|
||||
mail: stagiaire1@stage-ge.org
|
||||
uid: 2001
|
||||
gid: 2001
|
||||
stagiaire2:
|
||||
name: Stagiaire
|
||||
firstname: Deux
|
||||
mail: stagiaire2@stage-ge.org
|
||||
uid: 2002
|
||||
gid: 2002
|
||||
stagiaire3:
|
||||
name: Stagiaire
|
||||
firstname: Trois
|
||||
mail: stagiaire3@stage-ge.org
|
||||
uid: 2003
|
||||
gid: 2003
|
||||
stagiaire4:
|
||||
name: Stagiaire
|
||||
firstname: Quatre
|
||||
mail: stagiaire4@stage-ge.org
|
||||
uid: 2004
|
||||
gid: 2004
|
||||
stagiaire5:
|
||||
name: Stagiaire
|
||||
firstname: Cinq
|
||||
mail: stagiaire5@stage-ge.org
|
||||
uid: 2005
|
||||
gid: 2005
|
||||
stagiaire6:
|
||||
name: Stagiaire
|
||||
firstname: Six
|
||||
mail: stagiaire6@stage-ge.org
|
||||
uid: 2006
|
||||
gid: 2006
|
||||
stagiaire7:
|
||||
name: Stagiaire
|
||||
firstname: Sept
|
||||
mail: stagiaire7@stage-ge.org
|
||||
uid: 2007
|
||||
gid: 2007
|
||||
stagiaire8:
|
||||
name: Stagiaire
|
||||
firstname: Huit
|
||||
mail: stagiaire8@stage-ge.org
|
||||
uid: 2008
|
||||
gid: 2008
|
||||
stagiaire9:
|
||||
name: Stagiaire
|
||||
firstname: Neuf
|
||||
mail: stagiaire9@stage-ge.org
|
||||
uid: 2009
|
||||
gid: 2009
|
||||
stagiaire10:
|
||||
name: Stagiaire
|
||||
firstname: Dix
|
||||
mail: stagiaire10@stage-ge.org
|
||||
uid: 2010
|
||||
gid: 2010
|
||||
|
||||
# path certificat
|
||||
certs_path: /etc/pki/stage-ge
|
||||
|
||||
# architecture
|
||||
arch_map:
|
||||
i386: '386'
|
||||
x86_64: 'amd64'
|
||||
aarch64: 'arm64'
|
||||
armv7l: 'arm'
|
||||
armv6l: 'arm6vl'
|
||||
|
||||
arch: "{{ arch_map[ansible_architecture] | default(ansible_architecture) }}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
53
dns.yml
Normal file
53
dns.yml
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
- name: install bind chroot
|
||||
yum:
|
||||
name:
|
||||
- bind-chroot
|
||||
- bind-libs
|
||||
- bind-libs
|
||||
- bind-license
|
||||
- bind-utils
|
||||
state: present
|
||||
|
||||
- name: create data folder
|
||||
file:
|
||||
dest: /var/named/chroot/var/named/data
|
||||
state: directory
|
||||
|
||||
- name: copy named.conf
|
||||
template:
|
||||
src: named/named.conf.j2
|
||||
dest: "{{ dns_conf_file }}"
|
||||
|
||||
- name: copy zone file
|
||||
template:
|
||||
src: named/stage-ge.org.zone.j2
|
||||
dest: "{{ zone_file }}"
|
||||
|
||||
- name: copy create reverse lookup script
|
||||
template:
|
||||
src: scripts/createrevers.sh.j2
|
||||
dest: /tmp/createrevers.sh
|
||||
mode: 0755
|
||||
|
||||
- name: create reverse lookup file
|
||||
shell: /tmp/createrevers.sh
|
||||
changed_when: false
|
||||
|
||||
- name: set new dns
|
||||
nmcli:
|
||||
type: ethernet
|
||||
conn_name: "{{ ansible_default_ipv4.interface }}"
|
||||
dns4: "{{ new_dns }}"
|
||||
dns4_search:
|
||||
- "{{ new_search }}"
|
||||
state: present
|
||||
notify: restart_NetworkManager
|
||||
|
||||
- name: start and enable the named-chroot service
|
||||
systemd_service:
|
||||
state: restarted
|
||||
name: named-chroot
|
||||
enabled: true
|
||||
|
||||
|
||||
66
docker.yml
Normal file
66
docker.yml
Normal file
@ -0,0 +1,66 @@
|
||||
---
|
||||
- name: set var proxy_val
|
||||
set_fact:
|
||||
proxy_val: "{{ lookup('env','HTTP_PROXY') }}"
|
||||
|
||||
- name: add docker repo
|
||||
get_url:
|
||||
url: https://download.docker.com/linux/centos/docker-ce.repo
|
||||
dest: /etc/yum.repos.d/docer-ce.repo
|
||||
|
||||
- name: install docker-ce
|
||||
yum:
|
||||
name:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
state: present
|
||||
|
||||
- block:
|
||||
- name: create docker.service.d folder
|
||||
file:
|
||||
path: /etc/systemd/system/docker.service.d
|
||||
state: directory
|
||||
|
||||
- name: copy proxy configuration file for docker
|
||||
copy:
|
||||
src: docker/http-proxy.conf
|
||||
dest: /etc/systemd/system/docker.service.d/http-proxy.conf
|
||||
when: proxy|bool
|
||||
|
||||
- name: start docker
|
||||
systemd_service:
|
||||
name: docker
|
||||
state: restarted
|
||||
daemon-reload: true
|
||||
enabled: true
|
||||
|
||||
- name: get last version of lazydocker
|
||||
shell: |
|
||||
curl -L -s -H 'Accept: application/json' https://github.com/jesseduffield/lazydocker/releases/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/'| sed -e 's/^v//'
|
||||
register: version
|
||||
|
||||
- name: set real arch (x86_64) for lazydocker
|
||||
set_fact:
|
||||
real_arch: x86_64
|
||||
when: arch == "amd64"
|
||||
|
||||
- name: set real arch (arm64) for lazydocker
|
||||
set_fact:
|
||||
real_arch: arm64
|
||||
when: arch == "arm64"
|
||||
|
||||
- name: url
|
||||
debug:
|
||||
msg: " https://github.com/jesseduffield/lazydocker/releases/download/v{{ version.stdout }}/lazydocker_{{ version.stdout }}_{{ ansible_system }}_{{ real_arch}}.tar.gz"
|
||||
|
||||
- name: unarchive lazydocker
|
||||
unarchive:
|
||||
src: https://github.com/jesseduffield/lazydocker/releases/download/v{{ version.stdout }}/lazydocker_{{ version.stdout }}_{{ ansible_system }}_{{ real_arch }}.tar.gz
|
||||
dest: /usr/local/bin
|
||||
owner: root
|
||||
group: root
|
||||
mode: 755
|
||||
remote_src: yes
|
||||
|
||||
|
||||
7
files/certs/ca-config
Normal file
7
files/certs/ca-config
Normal file
@ -0,0 +1,7 @@
|
||||
countryName_default = CH
|
||||
stateOrProvinceName_default = Geneve
|
||||
localityName_default = Geneve
|
||||
0.organizationName_default = Stage
|
||||
commonName_default = stage-ge.org
|
||||
emailAddress_default = webadmin@stage-ge.org
|
||||
|
||||
103
files/certs/ca-config.orig
Normal file
103
files/certs/ca-config.orig
Normal file
@ -0,0 +1,103 @@
|
||||
HOME = .
|
||||
RANDFILE = $ENV::HOME/.rnd
|
||||
oid_section = new_oids
|
||||
|
||||
[ new_oids ]
|
||||
|
||||
[ ca ]
|
||||
default_ca = CA_default # The default ca section
|
||||
[ CA_default ]
|
||||
dir = . # Where everything is kept
|
||||
certs = $dir/certs # Where the issued certs are kept
|
||||
crl_dir = $dir/crl # Where the issued crl are kept
|
||||
database = $dir/dbca/index.txt # database index file.
|
||||
new_certs_dir = $dir/newcerts # default place for new certs.
|
||||
certificate = $dir/cacert.pem # The CA certificate
|
||||
serial = $dir/serial/serial # The current serial number
|
||||
crl = $dir/crl.pem # The current CRL
|
||||
private_key = $dir/private/cakey.pem# The private key
|
||||
RANDFILE = $dir/private/.rand # private random number file
|
||||
x509_extensions = usr_cert # The extentions to add to the cert
|
||||
default_days = 365 # how long to certify for
|
||||
default_crl_days= 30 # how long before next CRL
|
||||
default_md = md5 # which md to use.
|
||||
preserve = no # keep passed DN ordering
|
||||
policy = policy_match
|
||||
|
||||
[ policy_match ]
|
||||
countryName = match
|
||||
stateOrProvinceName = match
|
||||
organizationName = match
|
||||
organizationalUnitName = optional
|
||||
commonName = supplied
|
||||
emailAddress = optional
|
||||
|
||||
[ policy_anything ]
|
||||
countryName = optional
|
||||
stateOrProvinceName = optional
|
||||
localityName = optional
|
||||
organizationName = optional
|
||||
organizationalUnitName = optional
|
||||
commonName = supplied
|
||||
emailAddress = optional
|
||||
|
||||
[ req ]
|
||||
default_bits = 1024
|
||||
default_keyfile = privkey.pem
|
||||
distinguished_name = req_distinguished_name
|
||||
attributes = req_attributes
|
||||
x509_extensions = v3_ca # The extentions to add to the self signed cert
|
||||
string_mask = nombstr
|
||||
|
||||
[ req_distinguished_name ]
|
||||
countryName = Country Name (2 letter code)
|
||||
countryName_default = CH
|
||||
countryName_min = 2
|
||||
countryName_max = 2
|
||||
|
||||
stateOrProvinceName = State or Province Name (full name)
|
||||
stateOrProvinceName_default = Geneve
|
||||
|
||||
localityName = Locality Name (eg, city)
|
||||
localityName_default = Geneve
|
||||
|
||||
0.organizationName = Organization Name (eg, company)
|
||||
0.organizationName_default = Stage découverte
|
||||
|
||||
organizationalUnitName = Organizational Unit Name (eg, section)
|
||||
|
||||
organizationalUnitName_default = Stage
|
||||
|
||||
commonName = Common Name (eg, YOUR name)
|
||||
commonName_default = Stage CA
|
||||
commonName_max = 64
|
||||
|
||||
emailAddress = Email Address
|
||||
emailAddress_default = webadmin@stage-ge.org
|
||||
emailAddress_max = 40
|
||||
|
||||
[ req_attributes ]
|
||||
challengePassword = A challenge password
|
||||
challengePassword_min = 4
|
||||
challengePassword_max = 20
|
||||
|
||||
unstructuredName = An optional company name
|
||||
|
||||
[ usr_cert ]
|
||||
basicConstraints=CA:FALSE
|
||||
nsComment = "OpenSSL Generated Certificate"
|
||||
subjectKeyIdentifier=hash
|
||||
authorityKeyIdentifier=keyid,issuer:always
|
||||
|
||||
[ v3_req ]
|
||||
basicConstraints = CA:FALSE
|
||||
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
|
||||
|
||||
[ v3_ca ]
|
||||
subjectKeyIdentifier=hash
|
||||
authorityKeyIdentifier=keyid:always,issuer:always
|
||||
basicConstraints = CA:true
|
||||
|
||||
[ crl_ext ]
|
||||
authorityKeyIdentifier=keyid:always,issuer:always
|
||||
|
||||
3
files/certs/wilcard.cnf
Normal file
3
files/certs/wilcard.cnf
Normal file
@ -0,0 +1,3 @@
|
||||
basicConstraints=CA:FALSE
|
||||
subjectAltName=DNS:*.stage-ge.org
|
||||
extendedKeyUsage=serverAuth
|
||||
44
files/chat-box/README.md
Executable file
44
files/chat-box/README.md
Executable file
@ -0,0 +1,44 @@
|
||||
STAGE DECOUVERTE - DEVELOPPEMENT
|
||||
================================
|
||||
|
||||
# Présentations
|
||||
-------------
|
||||
|
||||
- Présentation générale du Développement:
|
||||
`Stage découverte - présentation DEV.pptx`
|
||||
- Travail pratique:
|
||||
`Stage découverte - programmation.pptx`
|
||||
|
||||
# Installation
|
||||
------------
|
||||
|
||||
Les répertoires suivants :
|
||||
- etapes
|
||||
- VSCode-win32
|
||||
|
||||
Doivent être copiés sur les postes des stagiaires.
|
||||
|
||||
Le répertoire "serveur" contient les fichiers php à mettre sur le serveur qui héberge le socket
|
||||
|
||||
Le répertoire "etapes/final" contient les js et les css utilisés dans les étapes 4 et 5
|
||||
Le fichier "etapes/final/js/main.js" doit être mis à jour avec le nom du serveur qui héberge le socket
|
||||
|
||||
|
||||
# Démarrage du socket
|
||||
------------
|
||||
|
||||
Lancer les containers
|
||||
`docker-compose up -d`
|
||||
|
||||
Démarrer le socket
|
||||
`docker exec -it apache_stage /bin/bash`
|
||||
`php -q socket.php`
|
||||
|
||||
Lancer une ou plusieurs fenêtres de navigation
|
||||
`http://devweb-ccb-t:8083`
|
||||
|
||||
L'URL du socket est renseignée :
|
||||
- main.js l.122 (devweb-ccb-t.ville-geneve.ch:8081)
|
||||
- socket.php l.5
|
||||
|
||||
|
||||
1280
files/chat-box/css/jquery.emojipicker.a.css
Normal file
1280
files/chat-box/css/jquery.emojipicker.a.css
Normal file
File diff suppressed because one or more lines are too long
53
files/chat-box/css/jquery.emojipicker.css
Normal file
53
files/chat-box/css/jquery.emojipicker.css
Normal file
File diff suppressed because one or more lines are too long
1247
files/chat-box/css/jquery.emojipicker.g.css
Normal file
1247
files/chat-box/css/jquery.emojipicker.g.css
Normal file
File diff suppressed because one or more lines are too long
1277
files/chat-box/css/jquery.emojipicker.tw.css
Normal file
1277
files/chat-box/css/jquery.emojipicker.tw.css
Normal file
File diff suppressed because one or more lines are too long
1
files/chat-box/css/palette-color-picker.css
Normal file
1
files/chat-box/css/palette-color-picker.css
Normal file
@ -0,0 +1 @@
|
||||
.palette-color-picker-button{position:relative;display:inline-block;width:28px;height:28px;margin-right:8px;background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path fill="#f5c86c" d="M2 2h8v8H2z"/><path fill="#f56c6c" d="M12 2h8v8h-8z"/><path fill="#f46ac6" d="M22 2h8v8h-8z"/><path fill="#c3f167" d="M2 12h8v8H2z"/><path fill="#f3f3f3" d="M12 12h8v8h-8z"/><path fill="#c76cf5" d="M22 12h8v8h-8z"/><path fill="#69e369" d="M2 22h8v8H2z"/><path fill="#6bc6f4" d="M12 22h8v8h-8z"/><path fill="#6b6bf5" d="M22 22h8v8h-8z"/><path d="M9 3v6H3V3h6m1-1H2v8h8V2zm9 1v6h-6V3h6m1-1h-8v8h8V2zm9 1v6h-6V3h6m1-1h-8v8h8V2zM9 13v6H3v-6h6m1-1H2v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8zM9 23v6H3v-6h6m1-1H2v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8z" opacity=".25"/></svg>') center center no-repeat;background-size:cover;cursor:pointer;box-shadow:0 0 0 1px #bbb;border:2px solid #fff}.palette-color-picker-bubble{display:none;margin:12px 0;position:absolute;bottom:100%;width:220px;padding:10px 8px 8px 8px;border:1px solid #bbb;border-radius:3px;background-color:#fff}.palette-color-picker-bubble:after,.palette-color-picker-bubble:before{top:100%;left:14px;border:solid transparent;content:' ';height:0;width:0;position:absolute;pointer-events:none}.palette-color-picker-bubble:after{border-color:transparent;border-top-color:#fff;border-width:8px;margin-left:-8px}.palette-color-picker-bubble:before{border-color:transparent;border-top-color:#bbb;border-width:9px;margin-left:-9px}.palette-color-picker-bubble.downside{bottom:auto;top:100%}.palette-color-picker-bubble.downside:after,.palette-color-picker-bubble.downside:before{top:auto;bottom:100%}.palette-color-picker-bubble.downside:after{border-top-color:transparent;border-bottom-color:#fff}.palette-color-picker-bubble.downside:before{border-top-color:transparent;border-bottom-color:#bbb}.palette-color-picker-bubble .swatch{position:relative;display:inline-block;font:0/0 a;width:12.66%;padding-top:11.00%;margin:1% 2%;outline:1px solid #bbb;border:2px solid #fff;border-radius:3px;cursor:pointer;overflow:hidden}.palette-color-picker-bubble .swatch.active{outline-color:#000;-webkit-box-shadow:0px 0px 5px 0px rgba(0,0,0,0.75);-moz-box-shadow:0px 0px 5px 0px rgba(0,0,0,0.75);box-shadow:0px 0px 5px 0px rgba(0,0,0,0.75)}.palette-color-picker-bubble .swatch.clear{background-color:#fff}.palette-color-picker-bubble .swatch.clear:before{position:absolute;content:'';display:block;top:-1px;left:0;width:100px;height:2px;background-color:#e00;transform-origin:0 0;transform:rotate(45deg)}.palette-color-picker-bubble.double .swatch{width:29.30%;padding-top:11.00%;margin:1% 2%}.palette-color-picker-bubble.double .swatch.clear:before{transform:rotate(22.5deg)}.palette-color-picker-bubble.wide .swatch{width:96.2%;padding-top:11.00%;margin:1% 2%}.palette-color-picker-bubble.wide .swatch.clear{width:12.66%}.palette-color-picker-bubble.force-left{left:-178px}.palette-color-picker-bubble.force-left:after,.palette-color-picker-bubble.force-left:before{left:188px}
|
||||
125
files/chat-box/css/style_chat.css
Normal file
125
files/chat-box/css/style_chat.css
Normal file
@ -0,0 +1,125 @@
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.chat-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.chat-box {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#forms-wrapper {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.messages {
|
||||
height: 800px;
|
||||
width: 600px;
|
||||
border: 1px solid #666;
|
||||
border-radius: 3px;
|
||||
padding: 1em;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
input {
|
||||
display: block;
|
||||
width: 500px;
|
||||
padding: 5px;
|
||||
height: 44px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
button {
|
||||
display: block;
|
||||
background: rgb(39, 112, 215);
|
||||
padding: 5px;
|
||||
margin: 5px 0;
|
||||
width: 150px;
|
||||
height: 44px;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
form.msg-form {
|
||||
bottom: 1em;
|
||||
right: 1em;
|
||||
left: 1em;
|
||||
}
|
||||
form.close-form button {
|
||||
background: rgb(237, 102, 102);
|
||||
border: 1px solid rgb(237, 102, 102);
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.hidden {
|
||||
visibility: hidden;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.msg {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.msg-text {
|
||||
padding: 5px;
|
||||
display: inline-block;
|
||||
border-radius: 5px;
|
||||
font-family: "Verdana", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
.msg-normal .msg-text {
|
||||
background:#ccc;
|
||||
color: white;
|
||||
font-family: "Verdana", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
.msg-normal .msg-sender {
|
||||
font-family: "Verdana", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.msg-notification .msg-text,
|
||||
.msg-join .msg-text,
|
||||
.msg-left .msg-text {
|
||||
background: #eee;
|
||||
border: 1px solid #ccc;
|
||||
font-family: "Verdana", sans-serif;
|
||||
}
|
||||
|
||||
.msg-join .msg-text,
|
||||
.msg-left .msg-text {
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.msg-notification .msg-sender,
|
||||
.msg-join .msg-sender,
|
||||
.msg-left .msg-sender {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#color-option-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
#color-option-wrapper .palette-color-picker-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
cursor: pointer;
|
||||
width: 44px;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
0
files/chat-box/etapes/00/page.html
Executable file
0
files/chat-box/etapes/00/page.html
Executable file
257
files/chat-box/etapes/00/style.css
Executable file
257
files/chat-box/etapes/00/style.css
Executable file
@ -0,0 +1,257 @@
|
||||
/* Global variables. */
|
||||
:root {
|
||||
/* Set sans-serif & mono fonts */
|
||||
--sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
|
||||
"Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
|
||||
"Helvetica Neue", sans-serif;
|
||||
--mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
|
||||
--standard-border-radius: 5px;
|
||||
|
||||
/* Default (light) theme */
|
||||
--bg: #fff;
|
||||
--accent-bg: #f5f7ff;
|
||||
--text: #212121;
|
||||
--text-light: #585858;
|
||||
--border: #898EA4;
|
||||
--accent: #0d47a1;
|
||||
--code: #d81b60;
|
||||
--preformatted: #444;
|
||||
--marked: #ffdd33;
|
||||
--disabled: #efefef;
|
||||
}
|
||||
|
||||
.chat-box {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
form {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.messages {
|
||||
height: 800px;
|
||||
width: 600px;
|
||||
border: 1px solid #666;
|
||||
border-radius: 3px;
|
||||
padding: 1em;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
/* Make the body a nice central block */
|
||||
body {
|
||||
color: var(--text);
|
||||
background-color: var(--bg);
|
||||
font-size: 1.15rem;
|
||||
font-family: var(--mono-font);
|
||||
}
|
||||
|
||||
/* Format headers */
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2.6rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 2rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.44rem;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 0.96rem;
|
||||
}
|
||||
|
||||
/* Format links & buttons */
|
||||
a,
|
||||
a:visited {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
button,
|
||||
[role="button"],
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="button"],
|
||||
label[type="button"] {
|
||||
border: none;
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--accent);
|
||||
font-size: 1rem;
|
||||
color: var(--bg);
|
||||
padding: 0.7rem 0.9rem;
|
||||
margin: 0.5rem 0;
|
||||
|
||||
/* Ensure buttons use correct font */
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
/* Format forms */
|
||||
textarea,
|
||||
select,
|
||||
input {
|
||||
font-size: inherit;
|
||||
font-family: inherit;
|
||||
padding: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--text);
|
||||
background-color: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--standard-border-radius);
|
||||
box-shadow: none;
|
||||
max-width: 100%;
|
||||
display: inline-block;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
textarea:not([cols]) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Add arrow to drop-down */
|
||||
select:not([multiple]) {
|
||||
background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%),
|
||||
linear-gradient(135deg, var(--text) 51%, transparent 49%);
|
||||
background-position: calc(100% - 15px), calc(100% - 10px);
|
||||
background-size: 5px 5px, 5px 5px;
|
||||
background-repeat: no-repeat;
|
||||
padding-right: 25px;
|
||||
}
|
||||
|
||||
/* checkbox and radio button style */
|
||||
input[type="checkbox"],
|
||||
input[type="radio"] {
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
width: min-content;
|
||||
}
|
||||
|
||||
input[type="checkbox"] + label,
|
||||
input[type="radio"] + label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
input[type="radio"] {
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked,
|
||||
input[type="radio"]:checked {
|
||||
background-color: var(--accent);
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked::after {
|
||||
/* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */
|
||||
content: " ";
|
||||
width: 0.18em;
|
||||
height: 0.32em;
|
||||
border-radius: 0;
|
||||
position: absolute;
|
||||
top: 0.05em;
|
||||
left: 0.17em;
|
||||
background-color: transparent;
|
||||
border-right: solid var(--bg) 0.08em;
|
||||
border-bottom: solid var(--bg) 0.08em;
|
||||
font-size: 1.8em;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
input[type="radio"]:checked::after {
|
||||
/* creates a colored circle for the checked radio button */
|
||||
content: " ";
|
||||
width: 0.25em;
|
||||
height: 0.25em;
|
||||
border-radius: 100%;
|
||||
position: absolute;
|
||||
top: 0.125em;
|
||||
background-color: var(--bg);
|
||||
left: 0.125em;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
mark {
|
||||
padding: 2px 5px;
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--marked);
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
||||
blockquote {
|
||||
margin: 2rem 0 2rem 2rem;
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-left: 0.35rem solid var(--accent);
|
||||
color: var(--text-light);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
/* Use mono font for code elements */
|
||||
code,
|
||||
pre,
|
||||
pre span,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: var(--mono-font);
|
||||
color: var(--code);
|
||||
}
|
||||
|
||||
kbd {
|
||||
color: var(--preformatted);
|
||||
border: 1px solid var(--preformatted);
|
||||
border-bottom: 3px solid var(--preformatted);
|
||||
border-radius: var(--standard-border-radius);
|
||||
padding: 0.1rem 0.4rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 1rem 1.4rem;
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
color: var(--preformatted);
|
||||
}
|
||||
|
||||
/* Fix embedded code within pre */
|
||||
pre code {
|
||||
color: var(--preformatted);
|
||||
background: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Classes for buttons and notices */
|
||||
.button,
|
||||
.button:visited {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
background: var(--accent);
|
||||
font-size: 1rem;
|
||||
color: var(--bg);
|
||||
padding: 0.7rem 0.9rem;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.button:hover,
|
||||
.button:focus {
|
||||
filter: brightness(1.4);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
25
files/chat-box/etapes/01/index.html
Executable file
25
files/chat-box/etapes/01/index.html
Executable file
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Stage informatique - Chat</title>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Stage DSIC - 2023</h1>
|
||||
<div class="chat-box">
|
||||
<div id="messages-wrapper">
|
||||
<div class="messages"></div>
|
||||
</div>
|
||||
<form>
|
||||
<label for="sender">Votre nom:</label><br>
|
||||
<input type="text" id="sender" name="sender" placeholder="Nom"><br>
|
||||
<label for="msg">Message:</label><br>
|
||||
<input type="text" id="msg" name="msg" placeholder="Message..."><br><br>
|
||||
<input id="button" type="button" value="Valider">
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
38
files/chat-box/etapes/02/colors.css
Executable file
38
files/chat-box/etapes/02/colors.css
Executable file
@ -0,0 +1,38 @@
|
||||
body {
|
||||
font-family: Lato,"Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||
font-size: 12px;
|
||||
}
|
||||
.color-chart-wrapper {
|
||||
display: flex;
|
||||
}
|
||||
table.color-chart td, table.color-chart th {
|
||||
padding: 5px 0;
|
||||
border-bottom: 1px solid #000;
|
||||
}
|
||||
.color-chart-wrapper>table.color-chart,
|
||||
.color-chart-wrapper>table.color-chart td,
|
||||
.color-chart-wrapper>table.color-chart th {
|
||||
width: 33.33333%;
|
||||
}
|
||||
.gradient_1,
|
||||
.gradient_2,
|
||||
.gradient_3,
|
||||
.gradient_4 {
|
||||
width: 100%;
|
||||
height: 400px;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
.gradient_1 {
|
||||
background: linear-gradient(#e66465, #9198e5);
|
||||
}
|
||||
.gradient_2 {
|
||||
background: linear-gradient(0.25turn, #3f87a6, #ebf8e1, #f69d3c);
|
||||
}
|
||||
.gradient_3 {
|
||||
background: linear-gradient(to left, #333, #333 50%, #eee 75%, #333 75%);
|
||||
}
|
||||
.gradient_4 {
|
||||
background: linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%),
|
||||
linear-gradient(127deg, rgba(0,255,0,.8), rgba(0,255,0,0) 70.71%),
|
||||
linear-gradient(336deg, rgba(0,0,255,.8), rgba(0,0,255,0) 70.71%);
|
||||
}
|
||||
1280
files/chat-box/etapes/02/colors.html
Executable file
1280
files/chat-box/etapes/02/colors.html
Executable file
File diff suppressed because it is too large
Load Diff
26
files/chat-box/etapes/02/index.html
Executable file
26
files/chat-box/etapes/02/index.html
Executable file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Stage informatique - Chat</title>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Stage DSIC - 2023</h1>
|
||||
<div class="chat-box">
|
||||
<div id="messages-wrapper">
|
||||
<div class="messages"></div>
|
||||
</div>
|
||||
<form>
|
||||
<label for="sender">Votre nom:</label><br>
|
||||
<input type="text" id="sender" name="sender" placeholder="Nom"><br>
|
||||
<label for="msg">Message:</label><br>
|
||||
<input type="text" id="msg" name="msg" placeholder="Message..."><br><br>
|
||||
<input id="button" type="button" value="Valider">
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
260
files/chat-box/etapes/02/style.css
Executable file
260
files/chat-box/etapes/02/style.css
Executable file
@ -0,0 +1,260 @@
|
||||
/* Global variables. */
|
||||
:root {
|
||||
/* Set sans-serif & mono fonts */
|
||||
--sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
|
||||
"Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
|
||||
"Helvetica Neue", sans-serif;
|
||||
--mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
|
||||
--standard-border-radius: 5px;
|
||||
|
||||
/* Default (light) theme */
|
||||
--bg: #fff;
|
||||
--accent-bg: #f5f7ff;
|
||||
--text: #212121;
|
||||
--text-light: #585858;
|
||||
--border: #898EA4;
|
||||
--accent: #0d47a1;
|
||||
--code: #d81b60;
|
||||
--preformatted: #444;
|
||||
--marked: #ffdd33;
|
||||
--disabled: #efefef;
|
||||
}
|
||||
|
||||
.chat-box {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
form {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.messages {
|
||||
height: 800px;
|
||||
width: 600px;
|
||||
border: 1px solid #666;
|
||||
border-radius: 3px;
|
||||
padding: 1em;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
margin-bottom: 5px;
|
||||
background: linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%),
|
||||
linear-gradient(127deg, rgba(0,255,0,.8), rgba(0,255,0,0) 70.71%),
|
||||
linear-gradient(336deg, rgba(0,0,255,.8), rgba(0,0,255,0) 70.71%);
|
||||
}
|
||||
|
||||
/* Make the body a nice central block */
|
||||
body {
|
||||
color: var(--text);
|
||||
background-color: var(--bg);
|
||||
font-size: 1.15rem;
|
||||
font-family: var(--mono-font);
|
||||
}
|
||||
|
||||
/* Format headers */
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2.6rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 2rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.44rem;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 0.96rem;
|
||||
}
|
||||
|
||||
/* Format links & buttons */
|
||||
a,
|
||||
a:visited {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
button,
|
||||
[role="button"],
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="button"],
|
||||
label[type="button"] {
|
||||
border: none;
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--accent);
|
||||
font-size: 1rem;
|
||||
color: var(--bg);
|
||||
padding: 0.7rem 0.9rem;
|
||||
margin: 0.5rem 0;
|
||||
|
||||
/* Ensure buttons use correct font */
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
/* Format forms */
|
||||
textarea,
|
||||
select,
|
||||
input {
|
||||
font-size: inherit;
|
||||
font-family: inherit;
|
||||
padding: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--text);
|
||||
background-color: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--standard-border-radius);
|
||||
box-shadow: none;
|
||||
max-width: 100%;
|
||||
display: inline-block;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
textarea:not([cols]) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Add arrow to drop-down */
|
||||
select:not([multiple]) {
|
||||
background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%),
|
||||
linear-gradient(135deg, var(--text) 51%, transparent 49%);
|
||||
background-position: calc(100% - 15px), calc(100% - 10px);
|
||||
background-size: 5px 5px, 5px 5px;
|
||||
background-repeat: no-repeat;
|
||||
padding-right: 25px;
|
||||
}
|
||||
|
||||
/* checkbox and radio button style */
|
||||
input[type="checkbox"],
|
||||
input[type="radio"] {
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
width: min-content;
|
||||
}
|
||||
|
||||
input[type="checkbox"] + label,
|
||||
input[type="radio"] + label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
input[type="radio"] {
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked,
|
||||
input[type="radio"]:checked {
|
||||
background-color: var(--accent);
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked::after {
|
||||
/* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */
|
||||
content: " ";
|
||||
width: 0.18em;
|
||||
height: 0.32em;
|
||||
border-radius: 0;
|
||||
position: absolute;
|
||||
top: 0.05em;
|
||||
left: 0.17em;
|
||||
background-color: transparent;
|
||||
border-right: solid var(--bg) 0.08em;
|
||||
border-bottom: solid var(--bg) 0.08em;
|
||||
font-size: 1.8em;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
input[type="radio"]:checked::after {
|
||||
/* creates a colored circle for the checked radio button */
|
||||
content: " ";
|
||||
width: 0.25em;
|
||||
height: 0.25em;
|
||||
border-radius: 100%;
|
||||
position: absolute;
|
||||
top: 0.125em;
|
||||
background-color: var(--bg);
|
||||
left: 0.125em;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
mark {
|
||||
padding: 2px 5px;
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--marked);
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
||||
blockquote {
|
||||
margin: 2rem 0 2rem 2rem;
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-left: 0.35rem solid var(--accent);
|
||||
color: var(--text-light);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
/* Use mono font for code elements */
|
||||
code,
|
||||
pre,
|
||||
pre span,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: var(--mono-font);
|
||||
color: var(--code);
|
||||
}
|
||||
|
||||
kbd {
|
||||
color: var(--preformatted);
|
||||
border: 1px solid var(--preformatted);
|
||||
border-bottom: 3px solid var(--preformatted);
|
||||
border-radius: var(--standard-border-radius);
|
||||
padding: 0.1rem 0.4rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 1rem 1.4rem;
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
color: var(--preformatted);
|
||||
}
|
||||
|
||||
/* Fix embedded code within pre */
|
||||
pre code {
|
||||
color: var(--preformatted);
|
||||
background: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Classes for buttons and notices */
|
||||
.button,
|
||||
.button:visited {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
background: var(--accent);
|
||||
font-size: 1rem;
|
||||
color: var(--bg);
|
||||
padding: 0.7rem 0.9rem;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.button:hover,
|
||||
.button:focus {
|
||||
filter: brightness(1.4);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
28
files/chat-box/etapes/03/index.html
Executable file
28
files/chat-box/etapes/03/index.html
Executable file
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Stage informatique - Chat</title>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
|
||||
<script type="text/javascript" src="validation.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Stage DSIC - 2023</h1>
|
||||
<div class="chat-box">
|
||||
<div id="messages-wrapper">
|
||||
<div class="messages"></div>
|
||||
</div>
|
||||
<form>
|
||||
<label for="sender">Votre nom:</label><br>
|
||||
<input type="text" id="sender" name="sender" placeholder="Nom"><br>
|
||||
<label for="msg">Message:</label><br>
|
||||
<input type="text" id="msg" name="msg" placeholder="Message..."><br><br>
|
||||
<input id="button" type="button" value="Valider">
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
4
files/chat-box/etapes/03/js/jquery-1.11.2.min.js
vendored
Executable file
4
files/chat-box/etapes/03/js/jquery-1.11.2.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
260
files/chat-box/etapes/03/style.css
Executable file
260
files/chat-box/etapes/03/style.css
Executable file
@ -0,0 +1,260 @@
|
||||
/* Global variables. */
|
||||
:root {
|
||||
/* Set sans-serif & mono fonts */
|
||||
--sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
|
||||
"Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
|
||||
"Helvetica Neue", sans-serif;
|
||||
--mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
|
||||
--standard-border-radius: 5px;
|
||||
|
||||
/* Default (light) theme */
|
||||
--bg: #fff;
|
||||
--accent-bg: #f5f7ff;
|
||||
--text: #212121;
|
||||
--text-light: #585858;
|
||||
--border: #898EA4;
|
||||
--accent: #0d47a1;
|
||||
--code: #d81b60;
|
||||
--preformatted: #444;
|
||||
--marked: #ffdd33;
|
||||
--disabled: #efefef;
|
||||
}
|
||||
|
||||
.chat-box {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
form {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.messages {
|
||||
height: 800px;
|
||||
width: 600px;
|
||||
border: 1px solid #666;
|
||||
border-radius: 3px;
|
||||
padding: 1em;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
margin-bottom: 5px;
|
||||
background: linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%),
|
||||
linear-gradient(127deg, rgba(0,255,0,.8), rgba(0,255,0,0) 70.71%),
|
||||
linear-gradient(336deg, rgba(0,0,255,.8), rgba(0,0,255,0) 70.71%);
|
||||
}
|
||||
|
||||
/* Make the body a nice central block */
|
||||
body {
|
||||
color: var(--text);
|
||||
background-color: var(--bg);
|
||||
font-size: 1.15rem;
|
||||
font-family: var(--mono-font);
|
||||
}
|
||||
|
||||
/* Format headers */
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2.6rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 2rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.44rem;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 0.96rem;
|
||||
}
|
||||
|
||||
/* Format links & buttons */
|
||||
a,
|
||||
a:visited {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
button,
|
||||
[role="button"],
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="button"],
|
||||
label[type="button"] {
|
||||
border: none;
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--accent);
|
||||
font-size: 1rem;
|
||||
color: var(--bg);
|
||||
padding: 0.7rem 0.9rem;
|
||||
margin: 0.5rem 0;
|
||||
|
||||
/* Ensure buttons use correct font */
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
/* Format forms */
|
||||
textarea,
|
||||
select,
|
||||
input {
|
||||
font-size: inherit;
|
||||
font-family: inherit;
|
||||
padding: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--text);
|
||||
background-color: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--standard-border-radius);
|
||||
box-shadow: none;
|
||||
max-width: 100%;
|
||||
display: inline-block;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
textarea:not([cols]) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Add arrow to drop-down */
|
||||
select:not([multiple]) {
|
||||
background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%),
|
||||
linear-gradient(135deg, var(--text) 51%, transparent 49%);
|
||||
background-position: calc(100% - 15px), calc(100% - 10px);
|
||||
background-size: 5px 5px, 5px 5px;
|
||||
background-repeat: no-repeat;
|
||||
padding-right: 25px;
|
||||
}
|
||||
|
||||
/* checkbox and radio button style */
|
||||
input[type="checkbox"],
|
||||
input[type="radio"] {
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
width: min-content;
|
||||
}
|
||||
|
||||
input[type="checkbox"] + label,
|
||||
input[type="radio"] + label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
input[type="radio"] {
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked,
|
||||
input[type="radio"]:checked {
|
||||
background-color: var(--accent);
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked::after {
|
||||
/* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */
|
||||
content: " ";
|
||||
width: 0.18em;
|
||||
height: 0.32em;
|
||||
border-radius: 0;
|
||||
position: absolute;
|
||||
top: 0.05em;
|
||||
left: 0.17em;
|
||||
background-color: transparent;
|
||||
border-right: solid var(--bg) 0.08em;
|
||||
border-bottom: solid var(--bg) 0.08em;
|
||||
font-size: 1.8em;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
input[type="radio"]:checked::after {
|
||||
/* creates a colored circle for the checked radio button */
|
||||
content: " ";
|
||||
width: 0.25em;
|
||||
height: 0.25em;
|
||||
border-radius: 100%;
|
||||
position: absolute;
|
||||
top: 0.125em;
|
||||
background-color: var(--bg);
|
||||
left: 0.125em;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
mark {
|
||||
padding: 2px 5px;
|
||||
border-radius: var(--standard-border-radius);
|
||||
background-color: var(--marked);
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
||||
blockquote {
|
||||
margin: 2rem 0 2rem 2rem;
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-left: 0.35rem solid var(--accent);
|
||||
color: var(--text-light);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
/* Use mono font for code elements */
|
||||
code,
|
||||
pre,
|
||||
pre span,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: var(--mono-font);
|
||||
color: var(--code);
|
||||
}
|
||||
|
||||
kbd {
|
||||
color: var(--preformatted);
|
||||
border: 1px solid var(--preformatted);
|
||||
border-bottom: 3px solid var(--preformatted);
|
||||
border-radius: var(--standard-border-radius);
|
||||
padding: 0.1rem 0.4rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 1rem 1.4rem;
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
color: var(--preformatted);
|
||||
}
|
||||
|
||||
/* Fix embedded code within pre */
|
||||
pre code {
|
||||
color: var(--preformatted);
|
||||
background: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Classes for buttons and notices */
|
||||
.button,
|
||||
.button:visited {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
background: var(--accent);
|
||||
font-size: 1rem;
|
||||
color: var(--bg);
|
||||
padding: 0.7rem 0.9rem;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.button:hover,
|
||||
.button:focus {
|
||||
filter: brightness(1.4);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
27
files/chat-box/etapes/03/validation.js
Executable file
27
files/chat-box/etapes/03/validation.js
Executable file
@ -0,0 +1,27 @@
|
||||
$(document).ready(function () {
|
||||
// Mettre une alerte au chargement de la page.
|
||||
alert('Hello !');
|
||||
|
||||
// Changer la couleur du bouton.
|
||||
$('#button').css('background-color', '#FFD700');
|
||||
|
||||
// Alerte au click du bouton.
|
||||
$('#button').on('click', function () {
|
||||
console.log('bienvenu ' + $('#sender').val());
|
||||
});
|
||||
|
||||
// Afficher les messages dans la zone des message.
|
||||
$('#button').on('click', function () {
|
||||
$(".messages").append($('#msg').val());
|
||||
});
|
||||
|
||||
// Valider la saisie du nom.
|
||||
$('#button').on('click', function () {
|
||||
if ($('#sender').val() == '') {
|
||||
alert("Veuillez saisir votre nom !");
|
||||
} else {
|
||||
console.log('bienvenu ' + $('#sender').val());
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
39
files/chat-box/etapes/04/index.html
Executable file
39
files/chat-box/etapes/04/index.html
Executable file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Stage informatique - Chat</title>
|
||||
<meta name="description" content="Un exemple de chat pour le stage informatique de la DSIC">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="../final/css/style.css">
|
||||
<link rel="stylesheet" href="../final/css/style_chat.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="chat-box">
|
||||
<div id="messages-wrapper">
|
||||
<div class="messages"></div>
|
||||
</div>
|
||||
<div id="forms-wrapper">
|
||||
<form action="" class="join-form">
|
||||
<input type="text" name="sender" id="sender" class="emojiable-option" placeholder="Saisi ton prénom">
|
||||
<div id="color-option-wrapper">
|
||||
<input type="hidden" name="color-option" id="color-option" data-palette='["#D50000","#304FFE","#00B8D4","#00C853","#FFD600","#FF6D00","#FF1744","#3D5AFE","#00E5FF","#00E676","#FFEA00","#FF9100","#FF5252","#536DFE","#18FFFF","#69F0AE","#FFFF00","#FFAB40"]' value="" placeholder="Choisi une couleur">
|
||||
</div>
|
||||
<button type="submit">Rejoindre le Chat</button>
|
||||
</form>
|
||||
<form action="" class="msg-form hidden">
|
||||
<input type="text" name="msg" id="msg" class="emojiable-option" placeholder="Ecrit un message">
|
||||
<button type="submit">Envoyer</button>
|
||||
</form>
|
||||
<form action="" class="close-form hidden">
|
||||
<button type="submit">Quitter le Chat</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../final/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
55
files/chat-box/etapes/05/index.html
Executable file
55
files/chat-box/etapes/05/index.html
Executable file
@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Stage informatique - Chat</title>
|
||||
<meta name="description" content="Un exemple de chat pour le stage informatique de la DSIC">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="../final/css/style_chat.css">
|
||||
<!-- Emoji -->
|
||||
<link rel="stylesheet" type="text/css" href="../final/css/jquery.emojipicker.css">
|
||||
<script type="text/javascript" src="../final/js/jquery-1.11.2.min.js"></script>
|
||||
<script type="text/javascript" src="../final/js/jquery.emojipicker.js"></script>
|
||||
<!-- Emoji Data -->
|
||||
<link rel="stylesheet" type="text/css" href="../final/css/jquery.emojipicker.tw.css">
|
||||
<script type="text/javascript" src="../final/js/jquery.emojis.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(e) {
|
||||
$('#sender').emojiPicker();
|
||||
$('#msg').emojiPicker();
|
||||
});
|
||||
</script>
|
||||
<!-- Color picker -->
|
||||
<link rel="stylesheet" href="../final/css/palette-color-picker.css">
|
||||
<script src="../final/js/palette-color-picker.js"></script>
|
||||
<script src="../final/js/ready.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="chat-box">
|
||||
<div id="messages-wrapper">
|
||||
<div class="messages"></div>
|
||||
</div>
|
||||
<div id="forms-wrapper">
|
||||
<form action="" class="join-form">
|
||||
<input type="text" name="sender" id="sender" class="emojiable-option" placeholder="Saisi ton prénom">
|
||||
<div id="color-option-wrapper">
|
||||
<input type="text" name="color-option" id="color-option" data-palette='["#D50000","#304FFE","#00B8D4","#00C853","#FFD600","#FF6D00","#FF1744","#3D5AFE","#00E5FF","#00E676","#FFEA00","#FF9100","#FF5252","#536DFE","#18FFFF","#69F0AE","#FFFF00","#FFAB40"]' value="" placeholder="Choisi une couleur">
|
||||
</div>
|
||||
<button type="submit">Rejoindre le Chat</button>
|
||||
</form>
|
||||
<form action="" class="msg-form hidden">
|
||||
<input type="text" name="msg" id="msg" class="emojiable-option" placeholder="Ecrit un message">
|
||||
<button type="submit">Envoyer</button>
|
||||
</form>
|
||||
<form action="" class="close-form hidden">
|
||||
<button type="submit">Quitter le Chat</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../final/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1280
files/chat-box/etapes/final/css/jquery.emojipicker.a.css
Executable file
1280
files/chat-box/etapes/final/css/jquery.emojipicker.a.css
Executable file
File diff suppressed because one or more lines are too long
53
files/chat-box/etapes/final/css/jquery.emojipicker.css
Executable file
53
files/chat-box/etapes/final/css/jquery.emojipicker.css
Executable file
File diff suppressed because one or more lines are too long
1247
files/chat-box/etapes/final/css/jquery.emojipicker.g.css
Executable file
1247
files/chat-box/etapes/final/css/jquery.emojipicker.g.css
Executable file
File diff suppressed because one or more lines are too long
1277
files/chat-box/etapes/final/css/jquery.emojipicker.tw.css
Executable file
1277
files/chat-box/etapes/final/css/jquery.emojipicker.tw.css
Executable file
File diff suppressed because one or more lines are too long
1
files/chat-box/etapes/final/css/palette-color-picker.css
Executable file
1
files/chat-box/etapes/final/css/palette-color-picker.css
Executable file
@ -0,0 +1 @@
|
||||
.palette-color-picker-button{position:relative;display:inline-block;width:28px;height:28px;margin-right:8px;background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path fill="#f5c86c" d="M2 2h8v8H2z"/><path fill="#f56c6c" d="M12 2h8v8h-8z"/><path fill="#f46ac6" d="M22 2h8v8h-8z"/><path fill="#c3f167" d="M2 12h8v8H2z"/><path fill="#f3f3f3" d="M12 12h8v8h-8z"/><path fill="#c76cf5" d="M22 12h8v8h-8z"/><path fill="#69e369" d="M2 22h8v8H2z"/><path fill="#6bc6f4" d="M12 22h8v8h-8z"/><path fill="#6b6bf5" d="M22 22h8v8h-8z"/><path d="M9 3v6H3V3h6m1-1H2v8h8V2zm9 1v6h-6V3h6m1-1h-8v8h8V2zm9 1v6h-6V3h6m1-1h-8v8h8V2zM9 13v6H3v-6h6m1-1H2v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8zM9 23v6H3v-6h6m1-1H2v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8z" opacity=".25"/></svg>') center center no-repeat;background-size:cover;cursor:pointer;box-shadow:0 0 0 1px #bbb;border:2px solid #fff}.palette-color-picker-bubble{display:none;margin:12px 0;position:absolute;bottom:100%;width:220px;padding:10px 8px 8px 8px;border:1px solid #bbb;border-radius:3px;background-color:#fff}.palette-color-picker-bubble:after,.palette-color-picker-bubble:before{top:100%;left:14px;border:solid transparent;content:' ';height:0;width:0;position:absolute;pointer-events:none}.palette-color-picker-bubble:after{border-color:transparent;border-top-color:#fff;border-width:8px;margin-left:-8px}.palette-color-picker-bubble:before{border-color:transparent;border-top-color:#bbb;border-width:9px;margin-left:-9px}.palette-color-picker-bubble.downside{bottom:auto;top:100%}.palette-color-picker-bubble.downside:after,.palette-color-picker-bubble.downside:before{top:auto;bottom:100%}.palette-color-picker-bubble.downside:after{border-top-color:transparent;border-bottom-color:#fff}.palette-color-picker-bubble.downside:before{border-top-color:transparent;border-bottom-color:#bbb}.palette-color-picker-bubble .swatch{position:relative;display:inline-block;font:0/0 a;width:12.66%;padding-top:11.00%;margin:1% 2%;outline:1px solid #bbb;border:2px solid #fff;border-radius:3px;cursor:pointer;overflow:hidden}.palette-color-picker-bubble .swatch.active{outline-color:#000;-webkit-box-shadow:0px 0px 5px 0px rgba(0,0,0,0.75);-moz-box-shadow:0px 0px 5px 0px rgba(0,0,0,0.75);box-shadow:0px 0px 5px 0px rgba(0,0,0,0.75)}.palette-color-picker-bubble .swatch.clear{background-color:#fff}.palette-color-picker-bubble .swatch.clear:before{position:absolute;content:'';display:block;top:-1px;left:0;width:100px;height:2px;background-color:#e00;transform-origin:0 0;transform:rotate(45deg)}.palette-color-picker-bubble.double .swatch{width:29.30%;padding-top:11.00%;margin:1% 2%}.palette-color-picker-bubble.double .swatch.clear:before{transform:rotate(22.5deg)}.palette-color-picker-bubble.wide .swatch{width:96.2%;padding-top:11.00%;margin:1% 2%}.palette-color-picker-bubble.wide .swatch.clear{width:12.66%}.palette-color-picker-bubble.force-left{left:-178px}.palette-color-picker-bubble.force-left:after,.palette-color-picker-bubble.force-left:before{left:188px}
|
||||
125
files/chat-box/etapes/final/css/style_chat.css
Executable file
125
files/chat-box/etapes/final/css/style_chat.css
Executable file
@ -0,0 +1,125 @@
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.chat-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.chat-box {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#forms-wrapper {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.messages {
|
||||
height: 800px;
|
||||
width: 600px;
|
||||
border: 1px solid #666;
|
||||
border-radius: 3px;
|
||||
padding: 1em;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
input {
|
||||
display: block;
|
||||
width: 500px;
|
||||
padding: 5px;
|
||||
height: 44px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
button {
|
||||
display: block;
|
||||
background: rgb(39, 112, 215);
|
||||
padding: 5px;
|
||||
margin: 5px 0;
|
||||
width: 150px;
|
||||
height: 44px;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
form.msg-form {
|
||||
bottom: 1em;
|
||||
right: 1em;
|
||||
left: 1em;
|
||||
}
|
||||
form.close-form button {
|
||||
background: rgb(237, 102, 102);
|
||||
border: 1px solid rgb(237, 102, 102);
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.hidden {
|
||||
visibility: hidden;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.msg {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.msg-text {
|
||||
padding: 5px;
|
||||
display: inline-block;
|
||||
border-radius: 5px;
|
||||
font-family: "Verdana", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
.msg-normal .msg-text {
|
||||
background:#ccc;
|
||||
color: white;
|
||||
font-family: "Verdana", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
.msg-normal .msg-sender {
|
||||
font-family: "Verdana", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.msg-notification .msg-text,
|
||||
.msg-join .msg-text,
|
||||
.msg-left .msg-text {
|
||||
background: #eee;
|
||||
border: 1px solid #ccc;
|
||||
font-family: "Verdana", sans-serif;
|
||||
}
|
||||
|
||||
.msg-join .msg-text,
|
||||
.msg-left .msg-text {
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.msg-notification .msg-sender,
|
||||
.msg-join .msg-sender,
|
||||
.msg-left .msg-sender {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#color-option-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
#color-option-wrapper .palette-color-picker-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
cursor: pointer;
|
||||
width: 44px;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
4
files/chat-box/etapes/final/js/jquery-1.11.2.min.js
vendored
Executable file
4
files/chat-box/etapes/final/js/jquery-1.11.2.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
637
files/chat-box/etapes/final/js/jquery.emojipicker.js
Executable file
637
files/chat-box/etapes/final/js/jquery.emojipicker.js
Executable file
@ -0,0 +1,637 @@
|
||||
;(function($) {
|
||||
|
||||
var pluginName = "emojiPicker",
|
||||
defaults = {
|
||||
width: '200',
|
||||
height: '350',
|
||||
position: 'right',
|
||||
fadeTime: 100,
|
||||
iconColor: 'black',
|
||||
iconBackgroundColor: '#eee',
|
||||
recentCount: 36,
|
||||
emojiSet: 'apple',
|
||||
container: 'body',
|
||||
button: true
|
||||
};
|
||||
|
||||
var MIN_WIDTH = 280,
|
||||
MAX_WIDTH = 600,
|
||||
MIN_HEIGHT = 100,
|
||||
MAX_HEIGHT = 350,
|
||||
MAX_ICON_HEIGHT = 50;
|
||||
|
||||
var categories = [
|
||||
{ name: 'people', label: 'People' },
|
||||
{ name: 'nature', label: 'Nature' },
|
||||
{ name: 'food', label: 'Food' },
|
||||
{ name: 'activity', label: 'Activities' },
|
||||
{ name: 'travel', label: 'Travel & Places' },
|
||||
{ name: 'object', label: 'Objects' },
|
||||
{ name: 'symbol', label: 'Symbols' },
|
||||
{ name: 'flag', label: 'Flags' }
|
||||
];
|
||||
|
||||
function EmojiPicker( element, options ) {
|
||||
|
||||
this.element = element;
|
||||
this.$el = $(element);
|
||||
|
||||
this.settings = $.extend( {}, defaults, options );
|
||||
|
||||
this.$container = $(this.settings.container);
|
||||
|
||||
// (type) Safety first
|
||||
this.settings.width = parseInt(this.settings.width);
|
||||
this.settings.height = parseInt(this.settings.height);
|
||||
|
||||
// Check for valid width/height
|
||||
if(this.settings.width >= MAX_WIDTH) {
|
||||
this.settings.width = MAX_WIDTH;
|
||||
} else if (this.settings.width < MIN_WIDTH) {
|
||||
this.settings.width = MIN_WIDTH;
|
||||
}
|
||||
if (this.settings.height >= MAX_HEIGHT) {
|
||||
this.settings.height = MAX_HEIGHT;
|
||||
} else if (this.settings.height < MIN_HEIGHT) {
|
||||
this.settings.height = MIN_HEIGHT;
|
||||
}
|
||||
|
||||
var possiblePositions = [ 'left',
|
||||
'right'
|
||||
/*,'top',
|
||||
'bottom'*/];
|
||||
if($.inArray(this.settings.position,possiblePositions) == -1) {
|
||||
this.settings.position = defaults.position; //current default
|
||||
}
|
||||
|
||||
// Do not enable if on mobile device (emojis already present)
|
||||
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
||||
this.init();
|
||||
} else {
|
||||
this.isMobile = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$.extend(EmojiPicker.prototype, {
|
||||
|
||||
init: function() {
|
||||
this.active = false;
|
||||
this.addPickerIcon();
|
||||
this.createPicker();
|
||||
this.listen();
|
||||
},
|
||||
|
||||
addPickerIcon: function() {
|
||||
// The wrapper is not needed if they have chosen to not use a button
|
||||
if (this.settings.button) {
|
||||
var elementHeight = this.$el.outerHeight();
|
||||
var iconHeight = elementHeight > MAX_ICON_HEIGHT ?
|
||||
MAX_ICON_HEIGHT :
|
||||
elementHeight;
|
||||
|
||||
// This can cause issues if the element is not visible when it is initiated
|
||||
var objectWidth = this.$el.width();
|
||||
|
||||
this.$el.width(objectWidth);
|
||||
|
||||
this.$wrapper = this.$el
|
||||
.wrap("<div class='emojiPickerIconWrap'></div>")
|
||||
.parent();
|
||||
|
||||
this.$icon = $('<div class="emojiPickerIcon"></div>')
|
||||
.height(iconHeight)
|
||||
.width(iconHeight)
|
||||
.addClass(this.settings.iconColor)
|
||||
.css('backgroundColor', this.settings.iconBackgroundColor);
|
||||
this.$wrapper.append( this.$icon );
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
createPicker: function() {
|
||||
|
||||
// Show template
|
||||
this.$picker = $( getPickerHTML() )
|
||||
.appendTo( this.$container )
|
||||
.width(this.settings.width)
|
||||
.height(this.settings.height)
|
||||
.css('z-index',10000);
|
||||
|
||||
// Picker height
|
||||
this.$picker.find('.sections')
|
||||
.height(parseInt(this.settings.height) - 40); // 40 is height of the tabs
|
||||
|
||||
// Tab size based on width
|
||||
if (this.settings.width < 240) {
|
||||
this.$picker.find('.emoji').css({'width':'1em', 'height':'1em'});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
destroyPicker: function() {
|
||||
if (this.isMobile) return this;
|
||||
|
||||
this.$picker.unbind('mouseover');
|
||||
this.$picker.unbind('mouseout');
|
||||
this.$picker.unbind('click');
|
||||
this.$picker.remove();
|
||||
|
||||
$.removeData(this.$el.get(0), 'emojiPicker');
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
// If the button is being used, wrapper has not been set,
|
||||
// and will not need a listener
|
||||
if (this.settings.button){
|
||||
// Clicking on the picker icon
|
||||
this.$wrapper.find('.emojiPickerIcon')
|
||||
.click( $.proxy(this.iconClicked, this) );
|
||||
}
|
||||
|
||||
// Click event for emoji
|
||||
this.$picker.on('click', 'em', $.proxy(this.emojiClicked, this));
|
||||
|
||||
// Hover event for emoji
|
||||
this.$picker.on('mouseover', 'em', $.proxy(this.emojiMouseover, this) );
|
||||
this.$picker.on('mouseout', 'em', $.proxy(this.emojiMouseout, this) );
|
||||
|
||||
// Click event for active tab
|
||||
this.$picker.find('nav .tab')
|
||||
.click( $.proxy(this.emojiCategoryClicked, this) )
|
||||
.mouseover( $.proxy(this.emojiTabMouseover, this) )
|
||||
.mouseout( $.proxy(this.emojiMouseout, this) );
|
||||
|
||||
// Scroll event for active tab
|
||||
this.$picker.find('.sections')
|
||||
.scroll( $.proxy(this.emojiScroll, this) );
|
||||
|
||||
this.$picker.click( $.proxy(this.pickerClicked, this) );
|
||||
|
||||
// Key events for search
|
||||
this.$picker.find('section.search input')
|
||||
.on('keyup search', $.proxy(this.searchCharEntered, this) );
|
||||
|
||||
// Shortcode hover
|
||||
this.$picker.find('.shortcode').mouseover(function(e) { e.stopPropagation(); });
|
||||
|
||||
$(document.body).click( $.proxy(this.clickOutside, this) );
|
||||
|
||||
// Resize events forces a reposition, which may or may not actually be required
|
||||
$(window).resize( $.proxy(this.updatePosition, this) );
|
||||
},
|
||||
|
||||
updatePosition: function() {
|
||||
|
||||
/* Process:
|
||||
1. Find the nearest positioned element by crawling up the ancestors, record it's offset
|
||||
2. Find the bottom left or right of the input element, record this (Account for position setting of left or right)
|
||||
3. Find the difference between the two, as this will become our new position
|
||||
4. Magic.
|
||||
|
||||
N.B. The removed code had a reference to top/bottom positioning, but I don't see the use case for this..
|
||||
*/
|
||||
|
||||
// Step 1
|
||||
// Luckily jquery already does this...
|
||||
var positionedParent = this.$picker.offsetParent();
|
||||
var parentOffset = positionedParent.offset(); // now have a top/left object
|
||||
|
||||
// Step 2
|
||||
var elOffset = this.$el.offset();
|
||||
if(this.settings.position == 'right'){
|
||||
elOffset.left += this.$el.outerWidth() - this.settings.width;
|
||||
}
|
||||
elOffset.top += this.$el.outerHeight();
|
||||
|
||||
// Step 3
|
||||
var diffOffset = {
|
||||
top: (elOffset.top - parentOffset.top),
|
||||
left: (elOffset.left - parentOffset.top)
|
||||
};
|
||||
|
||||
this.$picker.css({
|
||||
top: diffOffset.top,
|
||||
left: diffOffset.left
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$picker.hide(this.settings.fadeTime, 'linear', function() {
|
||||
this.active = false;
|
||||
if (this.settings.onHide) {
|
||||
this.settings.onHide( this.$picker, this.settings, this.active );
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.$el.focus();
|
||||
this.updatePosition();
|
||||
this.$picker.show(this.settings.fadeTime, 'linear', function() {
|
||||
this.active = true;
|
||||
if (this.settings.onShow) {
|
||||
this.settings.onShow( this.$picker, this.settings, this.active );
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/************
|
||||
* EVENTS *
|
||||
************/
|
||||
|
||||
iconClicked : function() {
|
||||
if ( this.$picker.is(':hidden') ) {
|
||||
this.show();
|
||||
if( this.$picker.find('.search input').length > 0 ) {
|
||||
this.$picker.find('.search input').focus();
|
||||
}
|
||||
} else {
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
emojiClicked: function(e) { var clickTarget = $(e.target);
|
||||
var emojiSpan;
|
||||
if (clickTarget.is('em')) {
|
||||
emojiSpan = clickTarget.find('span');
|
||||
} else {
|
||||
emojiSpan = clickTarget.parent().find('.emoji');
|
||||
}
|
||||
|
||||
var emojiShortcode = emojiSpan.attr('class').split('emoji-')[1];
|
||||
var emojiUnicode = toUnicode(findEmoji(emojiShortcode).unicode[defaults.emojiSet]);
|
||||
|
||||
insertAtCaret(this.element, emojiUnicode);
|
||||
addToLocalStorage(emojiShortcode);
|
||||
updateRecentlyUsed(emojiShortcode);
|
||||
|
||||
// For anyone who is relying on the keyup event
|
||||
$(this.element).trigger("keyup");
|
||||
|
||||
// trigger change event on input
|
||||
var event = document.createEvent("HTMLEvents");
|
||||
event.initEvent("input", true, true);
|
||||
this.element.dispatchEvent(event);
|
||||
},
|
||||
|
||||
emojiMouseover: function(e) {
|
||||
var emojiShortcode = $(e.target).parent().find('.emoji').attr('class').split('emoji-')[1];
|
||||
var $shortcode = $(e.target).parents('.emojiPicker').find('.shortcode');
|
||||
$shortcode.find('.random').hide();
|
||||
$shortcode.find('.info').show().html('<div class="emoji emoji-' + emojiShortcode + '"></div><em>' + emojiShortcode + '</em>');
|
||||
},
|
||||
|
||||
emojiMouseout: function(e) {
|
||||
$(e.target).parents('.emojiPicker').find('.shortcode .info').empty().hide();
|
||||
$(e.target).parents('.emojiPicker').find('.shortcode .random').show();
|
||||
},
|
||||
|
||||
emojiCategoryClicked: function(e) {
|
||||
var section = '';
|
||||
|
||||
// Update tab
|
||||
this.$picker.find('nav .tab').removeClass('active');
|
||||
if ($(e.target).parent().hasClass('tab')) {
|
||||
section = $(e.target).parent().attr('data-tab');
|
||||
$(e.target).parent('.tab').addClass('active');
|
||||
}
|
||||
else {
|
||||
section = $(e.target).attr('data-tab');
|
||||
$(e.target).addClass('active');
|
||||
}
|
||||
|
||||
var $section = this.$picker.find('section.' + section);
|
||||
|
||||
var heightOfSectionsHidden = $section.parent().scrollTop();
|
||||
var heightOfSectionToPageTop = $section.offset().top;
|
||||
var heightOfSectionsToPageTop = $section.parent().offset().top;
|
||||
|
||||
var scrollDistance = heightOfSectionsHidden
|
||||
+ heightOfSectionToPageTop
|
||||
- heightOfSectionsToPageTop;
|
||||
|
||||
$('.sections').off('scroll'); // Disable scroll event until animation finishes
|
||||
|
||||
var that = this;
|
||||
$('.sections').animate({
|
||||
scrollTop: scrollDistance
|
||||
}, 250, function() {
|
||||
that.$picker.find('.sections').on('scroll', $.proxy(that.emojiScroll, that) ); // Enable scroll event
|
||||
});
|
||||
},
|
||||
|
||||
emojiTabMouseover: function(e) {
|
||||
var section = '';
|
||||
if ($(e.target).parent().hasClass('tab')) {
|
||||
section = $(e.target).parent().attr('data-tab');
|
||||
}
|
||||
else {
|
||||
section = $(e.target).attr('data-tab');
|
||||
}
|
||||
|
||||
var categoryTitle = '';
|
||||
for (var i = 0; i < categories.length; i++) {
|
||||
if (categories[i].name == section) { categoryTitle = categories[i].label; }
|
||||
}
|
||||
if (categoryTitle == '') { categoryTitle = 'Recently Used'; }
|
||||
|
||||
var categoryCount = $('section.' + section).attr('data-count');
|
||||
var categoryHtml = '<em class="tabTitle">' + categoryTitle + ' <span class="count">(' + categoryCount + ' emojis)</span></em>';
|
||||
|
||||
var $shortcode = $(e.target).parents('.emojiPicker').find('.shortcode');
|
||||
$shortcode.find('.random').hide();
|
||||
$shortcode.find('.info').show().html(categoryHtml);
|
||||
},
|
||||
|
||||
emojiScroll: function(e) {
|
||||
var sections = $('section');
|
||||
$.each(sections, function(key, value) {
|
||||
var section = sections[key];
|
||||
var offsetFromTop = $(section).position().top;
|
||||
|
||||
if (section.className == 'search' || (section.className == 'people' && offsetFromTop > 0)) {
|
||||
$(section).parents('.emojiPicker').find('nav tab.recent').addClass('active');
|
||||
return;
|
||||
}
|
||||
|
||||
if (offsetFromTop <= 0) {
|
||||
$(section).parents('.emojiPicker').find('nav .tab').removeClass('active');
|
||||
$(section).parents('.emojiPicker').find('nav .tab[data-tab=' + section.className + ']').addClass('active');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
pickerClicked: function(e) {
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
clickOutside: function(e) {
|
||||
if ( this.active ) {
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
searchCharEntered: function(e) {
|
||||
var searchTerm = $(e.target).val();
|
||||
var searchEmojis = $(e.target).parents('.sections').find('section.search');
|
||||
var searchEmojiWrap = searchEmojis.find('.wrap');
|
||||
var sections = $(e.target).parents('.sections').find('section');
|
||||
|
||||
// Clear if X is clicked within input
|
||||
if (searchTerm == '') {
|
||||
sections.show();
|
||||
searchEmojiWrap.hide();
|
||||
}
|
||||
|
||||
if (searchTerm.length > 0) {
|
||||
sections.hide();
|
||||
searchEmojis.show();
|
||||
searchEmojiWrap.show();
|
||||
|
||||
var results = [];
|
||||
searchEmojiWrap.find('em').remove();
|
||||
|
||||
$.each($.fn.emojiPicker.emojis, function(i, emoji) {
|
||||
var shortcode = emoji.shortcode;
|
||||
if ( shortcode.indexOf(searchTerm) > -1 ) {
|
||||
results.push('<em><div class="emoji emoji-' + shortcode + '"></div></em>');
|
||||
}
|
||||
});
|
||||
searchEmojiWrap.append(results.join(''));
|
||||
} else {
|
||||
sections.show();
|
||||
searchEmojiWrap.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.fn[ pluginName ] = function ( options ) {
|
||||
|
||||
// Calling a function
|
||||
if (typeof options === 'string') {
|
||||
this.each(function() {
|
||||
var plugin = $.data( this, pluginName );
|
||||
switch(options) {
|
||||
case 'toggle':
|
||||
plugin.iconClicked();
|
||||
break;
|
||||
case 'destroy':
|
||||
plugin.destroyPicker();
|
||||
break;
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
// Don't attach to the same element twice
|
||||
if ( !$.data( this, pluginName ) ) {
|
||||
$.data( this, pluginName, new EmojiPicker( this, options ) );
|
||||
}
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
function getPickerHTML() {
|
||||
var nodes = [];
|
||||
var aliases = {
|
||||
'undefined': 'object'
|
||||
}
|
||||
var items = {};
|
||||
var localStorageSupport = (typeof(Storage) !== 'undefined') ? true : false;
|
||||
|
||||
// Re-Sort Emoji table
|
||||
$.each($.fn.emojiPicker.emojis, function(i, emoji) {
|
||||
var category = aliases[ emoji.category ] || emoji.category;
|
||||
items[ category ] = items[ category ] || [];
|
||||
items[ category ].push( emoji );
|
||||
});
|
||||
|
||||
nodes.push('<div class="emojiPicker">');
|
||||
nodes.push('<nav>');
|
||||
|
||||
// Recent Tab, if localstorage support
|
||||
if (localStorageSupport) {
|
||||
nodes.push('<div class="tab active" data-tab="recent"><div class="emoji emoji-tab-recent"></div></div>');
|
||||
}
|
||||
|
||||
// Emoji category tabs
|
||||
var categories_length = categories.length;
|
||||
for (var i = 0; i < categories_length; i++) {
|
||||
nodes.push('<div class="tab' +
|
||||
( !localStorageSupport && i == 0 ? ' active' : '' ) +
|
||||
'" data-tab="' +
|
||||
categories[i].name +
|
||||
'"><div class="emoji emoji-tab-' +
|
||||
categories[i].name +
|
||||
'"></div></div>');
|
||||
}
|
||||
nodes.push('</nav>');
|
||||
nodes.push('<div class="sections">');
|
||||
|
||||
// Search
|
||||
nodes.push('<section class="search">');
|
||||
nodes.push('<input type="search" placeholder="Search...">');
|
||||
nodes.push('<div class="wrap" style="display:none;"><h1>Search Results</h1></div>');
|
||||
nodes.push('</section>');
|
||||
|
||||
// Recent Section, if localstorage support
|
||||
if (localStorageSupport) {
|
||||
var recentlyUsedEmojis = [];
|
||||
var recentlyUsedCount = 0;
|
||||
var displayRecentlyUsed = ' style="display:none;"';
|
||||
|
||||
if (localStorage.emojis) {
|
||||
recentlyUsedEmojis = JSON.parse(localStorage.emojis);
|
||||
recentlyUsedCount = recentlyUsedEmojis.length;
|
||||
displayRecentlyUsed = ' style="display:block;"';
|
||||
}
|
||||
|
||||
nodes.push('<section class="recent" data-count="' + recentlyUsedEmojis.length + '"' + displayRecentlyUsed + '>');
|
||||
nodes.push('<h1>Recently Used</h1><div class="wrap">');
|
||||
|
||||
for (var i = recentlyUsedEmojis.length-1; i > -1 ; i--) {
|
||||
nodes.push('<em><span class="emoji emoji-' + recentlyUsedEmojis[i] + '"></span></em>');
|
||||
}
|
||||
nodes.push('</div></section>');
|
||||
}
|
||||
|
||||
// Emoji sections
|
||||
for (var i = 0; i < categories_length; i++) {
|
||||
var category_length = items[ categories[i].name ].length;
|
||||
nodes.push('<section class="' + categories[i].name + '" data-count="' + category_length + '">');
|
||||
nodes.push('<h1>' + categories[i].label + '</h1><div class="wrap">');
|
||||
for (var j = 0; j < category_length; j++) {
|
||||
var emoji = items[ categories[i].name ][ j ];
|
||||
nodes.push('<em><span class="emoji emoji-' + emoji.shortcode + '"></span></em>');
|
||||
}
|
||||
nodes.push('</div></section>');
|
||||
}
|
||||
nodes.push('</div>');
|
||||
|
||||
// Shortcode section
|
||||
nodes.push('<div class="shortcode"><span class="random">');
|
||||
nodes.push('<em class="tabTitle">' + generateEmojiOfDay() + '</em>');
|
||||
nodes.push('</span><span class="info"></span></div>');
|
||||
|
||||
nodes.push('</div>');
|
||||
return nodes.join("\n");
|
||||
}
|
||||
|
||||
function generateEmojiOfDay() {
|
||||
var emojis = $.fn.emojiPicker.emojis;
|
||||
var i = Math.floor(Math.random() * (364 - 0) + 0);
|
||||
var emoji = emojis[i];
|
||||
return 'Daily Emoji: <span class="eod"><span class="emoji emoji-' + emoji.name + '"></span> <span class="emojiName">' + emoji.name + '</span></span>';
|
||||
}
|
||||
|
||||
function findEmoji(emojiShortcode) {
|
||||
var emojis = $.fn.emojiPicker.emojis;
|
||||
for (var i = 0; i < emojis.length; i++) {
|
||||
if (emojis[i].shortcode == emojiShortcode) {
|
||||
return emojis[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function insertAtCaret(inputField, myValue) {
|
||||
if (document.selection) {
|
||||
//For browsers like Internet Explorer
|
||||
inputField.focus();
|
||||
var sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
inputField.focus();
|
||||
}
|
||||
else if (inputField.selectionStart || inputField.selectionStart == '0') {
|
||||
//For browsers like Firefox and Webkit based
|
||||
var startPos = inputField.selectionStart;
|
||||
var endPos = inputField.selectionEnd;
|
||||
var scrollTop = inputField.scrollTop;
|
||||
inputField.value = inputField.value.substring(0, startPos)+myValue+inputField.value.substring(endPos,inputField.value.length);
|
||||
inputField.focus();
|
||||
inputField.selectionStart = startPos + myValue.length;
|
||||
inputField.selectionEnd = startPos + myValue.length;
|
||||
inputField.scrollTop = scrollTop;
|
||||
} else {
|
||||
inputField.focus();
|
||||
inputField.value += myValue;
|
||||
}
|
||||
}
|
||||
|
||||
function toUnicode(code) {
|
||||
var codes = code.split('-').map(function(value, index) {
|
||||
return parseInt(value, 16);
|
||||
});
|
||||
return String.fromCodePoint.apply(null, codes);
|
||||
}
|
||||
|
||||
function addToLocalStorage(emoji) {
|
||||
var recentlyUsedEmojis = [];
|
||||
if (localStorage.emojis) {
|
||||
recentlyUsedEmojis = JSON.parse(localStorage.emojis);
|
||||
}
|
||||
|
||||
// If already in recently used, move to front
|
||||
var index = recentlyUsedEmojis.indexOf(emoji);
|
||||
if (index > -1) {
|
||||
recentlyUsedEmojis.splice(index, 1);
|
||||
}
|
||||
recentlyUsedEmojis.push(emoji);
|
||||
|
||||
if (recentlyUsedEmojis.length > defaults.recentCount) {
|
||||
recentlyUsedEmojis.shift();
|
||||
}
|
||||
|
||||
localStorage.emojis = JSON.stringify(recentlyUsedEmojis);
|
||||
}
|
||||
|
||||
function updateRecentlyUsed(emoji) {
|
||||
var recentlyUsedEmojis = JSON.parse(localStorage.emojis);
|
||||
var emojis = [];
|
||||
var recent = $('section.recent');
|
||||
|
||||
for (var i = recentlyUsedEmojis.length-1; i >= 0; i--) {
|
||||
emojis.push('<em><span class="emoji emoji-' + recentlyUsedEmojis[i] + '"></span></em>');
|
||||
}
|
||||
|
||||
// Fix height as emojis are added
|
||||
var prevHeight = recent.outerHeight();
|
||||
$('section.recent .wrap').html(emojis.join(''));
|
||||
var currentScrollTop = $('.sections').scrollTop();
|
||||
var newHeight = recent.outerHeight();
|
||||
var newScrollToHeight = 0;
|
||||
|
||||
if (!$('section.recent').is(':visible')) {
|
||||
recent.show();
|
||||
newScrollToHeight = newHeight;
|
||||
} else if (prevHeight != newHeight) {
|
||||
newScrollToHeight = newHeight - prevHeight;
|
||||
}
|
||||
|
||||
$('.sections').animate({
|
||||
scrollTop: currentScrollTop + newScrollToHeight
|
||||
}, 0);
|
||||
}
|
||||
|
||||
if (!String.fromCodePoint) {
|
||||
// ES6 Unicode Shims 0.1 , © 2012 Steven Levithan http://slevithan.com/ , MIT License
|
||||
String.fromCodePoint = function fromCodePoint () {
|
||||
var chars = [], point, offset, units, i;
|
||||
for (i = 0; i < arguments.length; ++i) {
|
||||
point = arguments[i];
|
||||
offset = point - 0x10000;
|
||||
units = point > 0xFFFF ? [0xD800 + (offset >> 10), 0xDC00 + (offset & 0x3FF)] : [point];
|
||||
chars.push(String.fromCharCode.apply(null, units));
|
||||
}
|
||||
return chars.join("");
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
9075
files/chat-box/etapes/final/js/jquery.emojis.js
Executable file
9075
files/chat-box/etapes/final/js/jquery.emojis.js
Executable file
File diff suppressed because it is too large
Load Diff
154
files/chat-box/etapes/final/js/main.js
Executable file
154
files/chat-box/etapes/final/js/main.js
Executable file
@ -0,0 +1,154 @@
|
||||
(function(){
|
||||
const colorPalette = ["#D50000","#304FFE","#00B8D4","#00C853","#FFD600","#FF6D00","#FF1744","#3D5AFE","#00E5FF","#00E676","#FFEA00","#FF9100","#FF5252","#536DFE","#18FFFF","#69F0AE","#FFFF00","#FFAB40"];
|
||||
const colorCount = colorPalette.length;
|
||||
const rand = Math.floor(Math.random() * colorCount) + 1;
|
||||
const userColor = colorPalette[rand];
|
||||
const colorOption = document.getElementById("color-option");
|
||||
colorOption.value = userColor;
|
||||
|
||||
function parseMessage(message) {
|
||||
var msg = {type: "", sender: "", text: "", color: ""};
|
||||
try {
|
||||
msg = JSON.parse(message);
|
||||
}
|
||||
catch(e) {
|
||||
return false;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
function appendMessage(message) {
|
||||
var msgContainer = document.querySelector(".messages");
|
||||
var parsedMessage;
|
||||
|
||||
if(parsedMessage = parseMessage(message)) {
|
||||
console.log("appending message...");
|
||||
|
||||
var msgElem, senderElem, textElem;
|
||||
var sender, text, color;
|
||||
|
||||
if (parsedMessage.color !== "") {
|
||||
color = parsedMessage.color;
|
||||
} else {
|
||||
color = userColor;
|
||||
}
|
||||
|
||||
msgElem = document.createElement("div");
|
||||
msgElem.classList.add("msg");
|
||||
msgElem.classList.add("msg-" + parsedMessage.type);
|
||||
|
||||
senderElem = document.createElement("div");
|
||||
senderElem.classList.add("msg-sender");
|
||||
|
||||
textElem = document.createElement("div");
|
||||
textElem.classList.add("msg-text");
|
||||
textElem.style.background = color;
|
||||
|
||||
sender = document.createTextNode(parsedMessage.sender + ": ");
|
||||
text = document.createTextNode(parsedMessage.text);
|
||||
|
||||
senderElem.appendChild(sender);
|
||||
textElem.appendChild(text);
|
||||
|
||||
msgElem.appendChild(senderElem);
|
||||
msgElem.appendChild(textElem);
|
||||
|
||||
msgContainer.appendChild(msgElem);
|
||||
}
|
||||
}
|
||||
|
||||
function setup() {
|
||||
var sender, color = "";
|
||||
var joinForm = document.querySelector("form.join-form");
|
||||
var msgForm = document.querySelector("form.msg-form");
|
||||
var closeForm = document.querySelector("form.close-form");
|
||||
|
||||
var joinFormSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
sender = document.getElementById("sender").value;
|
||||
if (sender) {
|
||||
color = colorOption.value;
|
||||
var joinMsg = {
|
||||
type: "join",
|
||||
sender: sender,
|
||||
text: sender + " joined the chat!",
|
||||
color: color
|
||||
};
|
||||
|
||||
socket.send(JSON.stringify(joinMsg));
|
||||
joinForm.classList.add("hidden");
|
||||
msgForm.classList.remove("hidden");
|
||||
closeForm.classList.remove("hidden");
|
||||
} else {
|
||||
alert("Veuillez saisir votre prénom.");
|
||||
}
|
||||
};
|
||||
|
||||
var msgFormSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
var msgField, msgText, msg, color;
|
||||
msgField = document.getElementById("msg");
|
||||
msgText = msgField.value;
|
||||
if (colorOption.value) {
|
||||
color = colorOption.value;
|
||||
} else {
|
||||
color = userColor;
|
||||
}
|
||||
|
||||
msg = {
|
||||
type: "normal",
|
||||
sender: sender,
|
||||
text: msgText,
|
||||
color: color
|
||||
};
|
||||
|
||||
socket.send(JSON.stringify(msg));
|
||||
msgField.value = "";
|
||||
};
|
||||
|
||||
var closeFormSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
socket.close();
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
joinForm.addEventListener("submit", joinFormSubmit);
|
||||
msgForm.addEventListener("submit", msgFormSubmit);
|
||||
closeForm.addEventListener("submit", closeFormSubmit);
|
||||
}
|
||||
|
||||
var socket = new WebSocket("ws:devweb-ccb-t.ville-geneve.ch:8081");
|
||||
|
||||
var socketOpen = (e) => {
|
||||
console.log("connected to the socket");
|
||||
var msg = {
|
||||
type: "join",
|
||||
sender: "Browser",
|
||||
text: "connected to the chat server",
|
||||
color: "white"
|
||||
};
|
||||
appendMessage(JSON.stringify(msg));
|
||||
setup();
|
||||
};
|
||||
|
||||
var socketMessage = (e) => {
|
||||
console.log("Message fom server: " + e.data);
|
||||
appendMessage(e.data);
|
||||
};
|
||||
|
||||
var socketClose = (e) => {
|
||||
|
||||
};
|
||||
|
||||
var socketError = (e) => {
|
||||
|
||||
};
|
||||
|
||||
socket.addEventListener("open", socketOpen);
|
||||
socket.addEventListener("message", socketMessage);
|
||||
socket.addEventListener("close", socketClose);
|
||||
socket.addEventListener("error", socketError);
|
||||
|
||||
})();
|
||||
265
files/chat-box/etapes/final/js/palette-color-picker.js
Executable file
265
files/chat-box/etapes/final/js/palette-color-picker.js
Executable file
@ -0,0 +1,265 @@
|
||||
/*!
|
||||
* JQuery Palette Color Picker v1.13 by Carlos Cabo ( @putuko )
|
||||
* https://github.com/carloscabo/jquery-palette-color-picker
|
||||
*/
|
||||
(function($) {
|
||||
// La magia aquí
|
||||
'use strict';
|
||||
|
||||
// Public core
|
||||
$.paletteColorPicker = function( el, options ) {
|
||||
var
|
||||
ns = 'palette-color-picker', // Base attr / class
|
||||
$el = $(el),
|
||||
plugin = this,
|
||||
timer = null,
|
||||
current_value = $el.val(),
|
||||
target = $el.attr('name'),
|
||||
$button = $('<div>')
|
||||
.addClass(ns+'-button')
|
||||
.attr('data-target', target),
|
||||
$bubble = $('<div>')
|
||||
.addClass(ns+'-bubble'),
|
||||
|
||||
// Final settings will be stored here
|
||||
settings = {},
|
||||
|
||||
// Default settings
|
||||
defaults = {
|
||||
custom_class: null,
|
||||
colors: null,
|
||||
position: 'upside', // upside | downside
|
||||
insert: 'before', // default
|
||||
clear_btn: 'first', // default
|
||||
timeout: 2000, // default
|
||||
set_background: false, // default
|
||||
close_all_but_this: false // default
|
||||
},
|
||||
|
||||
click_handler = ('ontouchstart' in document.documentElement ? 'touchstart click' : 'click');
|
||||
|
||||
// Init
|
||||
plugin.init = function() {
|
||||
// Extand settings with user options
|
||||
plugin.settings = $.extend({}, defaults, options);
|
||||
|
||||
// If input has not value add it
|
||||
var
|
||||
val = $el.attr('value');
|
||||
if (typeof val === typeof undefined || val === false) {
|
||||
val = '';
|
||||
$el.attr('value', val);
|
||||
}
|
||||
|
||||
// Backup initial value
|
||||
$el.attr('data-initialvalue', $el.attr('value') );
|
||||
|
||||
// If color were not passed as options get them from data-palette attribute
|
||||
if (plugin.settings.colors === null) {
|
||||
plugin.settings.colors = $el.data('palette');
|
||||
}
|
||||
|
||||
// If color is array of string, convert to obj
|
||||
if (typeof plugin.settings.colors[0] === 'string') {
|
||||
plugin.settings.colors = $.map(plugin.settings.colors, function(el, idx) {
|
||||
var b = {}; b[el] = el; return b;
|
||||
});
|
||||
}
|
||||
|
||||
// Capitalize position
|
||||
plugin.settings.insert = plugin.settings.insert.charAt(0).toUpperCase() + plugin.settings.insert.slice(1);
|
||||
|
||||
// Add custom_class
|
||||
if (plugin.settings.custom_class) {
|
||||
$bubble.addClass(plugin.settings.custom_class);
|
||||
}
|
||||
|
||||
// Create color swatches
|
||||
$.each( plugin.settings.colors, function( idx, obj ) {
|
||||
var
|
||||
key = Object.keys( obj )[0],
|
||||
col = obj[key],
|
||||
$sw = $('<span>').addClass('swatch')
|
||||
.attr({
|
||||
'title': key,
|
||||
'data-color': col,
|
||||
'data-name': key
|
||||
}).css('background-color', col);
|
||||
|
||||
if ( key === current_value ) {
|
||||
$sw.addClass('active');
|
||||
$button.css('background', col);
|
||||
}
|
||||
|
||||
$sw.appendTo( $bubble );
|
||||
});
|
||||
|
||||
// Create clear button if not null
|
||||
if (plugin.settings.clear_btn !== null) {
|
||||
var
|
||||
$clear_btn = $('<span>').addClass('swatch clear').attr('title', 'Clear selection');
|
||||
if (plugin.settings.clear_btn === 'last') {
|
||||
$clear_btn.addClass('last').appendTo( $bubble );
|
||||
} else {
|
||||
$clear_btn.prependTo( $bubble );
|
||||
}
|
||||
}
|
||||
|
||||
// Public
|
||||
plugin.destroy = function() {
|
||||
$button.remove();
|
||||
$.removeData( $el[0] );
|
||||
};
|
||||
|
||||
// Clears all
|
||||
plugin.clear = function() {
|
||||
$bubble.find('.active').removeClass('active');
|
||||
$button.removeAttr('style');
|
||||
$el.val('');
|
||||
};
|
||||
|
||||
// Reset to initial value
|
||||
plugin.reset = function() {
|
||||
// Dont had initial value
|
||||
if ( $el.attr('data-initialvalue') === '' ) {
|
||||
plugin.clear();
|
||||
} else {
|
||||
// Had initial value
|
||||
var iv = $el.attr('data-initialvalue');
|
||||
$bubble.find('[data-name="'+iv+'"]').trigger('click');
|
||||
}
|
||||
};
|
||||
|
||||
// reload value after it has been changed programatically
|
||||
plugin.reload = function() {
|
||||
|
||||
var newVal = $el.val();
|
||||
if ( newVal === '' || typeof newVal === typeof undefined || newVal === false ) {
|
||||
// Doesn't have the value to load so loading initial value
|
||||
plugin.reset();
|
||||
} else {
|
||||
// setting the value to new value
|
||||
if($bubble.find('[data-name="'+newVal+'"]').length) {
|
||||
// value will only be set if the color exists in options
|
||||
$bubble.find('[data-name="'+newVal+'"]').trigger('click');
|
||||
} else {
|
||||
// setting to the initial value if color does not exists
|
||||
plugin.reset();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Events
|
||||
// Simple click
|
||||
$button.append( $bubble ).on( click_handler, function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var $b = $( this );
|
||||
|
||||
// don't close on clicking the bubble
|
||||
if (!$(e.target).hasClass(ns+'-bubble')) {
|
||||
|
||||
// Call the callback, if set
|
||||
if (typeof plugin.settings.onbeforeshow_callback === 'function') {
|
||||
plugin.settings.onbeforeshow_callback(this);
|
||||
}
|
||||
|
||||
$b.toggleClass('active');
|
||||
var $current_bubble = $b.find('.'+ns+'-bubble');
|
||||
// Forces hiding other bubbles
|
||||
if (plugin.settings.close_all_but_this) {
|
||||
$('.'+ns+'-bubble').not($current_bubble).fadeOut();
|
||||
}
|
||||
$current_bubble.fadeToggle();
|
||||
|
||||
if ($b.hasClass('active')) {
|
||||
clearTimeout(plugin.timer);
|
||||
plugin.timer = setTimeout(function(){
|
||||
$b.trigger('pcp.fadeout');
|
||||
}, plugin.settings.timeout);
|
||||
}
|
||||
}
|
||||
})
|
||||
// Fade timer
|
||||
.on('pcp.fadeout', function() {
|
||||
$( this ).removeClass('active').find('.'+ns+'-bubble').fadeOut();
|
||||
})
|
||||
// Enter bubble
|
||||
.on('mouseenter', '.'+ns+'-bubble', function() {
|
||||
clearTimeout(plugin.timer);
|
||||
})
|
||||
// Leave bubble
|
||||
.on('mouseleave', '.'+ns+'-bubble', function() {
|
||||
plugin.timer = setTimeout(function(){
|
||||
$button.trigger('pcp.fadeout');
|
||||
}, plugin.settings.timeout);
|
||||
})
|
||||
// Click on swatches
|
||||
.on(click_handler, '.'+ns+'-bubble span.swatch', function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var
|
||||
col = $( this ).attr('data-color'),
|
||||
name = $( this ).attr('data-name'),
|
||||
// Select all button in document with same data target to keep them synconized
|
||||
$button = $('.'+ns+'-button[data-target="' + $( this ).closest( '.'+ns+'-button' ).attr('data-target') + '"]'),
|
||||
$bubble = $( this ).closest( '.'+ns+'-bubble' );
|
||||
|
||||
// console.log('.'+ns+'-button [data-target="' + $( this ).closest( '.'+ns+'-button' ).attr('data-target') + '"]');
|
||||
$bubble.find('.active').removeClass('active');
|
||||
|
||||
// Set background on color
|
||||
// User clicked in the clear swatch
|
||||
if ( $(e.target).is('.clear') ) {
|
||||
$button.removeAttr('style');
|
||||
col = '';
|
||||
} else {
|
||||
$(this).addClass('active');
|
||||
$button.css('background', col);
|
||||
}
|
||||
|
||||
// Call the callback, if set
|
||||
if (typeof plugin.settings.onchange_callback === "function") {
|
||||
plugin.settings.onchange_callback(col);
|
||||
}
|
||||
|
||||
if( plugin.settings.set_background === false ) {
|
||||
$('[name="' + $button.attr('data-target') + '"]').val(name);
|
||||
} else {
|
||||
$('[name="' + $button.attr('data-target') + '"]').css({'background-color' : col});
|
||||
}
|
||||
})['insert'+plugin.settings.insert]( $el );
|
||||
|
||||
// Upside / downside, default is upside
|
||||
if ( plugin.settings.position === 'downside' || ($el.offset().top) + 20 < $bubble.outerHeight() ) {
|
||||
$bubble.addClass('downside');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Close on clicking outside the palette
|
||||
$('body').on(click_handler,function(event) {
|
||||
if (!$(event.target).hasClass(ns+'-button')) {
|
||||
$( $button ).removeClass('active').find('.'+ns+'-bubble').fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
// Start
|
||||
plugin.init();
|
||||
};
|
||||
|
||||
// add the plugin to the jQuery.fn object
|
||||
$.fn.paletteColorPicker = function(options) {
|
||||
return this.each(function() {
|
||||
if (typeof $(this).data('paletteColorPickerPlugin') === 'undefined') {
|
||||
$(this).data('paletteColorPickerPlugin', new $.paletteColorPicker(this, options));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
// Sample usage
|
||||
// $(function() {
|
||||
// $('[data-palette-color-picker]').paletteColorPicker();
|
||||
// });
|
||||
24
files/chat-box/etapes/final/js/ready.js
Executable file
24
files/chat-box/etapes/final/js/ready.js
Executable file
@ -0,0 +1,24 @@
|
||||
$(document).ready(function(){
|
||||
//La magia aquí
|
||||
|
||||
// Sample 1
|
||||
$('[name="unique-name-1"]').paletteColorPicker({
|
||||
onbeforeshow_callback: function ( color_picker_button ) {
|
||||
console.log( 'onbeforeshow_callback!!!' );
|
||||
console.log( $(color_picker_button) );
|
||||
console.log( color_picker_button );
|
||||
},
|
||||
onchange_callback: function ( clicked_color ) {
|
||||
console.log( 'onchange_callback!!!' );
|
||||
console.log( $(clicked_color) );
|
||||
console.log( clicked_color );
|
||||
}
|
||||
});
|
||||
|
||||
$('[name="color-option"]').paletteColorPicker({
|
||||
clear_btn: 'last',
|
||||
close_all_but_this: true, // Default is false
|
||||
insert: 'before'
|
||||
});
|
||||
|
||||
});
|
||||
4
files/chat-box/js/jquery-1.11.2.min.js
vendored
Executable file
4
files/chat-box/js/jquery-1.11.2.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
637
files/chat-box/js/jquery.emojipicker.js
Executable file
637
files/chat-box/js/jquery.emojipicker.js
Executable file
@ -0,0 +1,637 @@
|
||||
;(function($) {
|
||||
|
||||
var pluginName = "emojiPicker",
|
||||
defaults = {
|
||||
width: '200',
|
||||
height: '350',
|
||||
position: 'right',
|
||||
fadeTime: 100,
|
||||
iconColor: 'black',
|
||||
iconBackgroundColor: '#eee',
|
||||
recentCount: 36,
|
||||
emojiSet: 'apple',
|
||||
container: 'body',
|
||||
button: true
|
||||
};
|
||||
|
||||
var MIN_WIDTH = 280,
|
||||
MAX_WIDTH = 600,
|
||||
MIN_HEIGHT = 100,
|
||||
MAX_HEIGHT = 350,
|
||||
MAX_ICON_HEIGHT = 50;
|
||||
|
||||
var categories = [
|
||||
{ name: 'people', label: 'People' },
|
||||
{ name: 'nature', label: 'Nature' },
|
||||
{ name: 'food', label: 'Food' },
|
||||
{ name: 'activity', label: 'Activities' },
|
||||
{ name: 'travel', label: 'Travel & Places' },
|
||||
{ name: 'object', label: 'Objects' },
|
||||
{ name: 'symbol', label: 'Symbols' },
|
||||
{ name: 'flag', label: 'Flags' }
|
||||
];
|
||||
|
||||
function EmojiPicker( element, options ) {
|
||||
|
||||
this.element = element;
|
||||
this.$el = $(element);
|
||||
|
||||
this.settings = $.extend( {}, defaults, options );
|
||||
|
||||
this.$container = $(this.settings.container);
|
||||
|
||||
// (type) Safety first
|
||||
this.settings.width = parseInt(this.settings.width);
|
||||
this.settings.height = parseInt(this.settings.height);
|
||||
|
||||
// Check for valid width/height
|
||||
if(this.settings.width >= MAX_WIDTH) {
|
||||
this.settings.width = MAX_WIDTH;
|
||||
} else if (this.settings.width < MIN_WIDTH) {
|
||||
this.settings.width = MIN_WIDTH;
|
||||
}
|
||||
if (this.settings.height >= MAX_HEIGHT) {
|
||||
this.settings.height = MAX_HEIGHT;
|
||||
} else if (this.settings.height < MIN_HEIGHT) {
|
||||
this.settings.height = MIN_HEIGHT;
|
||||
}
|
||||
|
||||
var possiblePositions = [ 'left',
|
||||
'right'
|
||||
/*,'top',
|
||||
'bottom'*/];
|
||||
if($.inArray(this.settings.position,possiblePositions) == -1) {
|
||||
this.settings.position = defaults.position; //current default
|
||||
}
|
||||
|
||||
// Do not enable if on mobile device (emojis already present)
|
||||
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
||||
this.init();
|
||||
} else {
|
||||
this.isMobile = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$.extend(EmojiPicker.prototype, {
|
||||
|
||||
init: function() {
|
||||
this.active = false;
|
||||
this.addPickerIcon();
|
||||
this.createPicker();
|
||||
this.listen();
|
||||
},
|
||||
|
||||
addPickerIcon: function() {
|
||||
// The wrapper is not needed if they have chosen to not use a button
|
||||
if (this.settings.button) {
|
||||
var elementHeight = this.$el.outerHeight();
|
||||
var iconHeight = elementHeight > MAX_ICON_HEIGHT ?
|
||||
MAX_ICON_HEIGHT :
|
||||
elementHeight;
|
||||
|
||||
// This can cause issues if the element is not visible when it is initiated
|
||||
var objectWidth = this.$el.width();
|
||||
|
||||
this.$el.width(objectWidth);
|
||||
|
||||
this.$wrapper = this.$el
|
||||
.wrap("<div class='emojiPickerIconWrap'></div>")
|
||||
.parent();
|
||||
|
||||
this.$icon = $('<div class="emojiPickerIcon"></div>')
|
||||
.height(iconHeight)
|
||||
.width(iconHeight)
|
||||
.addClass(this.settings.iconColor)
|
||||
.css('backgroundColor', this.settings.iconBackgroundColor);
|
||||
this.$wrapper.append( this.$icon );
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
createPicker: function() {
|
||||
|
||||
// Show template
|
||||
this.$picker = $( getPickerHTML() )
|
||||
.appendTo( this.$container )
|
||||
.width(this.settings.width)
|
||||
.height(this.settings.height)
|
||||
.css('z-index',10000);
|
||||
|
||||
// Picker height
|
||||
this.$picker.find('.sections')
|
||||
.height(parseInt(this.settings.height) - 40); // 40 is height of the tabs
|
||||
|
||||
// Tab size based on width
|
||||
if (this.settings.width < 240) {
|
||||
this.$picker.find('.emoji').css({'width':'1em', 'height':'1em'});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
destroyPicker: function() {
|
||||
if (this.isMobile) return this;
|
||||
|
||||
this.$picker.unbind('mouseover');
|
||||
this.$picker.unbind('mouseout');
|
||||
this.$picker.unbind('click');
|
||||
this.$picker.remove();
|
||||
|
||||
$.removeData(this.$el.get(0), 'emojiPicker');
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
// If the button is being used, wrapper has not been set,
|
||||
// and will not need a listener
|
||||
if (this.settings.button){
|
||||
// Clicking on the picker icon
|
||||
this.$wrapper.find('.emojiPickerIcon')
|
||||
.click( $.proxy(this.iconClicked, this) );
|
||||
}
|
||||
|
||||
// Click event for emoji
|
||||
this.$picker.on('click', 'em', $.proxy(this.emojiClicked, this));
|
||||
|
||||
// Hover event for emoji
|
||||
this.$picker.on('mouseover', 'em', $.proxy(this.emojiMouseover, this) );
|
||||
this.$picker.on('mouseout', 'em', $.proxy(this.emojiMouseout, this) );
|
||||
|
||||
// Click event for active tab
|
||||
this.$picker.find('nav .tab')
|
||||
.click( $.proxy(this.emojiCategoryClicked, this) )
|
||||
.mouseover( $.proxy(this.emojiTabMouseover, this) )
|
||||
.mouseout( $.proxy(this.emojiMouseout, this) );
|
||||
|
||||
// Scroll event for active tab
|
||||
this.$picker.find('.sections')
|
||||
.scroll( $.proxy(this.emojiScroll, this) );
|
||||
|
||||
this.$picker.click( $.proxy(this.pickerClicked, this) );
|
||||
|
||||
// Key events for search
|
||||
this.$picker.find('section.search input')
|
||||
.on('keyup search', $.proxy(this.searchCharEntered, this) );
|
||||
|
||||
// Shortcode hover
|
||||
this.$picker.find('.shortcode').mouseover(function(e) { e.stopPropagation(); });
|
||||
|
||||
$(document.body).click( $.proxy(this.clickOutside, this) );
|
||||
|
||||
// Resize events forces a reposition, which may or may not actually be required
|
||||
$(window).resize( $.proxy(this.updatePosition, this) );
|
||||
},
|
||||
|
||||
updatePosition: function() {
|
||||
|
||||
/* Process:
|
||||
1. Find the nearest positioned element by crawling up the ancestors, record it's offset
|
||||
2. Find the bottom left or right of the input element, record this (Account for position setting of left or right)
|
||||
3. Find the difference between the two, as this will become our new position
|
||||
4. Magic.
|
||||
|
||||
N.B. The removed code had a reference to top/bottom positioning, but I don't see the use case for this..
|
||||
*/
|
||||
|
||||
// Step 1
|
||||
// Luckily jquery already does this...
|
||||
var positionedParent = this.$picker.offsetParent();
|
||||
var parentOffset = positionedParent.offset(); // now have a top/left object
|
||||
|
||||
// Step 2
|
||||
var elOffset = this.$el.offset();
|
||||
if(this.settings.position == 'right'){
|
||||
elOffset.left += this.$el.outerWidth() - this.settings.width;
|
||||
}
|
||||
elOffset.top += this.$el.outerHeight();
|
||||
|
||||
// Step 3
|
||||
var diffOffset = {
|
||||
top: (elOffset.top - parentOffset.top),
|
||||
left: (elOffset.left - parentOffset.top)
|
||||
};
|
||||
|
||||
this.$picker.css({
|
||||
top: diffOffset.top,
|
||||
left: diffOffset.left
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$picker.hide(this.settings.fadeTime, 'linear', function() {
|
||||
this.active = false;
|
||||
if (this.settings.onHide) {
|
||||
this.settings.onHide( this.$picker, this.settings, this.active );
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.$el.focus();
|
||||
this.updatePosition();
|
||||
this.$picker.show(this.settings.fadeTime, 'linear', function() {
|
||||
this.active = true;
|
||||
if (this.settings.onShow) {
|
||||
this.settings.onShow( this.$picker, this.settings, this.active );
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/************
|
||||
* EVENTS *
|
||||
************/
|
||||
|
||||
iconClicked : function() {
|
||||
if ( this.$picker.is(':hidden') ) {
|
||||
this.show();
|
||||
if( this.$picker.find('.search input').length > 0 ) {
|
||||
this.$picker.find('.search input').focus();
|
||||
}
|
||||
} else {
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
emojiClicked: function(e) { var clickTarget = $(e.target);
|
||||
var emojiSpan;
|
||||
if (clickTarget.is('em')) {
|
||||
emojiSpan = clickTarget.find('span');
|
||||
} else {
|
||||
emojiSpan = clickTarget.parent().find('.emoji');
|
||||
}
|
||||
|
||||
var emojiShortcode = emojiSpan.attr('class').split('emoji-')[1];
|
||||
var emojiUnicode = toUnicode(findEmoji(emojiShortcode).unicode[defaults.emojiSet]);
|
||||
|
||||
insertAtCaret(this.element, emojiUnicode);
|
||||
addToLocalStorage(emojiShortcode);
|
||||
updateRecentlyUsed(emojiShortcode);
|
||||
|
||||
// For anyone who is relying on the keyup event
|
||||
$(this.element).trigger("keyup");
|
||||
|
||||
// trigger change event on input
|
||||
var event = document.createEvent("HTMLEvents");
|
||||
event.initEvent("input", true, true);
|
||||
this.element.dispatchEvent(event);
|
||||
},
|
||||
|
||||
emojiMouseover: function(e) {
|
||||
var emojiShortcode = $(e.target).parent().find('.emoji').attr('class').split('emoji-')[1];
|
||||
var $shortcode = $(e.target).parents('.emojiPicker').find('.shortcode');
|
||||
$shortcode.find('.random').hide();
|
||||
$shortcode.find('.info').show().html('<div class="emoji emoji-' + emojiShortcode + '"></div><em>' + emojiShortcode + '</em>');
|
||||
},
|
||||
|
||||
emojiMouseout: function(e) {
|
||||
$(e.target).parents('.emojiPicker').find('.shortcode .info').empty().hide();
|
||||
$(e.target).parents('.emojiPicker').find('.shortcode .random').show();
|
||||
},
|
||||
|
||||
emojiCategoryClicked: function(e) {
|
||||
var section = '';
|
||||
|
||||
// Update tab
|
||||
this.$picker.find('nav .tab').removeClass('active');
|
||||
if ($(e.target).parent().hasClass('tab')) {
|
||||
section = $(e.target).parent().attr('data-tab');
|
||||
$(e.target).parent('.tab').addClass('active');
|
||||
}
|
||||
else {
|
||||
section = $(e.target).attr('data-tab');
|
||||
$(e.target).addClass('active');
|
||||
}
|
||||
|
||||
var $section = this.$picker.find('section.' + section);
|
||||
|
||||
var heightOfSectionsHidden = $section.parent().scrollTop();
|
||||
var heightOfSectionToPageTop = $section.offset().top;
|
||||
var heightOfSectionsToPageTop = $section.parent().offset().top;
|
||||
|
||||
var scrollDistance = heightOfSectionsHidden
|
||||
+ heightOfSectionToPageTop
|
||||
- heightOfSectionsToPageTop;
|
||||
|
||||
$('.sections').off('scroll'); // Disable scroll event until animation finishes
|
||||
|
||||
var that = this;
|
||||
$('.sections').animate({
|
||||
scrollTop: scrollDistance
|
||||
}, 250, function() {
|
||||
that.$picker.find('.sections').on('scroll', $.proxy(that.emojiScroll, that) ); // Enable scroll event
|
||||
});
|
||||
},
|
||||
|
||||
emojiTabMouseover: function(e) {
|
||||
var section = '';
|
||||
if ($(e.target).parent().hasClass('tab')) {
|
||||
section = $(e.target).parent().attr('data-tab');
|
||||
}
|
||||
else {
|
||||
section = $(e.target).attr('data-tab');
|
||||
}
|
||||
|
||||
var categoryTitle = '';
|
||||
for (var i = 0; i < categories.length; i++) {
|
||||
if (categories[i].name == section) { categoryTitle = categories[i].label; }
|
||||
}
|
||||
if (categoryTitle == '') { categoryTitle = 'Recently Used'; }
|
||||
|
||||
var categoryCount = $('section.' + section).attr('data-count');
|
||||
var categoryHtml = '<em class="tabTitle">' + categoryTitle + ' <span class="count">(' + categoryCount + ' emojis)</span></em>';
|
||||
|
||||
var $shortcode = $(e.target).parents('.emojiPicker').find('.shortcode');
|
||||
$shortcode.find('.random').hide();
|
||||
$shortcode.find('.info').show().html(categoryHtml);
|
||||
},
|
||||
|
||||
emojiScroll: function(e) {
|
||||
var sections = $('section');
|
||||
$.each(sections, function(key, value) {
|
||||
var section = sections[key];
|
||||
var offsetFromTop = $(section).position().top;
|
||||
|
||||
if (section.className == 'search' || (section.className == 'people' && offsetFromTop > 0)) {
|
||||
$(section).parents('.emojiPicker').find('nav tab.recent').addClass('active');
|
||||
return;
|
||||
}
|
||||
|
||||
if (offsetFromTop <= 0) {
|
||||
$(section).parents('.emojiPicker').find('nav .tab').removeClass('active');
|
||||
$(section).parents('.emojiPicker').find('nav .tab[data-tab=' + section.className + ']').addClass('active');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
pickerClicked: function(e) {
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
clickOutside: function(e) {
|
||||
if ( this.active ) {
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
searchCharEntered: function(e) {
|
||||
var searchTerm = $(e.target).val();
|
||||
var searchEmojis = $(e.target).parents('.sections').find('section.search');
|
||||
var searchEmojiWrap = searchEmojis.find('.wrap');
|
||||
var sections = $(e.target).parents('.sections').find('section');
|
||||
|
||||
// Clear if X is clicked within input
|
||||
if (searchTerm == '') {
|
||||
sections.show();
|
||||
searchEmojiWrap.hide();
|
||||
}
|
||||
|
||||
if (searchTerm.length > 0) {
|
||||
sections.hide();
|
||||
searchEmojis.show();
|
||||
searchEmojiWrap.show();
|
||||
|
||||
var results = [];
|
||||
searchEmojiWrap.find('em').remove();
|
||||
|
||||
$.each($.fn.emojiPicker.emojis, function(i, emoji) {
|
||||
var shortcode = emoji.shortcode;
|
||||
if ( shortcode.indexOf(searchTerm) > -1 ) {
|
||||
results.push('<em><div class="emoji emoji-' + shortcode + '"></div></em>');
|
||||
}
|
||||
});
|
||||
searchEmojiWrap.append(results.join(''));
|
||||
} else {
|
||||
sections.show();
|
||||
searchEmojiWrap.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.fn[ pluginName ] = function ( options ) {
|
||||
|
||||
// Calling a function
|
||||
if (typeof options === 'string') {
|
||||
this.each(function() {
|
||||
var plugin = $.data( this, pluginName );
|
||||
switch(options) {
|
||||
case 'toggle':
|
||||
plugin.iconClicked();
|
||||
break;
|
||||
case 'destroy':
|
||||
plugin.destroyPicker();
|
||||
break;
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
// Don't attach to the same element twice
|
||||
if ( !$.data( this, pluginName ) ) {
|
||||
$.data( this, pluginName, new EmojiPicker( this, options ) );
|
||||
}
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
function getPickerHTML() {
|
||||
var nodes = [];
|
||||
var aliases = {
|
||||
'undefined': 'object'
|
||||
}
|
||||
var items = {};
|
||||
var localStorageSupport = (typeof(Storage) !== 'undefined') ? true : false;
|
||||
|
||||
// Re-Sort Emoji table
|
||||
$.each($.fn.emojiPicker.emojis, function(i, emoji) {
|
||||
var category = aliases[ emoji.category ] || emoji.category;
|
||||
items[ category ] = items[ category ] || [];
|
||||
items[ category ].push( emoji );
|
||||
});
|
||||
|
||||
nodes.push('<div class="emojiPicker">');
|
||||
nodes.push('<nav>');
|
||||
|
||||
// Recent Tab, if localstorage support
|
||||
if (localStorageSupport) {
|
||||
nodes.push('<div class="tab active" data-tab="recent"><div class="emoji emoji-tab-recent"></div></div>');
|
||||
}
|
||||
|
||||
// Emoji category tabs
|
||||
var categories_length = categories.length;
|
||||
for (var i = 0; i < categories_length; i++) {
|
||||
nodes.push('<div class="tab' +
|
||||
( !localStorageSupport && i == 0 ? ' active' : '' ) +
|
||||
'" data-tab="' +
|
||||
categories[i].name +
|
||||
'"><div class="emoji emoji-tab-' +
|
||||
categories[i].name +
|
||||
'"></div></div>');
|
||||
}
|
||||
nodes.push('</nav>');
|
||||
nodes.push('<div class="sections">');
|
||||
|
||||
// Search
|
||||
nodes.push('<section class="search">');
|
||||
nodes.push('<input type="search" placeholder="Search...">');
|
||||
nodes.push('<div class="wrap" style="display:none;"><h1>Search Results</h1></div>');
|
||||
nodes.push('</section>');
|
||||
|
||||
// Recent Section, if localstorage support
|
||||
if (localStorageSupport) {
|
||||
var recentlyUsedEmojis = [];
|
||||
var recentlyUsedCount = 0;
|
||||
var displayRecentlyUsed = ' style="display:none;"';
|
||||
|
||||
if (localStorage.emojis) {
|
||||
recentlyUsedEmojis = JSON.parse(localStorage.emojis);
|
||||
recentlyUsedCount = recentlyUsedEmojis.length;
|
||||
displayRecentlyUsed = ' style="display:block;"';
|
||||
}
|
||||
|
||||
nodes.push('<section class="recent" data-count="' + recentlyUsedEmojis.length + '"' + displayRecentlyUsed + '>');
|
||||
nodes.push('<h1>Recently Used</h1><div class="wrap">');
|
||||
|
||||
for (var i = recentlyUsedEmojis.length-1; i > -1 ; i--) {
|
||||
nodes.push('<em><span class="emoji emoji-' + recentlyUsedEmojis[i] + '"></span></em>');
|
||||
}
|
||||
nodes.push('</div></section>');
|
||||
}
|
||||
|
||||
// Emoji sections
|
||||
for (var i = 0; i < categories_length; i++) {
|
||||
var category_length = items[ categories[i].name ].length;
|
||||
nodes.push('<section class="' + categories[i].name + '" data-count="' + category_length + '">');
|
||||
nodes.push('<h1>' + categories[i].label + '</h1><div class="wrap">');
|
||||
for (var j = 0; j < category_length; j++) {
|
||||
var emoji = items[ categories[i].name ][ j ];
|
||||
nodes.push('<em><span class="emoji emoji-' + emoji.shortcode + '"></span></em>');
|
||||
}
|
||||
nodes.push('</div></section>');
|
||||
}
|
||||
nodes.push('</div>');
|
||||
|
||||
// Shortcode section
|
||||
nodes.push('<div class="shortcode"><span class="random">');
|
||||
nodes.push('<em class="tabTitle">' + generateEmojiOfDay() + '</em>');
|
||||
nodes.push('</span><span class="info"></span></div>');
|
||||
|
||||
nodes.push('</div>');
|
||||
return nodes.join("\n");
|
||||
}
|
||||
|
||||
function generateEmojiOfDay() {
|
||||
var emojis = $.fn.emojiPicker.emojis;
|
||||
var i = Math.floor(Math.random() * (364 - 0) + 0);
|
||||
var emoji = emojis[i];
|
||||
return 'Daily Emoji: <span class="eod"><span class="emoji emoji-' + emoji.name + '"></span> <span class="emojiName">' + emoji.name + '</span></span>';
|
||||
}
|
||||
|
||||
function findEmoji(emojiShortcode) {
|
||||
var emojis = $.fn.emojiPicker.emojis;
|
||||
for (var i = 0; i < emojis.length; i++) {
|
||||
if (emojis[i].shortcode == emojiShortcode) {
|
||||
return emojis[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function insertAtCaret(inputField, myValue) {
|
||||
if (document.selection) {
|
||||
//For browsers like Internet Explorer
|
||||
inputField.focus();
|
||||
var sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
inputField.focus();
|
||||
}
|
||||
else if (inputField.selectionStart || inputField.selectionStart == '0') {
|
||||
//For browsers like Firefox and Webkit based
|
||||
var startPos = inputField.selectionStart;
|
||||
var endPos = inputField.selectionEnd;
|
||||
var scrollTop = inputField.scrollTop;
|
||||
inputField.value = inputField.value.substring(0, startPos)+myValue+inputField.value.substring(endPos,inputField.value.length);
|
||||
inputField.focus();
|
||||
inputField.selectionStart = startPos + myValue.length;
|
||||
inputField.selectionEnd = startPos + myValue.length;
|
||||
inputField.scrollTop = scrollTop;
|
||||
} else {
|
||||
inputField.focus();
|
||||
inputField.value += myValue;
|
||||
}
|
||||
}
|
||||
|
||||
function toUnicode(code) {
|
||||
var codes = code.split('-').map(function(value, index) {
|
||||
return parseInt(value, 16);
|
||||
});
|
||||
return String.fromCodePoint.apply(null, codes);
|
||||
}
|
||||
|
||||
function addToLocalStorage(emoji) {
|
||||
var recentlyUsedEmojis = [];
|
||||
if (localStorage.emojis) {
|
||||
recentlyUsedEmojis = JSON.parse(localStorage.emojis);
|
||||
}
|
||||
|
||||
// If already in recently used, move to front
|
||||
var index = recentlyUsedEmojis.indexOf(emoji);
|
||||
if (index > -1) {
|
||||
recentlyUsedEmojis.splice(index, 1);
|
||||
}
|
||||
recentlyUsedEmojis.push(emoji);
|
||||
|
||||
if (recentlyUsedEmojis.length > defaults.recentCount) {
|
||||
recentlyUsedEmojis.shift();
|
||||
}
|
||||
|
||||
localStorage.emojis = JSON.stringify(recentlyUsedEmojis);
|
||||
}
|
||||
|
||||
function updateRecentlyUsed(emoji) {
|
||||
var recentlyUsedEmojis = JSON.parse(localStorage.emojis);
|
||||
var emojis = [];
|
||||
var recent = $('section.recent');
|
||||
|
||||
for (var i = recentlyUsedEmojis.length-1; i >= 0; i--) {
|
||||
emojis.push('<em><span class="emoji emoji-' + recentlyUsedEmojis[i] + '"></span></em>');
|
||||
}
|
||||
|
||||
// Fix height as emojis are added
|
||||
var prevHeight = recent.outerHeight();
|
||||
$('section.recent .wrap').html(emojis.join(''));
|
||||
var currentScrollTop = $('.sections').scrollTop();
|
||||
var newHeight = recent.outerHeight();
|
||||
var newScrollToHeight = 0;
|
||||
|
||||
if (!$('section.recent').is(':visible')) {
|
||||
recent.show();
|
||||
newScrollToHeight = newHeight;
|
||||
} else if (prevHeight != newHeight) {
|
||||
newScrollToHeight = newHeight - prevHeight;
|
||||
}
|
||||
|
||||
$('.sections').animate({
|
||||
scrollTop: currentScrollTop + newScrollToHeight
|
||||
}, 0);
|
||||
}
|
||||
|
||||
if (!String.fromCodePoint) {
|
||||
// ES6 Unicode Shims 0.1 , © 2012 Steven Levithan http://slevithan.com/ , MIT License
|
||||
String.fromCodePoint = function fromCodePoint () {
|
||||
var chars = [], point, offset, units, i;
|
||||
for (i = 0; i < arguments.length; ++i) {
|
||||
point = arguments[i];
|
||||
offset = point - 0x10000;
|
||||
units = point > 0xFFFF ? [0xD800 + (offset >> 10), 0xDC00 + (offset & 0x3FF)] : [point];
|
||||
chars.push(String.fromCharCode.apply(null, units));
|
||||
}
|
||||
return chars.join("");
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
9075
files/chat-box/js/jquery.emojis.js
Executable file
9075
files/chat-box/js/jquery.emojis.js
Executable file
File diff suppressed because it is too large
Load Diff
154
files/chat-box/js/main.js
Normal file
154
files/chat-box/js/main.js
Normal file
@ -0,0 +1,154 @@
|
||||
(function(){
|
||||
const colorPalette = ["#D50000","#304FFE","#00B8D4","#00C853","#FFD600","#FF6D00","#FF1744","#3D5AFE","#00E5FF","#00E676","#FFEA00","#FF9100","#FF5252","#536DFE","#18FFFF","#69F0AE","#FFFF00","#FFAB40"];
|
||||
const colorCount = colorPalette.length;
|
||||
const rand = Math.floor(Math.random() * colorCount) + 1;
|
||||
const userColor = colorPalette[rand];
|
||||
const colorOption = document.getElementById("color-option");
|
||||
colorOption.value = userColor;
|
||||
|
||||
function parseMessage(message) {
|
||||
var msg = {type: "", sender: "", text: "", color: ""};
|
||||
try {
|
||||
msg = JSON.parse(message);
|
||||
}
|
||||
catch(e) {
|
||||
return false;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
function appendMessage(message) {
|
||||
var msgContainer = document.querySelector(".messages");
|
||||
var parsedMessage;
|
||||
|
||||
if(parsedMessage = parseMessage(message)) {
|
||||
console.log("appending message...");
|
||||
|
||||
var msgElem, senderElem, textElem;
|
||||
var sender, text, color;
|
||||
|
||||
if (parsedMessage.color !== "") {
|
||||
color = parsedMessage.color;
|
||||
} else {
|
||||
color = userColor;
|
||||
}
|
||||
|
||||
msgElem = document.createElement("div");
|
||||
msgElem.classList.add("msg");
|
||||
msgElem.classList.add("msg-" + parsedMessage.type);
|
||||
|
||||
senderElem = document.createElement("div");
|
||||
senderElem.classList.add("msg-sender");
|
||||
|
||||
textElem = document.createElement("div");
|
||||
textElem.classList.add("msg-text");
|
||||
textElem.style.background = color;
|
||||
|
||||
sender = document.createTextNode(parsedMessage.sender + ": ");
|
||||
text = document.createTextNode(parsedMessage.text);
|
||||
|
||||
senderElem.appendChild(sender);
|
||||
textElem.appendChild(text);
|
||||
|
||||
msgElem.appendChild(senderElem);
|
||||
msgElem.appendChild(textElem);
|
||||
|
||||
msgContainer.appendChild(msgElem);
|
||||
}
|
||||
}
|
||||
|
||||
function setup() {
|
||||
var sender, color = "";
|
||||
var joinForm = document.querySelector("form.join-form");
|
||||
var msgForm = document.querySelector("form.msg-form");
|
||||
var closeForm = document.querySelector("form.close-form");
|
||||
|
||||
var joinFormSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
sender = document.getElementById("sender").value;
|
||||
if (sender) {
|
||||
color = colorOption.value;
|
||||
var joinMsg = {
|
||||
type: "join",
|
||||
sender: sender,
|
||||
text: sender + " joined the chat!",
|
||||
color: color
|
||||
};
|
||||
|
||||
socket.send(JSON.stringify(joinMsg));
|
||||
joinForm.classList.add("hidden");
|
||||
msgForm.classList.remove("hidden");
|
||||
closeForm.classList.remove("hidden");
|
||||
} else {
|
||||
alert("Veuillez saisir votre prénom.");
|
||||
}
|
||||
};
|
||||
|
||||
var msgFormSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
var msgField, msgText, msg, color;
|
||||
msgField = document.getElementById("msg");
|
||||
msgText = msgField.value;
|
||||
if (colorOption.value) {
|
||||
color = colorOption.value;
|
||||
} else {
|
||||
color = userColor;
|
||||
}
|
||||
|
||||
msg = {
|
||||
type: "normal",
|
||||
sender: sender,
|
||||
text: msgText,
|
||||
color: color
|
||||
};
|
||||
|
||||
socket.send(JSON.stringify(msg));
|
||||
msgField.value = "";
|
||||
};
|
||||
|
||||
var closeFormSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
socket.close();
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
joinForm.addEventListener("submit", joinFormSubmit);
|
||||
msgForm.addEventListener("submit", msgFormSubmit);
|
||||
closeForm.addEventListener("submit", closeFormSubmit);
|
||||
}
|
||||
|
||||
var socket = new WebSocket("ws:srv-stage.stage-ge.org:8090");
|
||||
|
||||
var socketOpen = (e) => {
|
||||
console.log("connected to the socket");
|
||||
var msg = {
|
||||
type: "join",
|
||||
sender: "Browser",
|
||||
text: "connected to the chat server",
|
||||
color: "white"
|
||||
};
|
||||
appendMessage(JSON.stringify(msg));
|
||||
setup();
|
||||
};
|
||||
|
||||
var socketMessage = (e) => {
|
||||
console.log("Message fom server: " + e.data);
|
||||
appendMessage(e.data);
|
||||
};
|
||||
|
||||
var socketClose = (e) => {
|
||||
|
||||
};
|
||||
|
||||
var socketError = (e) => {
|
||||
|
||||
};
|
||||
|
||||
socket.addEventListener("open", socketOpen);
|
||||
socket.addEventListener("message", socketMessage);
|
||||
socket.addEventListener("close", socketClose);
|
||||
socket.addEventListener("error", socketError);
|
||||
|
||||
})();
|
||||
265
files/chat-box/js/palette-color-picker.js
Executable file
265
files/chat-box/js/palette-color-picker.js
Executable file
@ -0,0 +1,265 @@
|
||||
/*!
|
||||
* JQuery Palette Color Picker v1.13 by Carlos Cabo ( @putuko )
|
||||
* https://github.com/carloscabo/jquery-palette-color-picker
|
||||
*/
|
||||
(function($) {
|
||||
// La magia aquí
|
||||
'use strict';
|
||||
|
||||
// Public core
|
||||
$.paletteColorPicker = function( el, options ) {
|
||||
var
|
||||
ns = 'palette-color-picker', // Base attr / class
|
||||
$el = $(el),
|
||||
plugin = this,
|
||||
timer = null,
|
||||
current_value = $el.val(),
|
||||
target = $el.attr('name'),
|
||||
$button = $('<div>')
|
||||
.addClass(ns+'-button')
|
||||
.attr('data-target', target),
|
||||
$bubble = $('<div>')
|
||||
.addClass(ns+'-bubble'),
|
||||
|
||||
// Final settings will be stored here
|
||||
settings = {},
|
||||
|
||||
// Default settings
|
||||
defaults = {
|
||||
custom_class: null,
|
||||
colors: null,
|
||||
position: 'upside', // upside | downside
|
||||
insert: 'before', // default
|
||||
clear_btn: 'first', // default
|
||||
timeout: 2000, // default
|
||||
set_background: false, // default
|
||||
close_all_but_this: false // default
|
||||
},
|
||||
|
||||
click_handler = ('ontouchstart' in document.documentElement ? 'touchstart click' : 'click');
|
||||
|
||||
// Init
|
||||
plugin.init = function() {
|
||||
// Extand settings with user options
|
||||
plugin.settings = $.extend({}, defaults, options);
|
||||
|
||||
// If input has not value add it
|
||||
var
|
||||
val = $el.attr('value');
|
||||
if (typeof val === typeof undefined || val === false) {
|
||||
val = '';
|
||||
$el.attr('value', val);
|
||||
}
|
||||
|
||||
// Backup initial value
|
||||
$el.attr('data-initialvalue', $el.attr('value') );
|
||||
|
||||
// If color were not passed as options get them from data-palette attribute
|
||||
if (plugin.settings.colors === null) {
|
||||
plugin.settings.colors = $el.data('palette');
|
||||
}
|
||||
|
||||
// If color is array of string, convert to obj
|
||||
if (typeof plugin.settings.colors[0] === 'string') {
|
||||
plugin.settings.colors = $.map(plugin.settings.colors, function(el, idx) {
|
||||
var b = {}; b[el] = el; return b;
|
||||
});
|
||||
}
|
||||
|
||||
// Capitalize position
|
||||
plugin.settings.insert = plugin.settings.insert.charAt(0).toUpperCase() + plugin.settings.insert.slice(1);
|
||||
|
||||
// Add custom_class
|
||||
if (plugin.settings.custom_class) {
|
||||
$bubble.addClass(plugin.settings.custom_class);
|
||||
}
|
||||
|
||||
// Create color swatches
|
||||
$.each( plugin.settings.colors, function( idx, obj ) {
|
||||
var
|
||||
key = Object.keys( obj )[0],
|
||||
col = obj[key],
|
||||
$sw = $('<span>').addClass('swatch')
|
||||
.attr({
|
||||
'title': key,
|
||||
'data-color': col,
|
||||
'data-name': key
|
||||
}).css('background-color', col);
|
||||
|
||||
if ( key === current_value ) {
|
||||
$sw.addClass('active');
|
||||
$button.css('background', col);
|
||||
}
|
||||
|
||||
$sw.appendTo( $bubble );
|
||||
});
|
||||
|
||||
// Create clear button if not null
|
||||
if (plugin.settings.clear_btn !== null) {
|
||||
var
|
||||
$clear_btn = $('<span>').addClass('swatch clear').attr('title', 'Clear selection');
|
||||
if (plugin.settings.clear_btn === 'last') {
|
||||
$clear_btn.addClass('last').appendTo( $bubble );
|
||||
} else {
|
||||
$clear_btn.prependTo( $bubble );
|
||||
}
|
||||
}
|
||||
|
||||
// Public
|
||||
plugin.destroy = function() {
|
||||
$button.remove();
|
||||
$.removeData( $el[0] );
|
||||
};
|
||||
|
||||
// Clears all
|
||||
plugin.clear = function() {
|
||||
$bubble.find('.active').removeClass('active');
|
||||
$button.removeAttr('style');
|
||||
$el.val('');
|
||||
};
|
||||
|
||||
// Reset to initial value
|
||||
plugin.reset = function() {
|
||||
// Dont had initial value
|
||||
if ( $el.attr('data-initialvalue') === '' ) {
|
||||
plugin.clear();
|
||||
} else {
|
||||
// Had initial value
|
||||
var iv = $el.attr('data-initialvalue');
|
||||
$bubble.find('[data-name="'+iv+'"]').trigger('click');
|
||||
}
|
||||
};
|
||||
|
||||
// reload value after it has been changed programatically
|
||||
plugin.reload = function() {
|
||||
|
||||
var newVal = $el.val();
|
||||
if ( newVal === '' || typeof newVal === typeof undefined || newVal === false ) {
|
||||
// Doesn't have the value to load so loading initial value
|
||||
plugin.reset();
|
||||
} else {
|
||||
// setting the value to new value
|
||||
if($bubble.find('[data-name="'+newVal+'"]').length) {
|
||||
// value will only be set if the color exists in options
|
||||
$bubble.find('[data-name="'+newVal+'"]').trigger('click');
|
||||
} else {
|
||||
// setting to the initial value if color does not exists
|
||||
plugin.reset();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Events
|
||||
// Simple click
|
||||
$button.append( $bubble ).on( click_handler, function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var $b = $( this );
|
||||
|
||||
// don't close on clicking the bubble
|
||||
if (!$(e.target).hasClass(ns+'-bubble')) {
|
||||
|
||||
// Call the callback, if set
|
||||
if (typeof plugin.settings.onbeforeshow_callback === 'function') {
|
||||
plugin.settings.onbeforeshow_callback(this);
|
||||
}
|
||||
|
||||
$b.toggleClass('active');
|
||||
var $current_bubble = $b.find('.'+ns+'-bubble');
|
||||
// Forces hiding other bubbles
|
||||
if (plugin.settings.close_all_but_this) {
|
||||
$('.'+ns+'-bubble').not($current_bubble).fadeOut();
|
||||
}
|
||||
$current_bubble.fadeToggle();
|
||||
|
||||
if ($b.hasClass('active')) {
|
||||
clearTimeout(plugin.timer);
|
||||
plugin.timer = setTimeout(function(){
|
||||
$b.trigger('pcp.fadeout');
|
||||
}, plugin.settings.timeout);
|
||||
}
|
||||
}
|
||||
})
|
||||
// Fade timer
|
||||
.on('pcp.fadeout', function() {
|
||||
$( this ).removeClass('active').find('.'+ns+'-bubble').fadeOut();
|
||||
})
|
||||
// Enter bubble
|
||||
.on('mouseenter', '.'+ns+'-bubble', function() {
|
||||
clearTimeout(plugin.timer);
|
||||
})
|
||||
// Leave bubble
|
||||
.on('mouseleave', '.'+ns+'-bubble', function() {
|
||||
plugin.timer = setTimeout(function(){
|
||||
$button.trigger('pcp.fadeout');
|
||||
}, plugin.settings.timeout);
|
||||
})
|
||||
// Click on swatches
|
||||
.on(click_handler, '.'+ns+'-bubble span.swatch', function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var
|
||||
col = $( this ).attr('data-color'),
|
||||
name = $( this ).attr('data-name'),
|
||||
// Select all button in document with same data target to keep them synconized
|
||||
$button = $('.'+ns+'-button[data-target="' + $( this ).closest( '.'+ns+'-button' ).attr('data-target') + '"]'),
|
||||
$bubble = $( this ).closest( '.'+ns+'-bubble' );
|
||||
|
||||
// console.log('.'+ns+'-button [data-target="' + $( this ).closest( '.'+ns+'-button' ).attr('data-target') + '"]');
|
||||
$bubble.find('.active').removeClass('active');
|
||||
|
||||
// Set background on color
|
||||
// User clicked in the clear swatch
|
||||
if ( $(e.target).is('.clear') ) {
|
||||
$button.removeAttr('style');
|
||||
col = '';
|
||||
} else {
|
||||
$(this).addClass('active');
|
||||
$button.css('background', col);
|
||||
}
|
||||
|
||||
// Call the callback, if set
|
||||
if (typeof plugin.settings.onchange_callback === "function") {
|
||||
plugin.settings.onchange_callback(col);
|
||||
}
|
||||
|
||||
if( plugin.settings.set_background === false ) {
|
||||
$('[name="' + $button.attr('data-target') + '"]').val(name);
|
||||
} else {
|
||||
$('[name="' + $button.attr('data-target') + '"]').css({'background-color' : col});
|
||||
}
|
||||
})['insert'+plugin.settings.insert]( $el );
|
||||
|
||||
// Upside / downside, default is upside
|
||||
if ( plugin.settings.position === 'downside' || ($el.offset().top) + 20 < $bubble.outerHeight() ) {
|
||||
$bubble.addClass('downside');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Close on clicking outside the palette
|
||||
$('body').on(click_handler,function(event) {
|
||||
if (!$(event.target).hasClass(ns+'-button')) {
|
||||
$( $button ).removeClass('active').find('.'+ns+'-bubble').fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
// Start
|
||||
plugin.init();
|
||||
};
|
||||
|
||||
// add the plugin to the jQuery.fn object
|
||||
$.fn.paletteColorPicker = function(options) {
|
||||
return this.each(function() {
|
||||
if (typeof $(this).data('paletteColorPickerPlugin') === 'undefined') {
|
||||
$(this).data('paletteColorPickerPlugin', new $.paletteColorPicker(this, options));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
// Sample usage
|
||||
// $(function() {
|
||||
// $('[data-palette-color-picker]').paletteColorPicker();
|
||||
// });
|
||||
24
files/chat-box/js/ready.js
Executable file
24
files/chat-box/js/ready.js
Executable file
@ -0,0 +1,24 @@
|
||||
$(document).ready(function(){
|
||||
//La magia aquí
|
||||
|
||||
// Sample 1
|
||||
$('[name="unique-name-1"]').paletteColorPicker({
|
||||
onbeforeshow_callback: function ( color_picker_button ) {
|
||||
console.log( 'onbeforeshow_callback!!!' );
|
||||
console.log( $(color_picker_button) );
|
||||
console.log( color_picker_button );
|
||||
},
|
||||
onchange_callback: function ( clicked_color ) {
|
||||
console.log( 'onchange_callback!!!' );
|
||||
console.log( $(clicked_color) );
|
||||
console.log( clicked_color );
|
||||
}
|
||||
});
|
||||
|
||||
$('[name="color-option"]').paletteColorPicker({
|
||||
clear_btn: 'last',
|
||||
close_all_but_this: true, // Default is false
|
||||
insert: 'before'
|
||||
});
|
||||
|
||||
});
|
||||
1280
files/chat-box/server/css/jquery.emojipicker.a.css
Executable file
1280
files/chat-box/server/css/jquery.emojipicker.a.css
Executable file
File diff suppressed because one or more lines are too long
53
files/chat-box/server/css/jquery.emojipicker.css
Executable file
53
files/chat-box/server/css/jquery.emojipicker.css
Executable file
File diff suppressed because one or more lines are too long
1247
files/chat-box/server/css/jquery.emojipicker.g.css
Executable file
1247
files/chat-box/server/css/jquery.emojipicker.g.css
Executable file
File diff suppressed because one or more lines are too long
1277
files/chat-box/server/css/jquery.emojipicker.tw.css
Executable file
1277
files/chat-box/server/css/jquery.emojipicker.tw.css
Executable file
File diff suppressed because one or more lines are too long
1
files/chat-box/server/css/palette-color-picker.css
Executable file
1
files/chat-box/server/css/palette-color-picker.css
Executable file
@ -0,0 +1 @@
|
||||
.palette-color-picker-button{position:relative;display:inline-block;width:28px;height:28px;margin-right:8px;background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path fill="#f5c86c" d="M2 2h8v8H2z"/><path fill="#f56c6c" d="M12 2h8v8h-8z"/><path fill="#f46ac6" d="M22 2h8v8h-8z"/><path fill="#c3f167" d="M2 12h8v8H2z"/><path fill="#f3f3f3" d="M12 12h8v8h-8z"/><path fill="#c76cf5" d="M22 12h8v8h-8z"/><path fill="#69e369" d="M2 22h8v8H2z"/><path fill="#6bc6f4" d="M12 22h8v8h-8z"/><path fill="#6b6bf5" d="M22 22h8v8h-8z"/><path d="M9 3v6H3V3h6m1-1H2v8h8V2zm9 1v6h-6V3h6m1-1h-8v8h8V2zm9 1v6h-6V3h6m1-1h-8v8h8V2zM9 13v6H3v-6h6m1-1H2v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8zM9 23v6H3v-6h6m1-1H2v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8zm9 1v6h-6v-6h6m1-1h-8v8h8v-8z" opacity=".25"/></svg>') center center no-repeat;background-size:cover;cursor:pointer;box-shadow:0 0 0 1px #bbb;border:2px solid #fff}.palette-color-picker-bubble{display:none;margin:12px 0;position:absolute;bottom:100%;width:220px;padding:10px 8px 8px 8px;border:1px solid #bbb;border-radius:3px;background-color:#fff}.palette-color-picker-bubble:after,.palette-color-picker-bubble:before{top:100%;left:14px;border:solid transparent;content:' ';height:0;width:0;position:absolute;pointer-events:none}.palette-color-picker-bubble:after{border-color:transparent;border-top-color:#fff;border-width:8px;margin-left:-8px}.palette-color-picker-bubble:before{border-color:transparent;border-top-color:#bbb;border-width:9px;margin-left:-9px}.palette-color-picker-bubble.downside{bottom:auto;top:100%}.palette-color-picker-bubble.downside:after,.palette-color-picker-bubble.downside:before{top:auto;bottom:100%}.palette-color-picker-bubble.downside:after{border-top-color:transparent;border-bottom-color:#fff}.palette-color-picker-bubble.downside:before{border-top-color:transparent;border-bottom-color:#bbb}.palette-color-picker-bubble .swatch{position:relative;display:inline-block;font:0/0 a;width:12.66%;padding-top:11.00%;margin:1% 2%;outline:1px solid #bbb;border:2px solid #fff;border-radius:3px;cursor:pointer;overflow:hidden}.palette-color-picker-bubble .swatch.active{outline-color:#000;-webkit-box-shadow:0px 0px 5px 0px rgba(0,0,0,0.75);-moz-box-shadow:0px 0px 5px 0px rgba(0,0,0,0.75);box-shadow:0px 0px 5px 0px rgba(0,0,0,0.75)}.palette-color-picker-bubble .swatch.clear{background-color:#fff}.palette-color-picker-bubble .swatch.clear:before{position:absolute;content:'';display:block;top:-1px;left:0;width:100px;height:2px;background-color:#e00;transform-origin:0 0;transform:rotate(45deg)}.palette-color-picker-bubble.double .swatch{width:29.30%;padding-top:11.00%;margin:1% 2%}.palette-color-picker-bubble.double .swatch.clear:before{transform:rotate(22.5deg)}.palette-color-picker-bubble.wide .swatch{width:96.2%;padding-top:11.00%;margin:1% 2%}.palette-color-picker-bubble.wide .swatch.clear{width:12.66%}.palette-color-picker-bubble.force-left{left:-178px}.palette-color-picker-bubble.force-left:after,.palette-color-picker-bubble.force-left:before{left:188px}
|
||||
125
files/chat-box/server/css/style_chat.css
Executable file
125
files/chat-box/server/css/style_chat.css
Executable file
@ -0,0 +1,125 @@
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.chat-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.chat-box {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#forms-wrapper {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.messages {
|
||||
height: 800px;
|
||||
width: 600px;
|
||||
border: 1px solid #666;
|
||||
border-radius: 3px;
|
||||
padding: 1em;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
input {
|
||||
display: block;
|
||||
width: 500px;
|
||||
padding: 5px;
|
||||
height: 44px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
button {
|
||||
display: block;
|
||||
background: rgb(39, 112, 215);
|
||||
padding: 5px;
|
||||
margin: 5px 0;
|
||||
width: 150px;
|
||||
height: 44px;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
form.msg-form {
|
||||
bottom: 1em;
|
||||
right: 1em;
|
||||
left: 1em;
|
||||
}
|
||||
form.close-form button {
|
||||
background: rgb(237, 102, 102);
|
||||
border: 1px solid rgb(237, 102, 102);
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.hidden {
|
||||
visibility: hidden;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.msg {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.msg-text {
|
||||
padding: 5px;
|
||||
display: inline-block;
|
||||
border-radius: 5px;
|
||||
font-family: "Verdana", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
.msg-normal .msg-text {
|
||||
background:#ccc;
|
||||
color: white;
|
||||
font-family: "Verdana", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
.msg-normal .msg-sender {
|
||||
font-family: "Verdana", sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.msg-notification .msg-text,
|
||||
.msg-join .msg-text,
|
||||
.msg-left .msg-text {
|
||||
background: #eee;
|
||||
border: 1px solid #ccc;
|
||||
font-family: "Verdana", sans-serif;
|
||||
}
|
||||
|
||||
.msg-join .msg-text,
|
||||
.msg-left .msg-text {
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.msg-notification .msg-sender,
|
||||
.msg-join .msg-sender,
|
||||
.msg-left .msg-sender {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#color-option-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
#color-option-wrapper .palette-color-picker-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
cursor: pointer;
|
||||
width: 44px;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
13
files/chat-box/server/docker-compose.yml
Executable file
13
files/chat-box/server/docker-compose.yml
Executable file
@ -0,0 +1,13 @@
|
||||
version: '3.6'
|
||||
services:
|
||||
apache:
|
||||
#image: francarmona/docker-ubuntu16-apache2-php7-mssql_client
|
||||
#image: francarmona/docker-ubuntu16-apache2-php7
|
||||
image: dsic-chat-box
|
||||
restart: always
|
||||
container_name: apache_stage
|
||||
ports:
|
||||
- 8001:80
|
||||
- 8090:8090
|
||||
volumes:
|
||||
- /home/chat-box/:/var/www
|
||||
60
files/chat-box/server/functions.php
Executable file
60
files/chat-box/server/functions.php
Executable file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
function unmask($text) {
|
||||
$length = @ord($text[1]) & 127;
|
||||
if($length == 126) {
|
||||
$masks = substr($text, 4, 4);
|
||||
$data = substr($text, 8);
|
||||
}
|
||||
elseif($length == 127) {
|
||||
$masks = substr($text, 10, 4);
|
||||
$data = substr($text, 14);
|
||||
}
|
||||
else {
|
||||
$masks = substr($text, 2, 4);
|
||||
$data = substr($text, 6);
|
||||
}
|
||||
$text = "";
|
||||
for ($i = 0; $i < strlen($data); ++$i) {
|
||||
$text .= $data[$i] ^ $masks[$i % 4];
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
function pack_data($text) {
|
||||
$bl = 0x80 | (0x1 & 0x0f);
|
||||
$length = strlen($text);
|
||||
|
||||
if($length <= 125) {
|
||||
$header = pack('CC', $bl, $length);
|
||||
}
|
||||
elseif($length > 125 && $length < 65536) {
|
||||
$header = pack('CCn', $bl, 126, $length);
|
||||
}
|
||||
elseif($length >= 65536) {
|
||||
$header = pack('CCNN', $bl, 127, $length);
|
||||
}
|
||||
return $header.$text;
|
||||
}
|
||||
|
||||
function handshake($request_header, $sock, $address, $port) {
|
||||
$headers = [];
|
||||
$lines = preg_split("/\r\n/", $request_header);
|
||||
|
||||
foreach($lines as $line) {
|
||||
$line = chop($line);
|
||||
if(preg_match('/\A(\S+): (.*)\z/', $line, $matches)){
|
||||
$headers[$matches[1]] = $matches[2];
|
||||
}
|
||||
}
|
||||
|
||||
$sec_key = $headers['Sec-WebSocket-Key'];
|
||||
$sec_accept = base64_encode(pack('H*', sha1($sec_key .
|
||||
'258EAFA5-E914-47DA-95CA-C5AB0DC85B11')));
|
||||
$response_header = "HTTP/1.1 101 Switching Protocols\r\n" .
|
||||
"Upgrade: websocket\r\n" .
|
||||
"Connection: Upgrade\r\n" .
|
||||
"Sec-WebSocket-Accept:$sec_accept\r\n\r\n";
|
||||
|
||||
socket_write($sock, $response_header, strlen($response_header));
|
||||
}
|
||||
55
files/chat-box/server/index.html
Executable file
55
files/chat-box/server/index.html
Executable file
@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Stage informatique - Chat</title>
|
||||
<meta name="description" content="Un exemple de chat pour le stage informatique de la DSIC">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="css/style_chat.css">
|
||||
<!-- Emoji -->
|
||||
<link rel="stylesheet" type="text/css" href="css/jquery.emojipicker.css">
|
||||
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery.emojipicker.js"></script>
|
||||
<!-- Emoji Data -->
|
||||
<link rel="stylesheet" type="text/css" href="css/jquery.emojipicker.tw.css">
|
||||
<script type="text/javascript" src="js/jquery.emojis.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(e) {
|
||||
$('#sender').emojiPicker();
|
||||
$('#msg').emojiPicker();
|
||||
});
|
||||
</script>
|
||||
<!-- Color picker -->
|
||||
<link rel="stylesheet" href="css/palette-color-picker.css">
|
||||
<script src="js/palette-color-picker.js"></script>
|
||||
<script src="js/ready.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="chat-box">
|
||||
<div id="messages-wrapper">
|
||||
<div class="messages"></div>
|
||||
</div>
|
||||
<div id="forms-wrapper">
|
||||
<form action="" class="join-form">
|
||||
<input type="text" name="sender" id="sender" class="emojiable-option" placeholder="Saisi ton prénom">
|
||||
<div id="color-option-wrapper">
|
||||
<input type="text" name="color-option" id="color-option" data-palette='["#D50000","#304FFE","#00B8D4","#00C853","#FFD600","#FF6D00","#FF1744","#3D5AFE","#00E5FF","#00E676","#FFEA00","#FF9100","#FF5252","#536DFE","#18FFFF","#69F0AE","#FFFF00","#FFAB40"]' value="" placeholder="Choisi une couleur">
|
||||
</div>
|
||||
<button type="submit">Rejoindre le Chat</button>
|
||||
</form>
|
||||
<form action="" class="msg-form hidden">
|
||||
<input type="text" name="msg" id="msg" class="emojiable-option" placeholder="Ecrit un message">
|
||||
<button type="submit">Envoyer</button>
|
||||
</form>
|
||||
<form action="" class="close-form hidden">
|
||||
<button type="submit">Quitter le Chat</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
4
files/chat-box/server/js/jquery-1.11.2.min.js
vendored
Executable file
4
files/chat-box/server/js/jquery-1.11.2.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
637
files/chat-box/server/js/jquery.emojipicker.js
Executable file
637
files/chat-box/server/js/jquery.emojipicker.js
Executable file
@ -0,0 +1,637 @@
|
||||
;(function($) {
|
||||
|
||||
var pluginName = "emojiPicker",
|
||||
defaults = {
|
||||
width: '200',
|
||||
height: '350',
|
||||
position: 'right',
|
||||
fadeTime: 100,
|
||||
iconColor: 'black',
|
||||
iconBackgroundColor: '#eee',
|
||||
recentCount: 36,
|
||||
emojiSet: 'apple',
|
||||
container: 'body',
|
||||
button: true
|
||||
};
|
||||
|
||||
var MIN_WIDTH = 280,
|
||||
MAX_WIDTH = 600,
|
||||
MIN_HEIGHT = 100,
|
||||
MAX_HEIGHT = 350,
|
||||
MAX_ICON_HEIGHT = 50;
|
||||
|
||||
var categories = [
|
||||
{ name: 'people', label: 'People' },
|
||||
{ name: 'nature', label: 'Nature' },
|
||||
{ name: 'food', label: 'Food' },
|
||||
{ name: 'activity', label: 'Activities' },
|
||||
{ name: 'travel', label: 'Travel & Places' },
|
||||
{ name: 'object', label: 'Objects' },
|
||||
{ name: 'symbol', label: 'Symbols' },
|
||||
{ name: 'flag', label: 'Flags' }
|
||||
];
|
||||
|
||||
function EmojiPicker( element, options ) {
|
||||
|
||||
this.element = element;
|
||||
this.$el = $(element);
|
||||
|
||||
this.settings = $.extend( {}, defaults, options );
|
||||
|
||||
this.$container = $(this.settings.container);
|
||||
|
||||
// (type) Safety first
|
||||
this.settings.width = parseInt(this.settings.width);
|
||||
this.settings.height = parseInt(this.settings.height);
|
||||
|
||||
// Check for valid width/height
|
||||
if(this.settings.width >= MAX_WIDTH) {
|
||||
this.settings.width = MAX_WIDTH;
|
||||
} else if (this.settings.width < MIN_WIDTH) {
|
||||
this.settings.width = MIN_WIDTH;
|
||||
}
|
||||
if (this.settings.height >= MAX_HEIGHT) {
|
||||
this.settings.height = MAX_HEIGHT;
|
||||
} else if (this.settings.height < MIN_HEIGHT) {
|
||||
this.settings.height = MIN_HEIGHT;
|
||||
}
|
||||
|
||||
var possiblePositions = [ 'left',
|
||||
'right'
|
||||
/*,'top',
|
||||
'bottom'*/];
|
||||
if($.inArray(this.settings.position,possiblePositions) == -1) {
|
||||
this.settings.position = defaults.position; //current default
|
||||
}
|
||||
|
||||
// Do not enable if on mobile device (emojis already present)
|
||||
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
||||
this.init();
|
||||
} else {
|
||||
this.isMobile = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$.extend(EmojiPicker.prototype, {
|
||||
|
||||
init: function() {
|
||||
this.active = false;
|
||||
this.addPickerIcon();
|
||||
this.createPicker();
|
||||
this.listen();
|
||||
},
|
||||
|
||||
addPickerIcon: function() {
|
||||
// The wrapper is not needed if they have chosen to not use a button
|
||||
if (this.settings.button) {
|
||||
var elementHeight = this.$el.outerHeight();
|
||||
var iconHeight = elementHeight > MAX_ICON_HEIGHT ?
|
||||
MAX_ICON_HEIGHT :
|
||||
elementHeight;
|
||||
|
||||
// This can cause issues if the element is not visible when it is initiated
|
||||
var objectWidth = this.$el.width();
|
||||
|
||||
this.$el.width(objectWidth);
|
||||
|
||||
this.$wrapper = this.$el
|
||||
.wrap("<div class='emojiPickerIconWrap'></div>")
|
||||
.parent();
|
||||
|
||||
this.$icon = $('<div class="emojiPickerIcon"></div>')
|
||||
.height(iconHeight)
|
||||
.width(iconHeight)
|
||||
.addClass(this.settings.iconColor)
|
||||
.css('backgroundColor', this.settings.iconBackgroundColor);
|
||||
this.$wrapper.append( this.$icon );
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
createPicker: function() {
|
||||
|
||||
// Show template
|
||||
this.$picker = $( getPickerHTML() )
|
||||
.appendTo( this.$container )
|
||||
.width(this.settings.width)
|
||||
.height(this.settings.height)
|
||||
.css('z-index',10000);
|
||||
|
||||
// Picker height
|
||||
this.$picker.find('.sections')
|
||||
.height(parseInt(this.settings.height) - 40); // 40 is height of the tabs
|
||||
|
||||
// Tab size based on width
|
||||
if (this.settings.width < 240) {
|
||||
this.$picker.find('.emoji').css({'width':'1em', 'height':'1em'});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
destroyPicker: function() {
|
||||
if (this.isMobile) return this;
|
||||
|
||||
this.$picker.unbind('mouseover');
|
||||
this.$picker.unbind('mouseout');
|
||||
this.$picker.unbind('click');
|
||||
this.$picker.remove();
|
||||
|
||||
$.removeData(this.$el.get(0), 'emojiPicker');
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
// If the button is being used, wrapper has not been set,
|
||||
// and will not need a listener
|
||||
if (this.settings.button){
|
||||
// Clicking on the picker icon
|
||||
this.$wrapper.find('.emojiPickerIcon')
|
||||
.click( $.proxy(this.iconClicked, this) );
|
||||
}
|
||||
|
||||
// Click event for emoji
|
||||
this.$picker.on('click', 'em', $.proxy(this.emojiClicked, this));
|
||||
|
||||
// Hover event for emoji
|
||||
this.$picker.on('mouseover', 'em', $.proxy(this.emojiMouseover, this) );
|
||||
this.$picker.on('mouseout', 'em', $.proxy(this.emojiMouseout, this) );
|
||||
|
||||
// Click event for active tab
|
||||
this.$picker.find('nav .tab')
|
||||
.click( $.proxy(this.emojiCategoryClicked, this) )
|
||||
.mouseover( $.proxy(this.emojiTabMouseover, this) )
|
||||
.mouseout( $.proxy(this.emojiMouseout, this) );
|
||||
|
||||
// Scroll event for active tab
|
||||
this.$picker.find('.sections')
|
||||
.scroll( $.proxy(this.emojiScroll, this) );
|
||||
|
||||
this.$picker.click( $.proxy(this.pickerClicked, this) );
|
||||
|
||||
// Key events for search
|
||||
this.$picker.find('section.search input')
|
||||
.on('keyup search', $.proxy(this.searchCharEntered, this) );
|
||||
|
||||
// Shortcode hover
|
||||
this.$picker.find('.shortcode').mouseover(function(e) { e.stopPropagation(); });
|
||||
|
||||
$(document.body).click( $.proxy(this.clickOutside, this) );
|
||||
|
||||
// Resize events forces a reposition, which may or may not actually be required
|
||||
$(window).resize( $.proxy(this.updatePosition, this) );
|
||||
},
|
||||
|
||||
updatePosition: function() {
|
||||
|
||||
/* Process:
|
||||
1. Find the nearest positioned element by crawling up the ancestors, record it's offset
|
||||
2. Find the bottom left or right of the input element, record this (Account for position setting of left or right)
|
||||
3. Find the difference between the two, as this will become our new position
|
||||
4. Magic.
|
||||
|
||||
N.B. The removed code had a reference to top/bottom positioning, but I don't see the use case for this..
|
||||
*/
|
||||
|
||||
// Step 1
|
||||
// Luckily jquery already does this...
|
||||
var positionedParent = this.$picker.offsetParent();
|
||||
var parentOffset = positionedParent.offset(); // now have a top/left object
|
||||
|
||||
// Step 2
|
||||
var elOffset = this.$el.offset();
|
||||
if(this.settings.position == 'right'){
|
||||
elOffset.left += this.$el.outerWidth() - this.settings.width;
|
||||
}
|
||||
elOffset.top += this.$el.outerHeight();
|
||||
|
||||
// Step 3
|
||||
var diffOffset = {
|
||||
top: (elOffset.top - parentOffset.top),
|
||||
left: (elOffset.left - parentOffset.top)
|
||||
};
|
||||
|
||||
this.$picker.css({
|
||||
top: diffOffset.top,
|
||||
left: diffOffset.left
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$picker.hide(this.settings.fadeTime, 'linear', function() {
|
||||
this.active = false;
|
||||
if (this.settings.onHide) {
|
||||
this.settings.onHide( this.$picker, this.settings, this.active );
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.$el.focus();
|
||||
this.updatePosition();
|
||||
this.$picker.show(this.settings.fadeTime, 'linear', function() {
|
||||
this.active = true;
|
||||
if (this.settings.onShow) {
|
||||
this.settings.onShow( this.$picker, this.settings, this.active );
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/************
|
||||
* EVENTS *
|
||||
************/
|
||||
|
||||
iconClicked : function() {
|
||||
if ( this.$picker.is(':hidden') ) {
|
||||
this.show();
|
||||
if( this.$picker.find('.search input').length > 0 ) {
|
||||
this.$picker.find('.search input').focus();
|
||||
}
|
||||
} else {
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
emojiClicked: function(e) { var clickTarget = $(e.target);
|
||||
var emojiSpan;
|
||||
if (clickTarget.is('em')) {
|
||||
emojiSpan = clickTarget.find('span');
|
||||
} else {
|
||||
emojiSpan = clickTarget.parent().find('.emoji');
|
||||
}
|
||||
|
||||
var emojiShortcode = emojiSpan.attr('class').split('emoji-')[1];
|
||||
var emojiUnicode = toUnicode(findEmoji(emojiShortcode).unicode[defaults.emojiSet]);
|
||||
|
||||
insertAtCaret(this.element, emojiUnicode);
|
||||
addToLocalStorage(emojiShortcode);
|
||||
updateRecentlyUsed(emojiShortcode);
|
||||
|
||||
// For anyone who is relying on the keyup event
|
||||
$(this.element).trigger("keyup");
|
||||
|
||||
// trigger change event on input
|
||||
var event = document.createEvent("HTMLEvents");
|
||||
event.initEvent("input", true, true);
|
||||
this.element.dispatchEvent(event);
|
||||
},
|
||||
|
||||
emojiMouseover: function(e) {
|
||||
var emojiShortcode = $(e.target).parent().find('.emoji').attr('class').split('emoji-')[1];
|
||||
var $shortcode = $(e.target).parents('.emojiPicker').find('.shortcode');
|
||||
$shortcode.find('.random').hide();
|
||||
$shortcode.find('.info').show().html('<div class="emoji emoji-' + emojiShortcode + '"></div><em>' + emojiShortcode + '</em>');
|
||||
},
|
||||
|
||||
emojiMouseout: function(e) {
|
||||
$(e.target).parents('.emojiPicker').find('.shortcode .info').empty().hide();
|
||||
$(e.target).parents('.emojiPicker').find('.shortcode .random').show();
|
||||
},
|
||||
|
||||
emojiCategoryClicked: function(e) {
|
||||
var section = '';
|
||||
|
||||
// Update tab
|
||||
this.$picker.find('nav .tab').removeClass('active');
|
||||
if ($(e.target).parent().hasClass('tab')) {
|
||||
section = $(e.target).parent().attr('data-tab');
|
||||
$(e.target).parent('.tab').addClass('active');
|
||||
}
|
||||
else {
|
||||
section = $(e.target).attr('data-tab');
|
||||
$(e.target).addClass('active');
|
||||
}
|
||||
|
||||
var $section = this.$picker.find('section.' + section);
|
||||
|
||||
var heightOfSectionsHidden = $section.parent().scrollTop();
|
||||
var heightOfSectionToPageTop = $section.offset().top;
|
||||
var heightOfSectionsToPageTop = $section.parent().offset().top;
|
||||
|
||||
var scrollDistance = heightOfSectionsHidden
|
||||
+ heightOfSectionToPageTop
|
||||
- heightOfSectionsToPageTop;
|
||||
|
||||
$('.sections').off('scroll'); // Disable scroll event until animation finishes
|
||||
|
||||
var that = this;
|
||||
$('.sections').animate({
|
||||
scrollTop: scrollDistance
|
||||
}, 250, function() {
|
||||
that.$picker.find('.sections').on('scroll', $.proxy(that.emojiScroll, that) ); // Enable scroll event
|
||||
});
|
||||
},
|
||||
|
||||
emojiTabMouseover: function(e) {
|
||||
var section = '';
|
||||
if ($(e.target).parent().hasClass('tab')) {
|
||||
section = $(e.target).parent().attr('data-tab');
|
||||
}
|
||||
else {
|
||||
section = $(e.target).attr('data-tab');
|
||||
}
|
||||
|
||||
var categoryTitle = '';
|
||||
for (var i = 0; i < categories.length; i++) {
|
||||
if (categories[i].name == section) { categoryTitle = categories[i].label; }
|
||||
}
|
||||
if (categoryTitle == '') { categoryTitle = 'Recently Used'; }
|
||||
|
||||
var categoryCount = $('section.' + section).attr('data-count');
|
||||
var categoryHtml = '<em class="tabTitle">' + categoryTitle + ' <span class="count">(' + categoryCount + ' emojis)</span></em>';
|
||||
|
||||
var $shortcode = $(e.target).parents('.emojiPicker').find('.shortcode');
|
||||
$shortcode.find('.random').hide();
|
||||
$shortcode.find('.info').show().html(categoryHtml);
|
||||
},
|
||||
|
||||
emojiScroll: function(e) {
|
||||
var sections = $('section');
|
||||
$.each(sections, function(key, value) {
|
||||
var section = sections[key];
|
||||
var offsetFromTop = $(section).position().top;
|
||||
|
||||
if (section.className == 'search' || (section.className == 'people' && offsetFromTop > 0)) {
|
||||
$(section).parents('.emojiPicker').find('nav tab.recent').addClass('active');
|
||||
return;
|
||||
}
|
||||
|
||||
if (offsetFromTop <= 0) {
|
||||
$(section).parents('.emojiPicker').find('nav .tab').removeClass('active');
|
||||
$(section).parents('.emojiPicker').find('nav .tab[data-tab=' + section.className + ']').addClass('active');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
pickerClicked: function(e) {
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
clickOutside: function(e) {
|
||||
if ( this.active ) {
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
searchCharEntered: function(e) {
|
||||
var searchTerm = $(e.target).val();
|
||||
var searchEmojis = $(e.target).parents('.sections').find('section.search');
|
||||
var searchEmojiWrap = searchEmojis.find('.wrap');
|
||||
var sections = $(e.target).parents('.sections').find('section');
|
||||
|
||||
// Clear if X is clicked within input
|
||||
if (searchTerm == '') {
|
||||
sections.show();
|
||||
searchEmojiWrap.hide();
|
||||
}
|
||||
|
||||
if (searchTerm.length > 0) {
|
||||
sections.hide();
|
||||
searchEmojis.show();
|
||||
searchEmojiWrap.show();
|
||||
|
||||
var results = [];
|
||||
searchEmojiWrap.find('em').remove();
|
||||
|
||||
$.each($.fn.emojiPicker.emojis, function(i, emoji) {
|
||||
var shortcode = emoji.shortcode;
|
||||
if ( shortcode.indexOf(searchTerm) > -1 ) {
|
||||
results.push('<em><div class="emoji emoji-' + shortcode + '"></div></em>');
|
||||
}
|
||||
});
|
||||
searchEmojiWrap.append(results.join(''));
|
||||
} else {
|
||||
sections.show();
|
||||
searchEmojiWrap.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.fn[ pluginName ] = function ( options ) {
|
||||
|
||||
// Calling a function
|
||||
if (typeof options === 'string') {
|
||||
this.each(function() {
|
||||
var plugin = $.data( this, pluginName );
|
||||
switch(options) {
|
||||
case 'toggle':
|
||||
plugin.iconClicked();
|
||||
break;
|
||||
case 'destroy':
|
||||
plugin.destroyPicker();
|
||||
break;
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
// Don't attach to the same element twice
|
||||
if ( !$.data( this, pluginName ) ) {
|
||||
$.data( this, pluginName, new EmojiPicker( this, options ) );
|
||||
}
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
function getPickerHTML() {
|
||||
var nodes = [];
|
||||
var aliases = {
|
||||
'undefined': 'object'
|
||||
}
|
||||
var items = {};
|
||||
var localStorageSupport = (typeof(Storage) !== 'undefined') ? true : false;
|
||||
|
||||
// Re-Sort Emoji table
|
||||
$.each($.fn.emojiPicker.emojis, function(i, emoji) {
|
||||
var category = aliases[ emoji.category ] || emoji.category;
|
||||
items[ category ] = items[ category ] || [];
|
||||
items[ category ].push( emoji );
|
||||
});
|
||||
|
||||
nodes.push('<div class="emojiPicker">');
|
||||
nodes.push('<nav>');
|
||||
|
||||
// Recent Tab, if localstorage support
|
||||
if (localStorageSupport) {
|
||||
nodes.push('<div class="tab active" data-tab="recent"><div class="emoji emoji-tab-recent"></div></div>');
|
||||
}
|
||||
|
||||
// Emoji category tabs
|
||||
var categories_length = categories.length;
|
||||
for (var i = 0; i < categories_length; i++) {
|
||||
nodes.push('<div class="tab' +
|
||||
( !localStorageSupport && i == 0 ? ' active' : '' ) +
|
||||
'" data-tab="' +
|
||||
categories[i].name +
|
||||
'"><div class="emoji emoji-tab-' +
|
||||
categories[i].name +
|
||||
'"></div></div>');
|
||||
}
|
||||
nodes.push('</nav>');
|
||||
nodes.push('<div class="sections">');
|
||||
|
||||
// Search
|
||||
nodes.push('<section class="search">');
|
||||
nodes.push('<input type="search" placeholder="Search...">');
|
||||
nodes.push('<div class="wrap" style="display:none;"><h1>Search Results</h1></div>');
|
||||
nodes.push('</section>');
|
||||
|
||||
// Recent Section, if localstorage support
|
||||
if (localStorageSupport) {
|
||||
var recentlyUsedEmojis = [];
|
||||
var recentlyUsedCount = 0;
|
||||
var displayRecentlyUsed = ' style="display:none;"';
|
||||
|
||||
if (localStorage.emojis) {
|
||||
recentlyUsedEmojis = JSON.parse(localStorage.emojis);
|
||||
recentlyUsedCount = recentlyUsedEmojis.length;
|
||||
displayRecentlyUsed = ' style="display:block;"';
|
||||
}
|
||||
|
||||
nodes.push('<section class="recent" data-count="' + recentlyUsedEmojis.length + '"' + displayRecentlyUsed + '>');
|
||||
nodes.push('<h1>Recently Used</h1><div class="wrap">');
|
||||
|
||||
for (var i = recentlyUsedEmojis.length-1; i > -1 ; i--) {
|
||||
nodes.push('<em><span class="emoji emoji-' + recentlyUsedEmojis[i] + '"></span></em>');
|
||||
}
|
||||
nodes.push('</div></section>');
|
||||
}
|
||||
|
||||
// Emoji sections
|
||||
for (var i = 0; i < categories_length; i++) {
|
||||
var category_length = items[ categories[i].name ].length;
|
||||
nodes.push('<section class="' + categories[i].name + '" data-count="' + category_length + '">');
|
||||
nodes.push('<h1>' + categories[i].label + '</h1><div class="wrap">');
|
||||
for (var j = 0; j < category_length; j++) {
|
||||
var emoji = items[ categories[i].name ][ j ];
|
||||
nodes.push('<em><span class="emoji emoji-' + emoji.shortcode + '"></span></em>');
|
||||
}
|
||||
nodes.push('</div></section>');
|
||||
}
|
||||
nodes.push('</div>');
|
||||
|
||||
// Shortcode section
|
||||
nodes.push('<div class="shortcode"><span class="random">');
|
||||
nodes.push('<em class="tabTitle">' + generateEmojiOfDay() + '</em>');
|
||||
nodes.push('</span><span class="info"></span></div>');
|
||||
|
||||
nodes.push('</div>');
|
||||
return nodes.join("\n");
|
||||
}
|
||||
|
||||
function generateEmojiOfDay() {
|
||||
var emojis = $.fn.emojiPicker.emojis;
|
||||
var i = Math.floor(Math.random() * (364 - 0) + 0);
|
||||
var emoji = emojis[i];
|
||||
return 'Daily Emoji: <span class="eod"><span class="emoji emoji-' + emoji.name + '"></span> <span class="emojiName">' + emoji.name + '</span></span>';
|
||||
}
|
||||
|
||||
function findEmoji(emojiShortcode) {
|
||||
var emojis = $.fn.emojiPicker.emojis;
|
||||
for (var i = 0; i < emojis.length; i++) {
|
||||
if (emojis[i].shortcode == emojiShortcode) {
|
||||
return emojis[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function insertAtCaret(inputField, myValue) {
|
||||
if (document.selection) {
|
||||
//For browsers like Internet Explorer
|
||||
inputField.focus();
|
||||
var sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
inputField.focus();
|
||||
}
|
||||
else if (inputField.selectionStart || inputField.selectionStart == '0') {
|
||||
//For browsers like Firefox and Webkit based
|
||||
var startPos = inputField.selectionStart;
|
||||
var endPos = inputField.selectionEnd;
|
||||
var scrollTop = inputField.scrollTop;
|
||||
inputField.value = inputField.value.substring(0, startPos)+myValue+inputField.value.substring(endPos,inputField.value.length);
|
||||
inputField.focus();
|
||||
inputField.selectionStart = startPos + myValue.length;
|
||||
inputField.selectionEnd = startPos + myValue.length;
|
||||
inputField.scrollTop = scrollTop;
|
||||
} else {
|
||||
inputField.focus();
|
||||
inputField.value += myValue;
|
||||
}
|
||||
}
|
||||
|
||||
function toUnicode(code) {
|
||||
var codes = code.split('-').map(function(value, index) {
|
||||
return parseInt(value, 16);
|
||||
});
|
||||
return String.fromCodePoint.apply(null, codes);
|
||||
}
|
||||
|
||||
function addToLocalStorage(emoji) {
|
||||
var recentlyUsedEmojis = [];
|
||||
if (localStorage.emojis) {
|
||||
recentlyUsedEmojis = JSON.parse(localStorage.emojis);
|
||||
}
|
||||
|
||||
// If already in recently used, move to front
|
||||
var index = recentlyUsedEmojis.indexOf(emoji);
|
||||
if (index > -1) {
|
||||
recentlyUsedEmojis.splice(index, 1);
|
||||
}
|
||||
recentlyUsedEmojis.push(emoji);
|
||||
|
||||
if (recentlyUsedEmojis.length > defaults.recentCount) {
|
||||
recentlyUsedEmojis.shift();
|
||||
}
|
||||
|
||||
localStorage.emojis = JSON.stringify(recentlyUsedEmojis);
|
||||
}
|
||||
|
||||
function updateRecentlyUsed(emoji) {
|
||||
var recentlyUsedEmojis = JSON.parse(localStorage.emojis);
|
||||
var emojis = [];
|
||||
var recent = $('section.recent');
|
||||
|
||||
for (var i = recentlyUsedEmojis.length-1; i >= 0; i--) {
|
||||
emojis.push('<em><span class="emoji emoji-' + recentlyUsedEmojis[i] + '"></span></em>');
|
||||
}
|
||||
|
||||
// Fix height as emojis are added
|
||||
var prevHeight = recent.outerHeight();
|
||||
$('section.recent .wrap').html(emojis.join(''));
|
||||
var currentScrollTop = $('.sections').scrollTop();
|
||||
var newHeight = recent.outerHeight();
|
||||
var newScrollToHeight = 0;
|
||||
|
||||
if (!$('section.recent').is(':visible')) {
|
||||
recent.show();
|
||||
newScrollToHeight = newHeight;
|
||||
} else if (prevHeight != newHeight) {
|
||||
newScrollToHeight = newHeight - prevHeight;
|
||||
}
|
||||
|
||||
$('.sections').animate({
|
||||
scrollTop: currentScrollTop + newScrollToHeight
|
||||
}, 0);
|
||||
}
|
||||
|
||||
if (!String.fromCodePoint) {
|
||||
// ES6 Unicode Shims 0.1 , © 2012 Steven Levithan http://slevithan.com/ , MIT License
|
||||
String.fromCodePoint = function fromCodePoint () {
|
||||
var chars = [], point, offset, units, i;
|
||||
for (i = 0; i < arguments.length; ++i) {
|
||||
point = arguments[i];
|
||||
offset = point - 0x10000;
|
||||
units = point > 0xFFFF ? [0xD800 + (offset >> 10), 0xDC00 + (offset & 0x3FF)] : [point];
|
||||
chars.push(String.fromCharCode.apply(null, units));
|
||||
}
|
||||
return chars.join("");
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
9075
files/chat-box/server/js/jquery.emojis.js
Executable file
9075
files/chat-box/server/js/jquery.emojis.js
Executable file
File diff suppressed because it is too large
Load Diff
154
files/chat-box/server/js/main.js
Executable file
154
files/chat-box/server/js/main.js
Executable file
@ -0,0 +1,154 @@
|
||||
(function(){
|
||||
const colorPalette = ["#D50000","#304FFE","#00B8D4","#00C853","#FFD600","#FF6D00","#FF1744","#3D5AFE","#00E5FF","#00E676","#FFEA00","#FF9100","#FF5252","#536DFE","#18FFFF","#69F0AE","#FFFF00","#FFAB40"];
|
||||
const colorCount = colorPalette.length;
|
||||
const rand = Math.floor(Math.random() * colorCount) + 1;
|
||||
const userColor = colorPalette[rand];
|
||||
const colorOption = document.getElementById("color-option");
|
||||
colorOption.value = userColor;
|
||||
|
||||
function parseMessage(message) {
|
||||
var msg = {type: "", sender: "", text: "", color: ""};
|
||||
try {
|
||||
msg = JSON.parse(message);
|
||||
}
|
||||
catch(e) {
|
||||
return false;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
function appendMessage(message) {
|
||||
var msgContainer = document.querySelector(".messages");
|
||||
var parsedMessage;
|
||||
|
||||
if(parsedMessage = parseMessage(message)) {
|
||||
console.log("appending message...");
|
||||
|
||||
var msgElem, senderElem, textElem;
|
||||
var sender, text, color;
|
||||
|
||||
if (parsedMessage.color !== "") {
|
||||
color = parsedMessage.color;
|
||||
} else {
|
||||
color = userColor;
|
||||
}
|
||||
|
||||
msgElem = document.createElement("div");
|
||||
msgElem.classList.add("msg");
|
||||
msgElem.classList.add("msg-" + parsedMessage.type);
|
||||
|
||||
senderElem = document.createElement("div");
|
||||
senderElem.classList.add("msg-sender");
|
||||
|
||||
textElem = document.createElement("div");
|
||||
textElem.classList.add("msg-text");
|
||||
textElem.style.background = color;
|
||||
|
||||
sender = document.createTextNode(parsedMessage.sender + ": ");
|
||||
text = document.createTextNode(parsedMessage.text);
|
||||
|
||||
senderElem.appendChild(sender);
|
||||
textElem.appendChild(text);
|
||||
|
||||
msgElem.appendChild(senderElem);
|
||||
msgElem.appendChild(textElem);
|
||||
|
||||
msgContainer.appendChild(msgElem);
|
||||
}
|
||||
}
|
||||
|
||||
function setup() {
|
||||
var sender, color = "";
|
||||
var joinForm = document.querySelector("form.join-form");
|
||||
var msgForm = document.querySelector("form.msg-form");
|
||||
var closeForm = document.querySelector("form.close-form");
|
||||
|
||||
var joinFormSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
sender = document.getElementById("sender").value;
|
||||
if (sender) {
|
||||
color = colorOption.value;
|
||||
var joinMsg = {
|
||||
type: "join",
|
||||
sender: sender,
|
||||
text: sender + " joined the chat!",
|
||||
color: color
|
||||
};
|
||||
|
||||
socket.send(JSON.stringify(joinMsg));
|
||||
joinForm.classList.add("hidden");
|
||||
msgForm.classList.remove("hidden");
|
||||
closeForm.classList.remove("hidden");
|
||||
} else {
|
||||
alert("Veuillez saisir votre prénom.");
|
||||
}
|
||||
};
|
||||
|
||||
var msgFormSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
var msgField, msgText, msg, color;
|
||||
msgField = document.getElementById("msg");
|
||||
msgText = msgField.value;
|
||||
if (colorOption.value) {
|
||||
color = colorOption.value;
|
||||
} else {
|
||||
color = userColor;
|
||||
}
|
||||
|
||||
msg = {
|
||||
type: "normal",
|
||||
sender: sender,
|
||||
text: msgText,
|
||||
color: color
|
||||
};
|
||||
|
||||
socket.send(JSON.stringify(msg));
|
||||
msgField.value = "";
|
||||
};
|
||||
|
||||
var closeFormSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
socket.close();
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
joinForm.addEventListener("submit", joinFormSubmit);
|
||||
msgForm.addEventListener("submit", msgFormSubmit);
|
||||
closeForm.addEventListener("submit", closeFormSubmit);
|
||||
}
|
||||
|
||||
var socket = new WebSocket("ws:srv-stage.stage-ge.org:8090");
|
||||
|
||||
var socketOpen = (e) => {
|
||||
console.log("connected to the socket");
|
||||
var msg = {
|
||||
type: "join",
|
||||
sender: "Browser",
|
||||
text: "connected to the chat server",
|
||||
color: "white"
|
||||
};
|
||||
appendMessage(JSON.stringify(msg));
|
||||
setup();
|
||||
};
|
||||
|
||||
var socketMessage = (e) => {
|
||||
console.log("Message fom server: " + e.data);
|
||||
appendMessage(e.data);
|
||||
};
|
||||
|
||||
var socketClose = (e) => {
|
||||
|
||||
};
|
||||
|
||||
var socketError = (e) => {
|
||||
|
||||
};
|
||||
|
||||
socket.addEventListener("open", socketOpen);
|
||||
socket.addEventListener("message", socketMessage);
|
||||
socket.addEventListener("close", socketClose);
|
||||
socket.addEventListener("error", socketError);
|
||||
|
||||
})();
|
||||
265
files/chat-box/server/js/palette-color-picker.js
Executable file
265
files/chat-box/server/js/palette-color-picker.js
Executable file
@ -0,0 +1,265 @@
|
||||
/*!
|
||||
* JQuery Palette Color Picker v1.13 by Carlos Cabo ( @putuko )
|
||||
* https://github.com/carloscabo/jquery-palette-color-picker
|
||||
*/
|
||||
(function($) {
|
||||
// La magia aquí
|
||||
'use strict';
|
||||
|
||||
// Public core
|
||||
$.paletteColorPicker = function( el, options ) {
|
||||
var
|
||||
ns = 'palette-color-picker', // Base attr / class
|
||||
$el = $(el),
|
||||
plugin = this,
|
||||
timer = null,
|
||||
current_value = $el.val(),
|
||||
target = $el.attr('name'),
|
||||
$button = $('<div>')
|
||||
.addClass(ns+'-button')
|
||||
.attr('data-target', target),
|
||||
$bubble = $('<div>')
|
||||
.addClass(ns+'-bubble'),
|
||||
|
||||
// Final settings will be stored here
|
||||
settings = {},
|
||||
|
||||
// Default settings
|
||||
defaults = {
|
||||
custom_class: null,
|
||||
colors: null,
|
||||
position: 'upside', // upside | downside
|
||||
insert: 'before', // default
|
||||
clear_btn: 'first', // default
|
||||
timeout: 2000, // default
|
||||
set_background: false, // default
|
||||
close_all_but_this: false // default
|
||||
},
|
||||
|
||||
click_handler = ('ontouchstart' in document.documentElement ? 'touchstart click' : 'click');
|
||||
|
||||
// Init
|
||||
plugin.init = function() {
|
||||
// Extand settings with user options
|
||||
plugin.settings = $.extend({}, defaults, options);
|
||||
|
||||
// If input has not value add it
|
||||
var
|
||||
val = $el.attr('value');
|
||||
if (typeof val === typeof undefined || val === false) {
|
||||
val = '';
|
||||
$el.attr('value', val);
|
||||
}
|
||||
|
||||
// Backup initial value
|
||||
$el.attr('data-initialvalue', $el.attr('value') );
|
||||
|
||||
// If color were not passed as options get them from data-palette attribute
|
||||
if (plugin.settings.colors === null) {
|
||||
plugin.settings.colors = $el.data('palette');
|
||||
}
|
||||
|
||||
// If color is array of string, convert to obj
|
||||
if (typeof plugin.settings.colors[0] === 'string') {
|
||||
plugin.settings.colors = $.map(plugin.settings.colors, function(el, idx) {
|
||||
var b = {}; b[el] = el; return b;
|
||||
});
|
||||
}
|
||||
|
||||
// Capitalize position
|
||||
plugin.settings.insert = plugin.settings.insert.charAt(0).toUpperCase() + plugin.settings.insert.slice(1);
|
||||
|
||||
// Add custom_class
|
||||
if (plugin.settings.custom_class) {
|
||||
$bubble.addClass(plugin.settings.custom_class);
|
||||
}
|
||||
|
||||
// Create color swatches
|
||||
$.each( plugin.settings.colors, function( idx, obj ) {
|
||||
var
|
||||
key = Object.keys( obj )[0],
|
||||
col = obj[key],
|
||||
$sw = $('<span>').addClass('swatch')
|
||||
.attr({
|
||||
'title': key,
|
||||
'data-color': col,
|
||||
'data-name': key
|
||||
}).css('background-color', col);
|
||||
|
||||
if ( key === current_value ) {
|
||||
$sw.addClass('active');
|
||||
$button.css('background', col);
|
||||
}
|
||||
|
||||
$sw.appendTo( $bubble );
|
||||
});
|
||||
|
||||
// Create clear button if not null
|
||||
if (plugin.settings.clear_btn !== null) {
|
||||
var
|
||||
$clear_btn = $('<span>').addClass('swatch clear').attr('title', 'Clear selection');
|
||||
if (plugin.settings.clear_btn === 'last') {
|
||||
$clear_btn.addClass('last').appendTo( $bubble );
|
||||
} else {
|
||||
$clear_btn.prependTo( $bubble );
|
||||
}
|
||||
}
|
||||
|
||||
// Public
|
||||
plugin.destroy = function() {
|
||||
$button.remove();
|
||||
$.removeData( $el[0] );
|
||||
};
|
||||
|
||||
// Clears all
|
||||
plugin.clear = function() {
|
||||
$bubble.find('.active').removeClass('active');
|
||||
$button.removeAttr('style');
|
||||
$el.val('');
|
||||
};
|
||||
|
||||
// Reset to initial value
|
||||
plugin.reset = function() {
|
||||
// Dont had initial value
|
||||
if ( $el.attr('data-initialvalue') === '' ) {
|
||||
plugin.clear();
|
||||
} else {
|
||||
// Had initial value
|
||||
var iv = $el.attr('data-initialvalue');
|
||||
$bubble.find('[data-name="'+iv+'"]').trigger('click');
|
||||
}
|
||||
};
|
||||
|
||||
// reload value after it has been changed programatically
|
||||
plugin.reload = function() {
|
||||
|
||||
var newVal = $el.val();
|
||||
if ( newVal === '' || typeof newVal === typeof undefined || newVal === false ) {
|
||||
// Doesn't have the value to load so loading initial value
|
||||
plugin.reset();
|
||||
} else {
|
||||
// setting the value to new value
|
||||
if($bubble.find('[data-name="'+newVal+'"]').length) {
|
||||
// value will only be set if the color exists in options
|
||||
$bubble.find('[data-name="'+newVal+'"]').trigger('click');
|
||||
} else {
|
||||
// setting to the initial value if color does not exists
|
||||
plugin.reset();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Events
|
||||
// Simple click
|
||||
$button.append( $bubble ).on( click_handler, function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var $b = $( this );
|
||||
|
||||
// don't close on clicking the bubble
|
||||
if (!$(e.target).hasClass(ns+'-bubble')) {
|
||||
|
||||
// Call the callback, if set
|
||||
if (typeof plugin.settings.onbeforeshow_callback === 'function') {
|
||||
plugin.settings.onbeforeshow_callback(this);
|
||||
}
|
||||
|
||||
$b.toggleClass('active');
|
||||
var $current_bubble = $b.find('.'+ns+'-bubble');
|
||||
// Forces hiding other bubbles
|
||||
if (plugin.settings.close_all_but_this) {
|
||||
$('.'+ns+'-bubble').not($current_bubble).fadeOut();
|
||||
}
|
||||
$current_bubble.fadeToggle();
|
||||
|
||||
if ($b.hasClass('active')) {
|
||||
clearTimeout(plugin.timer);
|
||||
plugin.timer = setTimeout(function(){
|
||||
$b.trigger('pcp.fadeout');
|
||||
}, plugin.settings.timeout);
|
||||
}
|
||||
}
|
||||
})
|
||||
// Fade timer
|
||||
.on('pcp.fadeout', function() {
|
||||
$( this ).removeClass('active').find('.'+ns+'-bubble').fadeOut();
|
||||
})
|
||||
// Enter bubble
|
||||
.on('mouseenter', '.'+ns+'-bubble', function() {
|
||||
clearTimeout(plugin.timer);
|
||||
})
|
||||
// Leave bubble
|
||||
.on('mouseleave', '.'+ns+'-bubble', function() {
|
||||
plugin.timer = setTimeout(function(){
|
||||
$button.trigger('pcp.fadeout');
|
||||
}, plugin.settings.timeout);
|
||||
})
|
||||
// Click on swatches
|
||||
.on(click_handler, '.'+ns+'-bubble span.swatch', function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var
|
||||
col = $( this ).attr('data-color'),
|
||||
name = $( this ).attr('data-name'),
|
||||
// Select all button in document with same data target to keep them synconized
|
||||
$button = $('.'+ns+'-button[data-target="' + $( this ).closest( '.'+ns+'-button' ).attr('data-target') + '"]'),
|
||||
$bubble = $( this ).closest( '.'+ns+'-bubble' );
|
||||
|
||||
// console.log('.'+ns+'-button [data-target="' + $( this ).closest( '.'+ns+'-button' ).attr('data-target') + '"]');
|
||||
$bubble.find('.active').removeClass('active');
|
||||
|
||||
// Set background on color
|
||||
// User clicked in the clear swatch
|
||||
if ( $(e.target).is('.clear') ) {
|
||||
$button.removeAttr('style');
|
||||
col = '';
|
||||
} else {
|
||||
$(this).addClass('active');
|
||||
$button.css('background', col);
|
||||
}
|
||||
|
||||
// Call the callback, if set
|
||||
if (typeof plugin.settings.onchange_callback === "function") {
|
||||
plugin.settings.onchange_callback(col);
|
||||
}
|
||||
|
||||
if( plugin.settings.set_background === false ) {
|
||||
$('[name="' + $button.attr('data-target') + '"]').val(name);
|
||||
} else {
|
||||
$('[name="' + $button.attr('data-target') + '"]').css({'background-color' : col});
|
||||
}
|
||||
})['insert'+plugin.settings.insert]( $el );
|
||||
|
||||
// Upside / downside, default is upside
|
||||
if ( plugin.settings.position === 'downside' || ($el.offset().top) + 20 < $bubble.outerHeight() ) {
|
||||
$bubble.addClass('downside');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Close on clicking outside the palette
|
||||
$('body').on(click_handler,function(event) {
|
||||
if (!$(event.target).hasClass(ns+'-button')) {
|
||||
$( $button ).removeClass('active').find('.'+ns+'-bubble').fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
// Start
|
||||
plugin.init();
|
||||
};
|
||||
|
||||
// add the plugin to the jQuery.fn object
|
||||
$.fn.paletteColorPicker = function(options) {
|
||||
return this.each(function() {
|
||||
if (typeof $(this).data('paletteColorPickerPlugin') === 'undefined') {
|
||||
$(this).data('paletteColorPickerPlugin', new $.paletteColorPicker(this, options));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
// Sample usage
|
||||
// $(function() {
|
||||
// $('[data-palette-color-picker]').paletteColorPicker();
|
||||
// });
|
||||
24
files/chat-box/server/js/ready.js
Executable file
24
files/chat-box/server/js/ready.js
Executable file
@ -0,0 +1,24 @@
|
||||
$(document).ready(function(){
|
||||
//La magia aquí
|
||||
|
||||
// Sample 1
|
||||
$('[name="unique-name-1"]').paletteColorPicker({
|
||||
onbeforeshow_callback: function ( color_picker_button ) {
|
||||
console.log( 'onbeforeshow_callback!!!' );
|
||||
console.log( $(color_picker_button) );
|
||||
console.log( color_picker_button );
|
||||
},
|
||||
onchange_callback: function ( clicked_color ) {
|
||||
console.log( 'onchange_callback!!!' );
|
||||
console.log( $(clicked_color) );
|
||||
console.log( clicked_color );
|
||||
}
|
||||
});
|
||||
|
||||
$('[name="color-option"]').paletteColorPicker({
|
||||
clear_btn: 'last',
|
||||
close_all_but_this: true, // Default is false
|
||||
insert: 'before'
|
||||
});
|
||||
|
||||
});
|
||||
96
files/chat-box/server/socket.php
Executable file
96
files/chat-box/server/socket.php
Executable file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
include 'functions.php';
|
||||
|
||||
$address = "0.0.0.0";
|
||||
$port = 8090;
|
||||
$null = NULL;
|
||||
|
||||
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
socket_bind($sock, $address, $port);
|
||||
socket_listen($sock);
|
||||
|
||||
echo "Listening for new connections on port {$port} \n";
|
||||
|
||||
$members = [];
|
||||
$connections = [];
|
||||
|
||||
$connections[] = $sock;
|
||||
|
||||
while(true) {
|
||||
$reads = $connections;
|
||||
$writes = $exceptions = $null;
|
||||
|
||||
socket_select($reads, $writes, $exceptions, 0);
|
||||
|
||||
if(in_array($sock, $reads)){
|
||||
$new_connection = socket_accept($sock);
|
||||
|
||||
$header = socket_read($new_connection, 1024);
|
||||
handshake($header, $new_connection, $address, $port);
|
||||
|
||||
$connections[] = $new_connection;
|
||||
|
||||
$reply = [
|
||||
"type" => "join",
|
||||
"sender" => "Server",
|
||||
"text" => "enter name to join...\n"
|
||||
];
|
||||
|
||||
$reply = pack_data(json_encode($reply));
|
||||
socket_write($new_connection, $reply, strlen($reply));
|
||||
|
||||
$sock_index = array_search($sock, $reads);
|
||||
unset($reads[$sock_index]);
|
||||
}
|
||||
|
||||
foreach($reads as $key => $value) {
|
||||
$data = socket_read($value, 1024);
|
||||
|
||||
if(!empty($data)) {
|
||||
// data contains some message
|
||||
// write to all connected clients
|
||||
|
||||
$message = unmask($data);
|
||||
$decoded_message = json_decode($message, true);
|
||||
|
||||
if($decoded_message) {
|
||||
if(isset($decoded_message["text"])) {
|
||||
if($decoded_message["type"] === "join"){
|
||||
$members[$key] = [
|
||||
"name" => $decoded_message["sender"],
|
||||
"connection" => $value
|
||||
];
|
||||
}
|
||||
$masked_message = pack_data($message);
|
||||
echo $masked_message.sender . " : " . $masked_message.text . "\n";
|
||||
foreach($members as $mkey => $mvalue) {
|
||||
socket_write($mvalue['connection'], $masked_message, strlen($masked_message));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($data === '') {
|
||||
// it's à connection close request, so data is empty
|
||||
echo "disconnecting client $key \n";
|
||||
unset($connections[$key]);
|
||||
|
||||
if(array_key_exists($key, $members)) {
|
||||
$message = [
|
||||
"type" => "left",
|
||||
"sender" => "Server",
|
||||
"text" => $members[$key]['name'] . " left the chat \n"
|
||||
];
|
||||
$masked_message = pack_data(json_encode($message));
|
||||
unset($members[$key]);
|
||||
foreach($members as $mkey => $mvalue) {
|
||||
socket_write($mvalue['connection'], $masked_message, strlen($masked_message));
|
||||
}
|
||||
}
|
||||
|
||||
socket_close($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
socket_close($sock);
|
||||
53
files/cyrus/cyrus.conf
Normal file
53
files/cyrus/cyrus.conf
Normal file
@ -0,0 +1,53 @@
|
||||
# standard standalone server implementation, with preforked processes
|
||||
|
||||
START {
|
||||
# do not delete this entry!
|
||||
recover cmd="ctl_cyrusdb -r"
|
||||
}
|
||||
|
||||
# UNIX sockets start with a slash and are put into /var/imap/sockets
|
||||
SERVICES {
|
||||
# add or remove based on preferences
|
||||
imap cmd="imapd" listen="imap" prefork=5
|
||||
#imaps cmd="imapd -s" listen="imaps" prefork=1
|
||||
#pop3 cmd="pop3d" listen="pop3" prefork=3
|
||||
#pop3s cmd="pop3d -s" listen="pop3s" prefork=1
|
||||
sieve cmd="timsieved" listen="sieve" prefork=0
|
||||
|
||||
# these are only necessary if receiving/exporting usenet via NNTP
|
||||
# nntp cmd="nntpd" listen="nntp" prefork=3
|
||||
# nntps cmd="nntpd -s" listen="nntps" prefork=1
|
||||
|
||||
# these are only necessary if using HTTP for CalDAV, CardDAV, or RSS
|
||||
# http cmd="httpd" listen="http" prefork=3
|
||||
# https cmd="httpd -s" listen="https" prefork=1
|
||||
|
||||
# at least one LMTP is required for delivery
|
||||
# lmtp cmd="lmtpd" listen="lmtp" prefork=0
|
||||
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
|
||||
lmtpunix cmd="lmtpd" listen="/run/cyrus/socket/lmtp" prefork=1
|
||||
|
||||
# this is only necessary if using notifications
|
||||
# notify cmd="notifyd" listen="/run/cyrus/socket/notify" proto="udp" prefork=1
|
||||
}
|
||||
|
||||
EVENTS {
|
||||
# this is required
|
||||
checkpoint cmd="ctl_cyrusdb -c" period=30
|
||||
|
||||
# this is only necessary if using duplicate delivery suppression,
|
||||
# Sieve or NNTP
|
||||
delprune cmd="cyr_expire -E 3" at=0400
|
||||
|
||||
# Expire data older than 28 days.
|
||||
deleteprune cmd="cyr_expire -E 4 -D 28" at=0430
|
||||
expungeprune cmd="cyr_expire -E 4 -X 28" at=0445
|
||||
|
||||
# this is only necessary if caching TLS sessions
|
||||
tlsprune cmd="tls_prune" at=0400
|
||||
}
|
||||
|
||||
DAEMON {
|
||||
# this is only necessary if using idled for IMAP IDLE
|
||||
# idled cmd="idled"
|
||||
}
|
||||
20
files/cyrus/imapd.conf
Normal file
20
files/cyrus/imapd.conf
Normal file
@ -0,0 +1,20 @@
|
||||
configdirectory: /var/lib/imap
|
||||
partition-default: /var/spool/imap
|
||||
admins: cyrus
|
||||
sievedir: /var/lib/imap/sieve
|
||||
sendmail: /usr/sbin/sendmail
|
||||
hashimapspool: true
|
||||
sasl_pwcheck_method: saslauthd
|
||||
#sasl_mech_list: PLAIN LOGIN
|
||||
sasl_mech_list: PLAIN
|
||||
#sasl_mech_list: LOGIN
|
||||
allowplaintext: yes
|
||||
defaultdomain: mail
|
||||
#tls_cert_file: /etc/pki/cyrus-imapd/cyrus-imapd.pem
|
||||
#tls_key_file: /etc/pki/cyrus-imapd/cyrus-imapd.pem
|
||||
#tls_ca_file: /etc/pki/tls/certs/ca-bundle.crt
|
||||
#tls_cert_file: /etc/pki/cyrus-imapd/cyrus-imap.dyndns.org.crt
|
||||
#tls_key_file: /etc/pki/cyrus-imapd/cyrus-imap.dyndns.org.key
|
||||
#tls_ca_file: /etc/pki/tls/certs/ca-gmetech.crt
|
||||
# uncomment this if you're operating in a DSCP environment (RFC-4594)
|
||||
# qosmarking: af13
|
||||
14
files/cyrus/local_recipients
Normal file
14
files/cyrus/local_recipients
Normal file
@ -0,0 +1,14 @@
|
||||
#Utilisateur Description
|
||||
stage1 #Stagaire 1
|
||||
stage2 #Stagaire 2
|
||||
stage3 #Stagaire 3
|
||||
stage4 #Stagaire 4
|
||||
stage5 #Stagaire 5
|
||||
stage6 #Stagaire 6
|
||||
stage7 #Stagaire 7
|
||||
stage8 #Stagaire 8
|
||||
stage9 #Stagaire 9
|
||||
stage10 #Stagaire 10
|
||||
mailadmin #Mail Admin
|
||||
#listes de distribution
|
||||
tous@stage-ge.org # Tous
|
||||
BIN
files/cyrus/sasldb2
Normal file
BIN
files/cyrus/sasldb2
Normal file
Binary file not shown.
44
files/displayTraffic.sh
Executable file
44
files/displayTraffic.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
############################################################
|
||||
# Decription: Capture password from tcp trame
|
||||
# Author: Gilles Mouchet (gmo@ville-ge.ch)
|
||||
# Creation Date: 27-Dec-2023
|
||||
# Version: 1.0
|
||||
# Usage: ./displayTraffic.sh
|
||||
# Changelog:
|
||||
#
|
||||
# V1.0 - 18-Dec-2023 - GMo
|
||||
# Added
|
||||
# - Creation of script from scratch
|
||||
#
|
||||
############################################################
|
||||
|
||||
case "$1" in
|
||||
all)
|
||||
sudo tcpdump port http or https -i lo -l -A
|
||||
;;
|
||||
https)
|
||||
sudo tcpdump port https -i lo -l -A
|
||||
;;
|
||||
http)
|
||||
sudo tcpdump port http -i lo -l -A
|
||||
;;
|
||||
pass)
|
||||
sudo tcpdump port http -i lo -l -A | grep -i "task=login?&_user=$LOGNAME&_pass" --color=auto --line-buffered -B20
|
||||
;;
|
||||
*)
|
||||
cat << EOF
|
||||
|
||||
Usage: ./displayTraffic.sh [ options ]
|
||||
Options:
|
||||
all display all traffic (http and https)
|
||||
https display all https traffic
|
||||
http dispaly all http traffic
|
||||
pass display password from $LOGNAME
|
||||
|
||||
2023-$(date +"%Y") - DSIC - Gilles Mouchet (gilles.mouchet@ville-ge.ch)
|
||||
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
65
files/docker-image/Dockerfile
Normal file
65
files/docker-image/Dockerfile
Normal file
@ -0,0 +1,65 @@
|
||||
FROM ubuntu:16.04
|
||||
#MAINTAINER Francisco Carmona <fcarmona.olmedo@gmail.com>
|
||||
|
||||
# Environments vars
|
||||
ENV TERM=xterm
|
||||
|
||||
#RUN apt-get update
|
||||
RUN apt-get -y upgrade
|
||||
|
||||
# Packages installation
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -y --fix-missing install apache2 \
|
||||
php \
|
||||
php-cli \
|
||||
php-gd \
|
||||
php-json \
|
||||
php-mbstring \
|
||||
php-xml \
|
||||
php-xsl \
|
||||
php-zip \
|
||||
php-soap \
|
||||
php-pear \
|
||||
php-mcrypt \
|
||||
libapache2-mod-php \
|
||||
curl \
|
||||
php-curl \
|
||||
apt-transport-https \
|
||||
nano \
|
||||
lynx-cur
|
||||
|
||||
RUN a2enmod rewrite
|
||||
RUN phpenmod mcrypt
|
||||
|
||||
# Composer install
|
||||
RUN curl -sS https://getcomposer.org/installer | php
|
||||
RUN mv composer.phar /usr/local/bin/composer
|
||||
|
||||
# Update the default apache site with the config we created.
|
||||
ADD config/apache/apache-virtual-hosts.conf /etc/apache2/sites-enabled/000-default.conf
|
||||
ADD config/apache/apache2.conf /etc/apache2/apache2.conf
|
||||
ADD config/apache/ports.conf /etc/apache2/ports.conf
|
||||
ADD config/apache/envvars /etc/apache2/envvars
|
||||
|
||||
# Update php.ini
|
||||
ADD config/php/php.conf /etc/php/7.0/apache2/php.ini
|
||||
|
||||
# Init
|
||||
ADD init.sh /init.sh
|
||||
RUN chmod 755 /*.sh
|
||||
|
||||
# Add phpinfo script for INFO purposes
|
||||
RUN echo "<?php phpinfo();" >> /var/www/index.php
|
||||
|
||||
RUN service apache2 restart
|
||||
|
||||
RUN chown -R www-data:www-data /var/www
|
||||
|
||||
WORKDIR /var/www/
|
||||
|
||||
# Volume
|
||||
VOLUME /var/www
|
||||
|
||||
# Ports: apache2
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["/init.sh"]
|
||||
77
files/docker-image/README.md
Normal file
77
files/docker-image/README.md
Normal file
@ -0,0 +1,77 @@
|
||||
# docker-ubuntu16-apache2-php7
|
||||
A docker image based on Ubuntu 16.04 with Apache2 + PHP 7.0
|
||||
|
||||
## Pull the image
|
||||
|
||||
Pull the latest stable version from the [Docker Hub Registry](https://hub.docker.com/r/francarmona/docker-ubuntu16-apache2-php7/)
|
||||
```
|
||||
docker pull francarmona/docker-ubuntu16-apache2-php7:latest
|
||||
```
|
||||
|
||||
If you prefer building the image from source, clone the repository and run docker build
|
||||
|
||||
```
|
||||
git clone https://github.com/franCarmona/docker-ubuntu16-apache2-php7.git
|
||||
docker build -t francarmona/docker-ubuntu16-apache2-php7 .
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
After building the image, run the container.
|
||||
```
|
||||
docker run --name apache2-php7 -v ~/path/to/code:/var/www -d -p [host-port]:80 francarmona/docker-ubuntu16-apache2-php7
|
||||
```
|
||||
Browse to [http://localhost:[host-port]](http://localhost:[host-port]) to view your app.
|
||||
|
||||
## Use as a base image
|
||||
|
||||
Some cases will be necessary to create a new image using this one as the base, for example to overwrite configuration files.
|
||||
|
||||
Create a Dockerfile with following content and then build the image.
|
||||
|
||||
```Dockerfile
|
||||
FROM francarmona/docker-ubuntu16-apache2-php7
|
||||
|
||||
MAINTAINER Your Name <your@email>
|
||||
|
||||
# Apache site conf
|
||||
ADD config/apache/apache-virtual-hosts.conf /etc/apache2/sites-enabled/000-default.conf
|
||||
ADD config/apache/apache2.conf /etc/apache2/apache2.conf
|
||||
```
|
||||
|
||||
## Packages included
|
||||
|
||||
* php7.0
|
||||
* php7.0-cli
|
||||
* apache2
|
||||
* php7.0-gd
|
||||
* php7.0-json
|
||||
* php7.0-mbstring
|
||||
* php7.0-xml
|
||||
* php7.0-xsl
|
||||
* php7.0-zip
|
||||
* php7.0-soap
|
||||
* php7.0-pear
|
||||
* php7.0-mcrypt
|
||||
* php7.0-curl
|
||||
* curl
|
||||
* libapacha2-mod-php
|
||||
* apt-transport-https
|
||||
* nano
|
||||
* lynx-cur
|
||||
* composer
|
||||
|
||||
## Exposed ports
|
||||
|
||||
80
|
||||
|
||||
## Exposed volumes
|
||||
|
||||
- webroot: `/var/www`
|
||||
|
||||
## Out of the box
|
||||
|
||||
* Ubuntu 16.04 LTS
|
||||
* Apache2
|
||||
* PHP7
|
||||
* Composer
|
||||
12
files/docker-image/config/apache/apache-virtual-hosts.conf
Normal file
12
files/docker-image/config/apache/apache-virtual-hosts.conf
Normal file
@ -0,0 +1,12 @@
|
||||
<VirtualHost *:80>
|
||||
RewriteEngine On
|
||||
DocumentRoot /var/www
|
||||
<Directory />
|
||||
Options +FollowSymLinks
|
||||
Options +SymLinksIfOwnerMatch
|
||||
AllowOverride All
|
||||
Order allow,deny
|
||||
AllowOverride All
|
||||
Allow from all
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
221
files/docker-image/config/apache/apache2.conf
Normal file
221
files/docker-image/config/apache/apache2.conf
Normal file
@ -0,0 +1,221 @@
|
||||
# This is the main Apache server configuration file. It contains the
|
||||
# configuration directives that give the server its instructions.
|
||||
# See http://httpd.apache.org/docs/2.4/ for detailed information about
|
||||
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
|
||||
# hints.
|
||||
#
|
||||
#
|
||||
# Summary of how the Apache 2 configuration works in Debian:
|
||||
# The Apache 2 web server configuration in Debian is quite different to
|
||||
# upstream's suggested way to configure the web server. This is because Debian's
|
||||
# default Apache2 installation attempts to make adding and removing modules,
|
||||
# virtual hosts, and extra configuration directives as flexible as possible, in
|
||||
# order to make automating the changes and administering the server as easy as
|
||||
# possible.
|
||||
|
||||
# It is split into several files forming the configuration hierarchy outlined
|
||||
# below, all located in the /etc/apache2/ directory:
|
||||
#
|
||||
# /etc/apache2/
|
||||
# |-- apache2.conf
|
||||
# | `-- ports.conf
|
||||
# |-- mods-enabled
|
||||
# | |-- *.load
|
||||
# | `-- *.conf
|
||||
# |-- conf-enabled
|
||||
# | `-- *.conf
|
||||
# `-- sites-enabled
|
||||
# `-- *.conf
|
||||
#
|
||||
#
|
||||
# * apache2.conf is the main configuration file (this file). It puts the pieces
|
||||
# together by including all remaining configuration files when starting up the
|
||||
# web server.
|
||||
#
|
||||
# * ports.conf is always included from the main configuration file. It is
|
||||
# supposed to determine listening ports for incoming connections which can be
|
||||
# customized anytime.
|
||||
#
|
||||
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
|
||||
# directories contain particular configuration snippets which manage modules,
|
||||
# global configuration fragments, or virtual host configurations,
|
||||
# respectively.
|
||||
#
|
||||
# They are activated by symlinking available configuration files from their
|
||||
# respective *-available/ counterparts. These should be managed by using our
|
||||
# helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
|
||||
# their respective man pages for detailed information.
|
||||
#
|
||||
# * The binary is called apache2. Due to the use of environment variables, in
|
||||
# the default configuration, apache2 needs to be started/stopped with
|
||||
# /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
|
||||
# work with the default configuration.
|
||||
|
||||
|
||||
# Global configuration
|
||||
#
|
||||
|
||||
#
|
||||
# ServerRoot: The top of the directory tree under which the server's
|
||||
# configuration, error, and log files are kept.
|
||||
#
|
||||
# NOTE! If you intend to place this on an NFS (or otherwise network)
|
||||
# mounted filesystem then please read the Mutex documentation (available
|
||||
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
|
||||
# you will save yourself a lot of trouble.
|
||||
#
|
||||
# Do NOT add a slash at the end of the directory path.
|
||||
#
|
||||
#ServerRoot "/etc/apache2"
|
||||
|
||||
#
|
||||
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
|
||||
#
|
||||
Mutex file:${APACHE_LOCK_DIR} default
|
||||
|
||||
#
|
||||
# PidFile: The file in which the server should record its process
|
||||
# identification number when it starts.
|
||||
# This needs to be set in /etc/apache2/envvars
|
||||
#
|
||||
PidFile ${APACHE_PID_FILE}
|
||||
|
||||
#
|
||||
# Timeout: The number of seconds before receives and sends time out.
|
||||
#
|
||||
Timeout 300
|
||||
|
||||
#
|
||||
# KeepAlive: Whether or not to allow persistent connections (more than
|
||||
# one request per connection). Set to "Off" to deactivate.
|
||||
#
|
||||
KeepAlive On
|
||||
|
||||
#
|
||||
# MaxKeepAliveRequests: The maximum number of requests to allow
|
||||
# during a persistent connection. Set to 0 to allow an unlimited amount.
|
||||
# We recommend you leave this number high, for maximum performance.
|
||||
#
|
||||
MaxKeepAliveRequests 100
|
||||
|
||||
#
|
||||
# KeepAliveTimeout: Number of seconds to wait for the next request from the
|
||||
# same client on the same connection.
|
||||
#
|
||||
KeepAliveTimeout 5
|
||||
|
||||
|
||||
# These need to be set in /etc/apache2/envvars
|
||||
User ${APACHE_RUN_USER}
|
||||
Group ${APACHE_RUN_GROUP}
|
||||
|
||||
#
|
||||
# HostnameLookups: Log the names of clients or just their IP addresses
|
||||
# e.g., www.apache.org (on) or 204.62.129.132 (off).
|
||||
# The default is off because it'd be overall better for the net if people
|
||||
# had to knowingly turn this feature on, since enabling it means that
|
||||
# each client request will result in AT LEAST one lookup request to the
|
||||
# nameserver.
|
||||
#
|
||||
HostnameLookups Off
|
||||
|
||||
# ErrorLog: The location of the error log file.
|
||||
# If you do not specify an ErrorLog directive within a <VirtualHost>
|
||||
# container, error messages relating to that virtual host will be
|
||||
# logged here. If you *do* define an error logfile for a <VirtualHost>
|
||||
# container, that host's errors will be logged there and not here.
|
||||
#
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
|
||||
#
|
||||
# LogLevel: Control the severity of messages logged to the error_log.
|
||||
# Available values: trace8, ..., trace1, debug, info, notice, warn,
|
||||
# error, crit, alert, emerg.
|
||||
# It is also possible to configure the log level for particular modules, e.g.
|
||||
# "LogLevel info ssl:warn"
|
||||
#
|
||||
LogLevel warn
|
||||
|
||||
# Include module configuration:
|
||||
IncludeOptional mods-enabled/*.load
|
||||
IncludeOptional mods-enabled/*.conf
|
||||
|
||||
# Include list of ports to listen on
|
||||
Include ports.conf
|
||||
|
||||
|
||||
# Sets the default security model of the Apache2 HTTPD server. It does
|
||||
# not allow access to the root filesystem outside of /usr/share and /var/www.
|
||||
# The former is used by web applications packaged in Debian,
|
||||
# the latter may be used for local directories served by the web server. If
|
||||
# your system is serving content from a sub-directory in /srv you must allow
|
||||
# access here, or in any related virtual host.
|
||||
<Directory />
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/share>
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
<Directory /var/www/>
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
#<Directory /srv/>
|
||||
# Options Indexes FollowSymLinks
|
||||
# AllowOverride None
|
||||
# Require all granted
|
||||
#</Directory>
|
||||
|
||||
|
||||
|
||||
|
||||
# AccessFileName: The name of the file to look for in each directory
|
||||
# for additional configuration directives. See also the AllowOverride
|
||||
# directive.
|
||||
#
|
||||
AccessFileName .htaccess
|
||||
|
||||
#
|
||||
# The following lines prevent .htaccess and .htpasswd files from being
|
||||
# viewed by Web clients.
|
||||
#
|
||||
<FilesMatch "^\.ht">
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
|
||||
|
||||
#
|
||||
# The following directives define some format nicknames for use with
|
||||
# a CustomLog directive.
|
||||
#
|
||||
# These deviate from the Common Log Format definitions in that they use %O
|
||||
# (the actual bytes sent including headers) instead of %b (the size of the
|
||||
# requested file), because the latter makes it impossible to detect partial
|
||||
# requests.
|
||||
#
|
||||
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
|
||||
# Use mod_remoteip instead.
|
||||
#
|
||||
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %O" common
|
||||
LogFormat "%{Referer}i -> %U" referer
|
||||
LogFormat "%{User-agent}i" agent
|
||||
|
||||
# Include of directories ignores editors' and dpkg's backup files,
|
||||
# see README.Debian for details.
|
||||
|
||||
# Include generic snippets of statements
|
||||
IncludeOptional conf-enabled/*.conf
|
||||
|
||||
# Include the virtual host configurations:
|
||||
IncludeOptional sites-enabled/*.conf
|
||||
|
||||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
|
||||
47
files/docker-image/config/apache/envvars
Normal file
47
files/docker-image/config/apache/envvars
Normal file
@ -0,0 +1,47 @@
|
||||
# envvars - default environment variables for apache2ctl
|
||||
|
||||
# this won't be correct after changing uid
|
||||
unset HOME
|
||||
|
||||
# for supporting multiple apache2 instances
|
||||
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
|
||||
SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
|
||||
else
|
||||
SUFFIX=
|
||||
fi
|
||||
|
||||
# Since there is no sane way to get the parsed apache2 config in scripts, some
|
||||
# settings are defined via environment variables and then used in apache2ctl,
|
||||
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
|
||||
export APACHE_RUN_USER=www-data
|
||||
export APACHE_RUN_GROUP=www-data
|
||||
# temporary state file location. This might be changed to /run in Wheezy+1
|
||||
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
|
||||
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
|
||||
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
|
||||
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
|
||||
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
|
||||
|
||||
## The locale used by some modules like mod_dav
|
||||
export LANG=C
|
||||
## Uncomment the following line to use the system default locale instead:
|
||||
#. /etc/default/locale
|
||||
|
||||
export LANG
|
||||
|
||||
## The command to get the status for 'apache2ctl status'.
|
||||
## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
|
||||
#export APACHE_LYNX='www-browser -dump'
|
||||
|
||||
## If you need a higher file descriptor limit, uncomment and adjust the
|
||||
## following line (default is 8192):
|
||||
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'
|
||||
|
||||
## If you would like to pass arguments to the web server, add them below
|
||||
## to the APACHE_ARGUMENTS environment.
|
||||
#export APACHE_ARGUMENTS=''
|
||||
|
||||
## Enable the debug mode for maintainer scripts.
|
||||
## This will produce a verbose output on package installations of web server modules and web application
|
||||
## installations which interact with Apache
|
||||
#export APACHE2_MAINTSCRIPT_DEBUG=1
|
||||
1
files/docker-image/config/apache/ports.conf
Normal file
1
files/docker-image/config/apache/ports.conf
Normal file
@ -0,0 +1 @@
|
||||
Listen 80
|
||||
1917
files/docker-image/config/php/php.conf
Normal file
1917
files/docker-image/config/php/php.conf
Normal file
File diff suppressed because it is too large
Load Diff
4
files/docker-image/init.sh
Normal file
4
files/docker-image/init.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /etc/apache2/envvars
|
||||
exec apache2 -D FOREGROUND
|
||||
4
files/docker/http-proxy.conf
Normal file
4
files/docker/http-proxy.conf
Normal file
@ -0,0 +1,4 @@
|
||||
[Service]
|
||||
Environment="HTTP_PROXY=http://proxy.ville-geneve.ch:8080"
|
||||
Environment="HTTPS_PROXY=http://proxy.ville-geneve.ch:8080"
|
||||
Environment="NO_PROXY=localhost,127.0.0.1,.ville-geneve.ch"
|
||||
14
files/httpd/http-www.conf
Normal file
14
files/httpd/http-www.conf
Normal file
@ -0,0 +1,14 @@
|
||||
# Default configuration
|
||||
<VirtualHost _default_:80>
|
||||
ServerName www.stage-ge.org
|
||||
ServerAlias www
|
||||
ServerAlias srv-stage.stage-ge.org
|
||||
ServerAlias srv-stage
|
||||
DocumentRoot /var/www/html/intranet
|
||||
<Directory /var/www/html/intranet>
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
ErrorLog /var/log/httpd/www-error.log
|
||||
CustomLog /var/log/httpd/www-access.log combined
|
||||
</VirtualHost>
|
||||
36
files/httpd/https-www.conf
Normal file
36
files/httpd/https-www.conf
Normal file
@ -0,0 +1,36 @@
|
||||
# Default configuration
|
||||
<VirtualHost _default_:443>
|
||||
ServerName www.stage-ge.org
|
||||
ServerAlias www
|
||||
ServerAlias srv-stage.stage-ge.org
|
||||
ServerAlias srv-stage
|
||||
DocumentRoot /var/www/html/intranet
|
||||
|
||||
<Directory /var/www/html/intranet>
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
ErrorLog /var/log/httpd/www-error.log
|
||||
CustomLog /var/log/httpd/www-access.log combined
|
||||
|
||||
## SSL
|
||||
|
||||
SSLEngine on
|
||||
SSLHonorCipherOrder on
|
||||
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
|
||||
SSLHonorCipherOrder on
|
||||
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4
|
||||
# Enable HTTP/2, if available
|
||||
Protocols h2 http/1.1
|
||||
# HTTP Strict Transport Security (mod_headers is required) (63072000 seconds)
|
||||
Header always set Strict-Transport-Security "max-age=63072000"
|
||||
|
||||
BrowserMatch "MSIE [2-5]" \
|
||||
nokeepalive ssl-unclean-shutdown \
|
||||
downgrade-1.0 force-response-1.0
|
||||
CustomLog logs/ssl_request_log \
|
||||
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
|
||||
SSLCertificateFile "/etc/pki/stage-ge/stage-ge.org.crt"
|
||||
SSLCertificateKeyFile "/etc/pki/stage-ge/stage-ge.org.key"
|
||||
SSLCertificateChainFile "/etc/pki/stage-ge/stageCA.crt"
|
||||
</VirtualHost>
|
||||
BIN
files/httpd/logo_26.png
Normal file
BIN
files/httpd/logo_26.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
3
files/httpd/phpinfo.php
Normal file
3
files/httpd/phpinfo.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
phpinfo();
|
||||
?>
|
||||
40
files/httpd/ssl.conf
Normal file
40
files/httpd/ssl.conf
Normal file
@ -0,0 +1,40 @@
|
||||
#
|
||||
# When we also provide SSL we have to listen to the
|
||||
# standard HTTPS port in addition.
|
||||
#
|
||||
Listen 443 https
|
||||
|
||||
##
|
||||
## SSL Global Context
|
||||
##
|
||||
## All SSL configuration in this context applies both to
|
||||
## the main server and all SSL-enabled virtual hosts.
|
||||
##
|
||||
|
||||
# Pass Phrase Dialog:
|
||||
# Configure the pass phrase gathering process.
|
||||
# The filtering dialog program (`builtin' is a internal
|
||||
# terminal dialog) has to provide the pass phrase on stdout.
|
||||
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
|
||||
|
||||
# Inter-Process Session Cache:
|
||||
# Configure the SSL Session Cache: First the mechanism
|
||||
# to use and second the expiring timeout (in seconds).
|
||||
SSLSessionCache shmcb:/run/httpd/sslcache(512000)
|
||||
SSLSessionCacheTimeout 300
|
||||
|
||||
#
|
||||
# Use "SSLCryptoDevice" to enable any supported hardware
|
||||
# accelerators. Use "openssl engine -v" to list supported
|
||||
# engine names. NOTE: If you enable an accelerator and the
|
||||
# server does not start, consult the error logs and ensure
|
||||
# your accelerator is functioning properly.
|
||||
#
|
||||
SSLCryptoDevice builtin
|
||||
#SSLCryptoDevice ubsec
|
||||
|
||||
##
|
||||
## SSL Virtual Host Context
|
||||
##
|
||||
|
||||
|
||||
23
files/httpd/vdg.css
Normal file
23
files/httpd/vdg.css
Normal file
@ -0,0 +1,23 @@
|
||||
body {
|
||||
font-family: verdana;
|
||||
}
|
||||
|
||||
h1 {
|
||||
/* font-size: 22px; */
|
||||
font-size: 16px;
|
||||
color: #4D5D86;
|
||||
}
|
||||
h2 {
|
||||
font-size: 12px;
|
||||
color: #4D5D86;
|
||||
}
|
||||
p {
|
||||
font-size: 12px;
|
||||
color: #4D5D86;
|
||||
}
|
||||
em {
|
||||
color: #A7001F;
|
||||
}
|
||||
div#content {
|
||||
font-size: 12px;
|
||||
}
|
||||
BIN
files/httpd/wlogo.gif
Normal file
BIN
files/httpd/wlogo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
34
files/lam/config.cfg
Normal file
34
files/lam/config.cfg
Normal file
@ -0,0 +1,34 @@
|
||||
password: {SSHA}D6AaX93kPmck9wAxNlq3GF93S7A= R7gkjQ==
|
||||
default: lam
|
||||
logLevel: 4
|
||||
logDestination: SYSLOG
|
||||
configDatabaseType: files
|
||||
configDatabaseServer: localhost
|
||||
configDatabasePort: 3306
|
||||
configDatabaseName: lam
|
||||
configDatabaseUser: lam
|
||||
configDatabasePassword: lam
|
||||
license:
|
||||
sessionTimeout: 30
|
||||
allowedHosts:
|
||||
allowedHostsSelfsystemd_service:
|
||||
encryptSession: true
|
||||
passwordMinLength: 0
|
||||
passwordMinUpper: 0
|
||||
passwordMinLower: 0
|
||||
passwordMinNumeric: 0
|
||||
passwordMinSymbol: 0
|
||||
passwordMinClasses: 0
|
||||
checkedRulesCount: -1
|
||||
passwordMustNotContain3Chars: false
|
||||
passwordMustNotContainUser: false
|
||||
externalPwdCheckUrl:
|
||||
errorReporting: default
|
||||
licenseEmailFrom:
|
||||
licenseEmailTo:
|
||||
licenseEmailDateSent:
|
||||
licenseWarningType:
|
||||
mailServer:
|
||||
mailUser:
|
||||
mailPassword:
|
||||
mailEncryption:
|
||||
44
files/lam/http-lam.conf
Normal file
44
files/lam/http-lam.conf
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
Alias /lam /usr/share/ldap-account-manager
|
||||
|
||||
<Directory /usr/share/ldap-account-manager>
|
||||
Options +FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
DirectoryIndex index.html
|
||||
</Directory>
|
||||
|
||||
<Directory /var/lib/ldap-account-manager/tmp>
|
||||
Options -Indexes
|
||||
</Directory>
|
||||
|
||||
<Directory /var/lib/ldap-account-manager/tmp/internal>
|
||||
Options -Indexes
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
<Directory /var/lib/ldap-account-manager/sess>
|
||||
Options -Indexes
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
<Directory /var/lib/ldap-account-manager/config>
|
||||
Options -Indexes
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/share/ldap-account-manager/lib>
|
||||
Options -Indexes
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/share/ldap-account-manager/help>
|
||||
Options -Indexes
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/share/ldap-account-manager/locale>
|
||||
Options -Indexes
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
147
files/lam/lam.conf
Normal file
147
files/lam/lam.conf
Normal file
@ -0,0 +1,147 @@
|
||||
|
||||
ServerURL: ldap://localhost:389
|
||||
|
||||
serverDisplayName:
|
||||
|
||||
useTLS: no
|
||||
|
||||
followReferrals: false
|
||||
|
||||
pagedResults: false
|
||||
|
||||
referentialIntegrityOverlay: false
|
||||
|
||||
hidePasswordPromptForExpiredPasswords: false
|
||||
|
||||
Passwd: lam
|
||||
|
||||
Admins: cn=Manager,dc=stage-ge,dc=org;cn=Admin LDAP,dc=stage-ge,dc=org;cn=Access LDAP,dc=stage-ge,dc=org
|
||||
|
||||
defaultLanguage: en_GB.utf8
|
||||
|
||||
timeZone: Europe/Zurich
|
||||
|
||||
scriptPath:
|
||||
|
||||
scriptServer:
|
||||
|
||||
scriptRights: 750
|
||||
|
||||
scriptUserName:
|
||||
|
||||
scriptSSHKey:
|
||||
|
||||
scriptSSHKeyPassword:
|
||||
|
||||
searchLimit: 0
|
||||
|
||||
activeTypes: user,group
|
||||
|
||||
accessLevel: 100
|
||||
|
||||
loginMethod: list
|
||||
|
||||
loginSearchSuffix: dc=yourdomain,dc=org
|
||||
|
||||
loginSearchFilter: uid=%USER%
|
||||
|
||||
loginSearchDN:
|
||||
|
||||
loginSearchPassword:
|
||||
|
||||
httpAuthentication: false
|
||||
|
||||
lamProMailFrom:
|
||||
|
||||
lamProMailReplyTo:
|
||||
|
||||
lamProMailSubject: Your password was reset
|
||||
|
||||
lamProMailIsHTML: false
|
||||
|
||||
lamProMailAllowAlternateAddress: true
|
||||
|
||||
lamProMailText: Dear @@givenName@@ @@sn@@,+::++::+your password was reset to: @@newPassword@@+::++::++::+Best regards+::++::+deskside support+::+
|
||||
|
||||
jobsBindPassword:
|
||||
|
||||
jobsBindUser:
|
||||
|
||||
jobsDatabase: SQLite
|
||||
|
||||
jobsDBHost:
|
||||
|
||||
jobsDBPort:
|
||||
|
||||
jobsDBUser:
|
||||
|
||||
jobsDBPassword:
|
||||
|
||||
jobsDBName:
|
||||
|
||||
jobToken: 608266336364
|
||||
|
||||
pwdResetAllowSpecificPassword: true
|
||||
|
||||
pwdResetAllowScreenPassword: true
|
||||
|
||||
pwdResetForcePasswordChange: true
|
||||
|
||||
pwdResetDefaultPasswordOutput: 2
|
||||
|
||||
twoFactorAuthentication: none
|
||||
|
||||
twoFactorAuthenticationURL: https://localhost
|
||||
|
||||
twoFactorAuthenticationClientId:
|
||||
|
||||
twoFactorAuthenticationSecretKey:
|
||||
|
||||
twoFactorAuthenticationDomain:
|
||||
|
||||
twoFactorAuthenticationInsecure:
|
||||
|
||||
twoFactorAuthenticationLabel:
|
||||
|
||||
twoFactorAuthenticationOptional:
|
||||
|
||||
twoFactorAuthenticationCaption:
|
||||
|
||||
twoFactorAuthenticationAttribute: uid
|
||||
|
||||
hideDnPart:
|
||||
modules: posixAccount_user_minUID: 10000
|
||||
modules: posixAccount_user_maxUID: 30000
|
||||
modules: posixAccount_host_minMachine: 50000
|
||||
modules: posixAccount_host_maxMachine: 60000
|
||||
modules: posixGroup_group_minGID: 10000
|
||||
modules: posixGroup_group_maxGID: 20000
|
||||
modules: posixAccount_user_uidGeneratorUsers: range
|
||||
modules: posixAccount_host_uidGeneratorUsers: range
|
||||
modules: posixAccount_group_gidGeneratorUsers: range
|
||||
modules: posixGroup_pwdHash: SSHA
|
||||
modules: posixAccount_pwdHash: SSHA
|
||||
types: suffix_user: dc=stage-ge,dc=org
|
||||
types: attr_user: #uid;#givenName;#sn;#uidNumber;#gidNumber
|
||||
types: modules_user: inetOrgPerson,posixAccount,shadowAccount
|
||||
types: suffix_group: ou=groups,dc=stage-ge,dc=org
|
||||
types: attr_group: #cn;#gidNumber;#memberUID;#description
|
||||
types: modules_group: posixGroup
|
||||
types: customLabel_user:
|
||||
types: filter_user:
|
||||
types: customLabel_group:
|
||||
types: filter_group:
|
||||
types: hidden_user:
|
||||
types: hidden_group:
|
||||
tools: treeViewSuffix: dc=stage-ge,dc=org
|
||||
tools: tool_hide_toolFileUpload: false
|
||||
tools: tool_hide_ImportExport: false
|
||||
tools: tool_hide_toolMultiEdit: false
|
||||
tools: tool_hide_toolOUEditor: false
|
||||
tools: tool_hide_toolPDFEditor: false
|
||||
tools: tool_hide_toolProfileEditor: false
|
||||
tools: tool_hide_toolSchemaBrowser: false
|
||||
tools: tool_hide_toolServerInformation: false
|
||||
tools: tool_hide_toolTests: false
|
||||
tools: tool_hide_TreeViewTool: false
|
||||
tools: tool_hide_toolWebauthn: false
|
||||
BIN
files/lam/ldap-account-manager-8.6-0.fedora.1.noarch.rpm
Normal file
BIN
files/lam/ldap-account-manager-8.6-0.fedora.1.noarch.rpm
Normal file
Binary file not shown.
16
files/ldap/base.ldif
Normal file
16
files/ldap/base.ldif
Normal file
@ -0,0 +1,16 @@
|
||||
dn: dc=stage-ge,dc=org
|
||||
objectClass: top
|
||||
objectClass: dcObject
|
||||
objectclass: organization
|
||||
o: Server Stage
|
||||
dc: stage-ge
|
||||
|
||||
# Création de l'ou people
|
||||
dn: ou=people,dc=stage-ge,dc=org
|
||||
objectClass: organizationalUnit
|
||||
ou: people
|
||||
|
||||
# Création de l'ou group
|
||||
dn: ou=groups,dc=stage-ge,dc=org
|
||||
objectClass: organizationalUnit
|
||||
ou: groups
|
||||
10
files/ldap/create-sudo-file.sh
Normal file
10
files/ldap/create-sudo-file.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
cat << 'EOL' > /etc/openldap/schema/sudo.ldif
|
||||
dn: cn=sudo,cn=schema,cn=config
|
||||
objectClass: olcSchemaConfig
|
||||
cn: sudo
|
||||
olcAttributeTypes: ( 1.3.6.1.4.1.15953.9.1.1 NAME 'sudoUser' DESC 'User(s) who may run sudo' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
olcAttributeTypes: ( 1.3.6.1.4.1.15953.9.1.2 NAME 'sudoHost' DESC 'Host(s) who may run sudo' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
olcAttributeTypes: ( 1.3.6.1.4.1.15953.9.1.3 NAME 'sudoCommand' DESC 'Command(s) to be executed by sudo' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
olcAttributeTypes: ( 1.3.6.1.4.1.15953.9.1.4 NAME 'sudoRunAs' DESC 'User(s) impersonated by sudo (deprecated)' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
||||
EOL
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user