diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..80df790 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +VERSION="1.1.4" diff --git a/scripts/install b/scripts/install index 9025b21..e97ce97 100644 --- a/scripts/install +++ b/scripts/install @@ -1,5 +1,7 @@ #!/bin/bash +source ./_common.sh + # Retrieve arguments domain=$1 path=$2 @@ -15,10 +17,13 @@ fi # Remove trailing "/" for next commands path=${path%/} +# Retrieve sources +wget -nv -O jappix.tar.gz https://github.com/jappix/jappix/archive/${VERSION}.tar.gz + # Copy files to the right place final_path=/var/www/jappix sudo mkdir -p $final_path -sudo cp -r ../source/* $final_path +sudo tar -C $final_path -xf jappix.tar.gz --strip-components 1 sudo cp ../conf/*.xml $final_path/store/conf/ # Set permissions to jappix directory diff --git a/scripts/upgrade b/scripts/upgrade index 6d2ec50..184e93e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,5 +1,7 @@ #!/bin/bash +source ./_common.sh + # Retrieve arguments domain=$(sudo yunohost app setting jappix domain) path=$(sudo yunohost app setting jappix path) @@ -15,14 +17,16 @@ then language="en" fi - # Remove trailing "/" for next commands path=${path%/} +# Retrieve sources +wget -nv -O jappix.tar.gz https://github.com/jappix/jappix/archive/${VERSION}.tar.gz + # Copy files to the right place final_path=/var/www/jappix sudo mkdir -p $final_path -sudo cp -r ../source/* $final_path +sudo tar -C $final_path -xf jappix.tar.gz --strip-components 1 sudo cp ../conf/*.xml $final_path/store/conf/ # Set permissions to jappix directory diff --git a/source/AUTHORS.md b/source/AUTHORS.md deleted file mode 100644 index d761d99..0000000 --- a/source/AUTHORS.md +++ /dev/null @@ -1,76 +0,0 @@ -Jappix Authors -============== - -Here are the Jappix contributors, who coded or translated the application: - - -Founders --------- - -* Valérian Saliou -* Julien Barrier - - -Organizations -------------- - -* PostPro (association) -* FrenchTouch Web Agency (company) - - -Developers ----------- - -* am0ur3ux -* Camaran -* Cyril "Kyriog" Glapa -* hunterjm -* LinkMauve -* Maranda -* Mathieui -* Olivier -* sim6 - - -Translators ------------ - -* allan -* Arsimael -* Belzeneph -* camaran -* Catdarko -* Cerritus -* chunzu -* ebraminio -* Eraser -* Finkregh -* GenghisKhan -* hamano -* JanCBorchardt -* jarda -* joeka -* kahpa -* kr2ysiek -* krohn -* Lenwe -* LinkMauve -* Liverbool -* lwj -* m1st -* Maime -* Maranda -* mbajur -* mentalo -* mkwm -* Natureshadow -* Och.Oyuka -* Otourly -* piotr.moskal -* pocamon -* quimi -* sahwar -* Valérian Saliou -* vitalyster -* zAchAry -* Zash diff --git a/source/CHANGELOG.md b/source/CHANGELOG.md deleted file mode 100644 index bbe9a13..0000000 --- a/source/CHANGELOG.md +++ /dev/null @@ -1,332 +0,0 @@ -Jappix Changelog -================ - -Here's the log of what has changed over the Jappix releases. - - -Primo, v1.1.2 (October 2014) ----------------------------- - - * XEP-0353: Jingle Message Initiation @valeriansaliou - * Fixes Jingle calls in Chrome 38+ @valeriansaliou - - -Primo, v1.1.1 (September 2014) ------------------------------- - - * Ignore empty XHTML-IM messages @eijebong, @valeriansaliou - * Fix a bug with message markers @valeriansaliou - - -Primo, v1.1.0 (June 2014) -------------------------- - - * XEP-0272: Multiparty Jingle (Muji) @valeriansaliou - * Prevent client crash on huge messages @valeriansaliou - * Beautified client code (JavaScript) @valeriansaliou - * Fix unavailable MUC rooms @emamirazavi - - -One, v1.0.7 (May 2014) ----------------------- - - * Fix BackLinks design @valeriansaliou - * Sort Jappix Mobile contacts alphabetically @valeriansaliou - * Display offline contacts in Jappix Mini @valeriansaliou - - -One, v1.0.6 (May 2014) ----------------------- - - * XEP-0308: Last Message Correction @valeriansaliou - * XEP-0333: Chat Markers @valeriansaliou - * XEP-0319: Last User Interaction into Presence @valeriansaliou - * XEP-0224: Attention @valeriansaliou - * XEP-0152: Reachability Addresses @valeriansaliou - * XEP-0334: Message Processing Hints @valeriansaliou - * Fix gateway contacts management @valeriansaliou - * Fix sounds in Jappix Mini @aryo, @valeriansaliou - - -One, v1.0.5 (May 2014) ----------------------- - - * Fix MUC bookmark shortcut button @valeriansaliou - * Fix HTML5 notifications in Firefox 22+ @valeriansaliou - * Fix server commands tool @valeriansaliou - * New translations added (Uzbek), and a few ones updated @nurkamol, @valeriansaliou - - -One, v1.0.4 (May 2014) ----------------------- - - * Fix update tool (on some environments) @valeriansaliou - * Fix MUC room join @maranda, @valeriansaliou - * Fix special chars in JIDs for Jappix Mini @dunger, @valeriansaliou - * Fix WebSocket session termination in JSJaC @sstrigler - * Enhance backend security (verify SSL certificates) @valeriansaliou - * Add assets client cache option @valeriansaliou - * Add SSO support to Jappix Mobile @valeriansaliou - - -One, v1.0.3 (March 2014) ------------------------- - - * Fix JSJaC packet register @valeriansaliou, @sstrigler - - -One, v1.0.2 (March 2014) ------------------------- - - * Fix IQ spoofing security issue @valeriansaliou, @sstrigler - * Better autocompletion @Nabellaleen - * Various bugfixes @Nabellaleen, @valeriansaliou - - -One, v1.0.1 (January 2014) --------------------------- - - * Change MAM namespace to a temporary one @maranda - * Fix broken Jappix Mini CSS loader in some cases @valeriansaliou - * Libs update @valeriansaliou - - -One, v1.0.0 (January 2014) --------------------------- - - * XEP-0166: Jingle @valeriansaliou - * XEP-0292: vCard4 Over XMPP @valeriansaliou - * XEP-0280: Message Carbons @valeriansaliou - * IE9, IE10, IE11 support @valeriansaliou - * Libs update @valeriansaliou - * Client code rewrite @valeriansaliou - * Directory tree re-organization @valeriansaliou - * Tested code (pass CSSLint, JSHint and PHPLint) @valeriansaliou - - -Nemesis Alpha 9, v0.9.9 (August 2013) -------------------------------------- - - * XEP-0313: Message Archive Management @valeriansaliou - * Drop support for Message Archiving (XEP-0136), outpaced by MAM (XEP-0313) @valeriansaliou - * Jappix Desktop performances improved (noticeable with big rosters) @valeriansaliou - * Fix Jappix Desktop avatar system, unable to cache avatars (thus increasing network load and delays) @valeriansaliou - * New translations added (Mongolian), and a few ones updated @valeriansaliou - - -Nemesis Alpha 8, v0.9.8 (May 2013) ----------------------------------- - - * RTL (Right-To-Left Languages) support @valeriansaliou - * Various bufixes @valeriansaliou - - -Nemesis Alpha 7, v0.9.7 (April 2013) ------------------------------------- - - * Fix overflow events in Mini @valeriansaliou - * Fix user info display bug with formatted text @valeriansaliou - * Jappix Me notification system @valeriansaliou - * Update JSJaC @valeriansaliou - * Update jQuery (v1.10.1) @valeriansaliou - - -Nemesis Alpha 6, v0.9.6 (April 2013) ------------------------------------- - - * Fix login with accented usernames @valeriansaliou - * WOFF Get API headers fixed @valeriansaliou - * Better Get API URL generator @valeriansaliou - * Fix broken Jappix Mini extraction script @valeriansaliou - * Show when user joins/exits MUC in Jappix Mini @valeriansaliou - - -Nemesis Alpha 5, v0.9.5 (March 2013) ------------------------------------- - - * Jappix Mini enhancements @valeriansaliou - * Fix Jappix over non-standard ports @valeriansaliou - * Locale detector improved @valeriansaliou - * Load more items on social channel scroll @valeriansaliou - * Fix a lot of English base language typos @valeriansaliou - * Support for XHTML microblog entries (Movim compatibility) @valeriansaliou - * Show Jappix Desktop on tablets (not mobile anymore) @valeriansaliou - * Option to disable Jappix Mini on mobile phones @valeriansaliou - * Fix broken MUC bookmarks retrieval @valeriansaliou - - -Nemesis Alpha 4, v0.9.4 (March 2013) ------------------------------------- - - * [SECURITY] Fix insafe HTML escaping @valeriansaliou - * PHP 5.4 compatibility @valeriansaliou - * Auto-populate microblog on connect @valeriansaliou - * Register API support for Metronome XMPPd @valeriansaliou - * Non-blocking PHP sessions @valeriansaliou - * Permissive geoloc selector in microblog @valeriansaliou - * Select priority more easily @valeriansaliou - * Compliancy with Atom specification (social inbox) @valeriansaliou - * Added project mirrors @valeriansaliou - - -Nemesis Alpha 3, v0.9.3 (February 2013) ---------------------------------------- - - * [SECURITY] More randomness in CAPTCHA @valeriansaliou - * Fix buggy roster filter with groups @valeriansaliou - * Add Piwik tracking feature (configurable in manager) @valeriansaliou - * Easy popup close by clicking away @valeriansaliou - * Fix cropped uploaded pictures @valeriansaliou - * Revert to old File Share API (which is far better) @valeriansaliou - * Fixes broken translations (strange UTF-8 chars due to bugged Gettext compiler) @valeriansaliou - - -Nemesis Alpha 2, v0.9.2 (January 2013) --------------------------------------- - - * [SECURITY] Introduce the Register API (prevents register flood by spam bots) @valeriansaliou - * Reworked Storage API @valeriansaliou - * Jappix Mini code beautify @valeriansaliou - * Lighter and Web-safe font files @valeriansaliou - * Better error logging @valeriansaliou - * Fix Openfire ping request @valeriansaliou - * Typing notification in Jappix Mini @valeriansaliou - * Support for WebKit notifications @valeriansaliou - * Jappix Mini groupchat suggest @valeriansaliou - * Enhanced Download API @valeriansaliou - * Mini animated chat icon, much sexier @valeriansaliou - * IE custom font compatibility @valeriansaliou - * Legal changes @valeriansaliou - * Update licensing with real names @valeriansaliou - - -Nemesis Alpha 1, v0.9.1 (2012) ------------------------------- - - * Show an 'add to home' button on iOS devices @camaran - * Ability to suspend statistics @valeriansaliou - * Fix IE9 issue with clustering @valeriansaliou - * Show profile button in user search results @valeriansaliou - * Ability to change message font, font size and color @valeriansaliou - * Fix choppy Jappix Mini status picker @valeriansaliou - * Sounds for Safari & IE9 @valeriansaliou - * Enhance new file storage functions @valeriansaliou - * No resize for textareas @valeriansaliou - * Add a configurable legal disclaimer @valeriansaliou - * Fix a loop bug on presence if no support for sessionStorage @valeriansaliou - * Universal fonts @valeriansaliou - * Add ability to configure the node owner name & website @valeriansaliou - * HTTP authentication for LDAP @valeriansaliou - * Better notification + comments management @valeriansaliou - - -Spaco, v0.9 (2011) ------------------- - - * [SECURITY] Fix when sending files to a contact @valeriansaliou - * Better Jappix Mini performances @valeriansaliou - * Fix Jappix Mini display issues @valeriansaliou - * Connection issue fixed with BOSH API @valeriansaliou - * Open XMPP links when Jappix is ready @valeriansaliou - - -Suno, v0.8 (2011) ---------------------- - - * XEP-0066: Out of Band Data @valeriansaliou - * Switch from OpenStreetMap to Google Maps for geolocation @valeriansaliou - - -Stelo, v0.7 (2011) ------------------- - - * Lighter Jappix Mini @valeriansaliou - * Welcome popup @valeriansaliou - * Support for /me command in Jappix Mini @valeriansaliou - * Fixes in social channel @valeriansaliou - * Bigger BOSH poll interval (avoids some overactivity errors) @valeriansaliou - * Compression disabled by default in Get API @valeriansaliou - * Send chatstates in MUC @valeriansaliou - * Social notification inbox @valeriansaliou - - -Lumo, v0.6 (2011) ------------------ - - * Smoother Mini animation @valeriansaliou - * Show avatars in social channel comments @valeriansaliou - * Legacy mode for microblog comments @valeriansaliou - * Microblog updated to comply with a new version of XEP-0277 @valeriansaliou - * Fix DNS SRV issue because of a 'route' attribute on BOSH initiation @valeriansaliou - - -Ribelo, v0.5 (2011) -------------------- - - * Add support for comments in microblog @valeriansaliou - * Jappix Mini fixes and improvements @valeriansaliou - - -Lupo, v0.4 (2011) ------------------ - - * Full IE5.5 compatibility for Jappix Mini @valeriansaliou - * BOSH without cURL (if cURL unavailable) @valeriansaliou - * Handle multiple microblog attached files @valeriansaliou - * Microblog attached files thumbnails @valeriansaliou - * BOM (Byte Order Mark) filtering for Get API @valeriansaliou - * Autoplay for new YouTube HTML5 player @valeriansaliou - * Support for privacy lists pushs @valeriansaliou - * Roster-side privacy lists (make contact blocking/unblocking easy) @valeriansaliou - * Better update checker @valeriansaliou - * XEP-0144: Roster Item Exchange @valeriansaliou - * Cross domain support for Internet Explorer and legacy browsers @valeriansaliou - * Update jQuery (v1.4.4) @valeriansaliou - * TZO fix (for negative timezones, e.g.: UTC-5) @valeriansaliou - * Better language detection @valeriansaliou - * Use HTML5 or Flash for YouTube embedded videos @valeriansaliou - - -Prism, v0.3 (2011) ------------------- - - * [SECURITY] Fix JS escape bug for quotes @valeriansaliou - * [SECURITY] HTML-encode notification username @valeriansaliou - * Introduction of Jappix Mini @valeriansaliou - * Introduction of Jappix Manager @valeriansaliou - * Introduction of Jappix Install @valeriansaliou - * XEP-0050: Ad-Hoc Commands @valeriansaliou - * XEP-0136: Message Archiving @valeriansaliou - * Update Jappix logo @valeriansaliou - * Declare application language to XMPP server @valeriansaliou - * Add a buddy search tool @valeriansaliou - * Support for old/legacy vCard server implementations @valeriansaliou - * Inbox messages sorted by date @valeriansaliou - * Better music search @valeriansaliou - * Human-readable geolocation @valeriansaliou - * Gateway show/hide @valeriansaliou - * HTML5 forms @valeriansaliou - * Better notification management @valeriansaliou - * Unified chat design @valeriansaliou - * Dynamic DOM load (better performances) @valeriansaliou - * Jappix logo shown when connected (improves branding) @valeriansaliou - - -Lidar, v0.2 (2010) ------------------- - - * Introduction of Jappix Mobile @valeriansaliou - * UI redesign (from grey to black and blue) @valeriansaliou - * Social channel introduced (microblog) @valeriansaliou - - -Genesis, v0.1 (2010) --------------------- - - * Initial version, released after private beta @valeriansaliou - * Introduction of Jappix Desktop @valeriansaliou - * Basic chat, groupchat, roster and profile features @valeriansaliou - * Basic UI @valeriansaliou - - -**For more information about what changed through time, check the changes made to our source code on GitHub: https://github.com/jappix/jappix/commits/master** diff --git a/source/COPYING.md b/source/COPYING.md deleted file mode 100644 index 7fc56b5..0000000 --- a/source/COPYING.md +++ /dev/null @@ -1,666 +0,0 @@ -Jappix Copying -============== - - - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license - for software and other kinds of works, specifically designed to ensure - cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are - designed to take away your freedom to share and change the works. By - contrast, our General Public Licenses are intended to guarantee your - freedom to share and change all versions of a program--to make sure it - remains free software for all its users. - - When we speak of free software, we are referring to freedom, not - price. Our General Public Licenses are designed to make sure that you - have the freedom to distribute copies of free software (and charge for - them if you wish), that you receive source code or can get it if you - want it, that you can change the software or use pieces of it in new - free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights - with two steps: (1) assert copyright on the software, and (2) offer - you this License which gives you legal permission to copy, distribute - and/or modify the software. - - A secondary benefit of defending all users' freedom is that - improvements made in alternate versions of the program, if they - receive widespread use, become available for other developers to - incorporate. Many developers of free software are heartened and - encouraged by the resulting cooperation. However, in the case of - software used on network servers, this result may fail to come about. - The GNU General Public License permits making a modified version and - letting the public access it on a server without ever releasing its - source code to the public. - - The GNU Affero General Public License is designed specifically to - ensure that, in such cases, the modified source code becomes available - to the community. It requires the operator of a network server to - provide the source code of the modified version running there to the - users of that server. Therefore, public use of a modified version, on - a publicly accessible server, gives the public access to the source - code of the modified version. - - An older license, called the Affero General Public License and - published by Affero, was designed to accomplish similar goals. This is - a different license, not a version of the Affero GPL, but Affero has - released a new version of the Affero GPL which permits relicensing under - this license. - - The precise terms and conditions for copying, distribution and - modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public - License. - - "Copyright" also means copyright-like laws that apply to other kinds - of works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this - License. Each licensee is addressed as "you". "Licensees" and - "recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work - in a fashion requiring copyright permission, other than the making of an - exact copy. The resulting work is called a "modified version" of the - earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based - on the Program. - - To "propagate" a work means to do anything with it that, without - permission, would make you directly or secondarily liable for - infringement under applicable copyright law, except executing it on a - computer or modifying a private copy. Propagation includes copying, - distribution (with or without modification), making available to the - public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other - parties to make or receive copies. Mere interaction with a user through - a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" - to the extent that it includes a convenient and prominently visible - feature that (1) displays an appropriate copyright notice, and (2) - tells the user that there is no warranty for the work (except to the - extent that warranties are provided), that licensees may convey the - work under this License, and how to view a copy of this License. If - the interface presents a list of user commands or options, such as a - menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work - for making modifications to it. "Object code" means any non-source - form of a work. - - A "Standard Interface" means an interface that either is an official - standard defined by a recognized standards body, or, in the case of - interfaces specified for a particular programming language, one that - is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other - than the work as a whole, that (a) is included in the normal form of - packaging a Major Component, but which is not part of that Major - Component, and (b) serves only to enable use of the work with that - Major Component, or to implement a Standard Interface for which an - implementation is available to the public in source code form. A - "Major Component", in this context, means a major essential component - (kernel, window system, and so on) of the specific operating system - (if any) on which the executable work runs, or a compiler used to - produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all - the source code needed to generate, install, and (for an executable - work) run the object code and to modify the work, including scripts to - control those activities. However, it does not include the work's - System Libraries, or general-purpose tools or generally available free - programs which are used unmodified in performing those activities but - which are not part of the work. For example, Corresponding Source - includes interface definition files associated with source files for - the work, and the source code for shared libraries and dynamically - linked subprograms that the work is specifically designed to require, - such as by intimate data communication or control flow between those - subprograms and other parts of the work. - - The Corresponding Source need not include anything that users - can regenerate automatically from other parts of the Corresponding - Source. - - The Corresponding Source for a work in source code form is that - same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of - copyright on the Program, and are irrevocable provided the stated - conditions are met. This License explicitly affirms your unlimited - permission to run the unmodified Program. The output from running a - covered work is covered by this License only if the output, given its - content, constitutes a covered work. This License acknowledges your - rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not - convey, without conditions so long as your license otherwise remains - in force. You may convey covered works to others for the sole purpose - of having them make modifications exclusively for you, or provide you - with facilities for running those works, provided that you comply with - the terms of this License in conveying all material for which you do - not control copyright. Those thus making or running the covered works - for you must do so exclusively on your behalf, under your direction - and control, on terms that prohibit them from making any copies of - your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under - the conditions stated below. Sublicensing is not allowed; section 10 - makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological - measure under any applicable law fulfilling obligations under article - 11 of the WIPO copyright treaty adopted on 20 December 1996, or - similar laws prohibiting or restricting circumvention of such - measures. - - When you convey a covered work, you waive any legal power to forbid - circumvention of technological measures to the extent such circumvention - is effected by exercising rights under this License with respect to - the covered work, and you disclaim any intention to limit operation or - modification of the work as a means of enforcing, against the work's - users, your or third parties' legal rights to forbid circumvention of - technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you - receive it, in any medium, provided that you conspicuously and - appropriately publish on each copy an appropriate copyright notice; - keep intact all notices stating that this License and any - non-permissive terms added in accord with section 7 apply to the code; - keep intact all notices of the absence of any warranty; and give all - recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, - and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to - produce it from the Program, in the form of source code under the - terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent - works, which are not by their nature extensions of the covered work, - and which are not combined with it such as to form a larger program, - in or on a volume of a storage or distribution medium, is called an - "aggregate" if the compilation and its resulting copyright are not - used to limit the access or legal rights of the compilation's users - beyond what the individual works permit. Inclusion of a covered work - in an aggregate does not cause this License to apply to the other - parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms - of sections 4 and 5, provided that you also convey the - machine-readable Corresponding Source under the terms of this License, - in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded - from the Corresponding Source as a System Library, need not be - included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any - tangible personal property which is normally used for personal, family, - or household purposes, or (2) anything designed or sold for incorporation - into a dwelling. In determining whether a product is a consumer product, - doubtful cases shall be resolved in favor of coverage. For a particular - product received by a particular user, "normally used" refers to a - typical or common use of that class of product, regardless of the status - of the particular user or of the way in which the particular user - actually uses, or expects or is expected to use, the product. A product - is a consumer product regardless of whether the product has substantial - commercial, industrial or non-consumer uses, unless such uses represent - the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, - procedures, authorization keys, or other information required to install - and execute modified versions of a covered work in that User Product from - a modified version of its Corresponding Source. The information must - suffice to ensure that the continued functioning of the modified object - code is in no case prevented or interfered with solely because - modification has been made. - - If you convey an object code work under this section in, or with, or - specifically for use in, a User Product, and the conveying occurs as - part of a transaction in which the right of possession and use of the - User Product is transferred to the recipient in perpetuity or for a - fixed term (regardless of how the transaction is characterized), the - Corresponding Source conveyed under this section must be accompanied - by the Installation Information. But this requirement does not apply - if neither you nor any third party retains the ability to install - modified object code on the User Product (for example, the work has - been installed in ROM). - - The requirement to provide Installation Information does not include a - requirement to continue to provide support service, warranty, or updates - for a work that has been modified or installed by the recipient, or for - the User Product in which it has been modified or installed. Access to a - network may be denied when the modification itself materially and - adversely affects the operation of the network or violates the rules and - protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, - in accord with this section must be in a format that is publicly - documented (and with an implementation available to the public in - source code form), and must require no special password or key for - unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this - License by making exceptions from one or more of its conditions. - Additional permissions that are applicable to the entire Program shall - be treated as though they were included in this License, to the extent - that they are valid under applicable law. If additional permissions - apply only to part of the Program, that part may be used separately - under those permissions, but the entire Program remains governed by - this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option - remove any additional permissions from that copy, or from any part of - it. (Additional permissions may be written to require their own - removal in certain cases when you modify the work.) You may place - additional permissions on material, added by you to a covered work, - for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you - add to a covered work, you may (if authorized by the copyright holders of - that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further - restrictions" within the meaning of section 10. If the Program as you - received it, or any part of it, contains a notice stating that it is - governed by this License along with a term that is a further restriction, - you may remove that term. If a license document contains a further - restriction but permits relicensing or conveying under this License, you - may add to a covered work material governed by the terms of that license - document, provided that the further restriction does not survive such - relicensing or conveying. - - If you add terms to a covered work in accord with this section, you - must place, in the relevant source files, a statement of the - additional terms that apply to those files, or a notice indicating - where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the - form of a separately written license, or stated as exceptions; - the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly - provided under this License. Any attempt otherwise to propagate or - modify it is void, and will automatically terminate your rights under - this License (including any patent licenses granted under the third - paragraph of section 11). - - However, if you cease all violation of this License, then your - license from a particular copyright holder is reinstated (a) - provisionally, unless and until the copyright holder explicitly and - finally terminates your license, and (b) permanently, if the copyright - holder fails to notify you of the violation by some reasonable means - prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is - reinstated permanently if the copyright holder notifies you of the - violation by some reasonable means, this is the first time you have - received notice of violation of this License (for any work) from that - copyright holder, and you cure the violation prior to 30 days after - your receipt of the notice. - - Termination of your rights under this section does not terminate the - licenses of parties who have received copies or rights from you under - this License. If your rights have been terminated and not permanently - reinstated, you do not qualify to receive new licenses for the same - material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or - run a copy of the Program. Ancillary propagation of a covered work - occurring solely as a consequence of using peer-to-peer transmission - to receive a copy likewise does not require acceptance. However, - nothing other than this License grants you permission to propagate or - modify any covered work. These actions infringe copyright if you do - not accept this License. Therefore, by modifying or propagating a - covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically - receives a license from the original licensors, to run, modify and - propagate that work, subject to this License. You are not responsible - for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an - organization, or substantially all assets of one, or subdividing an - organization, or merging organizations. If propagation of a covered - work results from an entity transaction, each party to that - transaction who receives a copy of the work also receives whatever - licenses to the work the party's predecessor in interest had or could - give under the previous paragraph, plus a right to possession of the - Corresponding Source of the work from the predecessor in interest, if - the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the - rights granted or affirmed under this License. For example, you may - not impose a license fee, royalty, or other charge for exercise of - rights granted under this License, and you may not initiate litigation - (including a cross-claim or counterclaim in a lawsuit) alleging that - any patent claim is infringed by making, using, selling, offering for - sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this - License of the Program or a work on which the Program is based. The - work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims - owned or controlled by the contributor, whether already acquired or - hereafter acquired, that would be infringed by some manner, permitted - by this License, of making, using, or selling its contributor version, - but do not include claims that would be infringed only as a - consequence of further modification of the contributor version. For - purposes of this definition, "control" includes the right to grant - patent sublicenses in a manner consistent with the requirements of - this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free - patent license under the contributor's essential patent claims, to - make, use, sell, offer for sale, import and otherwise run, modify and - propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express - agreement or commitment, however denominated, not to enforce a patent - (such as an express permission to practice a patent or covenant not to - sue for patent infringement). To "grant" such a patent license to a - party means to make such an agreement or commitment not to enforce a - patent against the party. - - If you convey a covered work, knowingly relying on a patent license, - and the Corresponding Source of the work is not available for anyone - to copy, free of charge and under the terms of this License, through a - publicly available network server or other readily accessible means, - then you must either (1) cause the Corresponding Source to be so - available, or (2) arrange to deprive yourself of the benefit of the - patent license for this particular work, or (3) arrange, in a manner - consistent with the requirements of this License, to extend the patent - license to downstream recipients. "Knowingly relying" means you have - actual knowledge that, but for the patent license, your conveying the - covered work in a country, or your recipient's use of the covered work - in a country, would infringe one or more identifiable patents in that - country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or - arrangement, you convey, or propagate by procuring conveyance of, a - covered work, and grant a patent license to some of the parties - receiving the covered work authorizing them to use, propagate, modify - or convey a specific copy of the covered work, then the patent license - you grant is automatically extended to all recipients of the covered - work and works based on it. - - A patent license is "discriminatory" if it does not include within - the scope of its coverage, prohibits the exercise of, or is - conditioned on the non-exercise of one or more of the rights that are - specifically granted under this License. You may not convey a covered - work if you are a party to an arrangement with a third party that is - in the business of distributing software, under which you make payment - to the third party based on the extent of your activity of conveying - the work, and under which the third party grants, to any of the - parties who would receive the covered work from you, a discriminatory - patent license (a) in connection with copies of the covered work - conveyed by you (or copies made from those copies), or (b) primarily - for and in connection with specific products or compilations that - contain the covered work, unless you entered into that arrangement, - or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting - any implied license or other defenses to infringement that may - otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or - otherwise) that contradict the conditions of this License, they do not - excuse you from the conditions of this License. If you cannot convey a - covered work so as to satisfy simultaneously your obligations under this - License and any other pertinent obligations, then as a consequence you may - not convey it at all. For example, if you agree to terms that obligate you - to collect a royalty for further conveying from those to whom you convey - the Program, the only way you could satisfy both those terms and this - License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the - Program, your modified version must prominently offer all users - interacting with it remotely through a computer network (if your version - supports such interaction) an opportunity to receive the Corresponding - Source of your version by providing access to the Corresponding Source - from a network server at no charge, through some standard or customary - means of facilitating copying of software. This Corresponding Source - shall include the Corresponding Source for any work covered by version 3 - of the GNU General Public License that is incorporated pursuant to the - following paragraph. - - Notwithstanding any other provision of this License, you have permission - to link or combine any covered work with a work licensed under version 3 - of the GNU General Public License into a single combined work, and to - convey the resulting work. The terms of this License will continue to - apply to the part which is the covered work, but the work with which it is - combined will remain governed by version 3 of the GNU General Public - License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of - the GNU Affero General Public License from time to time. Such new - versions will be similar in spirit to the present version, but may differ - in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the - Program specifies that a certain numbered version of the GNU Affero - General Public License "or any later version" applies to it, you have - the option of following the terms and conditions either of that - numbered version or of any later version published by the Free - Software Foundation. If the Program does not specify a version number - of the GNU Affero General Public License, you may choose any version - ever published by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future - versions of the GNU Affero General Public License can be used, that - proxy's public statement of acceptance of a version permanently - authorizes you to choose that version for the Program. - - Later license versions may give you additional or different - permissions. However, no additional obligations are imposed on any - author or copyright holder as a result of your choosing to follow a - later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY - APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT - HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY - OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, - THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM - IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF - ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING - WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS - THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY - GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE - USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF - DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD - PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), - EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF - SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided - above cannot be given local legal effect according to their terms, - reviewing courts shall apply local law that most closely approximates - an absolute waiver of all civil liability in connection with the - Program, unless a warranty or assumption of liability accompanies a - copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest - possible use to the public, the best way to achieve this is to make it - free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest - to attach them to the start of each source file to most effectively - state the exclusion of warranty; and each file should have at least - the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - - Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer - network, you should also make sure that it provides a way for users to - get its source. For example, if your program is a web application, its - interface could display a "Source" link that leads users to an archive - of the code. There are many ways you could offer source, and different - solutions will be better for different programs; see section 13 for the - specific requirements. - - You should also get your employer (if you work as a programmer) or school, - if any, to sign a "copyright disclaimer" for the program, if necessary. - For more information on this, and how to apply and follow the GNU AGPL, see - . diff --git a/source/COPYING_FONT.md b/source/COPYING_FONT.md deleted file mode 100644 index eb6a6e0..0000000 --- a/source/COPYING_FONT.md +++ /dev/null @@ -1,40 +0,0 @@ -Jappix Font Copying -=================== - -_Copyright © 2009 ParaType Ltd._ -_with Reserved Names "PT Sans" and "ParaType"._ - - -Font License ------------- - -Permission & Conditions ------------------------ - -Permission is hereby granted, free of charge, to any person obtaining a copy of the font software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the font software, subject to the following conditions: - -1. Neither the font software nor any of its individual components, in original or modified versions, may be sold by itself. - -2. Original or modified versions of the font software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. - -3. No modified version of the font software may use the Reserved Name(s) or combinations of Reserved Names with other words unless explicit written permission is granted by the ParaType. This restriction only applies to the primary font name as presented to the users. - -4. The name of ParaType or the author(s) of the font software shall not be used to promote, endorse or advertise any modified version, except to acknowledge the contribution(s) of ParaType and the author(s) or with explicit written permission of ParaType. - -5. The font software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. - - -Termination & Territory ------------------------ - -This license has no limits on time and territory, but it becomes null and void if any of the above conditions are not met. - - -Disclaimer ----------- - -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL PARATYPE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. - - -**ParaType Ltd** -**http://www.paratype.ru** diff --git a/source/COPYING_MINI.md b/source/COPYING_MINI.md deleted file mode 100644 index c8168c4..0000000 --- a/source/COPYING_MINI.md +++ /dev/null @@ -1,26 +0,0 @@ -Jappix Mini Copying -=================== - -Code ----- - -The following notice applies to the files which state that they are dual- -licensed under the MPL: - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - - -Artwork -------- - -The files img/sprites/mini.png and img/sprites/mini.gif were created by -Valérian Saliou and are dual-licensed under the Creative Commons Attribution 2.5 -License and the Creative Commons Attribution 3.0 License. - -They contain work from the FamFamFam Silk icon set by Mark James. - -* http://famfamfam.com/lab/icons/silk/ -* http://creativecommons.org/licenses/by/2.5/ -* http://creativecommons.org/licenses/by/3.0/ diff --git a/source/INSTALL.md b/source/INSTALL.md deleted file mode 100644 index 8708161..0000000 --- a/source/INSTALL.md +++ /dev/null @@ -1,21 +0,0 @@ -Jappix Installation -=================== - -It's very simple to install Jappix on your webserver, you just have to follow these things: - - -Installation ------------- - -* The HTTP server: https://github.com/jappix/jappix/wiki/HttpServer -* The XMPP server: https://github.com/jappix/jappix/wiki/XmppServer -* The BOSH server: https://github.com/jappix/jappix/wiki/BoshServer -* The Jappix app : https://github.com/jappix/jappix/wiki/JappixApp - -More ----- - -* The whole documentation is available at: https://github.com/jappix/jappix/wiki - - -Now, you can use Jappix. Happy socializing! diff --git a/source/PROTOCOL.md b/source/PROTOCOL.md deleted file mode 100644 index 846dfb1..0000000 --- a/source/PROTOCOL.md +++ /dev/null @@ -1,88 +0,0 @@ -Jappix Protocol Support -======================= - -Here are listed the XMPP Protocol Extensions that Jappix supports, as well as their implementation version. - - -# XMPP Core - - * RFC-6120: Extensible Messaging and Presence Protocol (XMPP): Core - * RFC-6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence - * RFC-6122: Extensible Messaging and Presence Protocol (XMPP): Address Format - - -# XMPP Extensions (Standardized) - - * XEP-0004: Data Forms *v2.9* - * XEP-0012: Last Activity *v2.0* - * XEP-0016: Privacy Lists *v1.6* - * XEP-0030: Service Discovery *v2.4* - * XEP-0045: Multi-User Chat *v1.25* - * XEP-0049: Private XML Storage *v1.2* - * XEP-0050: Ad-Hoc Commands *v1.2* - * XEP-0054: vcard-temp *v1.2* - * XEP-0055: Jabber Search *v1.3* - * XEP-0060: Publish-Subscribe *v1.13* - * XEP-0066: Out of Band Data *v1.5* - * XEP-0071: XHTML-IM *v1.5* - * XEP-0072: SOAP Over XMPP *v1.0* - * XEP-0077: In-Band Registration *v2.4* - * XEP-0080: User Location *v1.7* - * XEP-0084: User Avatar *v1.1* - * XEP-0085: Chat State Notifications *v2.1* - * XEP-0092: Software Version *v1.1* - * XEP-0107: User Mood *v1.2* - * XEP-0108: User Activity *v1.3* - * XEP-0115: Entity Capabilities *v1.5* - * XEP-0118: User Tune *v1.2* - * XEP-0124: Bidirectional-streams Over Synchronous HTTP (BOSH) *v1.10* - * XEP-0144: Roster Item Exchange *v1.0* - * XEP-0152: Reachability Addresses *v1.0* - * XEP-0166: Jingle *v1.1* - * XEP-0167: Jingle RTP Sessions *v1.1* - * XEP-0172: User Nickname *v1.1* - * XEP-0176: Jingle ICE-UDP Transport Method *v1.0* - * XEP-0177: Jingle Raw UDP Transport Method *v1.1* - * XEP-0184: Message Delivery Receipts *v1.2* - * XEP-0199: XMPP Ping *v2.0* - * XEP-0202: Entity Time *v2.0* - * XEP-0203: Delayed Delivery *v2.0* - * XEP-0224: Attention *v1.0* - * XEP-0215: External Service Discovery *v0.5* - * XEP-0249: Direct MUC Invitations *v1.2* - * XEP-0262: Use of ZRTP in Jingle RTP Sessions *v1.0* - * XEP-0266: Codecs for Jingle Audio *v1.0* - * XEP-0269: Jingle Early Media *v0.1* - * XEP-0277: Microblogging over XMPP *v0.6* - * XEP-0278: Jingle Relay Nodes *v0.2* - * XEP-0280: Message Carbons *v0.9* - * XEP-0292: vCard4 Over XMPP *v0.10* - * XEP-0293: Jingle RTP Feedback Negotiation *v0.1* - * XEP-0294: Jingle RTP Header Extensions Negotiation *v0.1* - * XEP-0299: Codecs for Jingle Video *v0.1* - * XEP-0308: Last Message Correction *v1.0* - * XEP-0319: Last User Interaction in Presence *v0.2* - * XEP-0320: Use of DTLS-SRTP in Jingle Sessions *v0.2* - * XEP-0333: Chat Markers *v0.2* - * XEP-0334: Message Processing Hints *v0.1* - * XEP-0338: Jingle Grouping Framework *v0.1* - * XEP-0339: Source-Specific Media Attributes in Jingle *v0.1* - * XEP-0353: Jingle Message Initiation *v0.1* - - -# XMPP Extensions (Updated) - - * XEP-0272: Multiparty Jingle (Muji) *v0.2* - * Alternate URL: https://demo.hakuma.holdings/valerian.saliou/xmpp/extensions/xep-0272.html - * XEP-0313: Message Archive Management *v0.3* - * Alternate URL: https://demo.hakuma.holdings/valerian.saliou/xmpp/extensions/xep-0313.html - - -# XMPP Extensions (Proposed) - * XEP-xxxx: Notification Inbox *v0.1* - * Alternate URL: http://xmpp.org/extensions/inbox/notification-inbox.html - - -# Others - - * RFC-3264: An Offer/Answer Model with Session Description Protocol (SDP) diff --git a/source/README.md b/source/README.md deleted file mode 100644 index 8413ee0..0000000 --- a/source/README.md +++ /dev/null @@ -1,73 +0,0 @@ -Jappix - - -Jappix is a fresh new open social platform which enables you to create your own cloud, wherever you want to. People must be able to get in touch with all their friends on a free decentralized network! - -You can build your own Jappix installation for your own requirements: if you want to use it as a personal social client, you can download it and put it on your webserver. It's easy, fast and free. - - -[![build status](https://ci.hakuma.holdings/projects/7/status.png?ref=master)](https://ci.hakuma.holdings/projects/7?ref=master) - - -License -------- - -Jappix is released under the terms of the AGPL license. See COPYING for details. - - -Installation ------------- - -Please refer to the installation instructions that are located in the INSTALL file to process the Jappix installation. - - -Translations ------------- - -Help us translate Jappix and get Jappix in your language! - -Start translating on https://www.transifex.com/projects/p/jappix/ (new translators are automatically approved when they join a translation team). - - -Links ------ - -* Jappix project website: https://jappix.org/ -* Jappix project dev panel: https://github.com/jappix/jappix -* Jappix nodes list: https://jappix.net/ -* Jappix main service: https://jappix.com/ -* Jappix commercial support: https://jappix.pro/ - - -Mirrors -------- - -In case a master service is down (GitHub for Git access or Jappix.org for project download), here is a list of available mirrors: - -* Project website mirror: https://project.jappix.com/ -* Development repository mirror: https://code.hakuma.holdings/jappix/jappix - - -MUC Links ---------- - -* Jappix.org support room: https://jappix.com/?r=support@muc.jappix.org -* Jappix.org dev-talk room: https://jappix.com/?r=dev@muc.jappix.org - - -Social networking ------------------ - -We're social and you can join us on: - -* Twitter: https://twitter.com/jappixorg -* Facebook: https://www.facebook.com/jappix -* Google+: https://plus.google.com/b/107215163233435523450/ - -We're not on your favorite social network? Contact us and we'll do everything we can to be there too! - - -One more thing... ------------------ - -Have fun with Jappix, and don't hesitate to help us by reporting bugs, translating or submitting new ideas! diff --git a/source/THANKS.md b/source/THANKS.md deleted file mode 100644 index 9cfe295..0000000 --- a/source/THANKS.md +++ /dev/null @@ -1,23 +0,0 @@ -Jappix Thanks -============= - -We would like to thanks the authors of these tools, coming from other projects: - - -Projects --------- - -* Base64 https://github.com/dankogai/js-base64 -* DrawSVGChart http://codingteam.net/project/codingteam -* idzXHR http://www.iadvize.com/plugin_strophe_xmpp.html -* JSJaC http://blog.jwchat.org/jsjac/ -* JSMin http://github.com/rgrove/jsmin-php/ -* jQuery http://jquery.com/ -* jQuery Form http://jquery.malsup.com/form/ -* jQuery Timers http://plugins.jquery.com/project/timers -* jXHR http://mulletxhr.com/ -* Mobile Detect https://github.com/serbanghita/Mobile-Detect -* ParaType http://paratype.ru/ -* PHP-gettext https://launchpad.net/php-gettext -* Silk icons http://www.famfamfam.com/lab/icons/silk/ -* Smileys http://www.gajim.org/ diff --git a/source/VERSION b/source/VERSION deleted file mode 100644 index 3793834..0000000 --- a/source/VERSION +++ /dev/null @@ -1 +0,0 @@ -Primo [1.1.2] diff --git a/source/app/.htaccess b/source/app/.htaccess deleted file mode 100644 index a6e0b16..0000000 --- a/source/app/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -# Security rule -deny from all \ No newline at end of file diff --git a/source/app/bundles/anonymous.xml b/source/app/bundles/anonymous.xml deleted file mode 100644 index 03008df..0000000 --- a/source/app/bundles/anonymous.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - anonymous.css - anonymous.js - diff --git a/source/app/bundles/desktop.xml b/source/app/bundles/desktop.xml deleted file mode 100644 index 4042d38..0000000 --- a/source/app/bundles/desktop.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - fonts.css~main.css~images.css~board.css~home.css~others.css~tools.css~roster.css~myinfos.css~pageengine.css~channel.css~pageswitch.css~smileys.css~popup.css~vcard.css~options.css~favorites.css~discovery.css~directory.css~adhoc.css~privacy.css~inbox.css~mucadmin.css~integratebox.css~userinfos.css~search.css~welcome.css~me.css~rosterx.css~call.css~jingle.css~muji.css - origin.js~jxhr.js~datejs.js~jquery.js~jquery.ui.js~jquery.json.js~jquery.form.js~jquery.timers.js~jquery.placeholder.js~jquery.textrange.js~jquery.scrollto.js~base64.js~jsjac.js~jsjac.jingle.js~system.js~constants.js~datastore.js~browser-detect.js~home.js~talk.js~popup.js~audio.js~board.js~bubble.js~chat.js~groupchat.js~smileys.js~oob.js~avatar.js~mucadmin.js~connection.js~dataform.js~discovery.js~directory.js~adhoc.js~privacy.js~errors.js~name.js~favorites.js~features.js~interface.js~xmpplinks.js~iq.js~message.js~chatstate.js~receipts.js~tooltip.js~filter.js~links.js~inbox.js~microblog.js~music.js~notification.js~httpreply.js~options.js~integratebox.js~pubsub.js~pep.js~presence.js~roster.js~call.js~jingle.js~muji.js~storage.js~console.js~common.js~utilities.js~date.js~caps.js~vcard.js~userinfos.js~search.js~autocompletion.js~welcome.js~me.js~rosterx.js~mam.js~carbons.js~correction.js~markers.js~attention.js - diff --git a/source/app/bundles/httpauth.xml b/source/app/bundles/httpauth.xml deleted file mode 100644 index e3e597e..0000000 --- a/source/app/bundles/httpauth.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - httpauth.js - diff --git a/source/app/bundles/install.xml b/source/app/bundles/install.xml deleted file mode 100644 index 25781b2..0000000 --- a/source/app/bundles/install.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - main.css~install.css~images.css - - diff --git a/source/app/bundles/manager.xml b/source/app/bundles/manager.xml deleted file mode 100644 index b7bfe7b..0000000 --- a/source/app/bundles/manager.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - main.css~manager.css~images.css - - diff --git a/source/app/bundles/mini.xml b/source/app/bundles/mini.xml deleted file mode 100644 index 742b084..0000000 --- a/source/app/bundles/mini.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - mini.css - origin.js~jxhr.js~base64.js~jsjac.js~jquery.json.js~jquery.timers.js~jquery.scrollto.js~system.js~constants.js~datastore.js~browser-detect.js~console.js~common.js~date.js~links.js~mini.js - diff --git a/source/app/bundles/mobile.xml b/source/app/bundles/mobile.xml deleted file mode 100644 index fdf0ac2..0000000 --- a/source/app/bundles/mobile.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - mobile.css~ios.css~images.css - origin.js~jxhr.js~base64.js~jsjac.js~system.js~constants.js~console.js~browser-detect.js~links.js~mobile.js~ios.js - diff --git a/source/app/fonts/eot/ptsans.eot b/source/app/fonts/eot/ptsans.eot deleted file mode 100644 index 21e0f53..0000000 Binary files a/source/app/fonts/eot/ptsans.eot and /dev/null differ diff --git a/source/app/fonts/eot/ptsansbold.eot b/source/app/fonts/eot/ptsansbold.eot deleted file mode 100644 index cfa6e65..0000000 Binary files a/source/app/fonts/eot/ptsansbold.eot and /dev/null differ diff --git a/source/app/fonts/eot/ptsansbolditalic.eot b/source/app/fonts/eot/ptsansbolditalic.eot deleted file mode 100644 index b65f36c..0000000 Binary files a/source/app/fonts/eot/ptsansbolditalic.eot and /dev/null differ diff --git a/source/app/fonts/eot/ptsansitalic.eot b/source/app/fonts/eot/ptsansitalic.eot deleted file mode 100644 index 9f71ea9..0000000 Binary files a/source/app/fonts/eot/ptsansitalic.eot and /dev/null differ diff --git a/source/app/fonts/svg/ptsans.svg b/source/app/fonts/svg/ptsans.svg deleted file mode 100644 index 8c42797..0000000 --- a/source/app/fonts/svg/ptsans.svg +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/app/fonts/svg/ptsansbold.svg b/source/app/fonts/svg/ptsansbold.svg deleted file mode 100644 index c36d936..0000000 --- a/source/app/fonts/svg/ptsansbold.svg +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/app/fonts/svg/ptsansbolditalic.svg b/source/app/fonts/svg/ptsansbolditalic.svg deleted file mode 100644 index f9975f5..0000000 --- a/source/app/fonts/svg/ptsansbolditalic.svg +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/app/fonts/svg/ptsansitalic.svg b/source/app/fonts/svg/ptsansitalic.svg deleted file mode 100644 index 4c595eb..0000000 --- a/source/app/fonts/svg/ptsansitalic.svg +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/app/fonts/ttf/ptsans.ttf b/source/app/fonts/ttf/ptsans.ttf deleted file mode 100644 index a005ea3..0000000 Binary files a/source/app/fonts/ttf/ptsans.ttf and /dev/null differ diff --git a/source/app/fonts/ttf/ptsansbold.ttf b/source/app/fonts/ttf/ptsansbold.ttf deleted file mode 100644 index 31e4588..0000000 Binary files a/source/app/fonts/ttf/ptsansbold.ttf and /dev/null differ diff --git a/source/app/fonts/ttf/ptsansbolditalic.ttf b/source/app/fonts/ttf/ptsansbolditalic.ttf deleted file mode 100644 index dbc8807..0000000 Binary files a/source/app/fonts/ttf/ptsansbolditalic.ttf and /dev/null differ diff --git a/source/app/fonts/ttf/ptsansitalic.ttf b/source/app/fonts/ttf/ptsansitalic.ttf deleted file mode 100644 index 883ea2f..0000000 Binary files a/source/app/fonts/ttf/ptsansitalic.ttf and /dev/null differ diff --git a/source/app/fonts/woff/ptsans.woff b/source/app/fonts/woff/ptsans.woff deleted file mode 100644 index 307fd51..0000000 Binary files a/source/app/fonts/woff/ptsans.woff and /dev/null differ diff --git a/source/app/fonts/woff/ptsansbold.woff b/source/app/fonts/woff/ptsansbold.woff deleted file mode 100644 index f92d6b7..0000000 Binary files a/source/app/fonts/woff/ptsansbold.woff and /dev/null differ diff --git a/source/app/fonts/woff/ptsansbolditalic.woff b/source/app/fonts/woff/ptsansbolditalic.woff deleted file mode 100644 index c25c617..0000000 Binary files a/source/app/fonts/woff/ptsansbolditalic.woff and /dev/null differ diff --git a/source/app/fonts/woff/ptsansitalic.woff b/source/app/fonts/woff/ptsansitalic.woff deleted file mode 100644 index b952d76..0000000 Binary files a/source/app/fonts/woff/ptsansitalic.woff and /dev/null differ diff --git a/source/app/images/others/blank.gif b/source/app/images/others/blank.gif deleted file mode 100644 index 35d42e8..0000000 Binary files a/source/app/images/others/blank.gif and /dev/null differ diff --git a/source/app/images/others/default-avatar.png b/source/app/images/others/default-avatar.png deleted file mode 100644 index 7cda4c6..0000000 Binary files a/source/app/images/others/default-avatar.png and /dev/null differ diff --git a/source/app/images/others/lock.png b/source/app/images/others/lock.png deleted file mode 100644 index 2a30039..0000000 Binary files a/source/app/images/others/lock.png and /dev/null differ diff --git a/source/app/images/placeholders/jingle_audio_local.png b/source/app/images/placeholders/jingle_audio_local.png deleted file mode 100644 index 582f507..0000000 Binary files a/source/app/images/placeholders/jingle_audio_local.png and /dev/null differ diff --git a/source/app/images/placeholders/jingle_audio_remote.png b/source/app/images/placeholders/jingle_audio_remote.png deleted file mode 100644 index 187b9db..0000000 Binary files a/source/app/images/placeholders/jingle_audio_remote.png and /dev/null differ diff --git a/source/app/images/placeholders/jingle_video_local.png b/source/app/images/placeholders/jingle_video_local.png deleted file mode 100644 index 79ddff5..0000000 Binary files a/source/app/images/placeholders/jingle_video_local.png and /dev/null differ diff --git a/source/app/images/placeholders/jingle_video_remote.png b/source/app/images/placeholders/jingle_video_remote.png deleted file mode 100644 index 476138f..0000000 Binary files a/source/app/images/placeholders/jingle_video_remote.png and /dev/null differ diff --git a/source/app/images/sprites/animate.gif b/source/app/images/sprites/animate.gif deleted file mode 100644 index 60b85d2..0000000 Binary files a/source/app/images/sprites/animate.gif and /dev/null differ diff --git a/source/app/images/sprites/animate.png b/source/app/images/sprites/animate.png deleted file mode 100644 index 0ec0b19..0000000 Binary files a/source/app/images/sprites/animate.png and /dev/null differ diff --git a/source/app/images/sprites/archives.png b/source/app/images/sprites/archives.png deleted file mode 100644 index 3375d69..0000000 Binary files a/source/app/images/sprites/archives.png and /dev/null differ diff --git a/source/app/images/sprites/background.png b/source/app/images/sprites/background.png deleted file mode 100644 index 4ae286d..0000000 Binary files a/source/app/images/sprites/background.png and /dev/null differ diff --git a/source/app/images/sprites/browsers.png b/source/app/images/sprites/browsers.png deleted file mode 100644 index 3fb3c63..0000000 Binary files a/source/app/images/sprites/browsers.png and /dev/null differ diff --git a/source/app/images/sprites/buttons.png b/source/app/images/sprites/buttons.png deleted file mode 100644 index 496f76a..0000000 Binary files a/source/app/images/sprites/buttons.png and /dev/null differ diff --git a/source/app/images/sprites/call.png b/source/app/images/sprites/call.png deleted file mode 100644 index 5b332dc..0000000 Binary files a/source/app/images/sprites/call.png and /dev/null differ diff --git a/source/app/images/sprites/home.png b/source/app/images/sprites/home.png deleted file mode 100644 index 5b5dd00..0000000 Binary files a/source/app/images/sprites/home.png and /dev/null differ diff --git a/source/app/images/sprites/install.png b/source/app/images/sprites/install.png deleted file mode 100644 index e2f4cd2..0000000 Binary files a/source/app/images/sprites/install.png and /dev/null differ diff --git a/source/app/images/sprites/manager.png b/source/app/images/sprites/manager.png deleted file mode 100644 index d63a3fe..0000000 Binary files a/source/app/images/sprites/manager.png and /dev/null differ diff --git a/source/app/images/sprites/me.png b/source/app/images/sprites/me.png deleted file mode 100644 index 639c83d..0000000 Binary files a/source/app/images/sprites/me.png and /dev/null differ diff --git a/source/app/images/sprites/mini.gif b/source/app/images/sprites/mini.gif deleted file mode 100644 index 53a8e99..0000000 Binary files a/source/app/images/sprites/mini.gif and /dev/null differ diff --git a/source/app/images/sprites/mini.png b/source/app/images/sprites/mini.png deleted file mode 100644 index 0c319e9..0000000 Binary files a/source/app/images/sprites/mini.png and /dev/null differ diff --git a/source/app/images/sprites/mobile.png b/source/app/images/sprites/mobile.png deleted file mode 100644 index 6f20018..0000000 Binary files a/source/app/images/sprites/mobile.png and /dev/null differ diff --git a/source/app/images/sprites/smileys.png b/source/app/images/sprites/smileys.png deleted file mode 100644 index 1c33243..0000000 Binary files a/source/app/images/sprites/smileys.png and /dev/null differ diff --git a/source/app/images/sprites/talk.png b/source/app/images/sprites/talk.png deleted file mode 100644 index ce2ea9d..0000000 Binary files a/source/app/images/sprites/talk.png and /dev/null differ diff --git a/source/app/images/sprites/welcome.png b/source/app/images/sprites/welcome.png deleted file mode 100644 index e11565c..0000000 Binary files a/source/app/images/sprites/welcome.png and /dev/null differ diff --git a/source/app/images/wait/wait-big.gif b/source/app/images/wait/wait-big.gif deleted file mode 100644 index 0cd9591..0000000 Binary files a/source/app/images/wait/wait-big.gif and /dev/null differ diff --git a/source/app/images/wait/wait-medium.png b/source/app/images/wait/wait-medium.png deleted file mode 100644 index dae48b7..0000000 Binary files a/source/app/images/wait/wait-medium.png and /dev/null differ diff --git a/source/app/images/wait/wait-small.gif b/source/app/images/wait/wait-small.gif deleted file mode 100644 index 6958575..0000000 Binary files a/source/app/images/wait/wait-small.gif and /dev/null differ diff --git a/source/app/images/wait/wait-typing.gif b/source/app/images/wait/wait-typing.gif deleted file mode 100644 index 22ec6bb..0000000 Binary files a/source/app/images/wait/wait-typing.gif and /dev/null differ diff --git a/source/app/javascripts/adhoc.js b/source/app/javascripts/adhoc.js deleted file mode 100644 index e4e898b..0000000 --- a/source/app/javascripts/adhoc.js +++ /dev/null @@ -1,158 +0,0 @@ -/* - -Jappix - An open social platform -These are the Ad-Hoc JS scripts for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var AdHoc = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Opens the adhoc popup - * @public - * @return {boolean} - */ - self.open = function() { - - try { - // Popup HTML content - var html = - '
' + Common._e("Commands") + '
' + - - '
' + - '
' + - - '
' + - '
' + - - '
' + - '
' + - - '' + Common._e("Close") + '' + - '
'; - - // Create the popup - Popup.create('adhoc', html); - - // Associate the events - self.launch(); - } catch(e) { - Console.error('AdHoc.open', e); - } finally { - return false; - } - - }; - - - /** - * Closes the adhoc popup - * @public - * @return {boolean} - */ - self.close = function() { - - try { - // Destroy the popup - Popup.destroy('adhoc'); - } catch(e) { - Console.error('AdHoc.close', e); - } finally { - return false; - } - - }; - - - /** - * Retrieves an entity adhoc command - * @public - * @param {string} xid - * @return {boolean} - */ - self.retrieve = function(xid) { - - try { - // Open the popup - self.open(); - - // Add a XID marker - $('#adhoc .adhoc-head').html('' + Name.getBuddy(xid).htmlEnc() + ' (' + xid.htmlEnc() + ')'); - - // Get the highest entity resource - var highest = Presence.highestPriority(xid); - - if(highest) - xid = highest; - - // Start a new adhoc command - DataForm.go(xid, 'command', '', '', 'adhoc'); - } catch(e) { - Console.error('AdHoc.retrieve', e); - } finally { - return false; - } - - }; - - - /** - * Starts an adhoc command on the user server - * @public - * @param {string} server - * @return {undefined} - */ - self.server = function(server) { - - try { - // Open the popup - self.open(); - - // Add a XID marker - $('#adhoc .adhoc-head').html('' + server.htmlEnc() + ''); - - // Start a new adhoc command - DataForm.go(server, 'command', '', '', 'adhoc'); - } catch(e) { - Console.error('AdHoc.server', e); - } - - }; - - - /** - * Plugin launcher - * @public - * @return {undefined} - */ - self.launch = function() { - - try { - // Click event - $('#adhoc .bottom .finish').click(self.close); - } catch(e) { - Console.error('AdHoc.launch', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/anonymous.js b/source/app/javascripts/anonymous.js deleted file mode 100644 index f38f819..0000000 --- a/source/app/javascripts/anonymous.js +++ /dev/null @@ -1,210 +0,0 @@ -/* - -Jappix - An open social platform -These are the anonymous mode JS script for Jappix - -------------------------------------------------- - -License: AGPL -Authors: Valérian Saliou, LinkMauve - -*/ - -// Bundle -var Anonymous = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Registers connection handlers - * @private - * @param {object} con - * @return {undefined} - */ - self._registerHandlers = function(con) { - - try { - con.registerHandler('message', Message.handle); - con.registerHandler('presence', Presence.handle); - con.registerHandler('iq', IQ.handle); - con.registerHandler('onconnect', self.connected); - con.registerHandler('onerror', Errors.handle); - con.registerHandler('ondisconnect', self.disconnected); - } catch(e) { - Console.error('Anonymous._registerHandlers', e); - } - - }; - - - /** - * Connected to an anonymous session - * @public - * @return {undefined} - */ - self.connected = function() { - - try { - Console.info('Jappix (anonymous) is now connected.'); - - // Connected marker - Connection.connected = true; - Connection.current_session = true; - Connection.reconnect_try = 0; - Connection.reconnect_timer = 0; - - // Not resumed? - if(!Connection.resume) { - // Create the app - Talk.create(); - - // Send our first presence - Presence.sendFirst(''); - - // Set last activity stamp - DateUtils.last_activity = DateUtils.getTimeStamp(); - - // Create the new groupchat - Chat.checkCreate(Common.generateXID(ANONYMOUS_ROOM, 'groupchat'), 'groupchat'); - - // Remove some nasty elements for the anonymous mode - $('.tools-mucadmin, .tools-add').remove(); - } - - // Resumed - else { - // Send again our presence - Presence.sendActions(); - - // Change the title - Interface.updateTitle(); - } - - // Remove the waiting icon - Interface.removeGeneralWait(); - } catch(e) { - Console.error('Anonymous.connected', e); - } - - }; - - - /** - * Disconnected from an anonymous session - * @public - * @return {undefined} - */ - self.disconnected = function() { - - try { - Console.info('Jappix (anonymous) is now disconnected.'); - } catch(e) { - Console.error('Anonymous.disconnected', e); - } - - }; - - - /** - * Logins to a anonymous account - * @public - * @param {string} server - * @return {boolean} - */ - self.login = function(server) { - - try { - if(Common.hasWebSocket()) { - // WebSocket supported & configured - con = new JSJaCWebSocketConnection({ - httpbase: HOST_WEBSOCKET - }); - } else { - var httpbase = (HOST_BOSH_MAIN || HOST_BOSH); - - // Check BOSH origin - BOSH_SAME_ORIGIN = Origin.isSame(httpbase); - - // We create the new http-binding connection - con = new JSJaCHttpBindingConnection({ - httpbase: httpbase - }); - } - - // And we handle everything that happen - self._registerHandlers(con); - - // We set the anonymous connection parameters - oArgs = {}; - oArgs.domain = server; - oArgs.authtype = 'saslanon'; - oArgs.resource = JAPPIX_RESOURCE + ' Anonymous (' + (new Date()).getTime() + ')'; - oArgs.secure = true; - oArgs.xmllang = XML_LANG; - - // We connect ! - con.connect(oArgs); - - // Change the page title - Interface.title('wait'); - } catch(e) { - Console.error('Anonymous.login', e); - - // Reset Jappix - self.disconnected(); - - // Open an unknown error - Board.openThisError(2); - } finally { - return false; - } - - }; - - - /** - * Plugin launcher - * @public - * @return {undefined} - */ - self.launch = function() { - - try { - $(document).ready(function() { - Console.info('Anonymous mode detected, connecting...'); - - // We add the login wait div - Interface.showGeneralWait(); - - // Get the vars - if(XMPPLinks.links_var.r) { - ANONYMOUS_ROOM = XMPPLinks.links_var.r; - } - - if(XMPPLinks.links_var.n) { - ANONYMOUS_NICK = XMPPLinks.links_var.n; - } - - // Fire the login action - self.login(HOST_ANONYMOUS); - }); - } catch(e) { - Console.error('Anonymous.launch', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); - -Anonymous.launch(); \ No newline at end of file diff --git a/source/app/javascripts/attention.js b/source/app/javascripts/attention.js deleted file mode 100644 index abcd44b..0000000 --- a/source/app/javascripts/attention.js +++ /dev/null @@ -1,216 +0,0 @@ -/* - -Jappix - An open social platform -Implementation of XEP-0224: Attention - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var Attention = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Displays attention message - * @private - * @param {string} xid - * @param {string} body - * @return {undefined} - */ - self._display = function(xid, body, mode) { - - try { - var name = Name.getBuddy(xid).htmlEnc(); - var hash = hex_md5(xid); - - // Compute some variables - var message = Common._e(Common.printf("You requested %s's attention to the conversation", name)); - - if(mode == 'him') { - message = Common._e(Common.printf("%s requested your attention to the conversation", name)); - } - - if(body) { - message += ' (' + body + ')'; - } - - // Display notification - Message.display( - 'chat', - xid, - hash, - name, - message, - DateUtils.getCompleteTime(), - DateUtils.getTimeStamp(), - 'system-message', - true, - undefined, - mode - ); - - // Add a marker to displayed message - $('#' + hash + ' .content .one-line.system-message:last').addClass('attention-notice'); - } catch(e) { - Console.error('Attention._display', e); - } - - }; - - - /** - * Sends attention stanza - * @private - * @param {string} xid - * @param {string} body - * @return {object} - */ - self._stanza = function(xid, body) { - - try { - var message = new JSJaCMessage(); - message.setType('headline'); - message.setTo(xid); - - if(body) { - message.setBody(body); - } - - // Attention node - message.appendNode('attention', { - 'xmlns': NS_URN_ATTENTION - }); - - con.send(message); - - return message; - } catch(e) { - Console.error('Attention._stanza', e); - } - - }; - - - /** - * Returns whether last attention message exists or not - * @private - * @param {string} xid - * @return {boolean} - */ - self._lastExists = function(xid, mode) { - - var last_exists = false; - - try { - var line_sel = $('#' + hex_md5(xid) + ' .content .one-line[data-mode="' + mode + '"]:last'); - last_exists = line_sel.is('.system-message.attention-notice') ? true : false; - } catch(e) { - Console.error('Attention._lastExists', e); - } finally { - return last_exists; - } - - }; - - - /** - * Return whether entity supports attention notifications - * @public - * @param {string} xid - * @return {boolean} - */ - self.hasSupport = function(xid) { - - var has_support = false; - - try { - has_support = true ? $('#' + hex_md5(xid)).attr('data-attention') == 'true' : false; - } catch(e) { - Console.error('Attention.hasSupport', e); - } finally { - return has_support; - } - - }; - - - /** - * Send an attention message - * @public - * @param {string} xid - * @param {string} body - * @return {undefined} - */ - self.send = function(xid, body) { - - try { - var mode = 'me'; - - // Don't send attention message twice - if(self._lastExists(xid, mode) === false) { - // Send message stanza - self._stanza(xid, body); - - // Display attention notification - self._display(xid, body, mode); - } else { - Console.debug('Attention.send', 'Not sending attention message to: ' + xid + ' because already sent.'); - } - } catch(e) { - Console.error('Attention.send', e); - } - - }; - - - /** - * Receive an attention notification - * @public - * @param {string} xid - * @return {undefined} - */ - self.receive = function(xid, body) { - - try { - var mode = 'him'; - var hash = hex_md5(xid); - - // Don't receive attention message twice - if((self._lastExists(xid, mode) === false) && Common.exists('#' + hash)) { - // Display attention notification - self._display(xid, body, mode); - - // Show a notification - Interface.messageNotify(hash, 'personal'); - Audio.play('catch-attention'); - - Board.quick( - xid, - 'chat', - Common._e("Attention to conversation requested."), - Name.getBuddy(xid) - ); - } - } catch(e) { - Console.error('Attention.receive', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/audio.js b/source/app/javascripts/audio.js deleted file mode 100644 index 62652ea..0000000 --- a/source/app/javascripts/audio.js +++ /dev/null @@ -1,212 +0,0 @@ -/* - -Jappix - An open social platform -These are the audio JS scripts for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var Audio = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Variables */ - self._timeout_stop = false; - - - /** - * Returns whether browser supports audio or not - * @private - * @return {boolean} - */ - self._isSupported = function() { - - is_supported = true; - - try { - if((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version < 9)) { - is_supported = false; - } - } catch(e) { - Console.error('Audio._isSupported', e); - } finally { - return is_supported; - } - - }; - - - /** - * Append audio DOM code - * @private - * @return {undefined} - */ - self._appendDOM = function() { - - try { - // If the audio elements aren't yet in the DOM - if(!Common.exists('#audio')) { - $('body').append( - '
' + - '' + - - '' + - - '' + - - '' + - - '' + - - '' + - '
' - ); - } - } catch(e) { - Console.error('Audio._appendDOM', e); - } - - }; - - - /** - * Plays the given sound ID - * @public - * @param {string} name - * @return {boolean} - */ - self.play = function(name, repeat) { - - try { - repeat = (typeof repeat === 'boolean') ? repeat : false; - - // Not supported? - if(!self._isSupported()) { - return false; - } - - // If the sounds are enabled - if(DataStore.getDB(Connection.desktop_hash, 'options', 'sounds') === '1') { - self._appendDOM(); - - // We play the target sound - var audio_raw_sel = $('#audio audio').filter('#' + name); - var audio_sel = audio_raw_sel[0]; - - if(audio_sel) { - // Fixes Chrome audio bug when Get API serves expired files (for development work purposes) - if(window.chrome && System.isDeveloper()) { - audio_sel.load(); - } - - // Must repeat sound? - if(repeat === true) { - // We hardcoded sound duration as it's a mess to add load event handlers to determine duration via Audio API... - var duration = parseInt((audio_raw_sel.attr('data-duration') || 0), 10); - - self._timeout_stop = false; - - audio_raw_sel.oneTime((duration + 's'), function() { - if(!self._timeout_stop) { - self.play(name, repeat); - } - }); - } - - audio_sel.play(); - - Console.info('Played sound with name: ' + name + ' (' + (repeat ? 'repeatedly' : 'one time') + ')'); - } else { - throw 'Sound does not exist: ' + name; - } - } - } catch(e) { - Console.error('Audio.play', e); - } finally { - return false; - } - - }; - - - /** - * Stops the given sound ID - * @public - * @param {string} name - * @return {boolean} - */ - self.stop = function(name) { - - try { - // Not supported? - if(!self._isSupported()) { - return false; - } - - self._timeout_stop = true; - - // Check the audio container exists before doing anything... - var audio_parent_sel = $('#audio'); - var audio_raw_sel = audio_parent_sel.find('audio').filter('#' + name); - var audio_sel = audio_raw_sel[0]; - - if(audio_parent_sel.size()) { - audio_raw_sel.stopTime(); - - if(audio_sel) { - if(!audio_sel.paused) { - audio_sel.pause(); - - Console.info('Stopped sound with name: ' + name); - } else { - Console.info('Sound with name: ' + name + ' already stopped'); - } - } else { - throw 'Sound does not exist: ' + name; - } - } else { - Console.warn('Audio container does not exist, aborting as nothing likely to be playing! (already stopped)'); - } - } catch(e) { - Console.error('Audio.stop', e); - } finally { - return false; - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/autocompletion.js b/source/app/javascripts/autocompletion.js deleted file mode 100644 index 78f48b5..0000000 --- a/source/app/javascripts/autocompletion.js +++ /dev/null @@ -1,256 +0,0 @@ -/* - -Jappix - An open social platform -These are the autocompletion tools JS script for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var Autocompletion = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Sort an autocompletion result array with insensitivity to the case, - * using the 1st elements (a[0] and b[0]) to process comparison - * @public - * @param {array} a - * @param {array} b - * @return {undefined} - */ - self.caseInsensitiveSort = function(a, b) { - - try { - // Put the two strings into lower case - var sort_a = a[0].toLowerCase(); - var sort_b = b[0].toLowerCase(); - - // Process the sort - if(sort_a > sort_b) { - return 1; - } - - if(sort_a < sort_b) { - return -1; - } - } catch(e) { - Console.error('Autocompletion.caseInsensitiveSort', e); - } - - }; - - - /** - * Split a query into its subqueries ready to be used in autocompletion - * @public - * @param {string} query - * @return {object} - */ - self.getSubQueries = function(query) { - - var result = []; - - try { - var subqueries = []; - var remnants = []; - - var query_last_char_pos = query.length - 1; - var space_counter = 0; - var cur_char; - - for(var i = query_last_char_pos; i >= 0; i--) { - // Search from the end of the query - cur_char = query.charAt(i); - - if(space_counter === 0 && cur_char.search(/\s/) === 0) { - // The first "local" space was found - // Add the subquery and its remnant to results - subqueries.push(query.slice(i+1)); - remnants.push(query.slice(0, i+1)); - - space_counter++; - } else { - space_counter = 0; - } - } - - if(space_counter === 0) { - // If the first char of the query is not a space, add the full query to results - subqueries.push(query); - remnants.push(''); - } - - result = [subqueries, remnants]; - } catch(e) { - Console.error('Autocompletion.getSubQueries', e); - } finally { - return result; - } - - }; - - - /** - * Creates an array with the autocompletion results. An autocompletion result - * is an array containing the result himself and the rank of the query which - * matched this answer - * @public - * @param {Array} query - * @param {string} id - * @return {Array} - */ - self.process = function(query, id) { - - var results = []; - - try { - // Replace forbidden characters in regex - query = Common.escapeRegex(query); - - // Build an array of regex to use - var query_reg_exp = []; - - for(i = 0; i < query.length; i++) { - if(query[i] !== null) { - query_reg_exp.push( - new RegExp('(^)' + query[i], 'gi') - ); - } - } - - // Search in the roster - var nick, regex; - - $('#' + id + ' .user').each(function() { - nick = $(this).find('.name').text(); - - for(i = 0; i < query_reg_exp.length; i++) { - regex = query_reg_exp[i]; - - if(nick.match(regex)) { - results.push([nick, i]); - } - } - }); - - // Sort the array - results = results.sort( - self.caseInsensitiveSort - ); - } catch(e) { - Console.error('Autocompletion.process', e); - } finally { - return results; - } - - }; - - - /** - * Resets the autocompletion tools - * @public - * @param {string} hash - * @return {undefined} - */ - self.reset = function(hash) { - - try { - $('#' + hash + ' .message-area').removeAttr('data-autocompletion-pointer') - .removeAttr('data-autocompletion-query'); - } catch(e) { - Console.error('Autocompletion.reset', e); - } - - }; - - - /** - * Autocompletes the chat input nick - * @public - * @param {string} hash - * @return {undefined} - */ - self.create = function(hash) { - - try { - // Initialize - var message_area_sel = $('#' + hash + ' .message-area'); - var value = message_area_sel.val(); - - if(!value) { - self.reset(hash); - } - - var query = message_area_sel.attr('data-autocompletion-query'); - - if(query === undefined) { - // The autocompletion has not been yet launched - query = self.getSubQueries(value); - message_area_sel.attr('data-autocompletion-query', JSON.stringify(query)); - } else { - // The autocompletion has already stored a query - query = JSON.parse(query); - } - - // Get the pointer - var pointer = message_area_sel.attr('data-autocompletion-pointer'); - var i = pointer ? parseInt(pointer, 10) : 0; - - // We get the nickname - var nick_result = self.process(query[0], hash)[i]; - var nick; - - if(nick_result !== undefined) { - nick = nick_result[0]; - } - - // Shit, this is my nick! - if((nick !== undefined) && (nick.toLowerCase() == Name.getMUCNick(hash).toLowerCase())) { - // Increment - i++; - - // Get the next nick - nick_result = self.process(query[0], hash)[i]; - - if (nick_result !== undefined) { - nick = nick_result[0]; - } - } - - // We quote the nick - if((nick_result !== undefined) && (nick !== undefined)) { - // Increment - i++; - - Utils.quoteMyNick( - hash, - nick, - query[1][nick_result[1]] - ); - - // Put a pointer - message_area_sel.attr('data-autocompletion-pointer', i); - } - } catch(e) { - Console.error('Autocompletion.create', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); diff --git a/source/app/javascripts/avatar.js b/source/app/javascripts/avatar.js deleted file mode 100644 index 4aae5a5..0000000 --- a/source/app/javascripts/avatar.js +++ /dev/null @@ -1,290 +0,0 @@ -/* - -Jappix - An open social platform -These are the avatar JS scripts for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou, Maranda - -*/ - -// Bundle -var Avatar = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Variables */ - self.pending = []; - - - /** - * Requests the avatar of a given user - * @public - * @param {string} xid - * @param {string} mode - * @param {boolean} enabled - * @param {boolean} photo - * @return {boolean} - */ - self.get = function(xid, mode, enabled, photo) { - - /* REF: http://xmpp.org/extensions/xep-0153.html */ - - try { - // No need to get the avatar, another process is yet running - if(Utils.existArrayValue(self.pending, xid)) { - return false; - } - - // Initialize: XML data is in one SQL entry, because some browser are sloooow with SQL requests - var xml = Common.XMLFromString( - DataStore.getPersistent('global', 'avatar', xid) - ); - var forced = false; - - // Retrieving forced? - if($(xml).find('forced').text() == 'true') { - forced = true; - } - - // No avatar in presence - if(!photo && !forced && enabled == 'true') { - // Pending marker - self.pending.push(xid); - - // Reset the avatar - self.reset(xid, hex_md5(xid)); - - Console.warn('No avatar for: ' + xid); - } - - // Try to catch the avatar - else { - // Define some stuffs - var type = $(xml).find('type').text(); - var binval = $(xml).find('binval').text(); - var checksum = $(xml).find('checksum').text(); - var updated = false; - - // Process the checksum of the avatar - if(checksum == photo || photo == 'forget' || forced) { - updated = true; - } - - // If the avatar is yet stored and a new retrieving is not needed - if(mode == 'cache' && type && binval && checksum && updated) { - // Pending marker - self.pending.push(xid); - - // Display the cache avatar - self.display(xid, hex_md5(xid), type, binval); - - Console.info('Read avatar from cache: ' + xid); - } - - // Else if the request has not yet been fired, we get it - else if((!updated || mode == 'force' || photo == 'forget') && enabled != 'false') { - // Pending marker - self.pending.push(xid); - - // Get the latest avatar - var iq = new JSJaCIQ(); - iq.setType('get'); - iq.setTo(xid); - - iq.appendNode('vCard', {'xmlns': NS_VCARD}); - - con.send(iq, self.handle); - - Console.info('Get avatar from server: ' + xid); - } - } - - return true; - } catch(e) { - Console.error('Avatar.get', e); - } - - }; - - - /** - * Handles the avatar - * @public - * @param {object} iq - * @return {undefined} - */ - self.handle = function(iq) { - - try { - // Extract the XML values - var handleXML = iq.getNode(); - var handleFrom = Common.fullXID(Common.getStanzaFrom(iq)); - - // Is this me? Remove the resource! - if(Common.bareXID(handleFrom) == Common.getXID()) { - handleFrom = Common.bareXID(handleFrom); - } - - // Get some other values - var hash = hex_md5(handleFrom); - var find = $(handleXML).find('vCard'); - var aChecksum = 'none'; - var oChecksum = null; - - // Read our own checksum - if(handleFrom == Common.getXID()) { - oChecksum = DataStore.getDB(Connection.desktop_hash, 'checksum', 1); - - // Avoid the "null" value - if(!oChecksum) { - oChecksum = ''; - } - } - - // vCard not empty? - if(find.size()) { - // We get our profile details - if(handleFrom == Common.getXID()) { - // Get the names - var names = Name.generateBuddy(iq); - var phone_number = find.find('TEL:has(NUMBER):first NUMBER:first').text(); - - // Write the values to the database - DataStore.setDB(Connection.desktop_hash, 'profile', 'name', names[0]); - DataStore.setDB(Connection.desktop_hash, 'profile', 'nick', names[1]); - DataStore.setDB(Connection.desktop_hash, 'profile', 'phone', phone_number); - } - - // We get the avatar - var aType = find.find('TYPE:first').text(); - var aBinval = find.find('BINVAL:first').text(); - - // No binval? - if(!aBinval) { - aType = 'none'; - aBinval = 'none'; - } - - // Enough data - else { - // No type? - if(!aType) { - aType = 'image/png'; - } else { - aChecksum = hex_sha1(Base64.decode(aBinval)); - } - } - - // We display the user avatar - self.display(handleFrom, hash, aType, aBinval); - - // Store the avatar - DataStore.setPersistent('global', 'avatar', handleFrom, '' + aType + '' + aBinval + '' + aChecksum + 'false'); - - Console.info('Avatar retrieved from server: ' + handleFrom); - } - - // vCard is empty - else { - self.reset(handleFrom); - } - - // We got a new checksum for us? - if(((oChecksum !== null) && (oChecksum != aChecksum)) || !Presence.first_sent) { - // Define a proper checksum - var pChecksum = aChecksum; - - if(pChecksum == 'none') { - pChecksum = ''; - } - - // Update our temp. checksum - DataStore.setDB(Connection.desktop_hash, 'checksum', 1, pChecksum); - - // Send the stanza - if(!Presence.first_sent) { - Storage.get(NS_OPTIONS); - } else if(DataStore.hasPersistent()) { - Presence.sendActions(pChecksum); - } - } - } catch(e) { - Console.error('Avatar.handle', e); - } - - }; - - - /** - * Reset the avatar of an user - * @public - * @param {string} xid - * @param {string} hash - * @return {undefined} - */ - self.reset = function(xid, hash) { - - try { - // Store the empty avatar - DataStore.setPersistent('global', 'avatar', xid, 'nonenonenonefalse'); - - // Display the empty avatar - self.display(xid, hash, 'none', 'none'); - } catch(e) { - Console.error('Avatar.reset', e); - } - - }; - - - /** - * Displays the avatar of an user - * @public - * @param {string} xid - * @param {string} hash - * @param {string} type - * @param {string} binval - * @return {undefined} - */ - self.display = function(xid, hash, type, binval) { - - try { - // Initialize the vars - var container = hash + ' .avatar-container'; - var code = ''; - - // Replace with the new avatar (in the roster and in the chat) - $('.' + container).html(code); - - // We can remove the pending marker - Utils.removeArrayValue(self.pending, xid); - } catch(e) { - Console.error('Avatar.display', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/base64.js b/source/app/javascripts/base64.js deleted file mode 100644 index 1ef3528..0000000 --- a/source/app/javascripts/base64.js +++ /dev/null @@ -1,82 +0,0 @@ -// License: PD - -// This code was written by Tyler Akins and has been placed in the -// public domain. It would be nice if you left this header intact. -// Base64 code from Tyler Akins -- http://rumkin.com - -var Base64 = (function () { - var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - - var obj = { - /** - * Encodes a string in base64 - * @param {String} input The string to encode in base64. - */ - encode: function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - do { - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - - output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + - keyStr.charAt(enc3) + keyStr.charAt(enc4); - } while (i < input.length); - - return output; - }, - - /** - * Decodes a base64 string. - * @param {String} input The string to decode. - */ - decode: function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - // remove all characters that are not A-Z, a-z, 0-9, +, /, or = - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - do { - enc1 = keyStr.indexOf(input.charAt(i++)); - enc2 = keyStr.indexOf(input.charAt(i++)); - enc3 = keyStr.indexOf(input.charAt(i++)); - enc4 = keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - } while (i < input.length); - - return output; - } - }; - - return obj; -})(); \ No newline at end of file diff --git a/source/app/javascripts/board.js b/source/app/javascripts/board.js deleted file mode 100644 index fd73bd4..0000000 --- a/source/app/javascripts/board.js +++ /dev/null @@ -1,421 +0,0 @@ -/* - -Jappix - An open social platform -These are the notification board JS script for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou, Maranda - -*/ - -// Bundle -var Board = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Contants */ - self.NOTIFICATION = (window.Notification || window.mozNotification || window.webkitNotification); - - - /** - * Generate board info message - * @private - * @param {string} id - * @return {string} - */ - self._generateBoardInfo = function(id) { - - var text = null; - - try { - switch(id) { - // Password change - case 1: - text = Common._e("Your password has been changed, now you can connect to your account with your new login data."); - - break; - - // Account deletion - case 2: - text = Common._e("Your XMPP account has been removed, bye!"); - - break; - - // Account logout - case 3: - text = Common._e("You have been logged out of your XMPP account, have a nice day!"); - - break; - - // Groupchat join - case 4: - text = Common._e("The room you tried to join doesn't seem to exist."); - - break; - - // Groupchat removal - case 5: - text = Common._e("The groupchat has been removed."); - - break; - - // Non-existant groupchat user - case 6: - text = Common._e("The user that you want to reach is not present in the room."); - - break; - } - } catch(e) { - Console.error('Board._generateBoardInfo', e); - } finally { - return text; - } - - }; - - - /** - * Generate board error message - * @private - * @param {string} id - * @return {string} - */ - self._generateBoardError = function(id) { - - var text = null; - - try { - switch(id) { - // Custom error - case 1: - text = '' + Common._e("Error") + ' » '; - - break; - - // Network error - case 2: - text = Common._e("Jappix has been interrupted by a network issue, a bug or bad login (check that you entered the right credentials), sorry for the inconvenience."); - - break; - - // List retrieving error - case 3: - text = Common._e("The element list on this server could not be obtained!"); - - break; - - // Attaching error - case 4: - text = Common.printf(Common._e("An error occured while uploading your file: maybe it is too big (%s maximum) or forbidden!"), JAPPIX_MAX_UPLOAD); - - break; - } - } catch(e) { - Console.error('Board._generateBoardError', e); - } finally { - return text; - } - - }; - - - /** - * Attaches board events - * @private - * @param {object} board_sel - * @return {undefined} - */ - self._attachEvents = function(board_sel) { - - try { - board_sel.click(function() { - self.closeThis(this); - }); - - board_sel.oneTime('5s', function() { - self.closeThis(this); - }); - - board_sel.slideDown(); - } catch(e) { - Console.error('Board._attachEvents', e); - } - - }; - - - /** - * Creates a board panel - * @public - * @param {string} type - * @param {string} id - * @return {boolean} - */ - self.create = function(type, id) { - - try { - // Text var - var text = ''; - - // Info - if(type == 'info') { - text = self._generateBoardInfo(id); - } else { - text = self._generateBoardError(id); - } - - // No text? - if(!text) { - return false; - } - - // Append the content - $('#board').append( - '
' + text + '
' - ); - - // Events (click and auto-hide) - self._attachEvents( - $('#board .one-board.' + type + '[data-id="' + id + '"]') - ); - - return true; - } catch(e) { - Console.error('Board.create', e); - } - - }; - - - /** - * Destroys the existing board notifications - * @public - * @return {undefined} - */ - self.destroy = function() { - - try { - $('#board').empty(); - } catch(e) { - Console.error('Board.destroy', e); - } - - }; - - - /** - * Executes a given action on the notification board - * @public - * @param {type} name - * @return {undefined} - */ - self.action = function(id, type) { - - try { - // In a first, we destroy other boards - self.destroy(); - - // Then we display the board - self.create(type, id); - } catch(e) { - Console.error('Board.action', e); - } - - }; - - - /** - * Opens a given error ID - * @public - * @param {string} id - * @return {undefined} - */ - self.openThisError = function(id) { - - try { - self.action(id, 'error'); - } catch(e) { - Console.error('Board.openThisError', e); - } - - }; - - - /** - * Opens a given info ID - * @public - * @param {string} id - * @return {undefined} - */ - self.openThisInfo = function(id) { - - try { - self.action(id, 'info'); - } catch(e) { - Console.error('Board.openThisInfo', e); - } - - }; - - - /** - * Closes a given board - * @public - * @param {string} board - * @return {undefined} - */ - self.closeThis = function(board) { - - try { - $(board).slideUp('normal', function() { - $(this).remove(); - }); - } catch(e) { - Console.error('Board.closeThis', e); - } - - }; - - - /** - * Creates a quick board (HTML5 notification) - * @public - * @param {string} xid - * @param {string} type - * @param {string} content - * @param {string} title - * @param {string} icon - * @return {object} - */ - self.quick = function(xid, type, content, title, icon) { - - try { - // Cannot process? - if(Common.isFocused() || !content || !self.NOTIFICATION) { - return; - } - - // Default icon? - if(!icon) { - icon = './images/others/default-avatar.png'; - - // Avatar icon? - if(xid) { - var avatar_xml = Common.XMLFromString( - DataStore.getPersistent('global', 'avatar', xid) - ); - - var avatar_type = $(avatar_xml).find('type').text() || 'image/png'; - var avatar_binval = $(avatar_xml).find('binval').text(); - - if(avatar_binval && avatar_type) { - icon = 'data:' + avatar_type + ';base64,' + avatar_binval; - } - } - } - - // Default title? - if(!title) { - title = Common._e("New event!"); - } - - // Create notification - var notification = new self.NOTIFICATION(title, { - dir: 'auto', - lang: '', - body: content, - tag: type, - icon: icon - }); - - // Click event - notification.onclick = function() { - // Click action? - switch(type) { - case 'chat': - Interface.switchChan(hex_md5(xid)); - break; - - case 'groupchat': - Interface.switchChan(hex_md5(Common.bareXID(xid))); - break; - - default: - break; - } - - // Focus on msg-me - window.focus(); - - // Remove notification - this.close(); - }; - - // Show event - notification.onshow = function() { - setTimeout(function() { - notification.close(); - }, 10000); - }; - - return notification; - } catch(e) { - Console.error('Board.quick', e); - } - - }; - - - /** - * Asks for permission to show quick boards (HTML5 notification) - * @public - * @return {undefined} - */ - self.quickPermission = function() { - - try { - self.NOTIFICATION.requestPermission(); - } catch(e) { - Console.error('Board.quickPermission', e); - } - - }; - - - /** - * Plugin launcher - * @public - * @return {undefined} - */ - self.launch = function() { - - try { - // Fires quickPermission() on document click - $(document).click(function() { - // Ask for permission to use quick boards - if((typeof con != 'undefined') && con.connected()) { - self.quickPermission(); - } - }); - } catch(e) { - Console.error('Board.launch', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); - -Board.launch(); \ No newline at end of file diff --git a/source/app/javascripts/browser-detect.js b/source/app/javascripts/browser-detect.js deleted file mode 100644 index cef3c4a..0000000 --- a/source/app/javascripts/browser-detect.js +++ /dev/null @@ -1,125 +0,0 @@ -/* BROWSER DETECT - * http://www.quirksmode.org/js/detect.html - * License: dual-licensed under MPLv2 and the original license - */ - -var BrowserDetect = { - init: function () { - this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; - this.version = this.searchVersion(navigator.userAgent) || - this.searchVersion(navigator.appVersion) || - "an unknown version"; - this.OS = this.searchString(this.dataOS) || "an unknown OS"; - }, - - searchString: function (data) { - for (var i=0;i' + attrs.text + ''; - }); - } - - // Append notification to DOM - call_subitem_sel.html( - '
' + - '
' + - '
' + - '' + - '
' + - - '' + - '
' + - - '
' + - '' + fullname + '' + - '' + map[type].text + '' + - - '
' + buttons_html + '
' + - '
' + - '
' - ); - - // Apply user avatar - Avatar.get(sender_xid, 'cache', 'true', 'forget'); - - // Apply button events - if(typeof map[type].buttons === 'object') { - $.each(map[type].buttons, function(button, attrs) { - call_tools_all_sel.find('a.reply-button[data-action="' + button + '"]').click(function() { - try { - // Remove notification - self._unnotify(); - - // Execute callback, if any - if(typeof attrs.cb === 'function') { - attrs.cb(xid, mode, options_arr); - } - - Console.info('Closed call notification drawer'); - } catch(e) { - Console.error('Call.notify[async]', e); - } finally { - return false; - } - }); - }); - } - - // Enable notification box! - call_tool_sel.addClass('active'); - - // Open notification box! - call_content_sel.show(); - } catch(e) { - Console.error('Call.notify', e); - } finally { - return false; - } - - }; - - - /** - * Remove notification - * @private - * @return {boolean} - */ - self._unnotify = function() { - - try { - // Selectors - var call_tools_all_sel = $('#top-content .tools-all:has(.tools.call)'); - var call_tool_sel = call_tools_all_sel.find('.tools.call'); - var call_content_sel = call_tools_all_sel.find('.call-content'); - var call_subitem_sel = call_content_sel.find('.tools-content-subitem'); - - // Close & disable notification box - call_content_sel.hide(); - call_subitem_sel.empty(); - call_tool_sel.removeClass('active'); - - // Stop all sounds - Audio.stop('incoming-call'); - Audio.stop('outgoing-call'); - } catch(e) { - Console.error('Call._unnotify', e); - } finally { - return false; - } - - }; - - - /** - * Processes the video elements size - * @private - * @param {object} screen - * @param {object} video - * @return {object} - */ - self._process_size = function(screen, video) { - - try { - if(!(typeof screen === 'object' && typeof video === 'object')) { - throw 'Invalid object passed, aborting!'; - } - - // Get the intrinsic size of the video - var video_w = video[0].videoWidth || video.width(); - var video_h = video[0].videoHeight || video.height(); - - // Get the screen size of the video - var screen_w = screen.width(); - var screen_h = screen.height(); - - // Process resize ratios (2 cases) - var r_1 = screen_h / video_h; - var r_2 = screen_w / video_w; - - // Process resized video sizes - var video_w_1 = video_w * r_1; - var video_h_1 = video_h * r_1; - - var video_w_2 = video_w * r_2; - var video_h_2 = video_h * r_2; - - // DOM view modifiers - var dom_width = 'auto'; - var dom_height = 'auto'; - var dom_left = 0; - var dom_top = 0; - - // Landscape/Portrait/Equal container? - if(video_w > video_h || (video_h == video_w && screen_w < screen_h)) { - // Not sufficient? - if(video_w_1 < screen_w) { - dom_width = screen_w + 'px'; - dom_top = -1 * (video_h_2 - screen_h) / 2; - } else { - dom_height = screen_h + 'px'; - dom_left = -1 * (video_w_1 - screen_w) / 2; - } - } else if(video_h > video_w || (video_h == video_w && screen_w > screen_h)) { - // Not sufficient? - if(video_h_1 < screen_h) { - dom_height = screen_h + 'px'; - dom_left = -1 * (video_w_1 - screen_w) / 2; - } else { - dom_width = screen_w + 'px'; - dom_top = -1 * (video_h_2 - screen_h) / 2; - } - } else if(screen_w == screen_h) { - dom_width = screen_w + 'px'; - dom_height = screen_h + 'px'; - } - - return { - width : dom_width, - height : dom_height, - left : dom_left, - top : dom_top - }; - } catch(e) { - Console.error('Call._process_size', e); - } - - }; - - - /** - * Adapts the local video view - * @public - * @param {object} local_sel - * @return {undefined} - */ - self.adapt_local = function(local_sel) { - - try { - var local_video_sel = local_sel.find('video'); - - // Process new sizes - var sizes = Call._process_size( - local_sel, - local_video_sel - ); - - // Apply new sizes - local_video_sel.css({ - 'height': sizes.height, - 'width': sizes.width, - 'margin-top': sizes.top, - 'margin-left': sizes.left - }); - } catch(e) { - Console.error('Call.adapt_local', e); - } - - }; - - - /** - * Adapts the remote video view - * @public - * @param {object} videobox_sel - * @return {undefined} - */ - self.adapt_remote = function(videobox_sel) { - - try { - var remote_video_sel, sizes; - - videobox_sel.find('.remote_video').each(function() { - remote_video_sel = $(this).find('video'); - - if(remote_video_sel.size()) { - // Process new sizes - sizes = Call._process_size( - $(this), - remote_video_sel - ); - - // Apply new sizes - remote_video_sel.css({ - 'height': sizes.height, - 'width': sizes.width, - 'margin-top': sizes.top, - 'margin-left': sizes.left - }); - } - }); - } catch(e) { - Console.error('Call.adapt_remote', e); - } - - }; - - - /** - * Start call elpsed time counter - * @public - * @return {boolean} - */ - self.start_counter = function() { - - try { - // Initialize counter - self.stop_counter(); - self._start_stamp = DateUtils.getTimeStamp(); - self._fire_clock(); - - // Fire it every second - $('#top-content .tools.call .counter').everyTime('1s', self._fire_clock); - - Console.info('Call counter started'); - } catch(e) { - Console.error('Call.start_counter', e); - } finally { - return false; - } - - }; - - - /** - * Stop call elpsed time counter - * @public - * @return {boolean} - */ - self.stop_counter = function() { - - try { - // Reset stamp storage - self._start_stamp = 0; - - // Reset counter - var counter_sel = $('#top-content .tools.call .counter'); - var default_count = counter_sel.attr('data-default'); - - counter_sel.stopTime(); - - $('#top-content .tools.call .counter').text(default_count); - $('#jingle, #muji').find('.elapsed').text(default_count); - - Console.info('Call counter stopped'); - } catch(e) { - Console.error('Call.stop_counter', e); - } finally { - return false; - } - - }; - - - /** - * Fires the counter clock (once more) - * @private - * @return {undefined} - */ - self._fire_clock = function() { - - try { - // Process updated time - var count = DateUtils.difference( - DateUtils.getTimeStamp(), - self._start_stamp - ); - - if(count.getHours()) { - count = count.toString('H:mm:ss'); - } else { - count = count.toString('mm:ss'); - } - - // Display updated counter - $('#top-content .tools.call .counter').text(count); - $('#jingle, #muji').find('.elapsed').text(count); - } catch(e) { - Console.error('Call._fire_clock', e); - } - - }; - - - /** - * Destroy the call interface - * @public - * @return {undefined} - */ - self.destroy_interface = function(container_sel) { - - try { - container_sel.stopTime(); - container_sel.find('*').stopTime(); - - container_sel.remove(); - } catch(e) { - Console.error('Call.destroy_interface', e); - } - - }; - - - /** - * Show the call interface - * @public - * @param {object} manager - * @param {object} call_sel - * @param {object} video_container_sel - * @return {boolean} - */ - self.show_interface = function(manager, call_sel, video_container_sel) { - - try { - if(manager.in_call()) { - call_sel.filter(':hidden').show(); - - // Launch back some events - video_container_sel.mousemove(); - } - } catch(e) { - Console.error('Call.show_interface', e); - } finally { - return false; - } - - }; - - - /** - * Hide the call interface - * @public - * @param {object} call_sel - * @param {object} video_container_sel - * @return {boolean} - */ - self.hide_interface = function(call_sel, video_container_sel) { - - try { - call_sel.filter(':visible').hide(); - - // Reset some events - video_container_sel.find('.topbar').stopTime().hide(); - } catch(e) { - Console.error('Call.hide_interface', e); - } finally { - return false; - } - - }; - - - /** - * Attaches interface events - * @public - * @param {object} manager - * @param {object} call_sel - * @param {object} video_container_sel - * @return {undefined} - */ - self.events_interface = function(manager, call_sel, video_container_sel) { - - try { - call_sel.everyTime(50, function() { - manager._adapt(); - }); - - // Close interface on click on semi-transparent background - call_sel.click(function(evt) { - try { - // Click on lock background? - if($(evt.target).is('.lock')) { - return manager._hide_interface(); - } - } catch(e) { - Console.error('Call.events_interface[async]', e); - } - }); - - // Click on a control or action button - call_sel.find('.topbar').find('.controls a, .actions a').click(function() { - try { - switch($(this).data('type')) { - case 'close': - manager._hide_interface(); break; - case 'stop': - case 'leave': - manager.stop(); break; - case 'mute': - manager.mute(); break; - case 'unmute': - manager.unmute(); break; - } - } catch(e) { - Console.error('Call.events_interface[async]', e); - } finally { - return false; - } - }); - - // Auto Hide/Show interface topbar - video_container_sel.mousemove(function() { - try { - var topbar_sel = $(this).find('.topbar'); - - if(topbar_sel.is(':hidden')) { - topbar_sel.stop(true).fadeIn(250); - } - - topbar_sel.stopTime(); - topbar_sel.oneTime('5s', function() { - topbar_sel.stop(true).fadeOut(250); - }); - } catch(e) { - Console.error('Call.events_interface[async]', e); - } - }); - } catch(e) { - Console.error('Call.events_interface', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); diff --git a/source/app/javascripts/caps.js b/source/app/javascripts/caps.js deleted file mode 100644 index 0538f43..0000000 --- a/source/app/javascripts/caps.js +++ /dev/null @@ -1,787 +0,0 @@ -/* - -Jappix - An open social platform -These are the CAPS JS script for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou, Maranda - -*/ - -// Bundle -var Caps = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Constants */ - self.disco_infos = { - 'identity': { - 'category': 'client', - 'type': 'web', - 'name': 'Jappix' - }, - - 'items': [ - NS_MUC, - NS_MUC_USER, - NS_MUC_ADMIN, - NS_MUC_OWNER, - NS_MUC_CONFIG, - NS_DISCO_INFO, - NS_DISCO_ITEMS, - NS_PUBSUB_RI, - NS_BOSH, - NS_CAPS, - NS_MOOD, - NS_ACTIVITY, - NS_TUNE, - NS_GEOLOC, - NS_NICK, - NS_URN_MBLOG, - NS_URN_INBOX, - NS_MOOD + NS_NOTIFY, - NS_ACTIVITY + NS_NOTIFY, - NS_TUNE + NS_NOTIFY, - NS_GEOLOC + NS_NOTIFY, - NS_URN_MBLOG + NS_NOTIFY, - NS_URN_INBOX + NS_NOTIFY, - NS_URN_DELAY, - NS_ROSTER, - NS_ROSTERX, - NS_HTTP_AUTH, - NS_CHATSTATES, - NS_XHTML_IM, - NS_URN_MAM, - NS_IPV6, - NS_LAST, - NS_PRIVATE, - NS_REGISTER, - NS_SEARCH, - NS_COMMANDS, - NS_VERSION, - NS_XDATA, - NS_VCARD, - NS_IETF_VCARD4, - NS_URN_ADATA, - NS_URN_AMETA, - NS_URN_TIME, - NS_URN_PING, - NS_URN_RECEIPTS, - NS_PRIVACY, - NS_IQOOB, - NS_XOOB, - NS_URN_CARBONS, - NS_URN_CORRECT, - NS_URN_MARKERS, - NS_URN_IDLE, - NS_URN_ATTENTION, - NS_URN_REACH, - NS_URN_HINTS - ] - }; - - - /** - * Parse identities from disco infos query response - * @private - * @param {object} query - * @return {object} - */ - self._parseDiscoIdentities = function(query) { - - var identities = []; - - try { - var cur_category, cur_type, cur_lang, cur_name; - - $(query).find('identity').each(function() { - cur_category = $(this).attr('category') || ''; - cur_type = $(this).attr('type') || ''; - cur_lang = $(this).attr('xml:lang') || ''; - cur_name = $(this).attr('name') || ''; - - identities.push(cur_category + '/' + cur_type + '/' + cur_lang + '/' + cur_name); - }); - } catch(e) { - Console.error('Caps._parseDiscoIdentities', e); - } finally { - return identities; - } - - }; - - - /** - * Parse features from disco infos query response - * @private - * @param {object} query - * @return {object} - */ - self._parseDiscoFeatures = function(query) { - - var features = []; - - try { - var cur_var; - - $(query).find('feature').each(function() { - cur_var = $(this).attr('var'); - - // Add the current value to the array - if(cur_var) { - features.push(cur_var); - } - }); - } catch(e) { - Console.error('Caps._parseDiscoFatures', e); - } finally { - return features; - } - - }; - - - /** - * Parse data form from disco infos query response - * @private - * @param {object} query - * @return {object} - */ - self._parseDiscoDataForms = function(query) { - - var data_forms = []; - - try { - var cur_string, cur_sort_var, - cur_text, cur_var, cur_sort_val; - - $(query).find('x[xmlns="' + NS_XDATA + '"]').each(function() { - // Initialize some stuffs - cur_string = ''; - cur_sort_var = []; - - // Add the form type field - $(this).find('field[var="FORM_TYPE"] value').each(function() { - cur_text = $(this).text(); - - if(cur_text) { - cur_string += cur_text + '<'; - } - }); - - // Add the var attributes into an array - $(this).find('field:not([var="FORM_TYPE"])').each(function() { - cur_var = $(this).attr('var'); - - if(cur_var) { - cur_sort_var.push(cur_var); - } - }); - - // Sort the var attributes - cur_sort_var = cur_sort_var.sort(); - - // Loop this sorted var attributes - $.each(cur_sort_var, function(i) { - // Initialize the value sorting - cur_sort_val = []; - - // Append it to the string - cur_string += cur_sort_var[i] + '<'; - - // Add each value to the array - $(this).find('field[var=' + cur_sort_var[i] + '] value').each(function() { - cur_sort_val.push($(this).text()); - }); - - // Sort the values - cur_sort_val = cur_sort_val.sort(); - - // Append the values to the string - for(var j in cur_sort_val) { - cur_string += cur_sort_val[j] + '<'; - } - }); - - // Any string? - if(cur_string) { - // Remove the undesired double '<' from the string - if(cur_string.match(/(.+)(<)+$/)) { - cur_string = cur_string.substring(0, cur_string.length - 1); - } - - // Add the current string to the array - data_forms.push(cur_string); - } - }); - } catch(e) { - Console.error('Caps._parseDiscoDataForms', e); - } finally { - return data_forms; - } - - }; - - - /** - * Apply XHTML-IM features from disco infos - * @private - * @param {string} xid - * @param {object} features - * @param {object} style_sel - * @param {object} message_area_sel - * @return {undefined} - */ - self._applyDiscoXHTMLIM = function(xid, features, style_sel, message_area_sel) { - - try { - // Apply - if(NS_XHTML_IM in features) { - style_sel.show(); - } else { - // Remove the tooltip elements - style_sel.hide(); - style_sel.find('.bubble-style').remove(); - - // Reset the markers - message_area_sel.removeAttr('style') - .removeAttr('data-font') - .removeAttr('data-fontsize') - .removeAttr('data-color') - .removeAttr('data-bold') - .removeAttr('data-italic') - .removeAttr('data-underline'); - } - - } catch(e) { - Console.error('Caps._applyDiscoXHTMLIM', e); - } - - }; - - - /** - * Apply Jingle features from disco infos - * @private - * @param {string} xid - * @param {object} path_sel - * @param {object} roster_sel - * @return {undefined} - */ - self._applyDiscoJingle = function(xid, path_sel, roster_sel) { - - try { - // Selectors - var roster_jingle_sel = roster_sel.find('.buddy-infos .call-jingle'); - var jingle_audio = path_sel.find('.tools-jingle-audio'); - var roster_jingle_audio = roster_jingle_sel.find('a.audio'); - var jingle_video = path_sel.find('.tools-jingle-video'); - var roster_jingle_video = roster_jingle_sel.find('a.video'); - var roster_jingle_separator = roster_jingle_sel.find('span.separator'); - - // Apply - var jingle_local_supported = JSJAC_JINGLE_AVAILABLE; - var jingle_audio_xid = self.getFeatureResource(xid, NS_JINGLE_APPS_RTP_AUDIO); - var jingle_video_xid = self.getFeatureResource(xid, NS_JINGLE_APPS_RTP_VIDEO); - - if(jingle_audio_xid && jingle_local_supported) { - jingle_audio.show(); - roster_jingle_audio.show(); - } else { - jingle_audio.hide(); - roster_jingle_audio.hide(); - } - - if(jingle_video_xid && jingle_local_supported) { - jingle_video.show(); - roster_jingle_video.show(); - } else { - jingle_video.hide(); - roster_jingle_video.hide(); - } - - if(jingle_audio_xid && jingle_video_xid && jingle_local_supported) { - roster_jingle_separator.show(); - } else { - roster_jingle_separator.hide(); - } - - if((jingle_audio_xid || jingle_video_xid) && jingle_local_supported) { - roster_jingle_sel.show(); - } else { - roster_jingle_sel.hide(); - } - } catch(e) { - Console.error('Caps._applyDiscoJingle', e); - } - - }; - - - /** - * Apply Out of Band Data features from disco infos - * @private - * @param {string} xid - * @param {object} features - * @param {object} file_sel - * @return {undefined} - */ - self._applyDiscoOOB = function(xid, features, file_sel) { - - try { - // Apply - var iq_oob_xid = self.getFeatureResource(xid, NS_IQOOB); - - if(iq_oob_xid || NS_XOOB in features) { - file_sel.show(); - - // Set a marker - file_sel.attr( - 'data-oob', - iq_oob_xid ? 'iq' : 'x' - ); - } else { - // Remove the tooltip elements - file_sel.hide(); - file_sel.find('.bubble-style').remove(); - - // Reset the marker - file_sel.removeAttr('data-oob'); - } - } catch(e) { - Console.error('Caps._applyDiscoOOB', e); - } - - }; - - - /** - * Apply Receipts features from disco infos - * @private - * @param {string} xid - * @param {object} features - * @param {object} message_area_sel - * @return {undefined} - */ - self._applyDiscoReceipts = function(xid, features, message_area_sel) { - - try { - // Apply - if(NS_URN_RECEIPTS in features) { - message_area_sel.attr('data-receipts', 'true'); - } else { - message_area_sel.removeAttr('data-receipts'); - } - } catch(e) { - Console.error('Caps._applyDiscoReceipts', e); - } - - }; - - - /** - * Apply Last Message Correction features from disco infos - * @private - * @param {string} xid - * @param {object} features - * @param {object} path_sel - * @return {undefined} - */ - self._applyDiscoCorrection = function(xid, features, path_sel) { - - try { - // Apply - if(NS_URN_CORRECT in features) { - path_sel.attr('data-correction', 'true'); - } else { - path_sel.removeAttr('data-correction'); - } - } catch(e) { - Console.error('Caps._applyDiscoCorrection', e); - } - - }; - - - /** - * Apply Chat Markers features from disco infos - * @private - * @param {string} xid - * @param {object} features - * @param {object} path_sel - * @return {undefined} - */ - self._applyDiscoMarkers = function(xid, features, path_sel) { - - try { - // Apply - if(NS_URN_MARKERS in features) { - path_sel.attr('data-markers', 'true'); - } else { - path_sel.removeAttr('data-markers'); - } - } catch(e) { - Console.error('Caps._applyDiscoMarkers', e); - } - - }; - - - /** - * Apply Attention features from disco infos - * @private - * @param {string} xid - * @param {object} features - * @param {object} path_sel - * @return {undefined} - */ - self._applyDiscoAttention = function(xid, features, path_sel) { - - try { - // Apply - if(NS_URN_ATTENTION in features) { - path_sel.attr('data-attention', 'true'); - } else { - path_sel.removeAttr('data-attention'); - } - } catch(e) { - Console.error('Caps._applyDiscoAttention', e); - } - - }; - - - /** - * Reads a stored Caps - * @public - * @param {string} caps - * @return {object} - */ - self.read = function(caps) { - - try { - return Common.XMLFromString( - DataStore.getPersistent('global', 'caps', caps) - ); - } catch(e) { - Console.error('Caps.read', e); - } - - }; - - - /** - * Returns an array of the Jappix disco#infos - * @public - * @return {object} - */ - self.myDiscoInfos = function() { - - try { - var disco_base = self.disco_infos.items; - - var disco_jingle = JSJaCJingle.disco(); - var disco_all = disco_base.concat(disco_jingle); - - return Utils.uniqueArrayValues(disco_all); - } catch(e) { - Console.error('Caps.myDiscoInfos', e); - } - - }; - - - /** - * Gets the disco#infos of an entity - * @public - * @param {string} to - * @param {string} caps - * @return {boolean} - */ - self.getDiscoInfos = function(to, caps) { - - try { - // No CAPS - if(!caps) { - Console.warn('No CAPS: ' + to); - - self.displayDiscoInfos(to, ''); - - return false; - } - - // Get the stored disco infos - var xml = self.read(caps); - - // Yet stored - if(xml) { - Console.info('CAPS from cache: ' + to); - - self.displayDiscoInfos(to, xml); - - return true; - } - - Console.info('CAPS from the network: ' + to); - - // Not stored: get the disco#infos - var iq = new JSJaCIQ(); - - iq.setTo(to); - iq.setType('get'); - iq.setQuery(NS_DISCO_INFO); - - con.send(iq, self.handleDiscoInfos); - - return true; - } catch(e) { - Console.error('Caps.getDiscoInfos', e); - } - - }; - - - /** - * Handles the disco#infos of an entity - * @public - * @param {object} iq - * @return {undefined} - */ - self.handleDiscoInfos = function(iq) { - - try { - if(!iq || (iq.getType() == 'error')) { - return; - } - - var from = Common.fullXID(Common.getStanzaFrom(iq)); - var query = iq.getQuery(); - - // Parse values - var identities = self._parseDiscoIdentities(query); - var features = self._parseDiscoFeatures(query); - var data_forms = self._parseDiscoDataForms(query); - - // Process the CAPS - var caps = self.process(identities, features, data_forms); - - // Get the XML string - var xml = Common.xmlToString(query); - - // Store the disco infos - DataStore.setPersistent('global', 'caps', caps, xml); - - // This is our server - if(from == Utils.getServer()) { - // Handle the features - Features.handle(xml); - - Console.info('Got our server CAPS'); - } else { - // Display the disco infos - self.displayDiscoInfos(from, xml); - - Console.info('Got CAPS: ' + from); - } - } catch(e) { - Console.error('Caps.handleDiscoInfos', e); - } - - }; - - - /** - * Displays the disco#infos everywhere needed for an entity - * @public - * @param {string} from - * @param {string} xml - * @return {undefined} - */ - self.displayDiscoInfos = function(from, xml) { - - try { - // Generate the chat path - var xid = Common.bareXID(from); - - // This comes from a private groupchat chat? - if(Utils.isPrivate(xid)) { - xid = from; - } - - hash = hex_md5(xid); - - // Display the supported features - var features = {}; - - $(xml).find('feature').each(function() { - var current = $(this).attr('var'); - - if(current) { - features[current] = 1; - } - }); - - // Paths - var path_sel = $('#' + hash); - var roster_sel = $('#roster .buddy.' + hash); - var message_area_sel = path_sel.find('.message-area'); - var style_sel = path_sel.find('.chat-tools-style'); - var file_sel = path_sel.find('.chat-tools-file'); - - // Apply Features - self._applyDiscoXHTMLIM(xid, features, style_sel, message_area_sel); - self._applyDiscoJingle(xid, path_sel, roster_sel); - self._applyDiscoOOB(xid, features, file_sel); - self._applyDiscoReceipts(xid, features, message_area_sel); - self._applyDiscoCorrection(xid, features, path_sel); - self._applyDiscoMarkers(xid, features, path_sel); - self._applyDiscoAttention(xid, features, path_sel); - } catch(e) { - Console.error('Caps.displayDiscoInfos', e); - } - - }; - - - /** - * Generates the CAPS hash - * @public - * @param {object} identities - * @param {object} features - * @param {object} dataforms - * @return {string} - */ - self.process = function(identities, features, dataforms) { - - try { - // Initialize - var caps_str = ''; - - // Sort the arrays - identities = identities.sort(); - features = features.sort(); - dataforms = dataforms.sort(); - - // Process the sorted identity string - for(var a in identities) { - caps_str += identities[a] + '<'; - } - - // Process the sorted feature string - for(var b in features) { - caps_str += features[b] + '<'; - } - - // Process the sorted data-form string - for(var c in dataforms) { - caps_str += dataforms[c] + '<'; - } - - // Process the SHA-1 hash - var cHash = b64_sha1(caps_str); - - return cHash; - } catch(e) { - Console.error('Caps.process', e); - } - - }; - - - /** - * Generates the Jappix CAPS hash - * @public - * @return {string} - */ - self.mine = function() { - - try { - return self.process( - [ - self.disco_infos.identity.category + '/' + - self.disco_infos.identity.type + '//' + - self.disco_infos.identity.name - ], - - self.myDiscoInfos(), - [] - ); - } catch(e) { - Console.error('Caps.mine', e); - } - - }; - - - /** - * Returns the user resource supporting given feature w/ highest priority - * @public - * @param {string} xid - * @param {string} feature_ns - * @return {string} - */ - self.getFeatureResource = function(xid, feature_ns) { - - var selected_xid = null; - - try { - if(!feature_ns) { - throw 'No feature namespace given!'; - } - - var max_priority = null; - var cur_xid_full, cur_presence_sel, cur_caps, cur_features, cur_priority; - - var resources_obj = Presence.resources(xid); - var fn_parse_resource = function(cur_resource) { - cur_xid_full = xid; - - if(cur_resource) { - cur_xid_full += '/' + cur_resource; - } - - cur_presence_sel = $(Presence.readStanza(cur_xid_full)); - - cur_priority = parseInt((cur_presence_sel.find('priority').text() || 0), 10); - cur_caps = cur_presence_sel.find('caps').text(); - - if(cur_caps) { - cur_features = self.read(cur_caps); - - if(cur_features && $(cur_features).find('feature[var="' + feature_ns + '"]').size() && - (cur_priority >= max_priority || max_priority === null)) { - max_priority = cur_priority; - selected_xid = cur_xid_full; - } - } - }; - - if(resources_obj.bare === 1) { - fn_parse_resource(null); - } - - for(var cur_resource in resources_obj.list) { - fn_parse_resource(cur_resource); - } - } catch(e) { - Console.error('Caps.getFeatureResource', e); - } finally { - return selected_xid; - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); diff --git a/source/app/javascripts/carbons.js b/source/app/javascripts/carbons.js deleted file mode 100644 index 4635b94..0000000 --- a/source/app/javascripts/carbons.js +++ /dev/null @@ -1,241 +0,0 @@ -/* - -Jappix - An open social platform -These are the Message Carbons JS script for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var Carbons = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Configures Message Carbons options - * @private - * @param {string} type - * @return {undefined} - */ - self._configure = function(type) { - - try { - if(!(type in {'enable': 1, 'disable': 1})) { - Console.error('Carbons._configure', 'Invalid type (must be either "enable" or "disable")'); return; - } - - var iq = new JSJaCIQ(); - iq.setType('set'); - - iq.appendNode(type, {'xmlns': NS_URN_CARBONS}); - - con.send(iq, function(iq) { - self._handleConfigure(iq, type); - }); - } catch(e) { - Console.error('Carbons._configure', e); - } - - }; - - - /** - * Configures Message Carbons options - * @private - * @param {object} iq - * @param {string} type - * @return {undefined} - */ - self._handleConfigure = function(iq, type) { - - try { - if(iq.getType() === 'result') { - Console.log('Message Carbons successfully configured (type: ' + type + ')'); - } else { - Console.error('Message Carbons could not be configured (type: ' + type + ')'); - } - } catch(e) { - Console.error('Carbons._handleConfigure', e); - } - - }; - - - /** - * Enables Message Carbons for this session - * @public - * @return {undefined} - */ - self.enable = function() { - - try { - self._configure('enable'); - } catch(e) { - Console.error('Carbons.enable', e); - } - - }; - - - /** - * Disables Message Carbons for this session - * @public - * @return {undefined} - */ - self.disable = function() { - - try { - self._configure('disable'); - } catch(e) { - Console.error('Carbons.disable', e); - } - - }; - - - /** - * Returns whether the server has Carbons support or not - * @public - * @return {boolean} - */ - self.has = function() { - - try { - return Features.enabledCarbons(); - } catch(e) { - Console.error('Carbons.has', e); - } - - }; - - - /** - * Returns the forwarded message stanza - * @public - * @param {object} message - * @return {object} - */ - self._getForwarded = function(message) { - - try { - var forwarded_message = $(message.getNode()).find('forwarded[xmlns="' + NS_URN_FORWARD + '"]:first message:first'); - - if(forwarded_message[0]) { - return JSJaCPacket.wrapNode(forwarded_message[0]); - } - - return null; - } catch(e) { - Console.error('Carbons._getForwarded', e); - } - - }; - - - /** - * Handles a forwarded sent message - * @public - * @param {object} message - * @return {undefined} - */ - self.handleSent = function(message) { - - try { - var forwarded_message = self._getForwarded(message); - - if(forwarded_message !== null) { - var to = Common.bareXID(forwarded_message.getTo()); - var hash = hex_md5(to); - var type = forwarded_message.getType(); - - // Display sent message - if(type === 'chat' || !type) { - // Chat opened? (no need to display sent messages if chat does not exist there...) - if(Chat.exists(hash)) { - // Get more data - var id = forwarded_message.getID(); - var body = $.trim(forwarded_message.getBody()); - var my_xid = Common.getXID(); - - // Generate the message body - var html_escape = (Message.generate(forwarded_message, body, hash) !== 'XHTML'); - if(!html_escape) { - body = Filter.xhtml(forwarded_message.getNode()); - } - - if(body) { - // Display the message (finally!) - Message.display( - 'chat', - my_xid, - hash, - Name.getBuddy(my_xid).htmlEnc(), - body, - DateUtils.getCompleteTime(), - DateUtils.getTimeStamp(), - 'user-message', - html_escape, - '', - 'me', - id - ); - - Console.debug('Got a sent message from another resource to: ' + (to || 'none')); - } else { - Console.debug('Got a sent message from another resource to: ' + (to || 'none') + ', was ignored because body empty'); - } - - // Handle chat markers change - Markers.handleCarbonChange(forwarded_message); - } else { - Console.debug('Got a sent message from another resource to: ' + (to || 'none') + ', was ignored because chat not open'); - } - } else { - Console.warning('Got a sent message from another resource to: ' + (to || 'none') + ', was ignored because of type: ' + type); - } - } - } catch(e) { - Console.error('Carbons.handleSent', e); - } - - }; - - - /** - * Handles a forwarded received message - * @public - * @param {object} message - * @return {undefined} - */ - self.handleReceived = function(message) { - - try { - var forwarded_message = self._getForwarded(message); - - if(forwarded_message !== null) { - Console.debug('Got a received message from another resource from: ' + (forwarded_message.getFrom() || 'none')); - - Message.handle(forwarded_message); - } - } catch(e) { - Console.error('Carbons.handleReceived', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/chat.js b/source/app/javascripts/chat.js deleted file mode 100644 index a9f0bd6..0000000 --- a/source/app/javascripts/chat.js +++ /dev/null @@ -1,672 +0,0 @@ -/* - -Jappix - An open social platform -These are the chat JS scripts for Jappix - -------------------------------------------------- - -License: AGPL -Authors: Valérian Saliou, Eric, Maranda - -*/ - -// Bundle -var Chat = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Apply generate events - * @private - * @param {string} path - * @param {string} id - * @param {string} xid - * @return {undefined} - */ - self._generateEvents = function(path, id, xid) { - - try { - // Click event: chat cleaner - $(path + 'tools-clear').click(function() { - self.clean(id); - }); - - // Click event: call (audio) - $(path + 'tools-jingle-audio').click(function() { - Jingle.start(xid, 'audio'); - }); - - // Click event: call (video) - $(path + 'tools-jingle-video').click(function() { - Jingle.start(xid, 'video'); - }); - - // Click event: user-infos - $(path + 'tools-infos').click(function() { - UserInfos.open(xid); - }); - } catch(e) { - Console.error('Chat._generateEvents', e); - } - - }; - - - /** - * Apply generate events - * @private - * @param {object} input_sel - * @param {string} xid - * @param {string} hash - * @return {undefined} - */ - self._createEvents = function(input_sel, xid, hash) { - - try { - self._createEventsInput(input_sel, hash); - self._createEventsKey(input_sel, xid, hash); - self._createEventsMouse(xid, hash); - } catch(e) { - Console.error('Chat._createEvents', e); - } - - }; - - - /** - * Apply generate events (input) - * @private - * @param {object} input_sel - * @param {string} hash - * @return {undefined} - */ - self._createEventsInput = function(input_sel, hash) { - - try { - input_sel.focus(function() { - // Clean notifications for this chat - Interface.chanCleanNotify(hash); - - // Store focus on this chat! - Interface.chat_focus_hash = hash; - }); - - input_sel.blur(function() { - // Reset storage about focus on this chat! - if(Interface.chat_focus_hash == hash) { - Interface.chat_focus_hash = null; - } - }); - } catch(e) { - Console.error('Chat._createEventsInput', e); - } - - }; - - - /** - * Apply generate events (key) - * @private - * @param {object} input_sel - * @param {string} xid - * @param {string} hash - * @return {undefined} - */ - self._createEventsKey = function(input_sel, xid, hash) { - - try { - input_sel.keydown(function(e) { - if(e.keyCode == 13) { - // Enter key - if(e.shiftKey || e.ctrlKey) { - // Add a new line - input_sel.val(input_sel.val() + '\n'); - } else { - if(Correction.isIn(xid) === true) { - var corrected_value = input_sel.val().trim(); - - if(corrected_value) { - // Send the corrected message - Correction.send(xid, 'chat', corrected_value); - } - - Correction.leave(xid); - } else { - // Send the message - Message.send(hash, 'chat'); - } - - // Reset the composing database entry - DataStore.setDB(Connection.desktop_hash, 'chatstate', xid, 'off'); - } - - return false; - } else if(e.keyCode == 8) { - // Leave correction mode? (another way, by flushing input value progressively) - if(Correction.isIn(xid) === true && !input_sel.val()) { - Correction.leave(xid); - } - } - }); - - input_sel.keyup(function(e) { - if(e.keyCode == 27) { - // Escape key - input_sel.val(''); - - // Leave correction mode? (simple escape way) - if(Correction.isIn(xid) === true) { - Correction.leave(xid); - } - } else { - Correction.detect(xid, input_sel); - } - }); - } catch(e) { - Console.error('Chat._createEventsKey', e); - } - - }; - - - /** - * Apply generate events (mouse) - * @private - * @param {string} xid - * @param {string} hash - * @return {undefined} - */ - self._createEventsMouse = function(xid, hash) { - - try { - // Scroll in chat content - $('#page-engine #' + hash + ' .content').scroll(function() { - var self = this; - - if(Features.enabledMAM() && !(xid in MAM.map_pending)) { - var has_state = xid in MAM.map_states; - var rsm_count = has_state ? MAM.map_states[xid].rsm.count : 1; - var rsm_before = has_state ? MAM.map_states[xid].rsm.first : ''; - - // Request more archives? - if(rsm_count > 0 && $(this).scrollTop() < MAM.SCROLL_THRESHOLD) { - var was_scroll_top = $(self).scrollTop() <= 32; - var wait_mam = $('#' + hash).find('.wait-mam'); - wait_mam.show(); - - MAM.getArchives({ - 'with': xid - }, { - 'max': MAM.REQ_MAX, - 'before': rsm_before - }, function() { - var wait_mam_height = was_scroll_top ? 0 : wait_mam.height(); - wait_mam.hide(); - - // Restore scroll? - if($(self).scrollTop() < MAM.SCROLL_THRESHOLD) { - var sel_mam_chunk = $(self).find('.mam-chunk:first'); - - var cont_padding_top = parseInt($(self).css('padding-top').replace(/[^-\d\.]/g, '')); - var cont_one_group_margin_bottom = parseInt(sel_mam_chunk.find('.one-group:last').css('margin-bottom').replace(/[^-\d\.]/g, '')); - var cont_mam_chunk_height = sel_mam_chunk.height(); - - $(self).scrollTop(wait_mam_height + cont_padding_top + cont_one_group_margin_bottom + cont_mam_chunk_height); - } - }); - } - } - }); - } catch(e) { - Console.error('Chat._createEventsMouse', e); - } - - }; - - - /** - * Apply generate events - * @private - * @param {string} type - * @param {string} id - * @param {string} xid - * @return {object} - */ - self._generateChatCode = function(type, id, xid) { - - var code_args = {}; - - try { - // Groupchat special code - if(type == 'groupchat') { - code_args.attributes = ' data-type="groupchat" data-correction="true"'; - code_args.avatar = ''; - code_args.name = '

' + Common._e("Subject") + ' ' + Common._e("no subject defined for this room.") + '

'; - code_args.code = '
' + - '

' + Common._e("Moderators") + '

' + - '

' + Common._e("Participants") + '

' + - '

' + Common._e("Visitors") + '

' + - '

' + Common._e("Others") + '

'; - code_args.link = ''; - code_args.style = ''; - - // Is this a gateway? - if(xid.match(/%/)) { - code_args.disabled = ''; - } else { - code_args.disabled = ' disabled=""'; - } - } else { - code_args.mam = '
'; - code_args.attributes = ' data-type="chat"'; - code_args.avatar = '
'; - code_args.name = '

'; - code_args.code = '
' + code_args.mam + '
'; - code_args.link = '' + - '' + - ''; - code_args.style = ' style="display: none;"'; - code_args.disabled = ''; - } - - // Not a groupchat private chat, we can use the buddy add icon - if((type == 'chat') || (type == 'groupchat')) { - var title; - - if(type == 'chat') { - title = Common._e("Add this contact to your friends"); - } else { - title = Common._e("Add this groupchat to your favorites"); - } - - code_args.link += ''; - } - - // IE DOM parsing bug fix - code_args.style_picker = '
' + - '' + - '
'; - - if((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version < 9)) { - code_args.style_picker = ''; - } - } catch(e) { - Console.error('Chat._generateChatCode', e); - } finally { - return code_args; - } - - }; - - - /** - * Correctly opens a new chat - * @public - * @param {string} xid - * @param {string} type - * @param {string} nickname - * @param {string} password - * @param {string} title - * @return {boolean} - */ - self.checkCreate = function(xid, type, nickname, password, title) { - - try { - // No XID? - if(!xid) { - return false; - } - - // We generate some stuffs - var hash = hex_md5(xid); - var name; - - // Gets the name of the user/title of the room - if(title) { - name = title; - } else { - // Private groupchat chat - if(type == 'private') { - name = Common.thisResource(xid); - } - - // XMPP-ID - else if(xid.indexOf('@') != -1) { - name = Name.getBuddy(xid); - } - - // Gateway - else { - name = xid; - } - } - - // If the target div does not exist - if(!Common.exists('#' + hash)) { - // We check the type of the chat to open - if((type == 'chat') || (type == 'private')) { - self.create(hash, xid, name, type); - } else if(type == 'groupchat') { - // Try to read the room stored configuration - if(!Utils.isAnonymous() && (!nickname || !password || !title)) { - // Catch the room data - var fData = $(Common.XMLFromString(DataStore.getDB(Connection.desktop_hash, 'favorites', xid))); - var fNick = fData.find('nick').text(); - var fPwd = fData.find('password').text(); - var fName = fData.find('name').text(); - - // Apply the room data - if(!nickname && fNick) - nickname = fNick; - if(!password && fPwd) - password = fPwd; - if(!title && fName) - name = fName; - } - - Groupchat.create(hash, xid, name, nickname, password); - } - } - - // Switch to the newly-created chat - Interface.switchChan(hash); - } catch(e) { - Console.error('Chat.checkCreate', e); - } finally { - return false; - } - - }; - - - /** - * Generates the chat DOM elements - * @public - * @param {string} type - * @param {string} id - * @param {string} xid - * @param {string} nick - * @return {undefined} - */ - self.generate = function(type, id, xid, nick) { - - try { - // Generate some stuffs - var path = '#' + id + ' .'; - var escaped_xid = escape(xid); - - // Special code - var chat_args = self._generateChatCode(type, id, xid); - - // Append the chat HTML code - $('#page-engine').append( - '
' + - '
' + - chat_args.avatar + - - '
' + - '

' + nick.htmlEnc() + '

' + - chat_args.name + - '
' + - '
' + - - chat_args.code + - - '
' + - '' + - - '
' + - '' + - '
' + - '
' + - '
' - ); - - self._generateEvents(path, id, xid); - } catch(e) { - Console.error('Chat.generate', e); - } - - }; - - - /** - * Generates the chat switch elements - * @public - * @param {string} type - * @param {string} id - * @param {string} xid - * @param {string} nick - * @return {undefined} - */ - self.generateSwitch = function(type, id, xid, nick) { - - try { - // Path to the element - var chat_switch = '#page-switch .'; - - // Special code - var special_class = ' unavailable'; - var show_close = true; - - // Groupchat - if(type == 'groupchat') { - special_class = ' groupchat-default'; - - if(Utils.isAnonymous() && (xid == Common.generateXID(ANONYMOUS_ROOM, 'groupchat'))) { - show_close = false; - } - } - - // Generate the HTML code - var html = '
' + - '
' + - - '
' + nick.htmlEnc() + '
'; - - // Show the close button if not MUC and not anonymous - if(show_close) { - html += '
' + - 'x' + - '
'; - } - - // Close the HTML - html += '
'; - - // Append the HTML code - $(chat_switch + 'chans, ' + chat_switch + 'more-content').append(html); - } catch(e) { - Console.error('Chat.generateSwitch', e); - } - - }; - - - /** - * Cleans given the chat lines - * @public - * @param {string} chat - * @return {undefined} - */ - self.clean = function(chat) { - - try { - // Remove the messages - $('#page-engine #' + chat + ' .content .one-group').remove(); - - // Clear the history database - Message.removeLocalArchive(chat); - - // Focus again - $(document).oneTime(10, function() { - $('#page-engine #' + chat + ' .text .message-area').focus(); - }); - } catch(e) { - Console.error('Chat.clean', e); - } - - }; - - - /** - * Returns whether chat exists or not - * @public - * @param {string} hash - * @return {boolean} - */ - self.exists = function(hash) { - - exists = false; - - try { - if(hash) { - exists = Common.exists('#' + hash + '.page-engine-chan[data-type="chat"]'); - } - } catch(e) { - Console.error('Chat.exists', e); - } finally { - return exists; - } - - }; - - - /** - * Creates a new chat - * @public - * @param {string} hash - * @param {string} xid - * @param {string} nick - * @param {string} type - * @return {undefined} - */ - self.create = function(hash, xid, nick, type) { - - try { - Console.info('New chat: ' + xid); - - // Create the chat content - self.generate(type, hash, xid, nick); - - // Create the chat switcher - self.generateSwitch(type, hash, xid, nick); - - // Is this a chat? - if(type == 'chat') { - // MAM? Get archives from there! - if(Features.enabledMAM()) { - MAM.getArchives({ - 'with': xid - }, { - 'max': MAM.REQ_MAX, - 'before': '' - }); - } else { - // Restore the chat history - var chat_history = Message.readLocalArchive(hash); - - if(chat_history) { - // Generate hashs - var my_hash = hex_md5(Common.getXID()); - var friend_hash = hex_md5(xid); - - // Add chat history HTML - var path_sel = $('#' + hash); - - path_sel.find('.content').append(chat_history); - - // Filter old groups & messages - var one_group_sel = path_sel.find('.one-group'); - one_group_sel.filter('[data-type="user-message"]').addClass('from-history').attr('data-type', 'old-message'); - path_sel.find('.user-message').removeClass('user-message').addClass('old-message'); - - // Regenerate user names - one_group_sel.filter('.' + my_hash + ' b.name').text( - Name.getBuddy(Common.getXID()) - ); - - one_group_sel.filter('.' + friend_hash + ' b.name').text( - Name.getBuddy(xid) - ); - - // Regenerate group dates - one_group_sel.each(function() { - var current_stamp = parseInt($(this).attr('data-stamp'), 10); - $(this).find('span.date').text(DateUtils.relative(current_stamp)); - }); - - // Regenerate avatars - if(Common.exists('#' + hash + ' .one-group.' + my_hash + ' .avatar-container')) { - Avatar.get(Common.getXID(), 'cache', 'true', 'forget'); - } - - if(Common.exists('#' + hash + ' .one-group.' + friend_hash + ' .avatar-container')) { - Avatar.get(xid, 'cache', 'true', 'forget'); - } - } - } - - // Add button - if(!Roster.isFriend(xid)) { - $('#' + hash + ' .tools-add').click(function() { - // Hide the icon (to tell the user all is okay) - $(this).hide(); - - // Send the subscribe request - Roster.addThisContact(xid, nick); - }).show(); - } - } - - // We catch the user's informations (like this avatar, vcard, and so on...) - UserInfos.get(hash, xid, nick, type); - - // The icons-hover functions - Tooltip.icons(xid, hash); - - // The event handlers - var input_sel = $('#page-engine #' + hash + ' .message-area'); - self._createEvents(input_sel, xid, hash); - - // Input events - ChatState.events(input_sel, xid, hash, 'chat'); - Markers.events(input_sel, xid, hash, 'chat'); - } catch(e) { - Console.error('Chat.create', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); diff --git a/source/app/javascripts/chatstate.js b/source/app/javascripts/chatstate.js deleted file mode 100644 index d0353fb..0000000 --- a/source/app/javascripts/chatstate.js +++ /dev/null @@ -1,252 +0,0 @@ -/* - -Jappix - An open social platform -These are the chatstate JS script for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var ChatState = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Sends a given chatstate to a given entity - * @public - * @param {string} state - * @param {string} xid - * @param {string} hash - * @return {undefined} - */ - self.send = function(state, xid, hash) { - - try { - var user_type = $('#' + hash).attr('data-type'); - - // If the friend client supports chatstates and is online - if((user_type == 'groupchat') || ((user_type == 'chat') && $('#' + hash + ' .message-area').attr('data-chatstates') && !Common.exists('#page-switch .' + hash + ' .unavailable'))) { - // Already sent? - if(DataStore.getDB(Connection.desktop_hash, 'currentchatstate', xid) == state) { - return; - } - - // Write the state - DataStore.setDB(Connection.desktop_hash, 'currentchatstate', xid, state); - - // New message stanza - var aMsg = new JSJaCMessage(); - aMsg.setTo(xid); - aMsg.setType(user_type); - - // Append the chatstate node - aMsg.appendNode(state, { - 'xmlns': NS_CHATSTATES - }); - - // Send this! - con.send(aMsg); - } - } catch(e) { - Console.error('ChatState.send', e); - } - - }; - - - /** - * Displays a given chatstate in a given chat - * @public - * @param {string} state - * @param {string} hash - * @param {string} type - * @return {undefined} - */ - self.display = function(state, hash, type) { - - try { - // Groupchat? - if(type == 'groupchat') { - self.reset(hash, type); - - // "gone" state not allowed - if(state != 'gone') { - $('#page-engine .page-engine-chan .user.' + hash).addClass(state); - } - } - - // Chat - else { - // We change the buddy name color in the page-switch - self.reset(hash, type); - $('#page-switch .' + hash + ' .name').addClass(state); - - // We generate the chatstate text - var text = ''; - - switch(state) { - // Active - case 'active': - text = Common._e("Your friend is paying attention to the conversation."); - - break; - - // Composing - case 'composing': - text = Common._e("Your friend is writing a message..."); - - break; - - // Paused - case 'paused': - text = Common._e("Your friend stopped writing a message."); - - break; - - // Inactive - case 'inactive': - text = Common._e("Your friend is doing something else."); - - break; - - // Gone - case 'gone': - text = Common._e("Your friend closed the chat."); - - break; - } - - // We reset the previous state - $('#' + hash + ' .chatstate').remove(); - - // We create the chatstate - $('#' + hash + ' .content').after( - '
' + text + '
' - ); - } - } catch(e) { - Console.error('ChatState.display', e); - } - - }; - - - /** - * Resets the chatstate switcher marker - * @public - * @param {string} hash - * @param {string} type - * @return {undefined} - */ - self.reset = function(hash, type) { - - try { - // Define the selector - var selector; - - if(type == 'groupchat') { - selector = $('#page-engine .page-engine-chan .user.' + hash); - } else { - selector = $('#page-switch .' + hash + ' .name'); - } - - // Reset! - selector.removeClass('active composing paused inactive gone'); - } catch(e) { - Console.error('ChatState.reset', e); - } - - }; - - - /** - * Adds the chatstate events - * @public - * @param {object} target - * @param {string} xid - * @param {string} hash - * @param {string} type - * @return {undefined} - */ - self.events = function(target, xid, hash, type) { - - try { - target.keyup(function(e) { - if(e.keyCode != 13) { - // Composing a message - if($(this).val() && (DataStore.getDB(Connection.desktop_hash, 'chatstate', xid) != 'on')) { - // We change the state detect input - DataStore.setDB(Connection.desktop_hash, 'chatstate', xid, 'on'); - - // We send the friend a "composing" chatstate - self.send('composing', xid, hash); - } - - // Flushed the message which was being composed - else if(!$(this).val() && (DataStore.getDB(Connection.desktop_hash, 'chatstate', xid) == 'on')) { - // We change the state detect input - DataStore.setDB(Connection.desktop_hash, 'chatstate', xid, 'off'); - - // We send the friend an "active" chatstate - self.send('active', xid, hash); - } - } - }); - - target.change(function() { - // Reset the composing database entry - DataStore.setDB(Connection.desktop_hash, 'chatstate', xid, 'off'); - }); - - target.focus(function() { - // Not needed - if(target.is(':disabled')) { - return; - } - - // Something was written, user started writing again - if($(this).val()) { - self.send('composing', xid, hash); - } - - // Chat only: Nothing in the input, user is active - else if(type == 'chat') { - self.send('active', xid, hash); - } - }); - - target.blur(function() { - // Not needed - if(target.is(':disabled')) { - return; - } - - // Something was written, user paused - if($(this).val()) { - self.send('paused', xid, hash); - } else if(type == 'chat') { - self.send('inactive', xid, hash); - } - }); - } catch(e) { - Console.error('ChatState.events', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/common.js b/source/app/javascripts/common.js deleted file mode 100644 index 5874604..0000000 --- a/source/app/javascripts/common.js +++ /dev/null @@ -1,906 +0,0 @@ -/* - -Jappix - An open social platform -These are the common JS script for Jappix - -------------------------------------------------- - -License: dual-licensed under AGPL and MPLv2 -Authors: Valérian Saliou, olivierm, regilero, Maranda - -*/ - -// Bundle -var Common = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Constants */ - self.R_DOMAIN_NAME = /^(([a-zA-Z0-9-\.]+)\.)?[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/i; - - - /** - * Checks if an element exists in the DOM - * @public - * @param {string} path - * @return {boolean} - */ - self.exists = function(path) { - - var exists = false; - - try { - if(jQuery(path).size() > 0) { - exists = true; - } - } catch(e) { - Console.error('Common.exists', e); - } finally { - return exists; - } - - }; - - - /** - * Checks if Jappix is connected - * @public - * @return {boolean} - */ - self.isConnected = function() { - - connected = false; - - try { - if((typeof con != 'undefined') && con && con.connected()) { - connected = true; - } - } catch(e) { - Console.error('Common.isConnected', e); - } finally { - return connected; - } - - }; - - - /** - * Checks if Jappix is connected - * @public - * @return {boolean} - */ - self.hasWebSocket = function() { - - has_websocket = false; - - try { - if(HOST_WEBSOCKET && typeof window.WebSocket != 'undefined') { - has_websocket = true; - } - } catch(e) { - Console.error('Common.hasWebSocket', e); - } finally { - return has_websocket; - } - - }; - - - /** - * Checks if Jappix has focus - * @public - * @return {boolean} - */ - self.isFocused = function() { - - has_focus = true; - - try { - if(!document.hasFocus()) { - has_focus = false; - } - } catch(e) { - Console.error('Common.isFocused', e); - } finally { - return has_focus; - } - - }; - - - /** - * Matches a domain name - * @public - * @param {string} xid - * @return {boolean} - */ - self.isDomain = function(xid) { - - is_domain = false; - - try { - if(xid.match(self.R_DOMAIN_NAME)) { - is_domain = true; - } - } catch(e) { - Console.error('Common.isDomain', e); - } finally { - return is_domain; - } - - }; - - - /** - * Generates the good XID - * @public - * @param {string} xid - * @param {string} type - * @return {string} - */ - self.generateXID = function(xid, type) { - - try { - // XID needs to be transformed - xid = xid.toLowerCase(); - - if(xid && (xid.indexOf('@') === -1)) { - // Groupchat XID - if(type == 'groupchat') { - return xid + '@' + HOST_MUC; - } - - // Gateway XID - if(self.isDomain(xid) === true) { - return xid; - } - - // User XID - return xid + '@' + HOST_MAIN; - } - - // Nothing special (yet bare XID) - return xid; - } catch(e) { - Console.error('Common.generateXID', e); - } - - }; - - - /** - * Gets the asked translated string - * @public - * @param {string} string - * @return {string} - */ - self._e = function(string) { - - try { - return string; - } catch(e) { - Console.error('Common._e', e); - } - - }; - - - /** - * Replaces '%s' to a given value for a translated string - * @public - * @param {string} string - * @param {string} value - * @return {string} - */ - self.printf = function(string, value) { - - try { - return string.replace('%s', value); - } catch(e) { - Console.error('Common.printf', e); - } - - }; - - - /** - * Returns the string after the last given char - * @public - * @param {string} given_char - * @param {string} str - * @return {string} - */ - self.strAfterLast = function(given_char, str) { - - try { - if(!given_char || !str) { - return ''; - } - - var char_index = str.lastIndexOf(given_char); - var str_return = str; - - if(char_index >= 0) { - str_return = str.substr(char_index + 1); - } - - return str_return; - } catch(e) { - Console.error('Common.strAfterLast', e); - } - - }; - - - /** - * Properly explodes a string with a given character - * @public - * @param {string} toEx - * @param {string} toStr - * @param {number} i - * @return {string} - */ - self.explodeThis = function(toEx, toStr, i) { - - try { - // Get the index of our char to explode - var index = toStr.indexOf(toEx); - - // We split if necessary the string - if(index !== -1) { - if(i === 0) { - toStr = toStr.substr(0, index); - } else { - toStr = toStr.substr(index + 1); - } - } - - // We return the value - return toStr; - } catch(e) { - Console.error('Common.explodeThis', e); - } - - }; - - - /** - * Cuts the resource of a XID - * @public - * @param {string} aXID - * @return {string} - */ - self.cutResource = function(aXID) { - - try { - return self.explodeThis('/', aXID, 0); - } catch(e) { - Console.error('Common.cutResource', e); - } - - }; - - - /** - * Gets the resource of a XID - * @public - * @param {string} aXID - * @return {string} - */ - self.thisResource = function(aXID) { - - resource = ''; - - try { - // Any resource? - if(self.isFullXID(aXID)) { - resource = self.explodeThis('/', aXID, 1); - } - } catch(e) { - Console.error('Common.thisResource', e); - } finally { - return resource; - } - - }; - - - /** - * Returns whether this XID is full or not - * @public - * @param {string} xid - * @return {boolean} - */ - self.isFullXID = function(xid) { - - try { - return xid.indexOf('/') !== -1; - } catch(e) { - Console.error('Common.isFullXID', e); - - return false; - } - - }; - - - /** - * nodepreps an XMPP node - * @public - * @param {string} node - * @return {string} - */ - self.nodeprep = function(node) { - - // Spec: http://tools.ietf.org/html/rfc6122#appendix-A - - try { - if(!node) { - return node; - } - - // Remove prohibited chars - var prohibited_chars = ['"', '&', '\'', '/', ':', '<', '>', '@']; - - for(var j in prohibited_chars) { - node = node.replace(prohibited_chars[j], ''); - } - - // Lower case - node = node.toLowerCase(); - - return node; - } catch(e) { - Console.error('Common.nodeprep', e); - } - - }; - - - /** - * Encodes quotes in a string - * @public - * @param {string} str - * @return {string} - */ - self.encodeQuotes = function(str) { - - try { - return (str + '').htmlEnc(); - } catch(e) { - Console.error('Common.encodeQuotes', e); - } - - }; - - - /** - * Escapes quotes in a string - * @public - * @param {string} str - * @return {string} - */ - self.escapeQuotes = function(str) { - - try { - return escape(self.encodeQuotes(str)); - } catch(e) { - Console.error('Common.escapeQuotes', e); - } - - }; - - - /** - * Unescapes quotes in a string - * @public - * @param {string} str - * @return {string} - */ - self.unescapeQuotes = function(str) { - - try { - return unescape(str); - } catch(e) { - Console.error('Common.unescapeQuotes', e); - } - - }; - - - /** - * Gets the bare XID from a XID - * @public - * @param {string} xid - * @return {string} - */ - self.bareXID = function(xid) { - - try { - // Cut the resource - xid = self.cutResource(xid); - - // Launch nodeprep - if(xid.indexOf('@') !== -1) { - xid = self.nodeprep(self.getXIDNick(xid, true)) + '@' + self.getXIDHost(xid); - } - - return xid; - } catch(e) { - Console.error('Common.bareXID', e); - } - - }; - - - /** - * Gets the full XID from a XID - * @public - * @param {string} xid - * @return {string} - */ - self.fullXID = function(xid) { - - try { - // Normalizes the XID - var full = self.bareXID(xid); - var resource = self.thisResource(xid); - - // Any resource? - if(resource) { - full += '/' + resource; - } - - return full; - } catch(e) { - Console.error('Common.fullXID', e); - } - - }; - - - /** - * Gets the nick from a XID - * @public - * @param {string} aXID - * @param {boolean} raw_explode - * @return {string} - */ - self.getXIDNick = function(aXID, raw_explode) { - - try { - if(raw_explode !== true) { - // Gateway nick? - if(aXID.match(/\\40/)) { - return self.explodeThis('\\40', aXID, 0); - } - } - - return self.explodeThis('@', aXID, 0); - } catch(e) { - Console.error('Common.getXIDNick', e); - } - - }; - - - /** - * Gets the host from a XID - * @public - * @param {string} aXID - * @return {string} - */ - self.getXIDHost = function(aXID) { - - try { - return self.explodeThis('@', aXID, 1); - } catch(e) { - Console.error('Common.getXIDHost', e); - } - - }; - - - /** - * Checks if we are RTL (Right-To-Left) - * @public - * @return {boolean} - */ - self.isRTL = function() { - - try { - return (self._e("default:LTR") == 'default:RTL'); - } catch(e) { - Console.error('Common.isRTL', e); - } - - }; - - - /** - * Checks if anonymous mode is allowed - * @public - * @return {boolean} - */ - self.allowedAnonymous = function() { - - try { - return (ANONYMOUS == 'on'); - } catch(e) { - Console.error('Common.allowedAnonymous', e); - } - - }; - - - /** - * Checks if host is locked - * @public - * @return {boolean} - */ - self.lockHost = function() { - - try { - return (LOCK_HOST == 'on'); - } catch(e) { - Console.error('Common.lockHost', e); - } - - }; - - - /** - * Gets the bare XID of the user - * @public - * @return {string} - */ - self.getXID = function() { - - try { - // Return the XID of the user - if(con.username && con.domain) { - return con.username + '@' + con.domain; - } - - return ''; - } catch(e) { - Console.error('Common.getXID', e); - } - - }; - - - /** - * Gets the full XID of the user - * @public - * @return {string} - */ - self.getFullXID = function() { - - try { - var xid = self.getXID(); - - // Return the full XID of the user - if(xid) { - return xid + '/' + con.resource; - } - - return ''; - } catch(e) { - Console.error('Common.getFullXID', e); - } - - }; - - - /** - * Generates the colors for a given user XID - * @public - * @param {type} xid - * @return {string} - */ - self.generateColor = function(xid) { - - try { - var colors = new Array( - 'ac0000', - 'a66200', - '007703', - '00705f', - '00236b', - '4e005c' - ); - - var number = 0; - - for(var i = 0; i < xid.length; i++) { - number += xid.charCodeAt(i); - } - - var color = '#' + colors[number % (colors.length)]; - - return color; - } catch(e) { - Console.error('Common.generateColor', e); - } - - }; - - - /** - * Checks if the XID is a gateway - * @public - * @param {string} xid - * @return {boolean} - */ - self.isGateway = function(xid) { - - is_gateway = true; - - try { - if(xid.indexOf('@') !== -1) { - is_gateway = false; - } - } catch(e) { - Console.error('Common.isGateway', e); - } finally { - return is_gateway; - } - - }; - - - /** - * Gets the from attribute of a stanza (overrides some servers like Prosody missing from attributes) - * @public - * @param {object} stanza - * @return {string} - */ - self.getStanzaFrom = function(stanza) { - - try { - var from = stanza.getFrom(); - - // No from, we assume this is our XID - if(!from) { - from = self.getXID(); - } - - return from; - } catch(e) { - Console.error('Common.getStanzaFrom', e); - } - - }; - - - /** - * Returns whether the stanza has been really sent from our own server or entity - * @public - * @param {object} stanza - * @return {string} - */ - self.isSafeStanza = function(stanza) { - - var is_safe = false; - - try { - var from = self.getStanzaFrom(stanza); - - is_safe = (!from || from == con.domain || from == self.getXID()) && true; - } catch(e) { - Console.error('Common.isSafeStanza', e); - } finally { - return is_safe; - } - - }; - - - /** - * Adds a zero to a date when needed - * @public - * @param {number} i - * @return {string} - */ - self.padZero = function(i) { - - try { - // Negative number (without first 0) - if(i > -10 && i < 0) { - return '-0' + (i * -1); - } - - // Positive number (without first 0) - if(i < 10 && i >= 0) { - return '0' + i; - } - - // All is okay - return i; - } catch(e) { - Console.error('Common.padZero', e); - } - - }; - - - /** - * Escapes a string (or an array of string) for a regex usage. In case of an - * array, escapes are not done "in place", keeping the query unmodified - * @public - * @param {object} query - * @return {object} - */ - self.escapeRegex = function(query) { - - var result = []; - - try { - if(query instanceof Array) { - result = [query.length]; - - for(i = 0; i < query.length; i++) { - try { - result[i] = Common.escapeRegex(query[i]); - } catch(e) { - Console.error('Common.escapeRegex', e); - result[i] = null; - } - } - } else { - try { - result = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); - } catch(e) { - Console.error('Common.escapeRegex[inner]', e); - } - } - } catch(e) { - Console.error('Common.escapeRegex', e); - } finally { - return result; - } - - }; - - - /** - * Returns a random array value - * @public - * @param {object} arr - * @return {object} - */ - self.randomArrayValue = function(arr) { - - try { - return arr[Math.floor(Math.random() * arr.length)]; - } catch(e) { - Console.error('Common.randomArrayValue', e); - } - - }; - - - /** - * Returns whether the browser is mobile or not - * @public - * @return {boolean} - */ - self.isMobile = function() { - - is_mobile = false; - - try { - is_mobile = /Android|iPhone|iPod|iPad|Windows Phone|BlackBerry|Bada|Maemo|Meego|webOS/i.test(navigator.userAgent); - } catch(e) { - Console.error('Common.isMobile', e); - } finally { - return is_mobile; - } - - }; - - - /** - * Converts a XML document to a string - * @public - * @param {object} xmlData - * @return {string} - */ - self.xmlToString = function(xmlData) { - - xml_str = null; - - try { - // For Mozilla, Firefox, Opera, etc. - if(window.XMLSerializer) { - xml_str = (new XMLSerializer()).serializeToString(xmlData); - } - - // For Internet Explorer - if(window.ActiveXObject) { - xml_str = xmlData.xml; - } - } catch(e) { - Console.error('Common.xmlToString', e); - } finally { - return xml_str; - } - - }; - - - /** - * Converts a string to a XML document - * @public - * @param {string} sXML - * @return {object} - */ - self.XMLFromString = function(sXML) { - - try { - // No data? - if(!sXML) { - return ''; - } - - // Add the XML tag - if(!sXML.match(/^<\?xml/i)) { - sXML = '' + sXML; - } - - // Parse it! - if(window.DOMParser) { - return (new DOMParser()).parseFromString(sXML, 'text/xml'); - } - - if(window.ActiveXObject) { - var oXML = new ActiveXObject('Microsoft.XMLDOM'); - oXML.loadXML(sXML); - - return oXML; - } - } catch(e) { - Console.error('Common.XMLFromString', e); - - return ''; - } - - }; - - - /** - * Watches for input value change (delays callback) - * @public - * @param {function} cb - * @return {function} - */ - self.typewatch = function(cb) { - - try { - var timer = 0; - - return function(callback, ms) { - clearTimeout(timer); - timer = setTimeout(callback, ms); - }; - } catch(e) { - Console.error('Common.typewatch', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); - -var JappixCommon = Common; diff --git a/source/app/javascripts/connection.js b/source/app/javascripts/connection.js deleted file mode 100644 index 6f1dadb..0000000 --- a/source/app/javascripts/connection.js +++ /dev/null @@ -1,1034 +0,0 @@ -/* - -Jappix - An open social platform -These are the connection JS script for Jappix - -------------------------------------------------- - -License: AGPL -Authors: Valérian Saliou, Maranda - -*/ - -// Bundle -var Connection = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Variables */ - self.current_session = false; - self.desktop_hash = null; - self.connected = false; - self.reconnect_try = 0; - self.reconnect_timer = 0; - self.resume = false; - - - /** - * Do registration on Register API - * @private - * @param {string} username - * @param {string} domain - * @param {string} pass - * @param {string} captcha - * @return {boolean} - */ - self._doRegisterAPI = function(username, domain, pass, captcha) { - - var is_success = false; - - try { - // Show the waiting image - Interface.showGeneralWait(); - - // Change the page title - Interface.title('wait'); - - // Send request - $.post('./server/register.php', {username: username, domain: domain, password: pass, captcha: captcha}, function(data) { - // Error registering - Interface.removeGeneralWait(); - Interface.title('home'); - - // In all case, update CAPTCHA - $('#home img.captcha_img').attr('src', './server/captcha.php?id=' + genID()); - $('#home input.captcha').val(''); - - // Registration okay - if($(data).find('query status').text() == '1') { - is_success = true; - self.handleRegistered(); - } else { - // Show error message - var error_message = ''; - - switch($(data).find('query message').text()) { - case 'CAPTCHA Not Matching': - error_message = Common._e("The security code you entered is invalid. Please retry with another one."); - - $('#home input.captcha').focus(); - - break; - - case 'Username Unavailable': - error_message = Common._e("The username you picked is not available. Please try another one."); - - $('#home input.nick').focus(); - - break; - - default: - error_message = Common._e("There was an error registering your account. Please retry."); - - break; - } - - if(error_message) { - Errors.show('', error_message, ''); - } - } - }); - } catch(e) { - Console.error('Connection._doRegisterAPI', e); - } finally { - return is_success; - } - - }; - - - /** - * Do registration throug in-band stream - * @private - * @param {string} username - * @param {string} domain - * @param {string} pass - * @return {boolean} - */ - self._doRegisterInBand = function(username, domain, pass) { - - var is_success = true; - - try { - if(Common.hasWebSocket()) { - // WebSocket supported & configured - con = new JSJaCWebSocketConnection({ - httpbase: HOST_WEBSOCKET - }); - } else { - var httpbase = (HOST_BOSH_MAIN || HOST_BOSH); - - // Check BOSH origin - BOSH_SAME_ORIGIN = Origin.isSame(httpbase); - - // We create the new http-binding connection - con = new JSJaCHttpBindingConnection({ - httpbase: httpbase - }); - } - - // We setup the connection ! - con.registerHandler('onconnect', self.handleRegistered); - con.registerHandler('onerror', Errors.handle); - - con.connect({ - 'domain': $.trim(domain), - 'username': $.trim(username), - 'resource': JAPPIX_RESOURCE + ' Register (' + (new Date()).getTime() + ')', - 'pass': pass, - 'register': true, - 'secure': true, - 'xmllang': XML_LANG - }); - - // Show the waiting image - Interface.showGeneralWait(); - - // Change the page title - Interface.title('wait'); - } catch(e) { - Console.error('Connection._doRegisterInBand', e); - is_success = false; - } finally { - return is_success; - } - - }; - - - /** - * Attaches reconnect events - * @private - * @param {string} mode - * @return {undefined} - */ - self._eventsReconnect = function(mode) { - - try { - // Click events - if(mode == 'normal') { - $('#reconnect a.finish.cancel').click(function() { - return self.cancelReconnect(); - }); - } - - $('#reconnect a.finish.reconnect').click(function() { - return self.acceptReconnect(mode); - }); - } catch(e) { - Console.error('Connection._eventsReconnect', e); - } - - }; - - - /** - * Schedules the next auto reconnect - * @private - * @param {string} mode - * @return {undefined} - */ - self._scheduleReconnect = function(mode) { - - try { - // Try to reconnect automatically after a while - if(self.reconnect_try < 5) { - self.reconnect_timer = 5 + (5 * self.reconnect_try); - } else { - self.reconnect_timer = 120; - } - - // Change the try number - self.reconnect_try++; - - // Fire the event! - $('#reconnect a.finish.reconnect').everyTime('1s', function() { - // We can reconnect! - if(self.reconnect_timer === 0) { - return self.acceptReconnect(mode); - } - - // Button text - if(self.reconnect_timer <= 10) { - $(this).text(Common._e("Reconnect") + ' (' + self.reconnect_timer + ')'); - } - - // Remove 1 second - self.reconnect_timer--; - }); - } catch(e) { - Console.error('Connection._scheduleReconnect', e); - } - - }; - - - /** - * Does the user login - * @public - * @param {string} lNick - * @param {string} lServer - * @param {string} lPass - * @param {string} lResource - * @param {number} lPriority - * @param {boolean} lRemember - * @param {object} loginOpts - * @return {boolean} - */ - self.doLogin = function(lNick, lServer, lPass, lResource, lPriority, lRemember, loginOpts) { - - try { - // get optionnal conn handlers - extend_obj = loginOpts || {}; - - // We remove the not completed class to avoid problems - $('#home .loginer input').removeClass('please-complete'); - - // We add the login wait div - Interface.showGeneralWait(); - - if(Common.hasWebSocket()) { - // WebSocket supported & configured - con = new JSJaCWebSocketConnection({ - httpbase: HOST_WEBSOCKET - }); - } else { - var httpbase = (HOST_BOSH_MAIN || HOST_BOSH); - - // Check BOSH origin - BOSH_SAME_ORIGIN = Origin.isSame(httpbase); - - // We create the new http-binding connection - con = new JSJaCHttpBindingConnection({ - httpbase: httpbase - }); - } - - // And we handle everything that happen - self.setupCon(con, extend_obj); - - // Generate a resource - var random_resource = DataStore.getDB(self.desktop_hash, 'session', 'resource'); - - if(!random_resource) { - random_resource = lResource + ' (' + (new Date()).getTime() + ')'; - } - - var con_args = { - 'domain': lServer.trim(), - 'username': lNick.trim(), - 'resource': random_resource, - 'pass': lPass, - 'secure': true, - 'xmllang': XML_LANG - }; - - self.desktop_hash = 'jd.' + hex_md5(con_args.username + '@' + con_args.domain); - - // Store the resource (for reconnection) - DataStore.setDB(self.desktop_hash, 'session', 'resource', random_resource); - - // Store session XML in temporary database - self.storeSession(lNick, lServer, lPass, lResource, lPriority, lRemember); - - // We store the infos of the user into the data-base - DataStore.setDB(self.desktop_hash, 'priority', 1, lPriority); - - // We connect ! - con.connect(con_args); - - // Change the page title - Interface.title('wait'); - - Console.info('Jappix is connecting...'); - } catch(e) { - Console.error('Connection.doLogin', e); - - // Reset Jappix - Talk.destroy(); - - // Open an unknown error - Board.openThisError(2); - } finally { - return false; - } - - }; - - - /** - * Handles the user registration - * @public - * @return {undefined} - */ - self.handleRegistered = function() { - - try { - Console.info('A new account has been registered.'); - - // We remove the waiting image - Interface.removeGeneralWait(); - - // Reset the title - Interface.title('home'); - - // We show the success information - $('#home .registerer .success').fadeIn('fast'); - - // We quit the session - if(Common.isConnected()) { - self.logout(); - } - } catch(e) { - Console.error('Connection.handleRegistered', e); - } - - }; - - - /** - * Does the user registration - * @public - * @param {string} username - * @param {string} domain - * @param {string} pass - * @param {string} captcha - * @return {boolean} - */ - self.doRegister = function(username, domain, pass, captcha) { - - try { - Console.info('Trying to register an account...'); - - // We change the registered information text - $('#home .homediv.registerer').append( - '
' + - Common._e("You have been registered, here is your XMPP address:") + - ' ' + username.htmlEnc() + '@' + domain.htmlEnc() + ' - ' + - '' + Common._e("Login") + '' + - '
' - ); - - // Login link - $('#home .homediv.registerer .success a').click(function() { - return self.doLogin(username, domain, pass, '', '10', false); - }); - - if((REGISTER_API == 'on') && (domain == HOST_MAIN) && captcha) { - self._doRegisterAPI(username, domain, pass, captcha); - } else { - self._doRegisterInBand(username, domain, pass); - } - } catch(e) { - Console.error('Connection.doRegister', e); - } finally { - return false; - } - - }; - - - /** - * Does the user anonymous login - * @public - * @return {boolean} - */ - self.doAnonymous = function() { - - try { - Console.info('Trying to login anonymously...'); - - var path_sel = $('#home .anonymouser'); - var room = path_sel.find('.room').val(); - var nick = path_sel.find('.nick').val(); - - // Form correctly completed? - if(room && nick) { - // We remove the not completed class to avoid problems - $('#home .anonymouser input').removeClass('please-complete'); - - // Redirect the user to the anonymous room - window.location.href = JAPPIX_LOCATION + '?r=' + room + '&n=' + nick; - } else { - path_sel.find('input[type="text"]').each(function() { - var this_sel = $(this); - - if(!this_sel.val()) { - $(document).oneTime(10, function() { - this_sel.addClass('please-complete').focus(); - }); - } else { - this_sel.removeClass('please-complete'); - } - }); - } - } catch(e) { - Console.error('Connection.doAnonymous', e); - } finally { - return false; - } - - }; - - - /** - * Handles the user connected event - * @public - * @return {undefined} - */ - self.handleConnected = function() { - - try { - Console.info('Jappix is now connected.'); - - // Connection markers - self.connected = true; - self.reconnect_try = 0; - self.reconnect_timer = 0; - - // We hide the home page - $('#home').hide(); - - // Any suggest to do before triggering connected event? - Groupchat.suggestCheck(); - - // Remove the waiting item - Interface.removeGeneralWait(); - - // Init call - Call.init(); - } catch(e) { - Console.error('Connection.handleConnected', e); - } - - }; - - - /** - * Triggers the connected state - * @public - * @return {undefined} - */ - self.triggerConnected = function() { - - try { - // Not resumed? - if(!self.resume) { - // Remember the session? - if(DataStore.getDB(self.desktop_hash, 'remember', 'session')) { - DataStore.setPersistent('global', 'session', 1, self.current_session); - } - - // We show the chatting app. - Talk.create(); - - // We reset the homepage - Home.change('default'); - - // We get all the other things - self.getEverything(); - - // Set last activity stamp - DateUtils.last_activity = DateUtils.getTimeStamp(); - } - - // Resumed - else { - // Send our presence - Presence.sendActions(); - - // Change the title - Interface.updateTitle(); - } - } catch(e) { - Console.error('Connection.triggerConnected', e); - } - - }; - - - /** - * Handles the user disconnected event - * @public - * @return {undefined} - */ - self.handleDisconnected = function() { - - try { - Console.info('Jappix is now disconnected.'); - - // Abort ongoing call (if any) - Call.stop(true); - - // Normal disconnection - if(!self.current_session && !self.connected) { - Talk.destroy(); - self.desktop_hash = null; - } - } catch(e) { - Console.error('Connection.handleDisconnected', e); - } - - }; - - - /** - * Setups the normal connection - * @public - * @param {object} con - * @param {object} extend_obj - * @return {undefined} - */ - self.setupCon = function(con, extend_obj) { - - try { - var connection_handlers = { - 'message': Message.handle, - 'presence': Presence.handle, - 'iq': IQ.handle, - 'onconnect': self.handleConnected, - 'onerror': Errors.handle, - 'ondisconnect': self.handleDisconnected - }; - - for(var cur_handler in connection_handlers) { - con.registerHandler( - cur_handler, - connection_handlers[cur_handler] - ); - } - - // Extended handlers - extend_obj = extend_obj || {}; - - jQuery.each(extend_obj, function(keywd,funct) { - con.registerHandler(keywd, funct); - }); - } catch(e) { - Console.error('Connection.setupCon', e); - } - - }; - - - /** - * Logouts from the server - * @public - * @return {boolean} - */ - self.logout = function() { - - logout_done = false; - - try { - if(Common.isConnected()) { - Console.info('Jappix is disconnecting...'); - - // Disconnect from the XMPP server - con.disconnect(); - - logout_done = true; - } - } catch(e) { - Console.error('Connection.logout', e); - } finally { - return logout_done; - } - - }; - - - /** - * Terminates the user session - * @public - * @return {undefined} - */ - self.terminate = function() { - - try { - if(Common.isConnected()) { - // Clear temporary session storage - self.resetConMarkers(); - - // Show the waiting item (useful if BOSH is sloooow) - Interface.showGeneralWait(); - - // Change the page title - Interface.title('wait'); - - // Disconnect from the XMPP server - self.logout(); - } - } catch(e) { - Console.error('Connection.terminate', e); - } - - }; - - - /** - * Quits a session - * @public - * @param {type} name - * @return {undefined} - */ - self.quit = function() { - - try { - if(!Common.isConnected()) { - return; - } - - // We show the waiting image - Interface.showGeneralWait(); - - // Change the page title - Interface.title('wait'); - - // We disconnect from the XMPP server - self.logout(); - } catch(e) { - Console.error('Connection.quit', e); - } - - }; - - - /** - * Creates the reconnect pane - * @public - * @param {string} mode - * @return {undefined} - */ - self.createReconnect = function(mode) { - - try { - Console.error('This is not a normal disconnection, show the reconnect pane...'); - - // Reconnect pane not yet displayed? - if(!Common.exists('#reconnect')) { - // Blur the focused input/textarea/select - $('input, select, textarea').blur(); - - // Create the HTML code - var html = '
' + - '
' + - Common._e("Due to a network issue, you were disconnected. What do you want to do now?"); - - // Can we cancel reconnection? - if(mode == 'normal') { - html += '' + Common._e("Cancel") + ''; - } - - html += '' + Common._e("Reconnect") + '' + - '
'; - - // Append the code - $('body').append(html); - - // Attach events - self._eventsReconnect(mode); - - // Schedule next reconnect - self._scheduleReconnect(mode); - - // Page title - Interface.updateTitle(); - } - } catch(e) { - Console.error('Connection.createReconnect', e); - } - - }; - - - /** - * Reconnects the user if he was disconnected (network issue) - * @public - * @param {string} mode - * @return {boolean} - */ - self.acceptReconnect = function(mode) { - - try { - Console.info('Trying to reconnect the user...'); - - // Resume marker - self.resume = true; - - // Show waiting item - Interface.showGeneralWait(); - - // Reset some various stuffs - var groupchats = '#page-engine .page-engine-chan[data-type="groupchat"]'; - var groupchats_sel = $(groupchats); - - groupchats_sel.find('.list .role').hide(); - groupchats_sel.find('.one-group, ' + groupchats + ' .list .user').remove(); - groupchats_sel.attr('data-initial', 'false'); - - // Stop the timer - $('#reconnect a.finish.reconnect').stopTime(); - - // Remove the reconnect pane - $('#reconnect').remove(); - - // Try to login again - if(mode == 'normal') { - self.loginFromSession(Common.XMLFromString(self.current_session)); - } else if(mode == 'anonymous') { - Anonymous.login(HOST_ANONYMOUS); - } - } catch(e) { - Console.error('Connection.acceptReconnect', e); - } finally { - return false; - } - - }; - - - /** - * Cancel the reconnection of user account (network issue) - * @public - * @return {boolean} - */ - self.cancelReconnect = function() { - - try { - Console.info('User has canceled automatic reconnection...'); - - // Stop the timer - $('#reconnect a.finish.reconnect').stopTime(); - - // Remove the reconnect pane - $('#reconnect').remove(); - - // Destroy the talk page - Talk.destroy(); - - // Renitialize the previous session parameters - self.resetConMarkers(); - } catch(e) { - Console.error('Connection.cancelReconnect', e); - } finally { - return false; - } - - }; - - - /** - * Clears session reminder database - * @public - * @return {undefined} - */ - self.clearLastSession = function() { - - try { - // Clear temporary storage - self.resetConMarkers(); - - // Clear persistent storage - if($(Common.XMLFromString(DataStore.getPersistent('global', 'session', 1))).find('stored').text() == 'true') { - DataStore.removePersistent('global', 'session', 1); - } - } catch(e) { - Console.error('Connection.clearLastSession', e); - } - - }; - - - /** - * Resets the connection markers - * @public - * @return {undefined} - */ - self.resetConMarkers = function() { - - try { - self.current_session = false; - self.connected = false; - self.resume = false; - self.reconnect_try = 0; - self.reconnect_timer = 0; - } catch(e) { - Console.error('Connection.resetConMarkers', e); - } - - }; - - - /** - * Logins from a saved session - * @public - * @param {string} data - * @return {undefined} - */ - self.loginFromSession = function(data) { - - try { - // Select the data - var session = $(data); - - // Fire the login event - self.doLogin( - session.find('username').text(), - session.find('domain').text(), - session.find('password').text(), - session.find('resource').text(), - session.find('priority').text(), - false - ); - } catch(e) { - Console.error('Connection.loginFromSession', e); - } - - }; - - - /** - * Quits a session normally - * @public - * @return {boolean} - */ - self.normalQuit = function() { - - try { - // Reset our database - self.clearLastSession(); - - // We quit the current session - self.quit(); - - // We show an info - Board.openThisInfo(3); - } catch(e) { - Console.error('Connection.normalQuit', e); - } finally { - return false; - } - - }; - - - /** - * Gets all the users stuff - * @public - * @return {undefined} - */ - self.getEverything = function() { - - try { - Features.get(); - Roster.get(); - Privacy.list(); - Storage.get(NS_ROSTERNOTES); - } catch(e) { - Console.error('Connection.getEverything', e); - } - - }; - - - /** - * Generates session data to store - * @public - * @param {string} lNick - * @param {string} lServer - * @param {string} lPass - * @param {string} lResource - * @param {number} lPriority - * @param {boolean} lRemember - * @return {undefined} - */ - self.storeSession = function(lNick, lServer, lPass, lResource, lPriority, lRemember) { - - try { - // Generate a session XML to be stored - session_xml = '' + - 'true' + - '' + lServer.htmlEnc() + '' + - '' + lNick.htmlEnc() + '' + - '' + lResource.htmlEnc() + '' + - '' + lPass.htmlEnc() + '' + - '' + lPriority.htmlEnc() + '' + - ''; - - // Save the session parameters (for reconnect if network issue) - self.current_session = session_xml; - - // Remember me? - if(lRemember) { - DataStore.setDB(self.desktop_hash, 'remember', 'session', 1); - } - - return session_xml; - } catch(e) { - Console.error('Connection.storeSession', e); - } - - }; - - - /** - * Plugin launcher - * @public - * @return {undefined} - */ - self.launch = function() { - - try { - $(document).ready(function() { - // Logouts when Jappix is closed - $(window).bind('beforeunload', Connection.terminate); - - // Nothing to do when anonymous! - if(Utils.isAnonymous()) { - return; - } - - // Connection params submitted in URL? - if(XMPPLinks.links_var.u && XMPPLinks.links_var.q) { - // Generate login data - var login_xid = Common.bareXID(Common.generateXID(XMPPLinks.links_var.u, 'chat')); - var login_nick = Common.getXIDNick(login_xid); - var login_server = Common.getXIDHost(login_xid); - var login_pwd = XMPPLinks.links_var.q; - var login_resource = JAPPIX_RESOURCE + ' (' + (new Date()).getTime() + ')'; - var login_priority = '10'; - var login_remember = 1; - - // Must store session? - if(XMPPLinks.links_var.h && (XMPPLinks.links_var.h === '1')) { - // Store session - var session_xml = self.storeSession( - login_nick, - login_server, - login_pwd, - login_resource, - login_priority, - true - ); - - DataStore.setPersistent('global', 'session', 1, session_xml); - - // Redirect to a clean URL - document.location.href = './'; - } else { - // Hide the homepage - $('#home').hide(); - - // Show the waiting icon - Interface.showGeneralWait(); - - // Proceed login - self.doLogin(login_nick, login_server, login_pwd, login_resource, login_priority, login_remember); - } - - return; - } - - // Try to resume a stored session, if not anonymous - var session = Common.XMLFromString( - DataStore.getPersistent('global', 'session', 1) - ); - - if($(session).find('stored').text() == 'true') { - // Hide the homepage - $('#home').hide(); - - // Show the waiting icon - Interface.showGeneralWait(); - - // Login! - self.loginFromSession(session); - - Console.info('Saved session found, resuming it...'); - } else if((parent.location.hash != '#OK') && XMPPLinks.links_var.x) { - Home.change('loginer'); - - Console.info('A XMPP link is set, switch to login page.'); - } - }); - } catch(e) { - Console.error('Connection.launch', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); - -Connection.launch(); \ No newline at end of file diff --git a/source/app/javascripts/console.js b/source/app/javascripts/console.js deleted file mode 100644 index d645e54..0000000 --- a/source/app/javascripts/console.js +++ /dev/null @@ -1,66 +0,0 @@ -// License: MIT - -/* - * Console.js - * - * An interface to native console methods - * Avoids issues when browser does not have native support for console - * - * @license OS - * @author Valérian Saliou - * @url https://github.com/valeriansaliou/console.js - */ - -var Console = (function () { - - var self = this; - - - /* Variables */ - self._available = typeof(window.console) != 'undefined'; - self._has = self._available && JappixSystem.isDeveloper(); - self._console = self._available ? console : {}; - - - /* Adapters */ - self._adapter = function (level) { - if (!self._has) { - return function() {}; - } - - var adapter = null; - try { - switch (level) { - case 0: - adapter = console.warn; break; - case 1: - adapter = console.error; break; - case 2: - adapter = console.info; break; - case 3: - adapter = console.log; break; - case 4: - adapter = console.debug; break; - } - } catch (e) { - adapter = function() {}; - } - - return adapter.bind(self._console); - }; - - - /* Methods */ - self.warn = self._adapter(0); - self.error = self._adapter(1); - self.info = self._adapter(2); - self.log = self._adapter(3); - self.debug = self._adapter(4); - - - /* Return class scope */ - return self; - -})(); - -var JappixConsole = Console; \ No newline at end of file diff --git a/source/app/javascripts/constants.js b/source/app/javascripts/constants.js deleted file mode 100644 index 69b71d1..0000000 --- a/source/app/javascripts/constants.js +++ /dev/null @@ -1,237 +0,0 @@ -/* - -Jappix - An open social platform -These are the constants JS scripts for Jappix - -------------------------------------------------- - -License: dual-licensed under AGPL and MPLv2 -Authors: Stefan Strigler, Valérian Saliou, Kloadut, Maranda - -*/ - -// XMPP XMLNS attributes -var NS_PROTOCOL = 'http://jabber.org/protocol/'; -var NS_FEATURES = 'http://jabber.org/features/'; -var NS_CLIENT = 'jabber:client'; -var NS_IQ = 'jabber:iq:'; -var NS_X = 'jabber:x:'; -var NS_IETF = 'urn:ietf:params:xml:ns:'; -var NS_IETF_XMPP = NS_IETF + 'xmpp-'; -var NS_XMPP = 'urn:xmpp:'; - -var NS_STORAGE = 'storage:'; -var NS_BOOKMARKS = NS_STORAGE + 'bookmarks'; -var NS_ROSTERNOTES = NS_STORAGE + 'rosternotes'; - -var NS_JAPPIX = 'jappix:'; -var NS_INBOX = NS_JAPPIX + 'inbox'; -var NS_OPTIONS = NS_JAPPIX + 'options'; - -var NS_DISCO_ITEMS = NS_PROTOCOL + 'disco#items'; -var NS_DISCO_INFO = NS_PROTOCOL + 'disco#info'; -var NS_VCARD = 'vcard-temp'; -var NS_VCARD_P = NS_VCARD + ':x:update'; -var NS_IETF_VCARD4 = NS_IETF + 'vcard-4.0'; -var NS_XMPP_VCARD4 = NS_XMPP + 'vcard4'; -var NS_URN_ADATA = NS_XMPP + 'avatar:data'; -var NS_URN_AMETA = NS_XMPP + 'avatar:metadata'; -var NS_AUTH = NS_IQ + 'auth'; -var NS_AUTH_ERROR = NS_IQ + 'auth:error'; -var NS_REGISTER = NS_IQ + 'register'; -var NS_SEARCH = NS_IQ + 'search'; -var NS_ROSTER = NS_IQ + 'roster'; -var NS_PRIVACY = NS_IQ + 'privacy'; -var NS_PRIVATE = NS_IQ + 'private'; -var NS_VERSION = NS_IQ + 'version'; -var NS_TIME = NS_IQ + 'time'; -var NS_LAST = NS_IQ + 'last'; -var NS_IQDATA = NS_IQ + 'data'; -var NS_XDATA = NS_X + 'data'; -var NS_IQOOB = NS_IQ + 'oob'; -var NS_XOOB = NS_X + 'oob'; -var NS_DELAY = NS_X + 'delay'; -var NS_EXPIRE = NS_X + 'expire'; -var NS_EVENT = NS_X + 'event'; -var NS_XCONFERENCE = NS_X + 'conference'; -var NS_STATS = NS_PROTOCOL + 'stats'; -var NS_MUC = NS_PROTOCOL + 'muc'; -var NS_MUC_USER = NS_MUC + '#user'; -var NS_MUC_ADMIN = NS_MUC + '#admin'; -var NS_MUC_OWNER = NS_MUC + '#owner'; -var NS_MUC_CONFIG = NS_MUC + '#roomconfig'; -var NS_PUBSUB = NS_PROTOCOL + 'pubsub'; -var NS_PUBSUB_EVENT = NS_PUBSUB + '#event'; -var NS_PUBSUB_OWNER = NS_PUBSUB + '#owner'; -var NS_PUBSUB_NMI = NS_PUBSUB + '#node-meta-info'; -var NS_PUBSUB_NC = NS_PUBSUB + '#node_config'; -var NS_PUBSUB_CN = NS_PUBSUB + '#config-node'; -var NS_PUBSUB_RI = NS_PUBSUB + '#retrieve-items'; -var NS_COMMANDS = NS_PROTOCOL + 'commands'; -var NS_BOSH = NS_PROTOCOL + 'httpbind'; -var NS_STREAM = 'http://etherx.jabber.org/streams'; -var NS_URN_TIME = NS_XMPP + 'time'; -var NS_URN_PING = NS_XMPP + 'ping'; -var NS_URN_MBLOG = NS_XMPP + 'microblog:0'; -var NS_URN_INBOX = NS_XMPP + 'inbox'; -var NS_URN_FORWARD = NS_XMPP + 'forward:0'; -var NS_URN_MAM = NS_XMPP + 'mam:tmp'; -var NS_URN_DELAY = NS_XMPP + 'delay'; -var NS_URN_RECEIPTS = NS_XMPP + 'receipts'; -var NS_URN_CARBONS = NS_XMPP + 'carbons:2'; -var NS_URN_CORRECT = NS_XMPP + 'message-correct:0'; -var NS_URN_IDLE = NS_XMPP + 'idle:1'; -var NS_URN_REACH = NS_XMPP + 'reach:0'; -var NS_URN_MARKERS = NS_XMPP + 'chat-markers:0'; -var NS_URN_ATTENTION = NS_XMPP + 'attention:0'; -var NS_URN_HINTS = NS_XMPP + 'hints'; -var NS_RSM = NS_PROTOCOL + 'rsm'; -var NS_IPV6 = 'ipv6'; -var NS_XHTML = 'http://www.w3.org/1999/xhtml'; -var NS_XHTML_IM = NS_PROTOCOL + 'xhtml-im'; -var NS_CHATSTATES = NS_PROTOCOL + 'chatstates'; -var NS_HTTP_AUTH = NS_PROTOCOL + 'http-auth'; -var NS_ROSTERX = NS_PROTOCOL + 'rosterx'; -var NS_MOOD = NS_PROTOCOL + 'mood'; -var NS_ACTIVITY = NS_PROTOCOL + 'activity'; -var NS_TUNE = NS_PROTOCOL + 'tune'; -var NS_GEOLOC = NS_PROTOCOL + 'geoloc'; -var NS_NICK = NS_PROTOCOL + 'nick'; -var NS_NOTIFY = '+notify'; -var NS_CAPS = NS_PROTOCOL + 'caps'; -var NS_ATOM = 'http://www.w3.org/2005/Atom'; - -var NS_STANZAS = NS_IETF_XMPP + 'stanzas'; -var NS_STREAMS = NS_IETF_XMPP + 'streams'; - -var NS_TLS = NS_IETF_XMPP + 'tls'; -var NS_SASL = NS_IETF_XMPP + 'sasl'; -var NS_SESSION = NS_IETF_XMPP + 'session'; -var NS_BIND = NS_IETF_XMPP + 'bind'; - -var NS_FEATURE_IQAUTH = NS_FEATURES + 'iq-auth'; -var NS_FEATURE_IQREGISTER = NS_FEATURES + 'iq-register'; -var NS_FEATURE_COMPRESS = NS_FEATURES + 'compress'; - -var NS_COMPRESS = NS_PROTOCOL + 'compress'; - -var NS_METRONOME_MAM_PURGE = 'http://metronome.im/protocol/mam-purge'; - -// Available locales -var LOCALES_AVAILABLE_ID = []; -var LOCALES_AVAILABLE_NAMES = []; - -// XML lang -var XML_LANG = null; - -// Jappix parameters -var JAPPIX_STATIC = null; -var JAPPIX_VERSION = null; -var JAPPIX_MAX_FILE_SIZE = null; -var JAPPIX_MAX_UPLOAD = null; - -// Jappix main configuration -var SERVICE_NAME = null; -var SERVICE_DESC = null; -var OWNER_NAME = null; -var OWNER_WEBSITE = null; -var LEGAL = null; -var JAPPIX_RESOURCE = null; -var LOCK_HOST = null; -var ANONYMOUS = null; -var HTTP_AUTH = null; -var REGISTRATION = null; -var BOSH_PROXY = null; -var MANAGER_LINK = null; -var GROUPCHATS_JOIN = null; -var GROUPCHATS_SUGGEST = null; -var ENCRYPTION = null; -var HTTPS_STORAGE = null; -var HTTPS_FORCE = null; -var COMPRESSION = null; -var ADS_ENABLE = null; -var GADS_CLIENT = null; -var GADS_SLOT = null; -var MULTI_FILES = null; -var DEVELOPER = null; -var REGISTER_API = null; - -// Jappix hosts configuration -var HOST_MAIN = null; -var HOST_MUC = null; -var HOST_PUBSUB = null; -var HOST_VJUD = null; -var HOST_ANONYMOUS = null; -var HOST_STUN = null; -var HOST_TURN = null; -var HOST_TURN_USERNAME = null; -var HOST_TURN_PASSWORD = null; -var HOST_BOSH = null; -var HOST_BOSH_MAIN = null; -var HOST_BOSH_MINI = null; -var HOST_WEBSOCKET = null; -var HOST_STATIC = null; -var HOST_UPLOAD = null; - -// Anonymous mode -var ANONYMOUS_ROOM = null; -var ANONYMOUS_NICK = null; - -// Node parameters -var JAPPIX_LOCATION = JappixSystem.location(); -var JAPPIX_MINI_CSS = null; -var BOSH_SAME_ORIGIN = false; - -// XMPP error stanzas -function STANZA_ERROR(code, type, cond) { - if(window == this) { - return new STANZA_ERROR(code, type, cond); - } - - this.code = code; - this.type = type; - this.cond = cond; -} - -var ERR_BAD_REQUEST = - STANZA_ERROR('400', 'modify', 'bad-request'); -var ERR_CONFLICT = - STANZA_ERROR('409', 'cancel', 'conflict'); -var ERR_FEATURE_NOT_IMPLEMENTED = - STANZA_ERROR('501', 'cancel', 'feature-not-implemented'); -var ERR_FORBIDDEN = - STANZA_ERROR('403', 'auth', 'forbidden'); -var ERR_GONE = - STANZA_ERROR('302', 'modify', 'gone'); -var ERR_INTERNAL_SERVER_ERROR = - STANZA_ERROR('500', 'wait', 'internal-server-error'); -var ERR_ITEM_NOT_FOUND = - STANZA_ERROR('404', 'cancel', 'item-not-found'); -var ERR_JID_MALFORMED = - STANZA_ERROR('400', 'modify', 'jid-malformed'); -var ERR_NOT_ACCEPTABLE = - STANZA_ERROR('406', 'modify', 'not-acceptable'); -var ERR_NOT_ALLOWED = - STANZA_ERROR('405', 'cancel', 'not-allowed'); -var ERR_NOT_AUTHORIZED = - STANZA_ERROR('401', 'auth', 'not-authorized'); -var ERR_PAYMENT_REQUIRED = - STANZA_ERROR('402', 'auth', 'payment-required'); -var ERR_RECIPIENT_UNAVAILABLE = - STANZA_ERROR('404', 'wait', 'recipient-unavailable'); -var ERR_REDIRECT = - STANZA_ERROR('302', 'modify', 'redirect'); -var ERR_REGISTRATION_REQUIRED = - STANZA_ERROR('407', 'auth', 'registration-required'); -var ERR_REMOTE_SERVER_NOT_FOUND = - STANZA_ERROR('404', 'cancel', 'remote-server-not-found'); -var ERR_REMOTE_SERVER_TIMEOUT = - STANZA_ERROR('504', 'wait', 'remote-server-timeout'); -var ERR_RESOURCE_CONSTRAINT = - STANZA_ERROR('500', 'wait', 'resource-constraint'); -var ERR_SERVICE_UNAVAILABLE = - STANZA_ERROR('503', 'cancel', 'service-unavailable'); -var ERR_SUBSCRIPTION_REQUIRED = - STANZA_ERROR('407', 'auth', 'subscription-required'); -var ERR_UNEXPECTED_REQUEST = - STANZA_ERROR('400', 'wait', 'unexpected-request'); diff --git a/source/app/javascripts/correction.js b/source/app/javascripts/correction.js deleted file mode 100644 index deea70c..0000000 --- a/source/app/javascripts/correction.js +++ /dev/null @@ -1,509 +0,0 @@ -/* - -Jappix - An open social platform -Implementation of XEP-0308: Last Message Correction - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var Correction = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * @private - * @param {string} xid - * @return {boolean} - */ - self._hasSupport = function(xid) { - - var support = false; - - try { - if($('#' + hex_md5(xid) + '[data-correction="true"]').size()) { - support = true; - } - } catch(e) { - Console.error('Correction._hasSupport', e); - } finally { - return support; - } - - }; - - - /** - * @private - * @param {string} xid - * @return {string} - */ - self._getLastID = function(xid) { - - var last_id = null; - - try { - if(self._hasSupport(xid) === true) { - // Check last message from ourselves - last_id = $('#' + hex_md5(xid) + ' .content .one-line.user-message[data-mode="me"]:last').attr('data-id') || null; - } - } catch(e) { - Console.error('Correction._getLastID', e); - } finally { - return last_id; - } - - }; - - - /** - * @private - * @param {string} xid - * @return {string} - */ - self._getCurrentID = function(xid) { - - var current_id = null; - - try { - if(self._hasSupport(xid) === true) { - // Check the ID of the message being edited (if any) - current_id = $('#' + hex_md5(xid) + ' .message-area').attr('data-correction-current') || null; - } - } catch(e) { - Console.error('Correction._getCurrentID', e); - } finally { - return current_id; - } - - }; - - - /** - * @private - * @param {string} xid - * @return {object} - */ - self._getLastMessage = function(xid) { - - var last_message_val = null; - var last_message_sel = null; - - try { - if(self._hasSupport(xid) === true) { - // Check last message from ourselves - last_message_sel = $('#' + hex_md5(xid) + ' .content .one-line.user-message[data-mode="me"]:last'); - last_message_val = last_message_sel.find('.message-content').text() || null; - - if(last_message_val === null) { - last_message_sel = null; - } - } - } catch(e) { - Console.error('Correction._getLastMessage', e); - } finally { - return { - 'value': last_message_val, - 'selector': last_message_sel - }; - } - - }; - - - /** - * @private - * @param {string} xid - * @param {object} message_sel - * @return {undefined} - */ - self._bindInterface = function(xid, message_sel) { - - try { - // Add message area elements - var text_sel = $('#' + hex_md5(xid) + ' .text'); - - text_sel.addClass('correction-active'); - text_sel.prepend( - '
' + - '' + Common._e("Editing") + '' + - '' + Common._e("Cancel") + '' + - '
' - ); - - // Add message correction marker - message_sel.addClass('correction-active'); - message_sel.find('.correction-label').remove(); - message_sel.find('.correction-edit').hide(); - - message_sel.append( - '' + - Common._e("Being edited") + - '' - ); - - // Bind click events - text_sel.find('.correction-cancel').click(function() { - self.leave(xid); - return false; - }); - } catch(e) { - Console.error('Correction._bindInterface', e); - } - - }; - - - /** - * @private - * @param {string} xid - * @param {object} message_sel - * @return {undefined} - */ - self._unbindInterface = function(xid, message_sel) { - - try { - // Remove message area elements - var text_sel = $('#' + hex_md5(xid) + ' .text'); - text_sel.removeClass('correction-active'); - text_sel.find('.correction-toolbox, .correction-label').remove(); - - if(message_sel.size()) { - message_sel.find('.correction-edit').css('display', ''); - - // Remove message correction marker - message_sel.removeClass('correction-active'); - message_sel.find('.correction-label').remove(); - } - } catch(e) { - Console.error('Correction._unbindInterface', e); - } - - }; - - - /** - * @private - * @param {string} xid - * @param {string} full_xid - * @param {string} type - * @param {string} message_id - * @param {string} message_body - * @return {string} - */ - self._sendStanza = function(xid, full_xid, type, message_id, message_body) { - - var args = { - 'id': null, - 'xhtml': false, - 'message': null - }; - - try { - var hash = hex_md5(xid); - var id = genID(); - args.id = id; - - // Initialize message stanza - var message = new JSJaCMessage(); - args.message = message; - - message.setType(type); - message.setTo(full_xid); - message.setID(id); - - // Generates the correct message depending of the choosen style - var generate_message = Message.generate(message, message_body, hash); - args.xhtml = (generate_message === 'XHTML'); - - // Receipt request - var receipt_request = Receipts.request(hash); - - if(receipt_request) { - message.appendNode('request', {'xmlns': NS_URN_RECEIPTS}); - } - - // Chatstate - message.appendNode('active', {'xmlns': NS_CHATSTATES}); - - if(message_id !== null) { - message.appendNode('replace', { - 'xmlns': NS_URN_CORRECT, - 'id': message_id - }); - } - - con.send(message, Errors.handleReply); - } catch(e) { - Console.error('Correction._sendStanza', e); - } finally { - return args; - } - - }; - - - /** - * Detects correction mode request (in input) - * @public - * @param {string} xid - * @param {object} input_sel - * @return {undefined} - */ - self.detect = function(xid, input_sel) { - - try { - // Other keys - if(input_sel.val().match(/^\/correct/) && self.isIn(xid) === false) { - // Enter correction mode? - self.enter(xid); - } - } catch(e) { - Console.error('Correction.detect', e); - } - - }; - - - /** - * Enter correction mode (for last message) - * @public - * @param {string} xid - * @return {undefined} - */ - self.enter = function(xid) { - - try { - Console.debug('Correction.enter', 'Requested to enter the correction mode with: ' + xid); - - if(self._hasSupport(xid) === true && self.isIn(xid) === false) { - var last_message = self._getLastMessage(xid); - - if(last_message.value && last_message.selector) { - Console.info('Correction.enter', 'Valid last message found for correction mode with: ' + xid); - - var message_area_sel = $('#' + hex_md5(xid) + ' .message-area'); - message_area_sel.val(last_message.value); - - self._bindInterface( - xid, - last_message.selector - ); - - // Focus hack (to get cursor at the end of textarea) - message_area_sel.oneTime(10, function() { - message_area_sel[0].select(); - message_area_sel[0].selectionStart = message_area_sel[0].selectionEnd; - }); - } - } - } catch(e) { - Console.error('Correction.enter', e); - } - - }; - - - /** - * Leave correction mode - * @public - * @param {string} xid - * @return {undefined} - */ - self.leave = function(xid) { - - try { - if(self.isIn(xid) === true) { - var base_sel = $('#' + hex_md5(xid)); - var active_message_sel = base_sel.find('.content .one-line.user-message.correction-active'); - - self._unbindInterface(xid, active_message_sel); - - var message_area_sel = base_sel.find('.message-area'); - message_area_sel.val(''); - message_area_sel.focus(); - } - } catch(e) { - Console.error('Correction.leave', e); - } - - }; - - - /** - * Send corrected message - * @public - * @param {string} xid - * @param {string} type - * @param {string} replacement - * @return {undefined} - */ - self.send = function(xid, type, replacement) { - - try { - if(self._hasSupport(xid) === true) { - if(self._getLastMessage(xid).value != replacement) { - var own_xid = Common.getXID(); - var hash = hex_md5(xid); - var replace_id = self._getLastID(xid); - - Console.info('Correction.send', 'Sending replacement message for: ' + xid + ' "' + replacement + '" with ID: ' + (replace_id || 'none')); - - // Send the stanza itself - var full_xid = Presence.highestPriority(xid) || xid; - var stanza_args = self._sendStanza( - xid, - full_xid, - type, - replace_id, - replacement - ); - - // Update DOM (for chat only) - if(type == 'chat') { - // Filter the xHTML message (for us!) - var replacement_formatted = replacement; - - if(stanza_args.xhtml) { - replacement_formatted = Filter.xhtml(stanza_args.message.getNode()); - } - - // Remove old message - old_message_sel = $('#' + hash + ' .content .one-line.user-message[data-mode="me"]').filter(function() { - return ($(this).attr('data-id') + '') === (replace_id + ''); - }).filter(':last'); - - var edit_count = old_message_sel.attr('data-edit-count') || 0; - edit_count = isNaN(edit_count) ? 0 : parseInt(edit_count, 10); - - if(type == 'chat') { - old_message_sel.remove(); - } - - // Display edited message - Message.display( - 'chat', - own_xid, - hash, - Name.getBuddy(own_xid).htmlEnc(), - replacement_formatted, - DateUtils.getCompleteTime(), - DateUtils.getTimeStamp(), - 'user-message', - !stanza_args.xhtml, - '', - 'me', - stanza_args.id, - undefined, - undefined, - true, - (edit_count + 1) - ); - } - } - } - } catch(e) { - Console.error('Correction.send', e); - } - - }; - - - /** - * Catches a replace message - * @public - * @param {object} message - * @param {string} hash - * @param {string} type - * @return {object} - */ - self.catch = function(message, hash, type) { - - var edit_results = { - 'has_replace': false, - 'is_edited': false, - 'count': 0, - 'next_count': 0 - }; - - try { - var replace_node = message.getChild('replace', NS_URN_CORRECT); - - if(replace_node) { - edit_results.has_replace = true; - var message_edit_id = $(replace_node).attr('id'); - - if(typeof message_edit_id != 'undefined') { - var message_edit_sel = $('#' + hash + ' .one-line.user-message').filter(function() { - var this_sel = $(this); - var is_valid_mode = true; - - if(type == 'chat') { - is_valid_mode = true ? this_sel.attr('data-mode') == 'him' : false; - } - - return is_valid_mode && ((this_sel.attr('data-id') + '') === (message_edit_id + '')); - }).filter(':last'); - - if(message_edit_sel.size()) { - edit_results.count = message_edit_sel.attr('data-edit-count') || 0; - edit_results.count = isNaN(edit_results.count) ? 0 : parseInt(edit_results.count, 10); - edit_results.next_count = edit_results.count + 1; - edit_results.is_edited = true; - - // Empty group? - var message_edit_group_sel = message_edit_sel.parents('.one-group'); - - if(message_edit_group_sel.find('.one-line').size() <= 1) { - message_edit_group_sel.remove(); - } else { - message_edit_sel.remove(); - } - } - } - } - } catch(e) { - Console.error('Correction.catch', e); - } finally { - return edit_results; - } - - }; - - - /** - * Returns whether we are in correction mode or not - * @public - * @param {string} xid - * @return {boolean} - */ - self.isIn = function(xid) { - - var is_in = false; - - try { - is_in = $('#' + hex_md5(xid) + ' .text').hasClass('correction-active'); - } catch(e) { - Console.error('Correction.isIn', e); - } finally { - return is_in; - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); diff --git a/source/app/javascripts/dataform.js b/source/app/javascripts/dataform.js deleted file mode 100644 index b409768..0000000 --- a/source/app/javascripts/dataform.js +++ /dev/null @@ -1,1200 +0,0 @@ -/* - -Jappix - An open social platform -These are the dataform JS scripts for Jappix - -------------------------------------------------- - -License: AGPL -Authors: Valérian Saliou, Maranda - -*/ - -// Bundle -var DataForm = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Gets the defined dataform elements - * @public - * @param {string} host - * @param {string} type - * @param {string} node - * @param {string} action - * @param {string} target - * @return {boolean} - */ - self.go = function(host, type, node, action, target) { - - try { - // Clean the current session - self.clean(target); - - // We tell the user that a search has been launched - $('#' + target + ' .wait').show(); - - // If we have enough data - if(host && type) { - // Generate a session ID - var sessionID = Math.round(100000.5 + (((900000.49999) - (100000.5)) * Math.random())); - var id = target + '-' + sessionID + '-' + genID(); - $('.' + target + '-results').attr('data-session', target + '-' + sessionID); - - // We request the service item - var iq = new JSJaCIQ(); - iq.setID(id); - iq.setTo(host); - iq.setType('get'); - - // MUC admin query - if(type == 'muc') { - iq.setQuery(NS_MUC_OWNER); - con.send(iq, self.handleMUC); - } - - // Browse query - else if(type == 'browse') { - var iqQuery = iq.setQuery(NS_DISCO_ITEMS); - - if(node) { - iqQuery.setAttribute('node', node); - } - - con.send(iq, self.handleBrowse); - } - - // Command - else if(type == 'command') { - var items; - - if(node) { - items = iq.appendNode('command', {'node': node, 'xmlns': NS_COMMANDS}); - } - - else { - items = iq.setQuery(NS_DISCO_ITEMS); - items.setAttribute('node', NS_COMMANDS); - } - - if(action && node) { - iq.setType('set'); - items.setAttribute('action', action); - } - - con.send(iq, self.handleCommand); - } - - // Search query - else if(type == 'search') { - iq.setQuery(NS_SEARCH); - con.send(iq, self.handleSearch); - } - - // Subscribe query - else if(type == 'subscribe') { - iq.setQuery(NS_REGISTER); - con.send(iq, self.handleSubscribe); - } - - // Join - else if(type == 'join') { - if(target == 'discovery') { - Discovery.close(); - } - - Chat.checkCreate(host, 'groupchat'); - } - } - } catch(e) { - Console.error('DataForm.go', e); - } finally { - return false; - } - - }; - - - /** - * Sends a given dataform - * @public - * @param {string} type - * @param {string} action - * @param {string} x_type - * @param {string} id - * @param {string} xid - * @param {string} node - * @param {string} sessionid - * @param {string} target - * @return {boolean} - */ - self.send = function(type, action, x_type, id, xid, node, sessionid, target) { - - try { - // Path - var pathID = '#' + target + ' .results[data-session="' + id + '"]'; - - // New IQ - var iq = new JSJaCIQ(); - iq.setTo(xid); - iq.setType('set'); - - // Set the correct query - var query; - - if(type == 'subscribe') { - iqQuery = iq.setQuery(NS_REGISTER); - } else if(type == 'search') { - iqQuery = iq.setQuery(NS_SEARCH); - } else if(type == 'command') { - iqQuery = iq.appendNode('command', {'xmlns': NS_COMMANDS, 'node': node, 'sessionid': sessionid, 'action': action}); - } else if(type == 'x') { - iqQuery = iq.setQuery(NS_MUC_OWNER); - } - - // Build the XML document - if(action != 'cancel') { - // No X node - if(Common.exists('input.register-special') && (type == 'subscribe')) { - $('input.register-special').each(function() { - var iName = $(this).attr('name'); - var iValue = $(this).val(); - - iqQuery.appendChild(iq.buildNode(iName, {'xmlns': NS_REGISTER}, iValue)); - }); - } - - // Can create the X node - else { - var iqX = iqQuery.appendChild(iq.buildNode('x', {'xmlns': NS_XDATA, 'type': x_type})); - - // Each input - $(pathID + ' .oneresult input, ' + pathID + ' .oneresult textarea, ' + pathID + ' .oneresult select').each(function() { - // Get the current input value - var iVar = $(this).attr('name'); - var iType = $(this).attr('data-type'); - var iValue = $(this).val(); - - // Build a new field node - var field = iqX.appendChild(iq.buildNode('field', {'var': iVar, 'type': iType, 'xmlns': NS_XDATA})); - - // Boolean input? - if(iType == 'boolean') { - if($(this).filter(':checked').size()) { - iValue = '1'; - } else { - iValue = '0'; - } - } - - // JID-multi input? - if(iType == 'jid-multi') { - // Values array - var xid_arr = [iValue]; - var xid_check = []; - - // Try to split it - if(iValue.indexOf(',') != -1) { - xid_arr = iValue.split(','); - } - - // Append each value to the XML document - for(var i in xid_arr) { - // Get the current value - xid_current = $.trim(xid_arr[i]); - - // No current value? - if(!xid_current) { - continue; - } - - // Add the current value - if(!Utils.existArrayValue(xid_check, xid_current)) { - xid_check.push(xid_current); - field.appendChild(iq.buildNode('value', {'xmlns': NS_XDATA}, xid_current)); - } - } - } - - // List-multi selector? - else if(iType == 'list-multi') { - // Any value? - if(iValue && iValue.length) { - for(var j in iValue) { - field.appendChild(iq.buildNode('value', {'xmlns': NS_XDATA}, iValue[j])); - } - } - } - - // Other inputs? - else { - field.appendChild(iq.buildNode('value', {'xmlns': NS_XDATA}, iValue)); - } - }); - } - } - - // Clean the current session - self.clean(target); - - // Show the waiting item - $('#' + target + ' .wait').show(); - - // Change the ID of the current discovered item - var iqID = target + '-' + genID(); - $('#' + target + ' .' + target + '-results').attr('data-session', iqID); - iq.setID(iqID); - - // Send the IQ - if(type == 'subscribe') { - con.send(iq, self.handleSubscribe); - } else if(type == 'search') { - con.send(iq, self.handleSearch); - } else if(type == 'command') { - con.send(iq, self.handleCommand); - } else { - con.send(iq); - } - } catch(e) { - Console.error('DataForm.send', e); - } finally { - return false; - } - - }; - - - /** - * Displays the good dataform buttons - * @public - * @param {string} type - * @param {string} action - * @param {string} id - * @param {string} xid - * @param {string} node - * @param {string} sessionid - * @param {string} target - * @param {string} pathID - * @return {undefined} - */ - self.buttons = function(type, action, id, xid, node, sessionid, target, pathID) { - - try { - // No need to use buttons? - if(type == 'muc') { - return; - } - - // Override the "undefined" output - if(!id) - id = ''; - if(!xid) - xid = ''; - if(!node) - node = ''; - if(!sessionid) - sessionid = ''; - - // We generate the buttons code - var buttonsCode = '
'; - - if(action == 'submit') { - if((target == 'adhoc') && (type == 'command')) { - buttonsCode += '' + Common._e("Submit") + ''; - - // When keyup on one text input - $(pathID + ' input').keyup(function(e) { - if(e.keyCode == 13) { - self.send(type, 'execute', 'submit', id, xid, node, sessionid, target); - - return false; - } - }); - } else { - buttonsCode += '' + Common._e("Submit") + ''; - - // When keyup on one text input - $(pathID + ' input').keyup(function(e) { - if(e.keyCode == 13) { - self.send(type, 'submit', 'submit', id, xid, node, sessionid, target); - - return false; - } - }); - } - } - - if((action == 'submit') && (type != 'subscribe') && (type != 'search')) { - buttonsCode += '' + Common._e("Cancel") + ''; - } - - if(((action == 'back') || (type == 'subscribe') || (type == 'search')) && (target == 'discovery')) { - buttonsCode += '' + Common._e("Close") + ''; - } - - if((action == 'back') && ((target == 'welcome') || (target == 'directory'))) { - buttonsCode += '' + Common._e("Previous") + ''; - } - - if((action == 'back') && (target == 'adhoc')) { - buttonsCode += '' + Common._e("Previous") + ''; - } - - buttonsCode += '
'; - - // We display the buttons code - $(pathID).append(buttonsCode); - - // If no submit link, lock the form - if(!Common.exists(pathID + ' a.submit')) { - $(pathID + ' input, ' + pathID + ' textarea').attr('readonly', true); - } - } catch(e) { - Console.error('DataForm.buttons', e); - } - - }; - - - /** - * Handles the MUC dataform - * @public - * @param {object} iq - * @return {undefined} - */ - self.handleMUC = function(iq) { - - try { - Errors.handleReply(iq); - self.handleContent(iq, 'muc'); - } catch(e) { - Console.error('DataForm.handleMUC', e); - } - - }; - - - /** - * Handles the browse dataform - * @public - * @param {object} iq - * @return {undefined} - */ - self.handleBrowse = function(iq) { - - try { - Errors.handleReply(iq); - self.handleContent(iq, 'browse'); - } catch(e) { - Console.error('DataForm.handleBrowse', e); - } - - }; - - - /** - * Handles the command dataform - * @public - * @param {object} iq - * @return {undefined} - */ - self.handleCommand = function(iq) { - - try { - Errors.handleReply(iq); - self.handleContent(iq, 'command'); - } catch(e) { - Console.error('DataForm.handleCommand', e); - } - - }; - - - /** - * Handles the subscribe dataform - * @public - * @param {object} iq - * @return {undefined} - */ - self.handleSubscribe = function(iq) { - - try { - Errors.handleReply(iq); - self.handleContent(iq, 'subscribe'); - } catch(e) { - Console.error('DataForm.handleSubscribe', e); - } - - }; - - - /** - * Handles the search dataform - * @public - * @param {object} iq - * @return {undefined} - */ - self.handleSearch = function(iq) { - - try { - Errors.handleReply(iq); - self.handleContent(iq, 'search'); - } catch(e) { - Console.error('DataForm.handleSearch', e); - } - - }; - - - /** - * Handles the dataform content - * @public - * @param {object} iq - * @param {string} type - * @return {undefined} - */ - self.handleContent = function(iq, type) { - - try { - // Get the ID - var sID = iq.getID(); - - // Get the target - var splitted = sID.split('-'); - var target = splitted[0]; - var sessionID = target + '-' + splitted[1]; - var from = Common.fullXID(Common.getStanzaFrom(iq)); - var pathID = '#' + target + ' .results[data-session="' + sessionID + '"]'; - - // If an error occured - if(!iq || (iq.getType() != 'result')) { - self.noResult(pathID); - } - - // If we got something okay - else { - var handleXML = iq.getNode(); - - if(type == 'browse') { - if($(handleXML).find('item').attr('jid')) { - // Get the query node - var queryNode = $(handleXML).find('query').attr('node'); - - $(handleXML).find('item').each(function() { - // We parse the received xml - var itemHost = $(this).attr('jid'); - var itemNode = $(this).attr('node'); - var itemName = $(this).attr('name'); - var itemHash = hex_md5(itemHost); - - // Node - if(itemNode) { - $(pathID).append( - '
' + - '
' + itemNode.htmlEnc() + '
' + - '
' - ); - } - - // Item - else if(queryNode && itemName) { - $(pathID).append( - '
' + - '
' + itemName.htmlEnc() + '
' + - '
' - ); - } - - // Item with children - else { - // We display the waiting element - $(pathID + ' .disco-wait .disco-category-title').after( - '
' + - '
' + - '
' + itemHost + '
' + - '
' + Common._e("Requesting this service...") + '
' + - '
' - ); - - // We display the category - $('#' + target + ' .disco-wait').show(); - - // We ask the server what's the service type - self.getType(itemHost, itemNode, sessionID); - } - }); - } - - // Else, there are no items for this query - else - self.noResult(pathID); - } - - else if((type == 'muc') || (type == 'search') || (type == 'subscribe') || ((type == 'command') && $(handleXML).find('command').attr('xmlns'))) { - // Get some values - var xCommand = $(handleXML).find('command'); - var bNode = xCommand.attr('node'); - var bSession = xCommand.attr('sessionid'); - var bStatus = xCommand.attr('status'); - var xRegister = $(handleXML).find('query[xmlns="' + NS_REGISTER + '"]').text(); - var xElement = $(handleXML).find('x'); - - // Search done - if((xElement.attr('type') == 'result') && (type == 'search')) { - var bPath = pathID; - - // Display the result - $(handleXML).find('item').each(function() { - // Have some "flexibility" for what regards field names, it would be better to return the whole original DF - // layout, but on a large amount of result which have many fields, there's a very high chance the browser can - // choke on old systems or new ones even. - - // Search for useful fields, return first result. This is rather hacky, but jQuery is horrible when it comes to - // matching st. using patterns. (TODO: Improve and return the full DF layout without choking the browser) - var bName; - var bCountry; - var doneName, doneCountry; - - $.each($(this).find('field'), function(i, item) { - var $item = $(item); - - if($(item).attr('var').match(/^(fn|name|[^n][^i][^c][^k]name)$/gi) && doneName !== true) { - bName = $item.children('value:first').text(); - doneName = true; - } else if($(item).attr('var').match(/^(ctry|country.*)$/gi) && doneCountry !== true) { - bCountry = $item.children('value:first').text(); - doneCountry = true; - } - }); - - var bXID = $(this).find('field[var="jid"] value:first').text(); - var dName = bName; - - // Override "undefined" value - if(!bXID) - bXID = ''; - if(!bName) - bName = Common._e("Unknown name"); - if(!bCountry) - bCountry = Common._e("Unknown country"); - - // User hash - var bHash = hex_md5(bXID); - - // HTML code - var bHTML = '
' + - '
' + - '' + - '
' + - '
' + bName + '
' + - '
' + bCountry + '
' + - '
' + bXID + '
' + - '
'; - - // The buddy is not in our buddy list? - if(!Common.exists('#roster .buddy[data-xid="' + escape(bXID) + '"]')) { - bHTML += '' + Common._e("Add") + ''; - } - - // Chat button, if not in welcome/directory mode - if(target == 'discovery') { - bHTML += '' + Common._e("Chat") + ''; - } - - // Profile button, if not in discovery mode - else { - bHTML += '' + Common._e("Profile") + ''; - } - - // Close the HTML element - bHTML += '
'; - - $(bPath).append(bHTML); - - // Click events - $(bPath + ' .' + bHash + ' a').click(function() { - // Buddy add - if($(this).is('.one-add')) { - $(this).hide(); - - Roster.addThisContact(bXID, dName); - } - - // Buddy chat - if($(this).is('.one-chat')) { - if(target == 'discovery') - Discovery.close(); - - Chat.checkCreate(bXID, 'chat', '', '', dName); - } - - // Buddy profile - if($(this).is('.one-profile')) { - UserInfos.open(bXID); - } - - return false; - }); - - // Get the user's avatar - if(bXID) { - Avatar.get(bXID, 'cache', 'true', 'forget'); - } - }); - - // No result? - if(!$(handleXML).find('item').size()) - self.noResult(pathID); - - // Previous button - self.buttons(type, 'back', sessionID, from, bNode, bSession, target, pathID); - } - - // Command to complete - else if(xElement.attr('xmlns') || ((type == 'subscribe') && xRegister)) { - // We display the elements - self.fill(handleXML, sessionID); - - // We display the buttons - if(bStatus != 'completed') { - self.buttons(type, 'submit', sessionID, from, bNode, bSession, target, pathID); - } else { - self.buttons(type, 'back', sessionID, from, bNode, bSession, target, pathID); - } - } - - // Command completed or subscription done - else if(((bStatus == 'completed') && (type == 'command')) || (!xRegister && (type == 'subscribe'))) { - // Display the good text - var cNote = $(xCommand).find('note'); - - // Any note? - if(cNote.size()) { - cNote.each(function() { - $(pathID).append( - '
' + $(this).text().htmlEnc() + '
' - ); - }); - } - - // Default text - else { - $(pathID).append('
' + Common._e("Your form has been sent.") + '
'); - } - - // Display the back button - self.buttons(type, 'back', sessionID, from, '', '', target, pathID); - - // Add the gateway to our roster if subscribed - if(type == 'subscribe') { - Roster.addThisContact(from); - } - } - - // Command canceled - else if((bStatus == 'canceled') && (type == 'command')) { - if(target == 'discovery') { - Discovery.start(); - } else if(target == 'adhoc') { - dataForm(from, 'command', '', '', 'adhoc'); - } - } - - // No items for this query - else - self.noResult(pathID); - } - - else if(type == 'command') { - if($(handleXML).find('item').attr('jid')) { - // We display the elements - $(handleXML).find('item').each(function() { - // We parse the received xml - var itemHost = $(this).attr('jid'); - var itemNode = $(this).attr('node'); - var itemName = $(this).attr('name'); - var itemHash = hex_md5(itemHost); - - // We display the waiting element - $(pathID).prepend( - '
' + - '
' + itemName + '
' + - '
»
' + - '
' - ); - }); - } - - // Else, there are no items for this query - else { - self.noResult(pathID); - } - } - } - - // Focus on the first input - $(document).oneTime(10, function() { - $(pathID + ' input:visible:first').focus(); - }); - - // Hide the wait icon - $('#' + target + ' .wait').hide(); - } catch(e) { - Console.error('DataForm.handleContent', e); - } - - }; - - - /** - * Fills the dataform elements - * @public - * @param {type} xml - * @param {type} id - * @return {boolean} - */ - self.fill = function(xml, id) { - - /* REF: http://xmpp.org/extensions/xep-0004.html */ - - try { - // Initialize new vars - var target = id.split('-')[0]; - var pathID = '#' + target + ' .results[data-session="' + id + '"]'; - var selector, is_dataform; - - // Is it a dataform? - if($(xml).find('x[xmlns="' + NS_XDATA + '"]').size()) { - is_dataform = true; - } else { - is_dataform = false; - } - - // Determines the good selector to use - if(is_dataform) { - selector = $(xml).find('x[xmlns="' + NS_XDATA + '"]'); - } else { - selector = $(xml); - } - - // Form title - selector.find('title').each(function() { - $(pathID).append( - '
' + $(this).text().htmlEnc() + '
' - ); - }); - - // Form instructions - selector.find('instructions').each(function() { - $(pathID).append( - '
' + $(this).text().htmlEnc() + '
' - ); - }); - - // Register? - if(!is_dataform) { - // Items to detect - var reg_names = [Common._e("Nickname"), Common._e("Name"), Common._e("Password"), Common._e("E-mail")]; - var reg_ids = ['username', 'name', 'password', 'email']; - - // Append these inputs - $.each(reg_names, function(a) { - selector.find(reg_ids[a]).each(function() { - $(pathID).append( - '
' + - '' + - '' + - '
' - ); - }); - }); - - return false; - } - - // Dataform? - selector.find('field').each(function() { - // We parse the received xml - var type = $(this).attr('type'); - var label = $(this).attr('label'); - var field = $(this).attr('var'); - var value = $(this).find('value:first').text(); - var required = ''; - - // No value? - if(!field) { - return; - } - - // Required input? - if($(this).find('required').size()) { - required = ' required=""'; - } - - // Compatibility fix - if(!label) { - label = field; - } - - if(!type) { - type = ''; - } - - // Generate some values - var input; - var hideThis = ''; - - // Fixed field - if(type == 'fixed') { - $(pathID).append('
' + value.htmlEnc() + '
'); - } else { - // Hidden field - if(type == 'hidden') { - hideThis = ' style="display: none;"'; - input = ''; - } - - // Boolean field - else if(type == 'boolean') { - var checked; - - if(value == '1') - checked = 'checked'; - else - checked = ''; - - input = ''; - } - - // List-single/list-multi field - else if((type == 'list-single') || (type == 'list-multi')) { - var multiple = ''; - - // Multiple options? - if(type == 'list-multi') { - multiple = ' multiple=""'; - } - - // Append the select field - input = ''; - } - - // Text-multi field - else if(type == 'text-multi') { - input = ''; - } - - // JID-multi field - else if(type == 'jid-multi') { - // Put the XID into an array - var xid_arr = []; - - $(this).find('value').each(function() { - var cValue = $(this).text(); - - if(!Utils.existArrayValue(xid_arr, cValue)) { - xid_arr.push(cValue); - } - }); - - // Sort the array - xid_arr.sort(); - - // Create the input - var xid_value = ''; - - if(xid_arr.length) { - for(var i in xid_arr) { - // Any pre-value - if(xid_value) { - xid_value += ', '; - } - - // Add the current XID - xid_value += xid_arr[i]; - } - } - - input = ''; - } - - // Other stuffs that are similar - else { - // Text-single field - var iType = 'text'; - - // Text-private field - if(type == 'text-private') { - iType = 'password'; - } - - // JID-single field - else if(type == 'jid-single') { - iType = 'email'; - } - - input = ''; - } - - // Append the HTML markup for this field - $(pathID).append( - '
' + - '' + - input + - '
' - ); - } - }); - } catch(e) { - Console.error('DataForm.fill', e); - } finally { - return false; - } - - }; - - - /** - * Gets the dataform type - * @public - * @param {string} host - * @param {string} node - * @param {string} id - * @return {undefined} - */ - self.getType = function(host, node, id) { - - try { - var iq = new JSJaCIQ(); - iq.setID(id + '-' + genID()); - iq.setTo(host); - iq.setType('get'); - - var iqQuery = iq.setQuery(NS_DISCO_INFO); - - if(node) { - iqQuery.setAttribute('node', node); - } - - con.send(iq, self.handleThisBrowse); - } catch(e) { - Console.error('DataForm.getType', e); - } - - }; - - - /** - * Handles the browse stanza - * @public - * @param {object} iq - * @return {undefined} - */ - self.handleThisBrowse = function(iq) { - - /* REF: http://xmpp.org/registrar/disco-categories.html */ - - try { - var id = iq.getID(); - var splitted = id.split('-'); - var target = splitted[0]; - var sessionID = target + '-' + splitted[1]; - var from = Common.fullXID(Common.getStanzaFrom(iq)); - var hash = hex_md5(from); - var handleXML = iq.getQuery(); - var pathID = '#' + target + ' .results[data-session="' + sessionID + '"]'; - - // We first remove the waiting element - $(pathID + ' .disco-wait .' + hash).remove(); - - if($(handleXML).find('identity').attr('type')) { - var category = $(handleXML).find('identity').attr('category'); - var type = $(handleXML).find('identity').attr('type'); - var named = $(handleXML).find('identity').attr('name'); - - if(named) { - gName = named; - } else { - gName = ''; - } - - var one, two, three, four, five; - - // Get the features that this entity supports - var findFeature = $(handleXML).find('feature'); - - for(var i in findFeature) { - var current = findFeature.eq(i).attr('var'); - - switch(current) { - case NS_SEARCH: - one = 1; - break; - - case NS_MUC: - two = 1; - break; - - case NS_REGISTER: - three = 1; - break; - - case NS_COMMANDS: - four = 1; - break; - - case NS_DISCO_ITEMS: - five = 1; - break; - - default: - break; - } - } - - var buttons = Array(one, two, three, four, five); - - // We define the toolbox links depending on the supported features - var tools = ''; - var aTools = Array('search', 'join', 'subscribe', 'command', 'browse'); - var bTools = Array(Common._e("Search"), Common._e("Join"), Common._e("Subscribe"), Common._e("Command"), Common._e("Browse")); - - for(var b in buttons) { - if(buttons[b]) { - tools += ''; - } - } - - // As defined in the ref, we detect the type of each category to put an icon - switch(category) { - case 'account': - case 'auth': - case 'automation': - case 'client': - case 'collaboration': - case 'component': - case 'conference': - case 'directory': - case 'gateway': - case 'headline': - case 'hierarchy': - case 'proxy': - case 'pubsub': - case 'server': - case 'store': - break; - - default: - category = 'others'; - } - - // We display the item we found - $(pathID + ' .disco-' + category + ' .disco-category-title').after( - '
' + - '
' + - '
' + from + '
' + - '
' + gName + '
' + - '
' + tools + '
' + - '
' - ); - - // We display the category - $(pathID + ' .disco-' + category).show(); - } - - else { - $(pathID + ' .disco-others .disco-category-title').after( - '
' + - '
' + - '
' + from + '
' + - '
' + Common._e("Service offline or broken") + '
' + - '
' - ); - - // We display the category - $(pathID + ' .disco-others').show(); - } - - // We hide the waiting stuffs if there's no remaining loading items - if(!$(pathID + ' .disco-wait .' + target + '-oneresult').size()) { - $(pathID + ' .disco-wait, #' + target + ' .wait').hide(); - } - } catch(e) { - Console.error('DataForm.handleThisBrowse', e); - } - - }; - - - /** - * Cleans the current data-form popup - * @public - * @param {string} target - * @return {undefined} - */ - self.clean = function(target) { - - try { - if(target == 'discovery') { - Discovery.clean(); - } else { - $('#' + target + ' div.results').empty(); - } - } catch(e) { - Console.error('DataForm.clean', e); - } - - }; - - - /** - * Displays the no result indicator - * @public - * @param {string} path - * @return {undefined} - */ - self.noResult = function(path) { - - try { - $(path).prepend('

' + Common._e("Sorry, but the entity didn't return any result!") + '

'); - } catch(e) { - Console.error('DataForm.noResult', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/datastore.js b/source/app/javascripts/datastore.js deleted file mode 100644 index 1f4b64f..0000000 --- a/source/app/javascripts/datastore.js +++ /dev/null @@ -1,506 +0,0 @@ -/* - -Jappix - An open social platform -These are the temporary/persistent data store functions - -------------------------------------------------- - -License: dual-licensed under AGPL and MPLv2 -Authors: Valérian Saliou, Maranda - -*/ - -// Bundle -var DataStore = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Variables */ - self._db_emulated = {}; - self._persistent_emulated = {}; - - - /** - * Common: storage adapter - * @public - * @param {object} storage_native - * @param {object} storage_emulated - * @return {undefined} - */ - self._adapter = function(storage_native, storage_emulated) { - - try { - var legacy = !storage_native; - - this.key = function(key) { - if(legacy) { - if(key >= this.length) { - return null; - } - - var c = 0; - - for(var name in storage_emulated) { - if(c++ == key) return name; - } - - return null; - } - - return storage_native.key(key); - }; - - this.getItem = function(key) { - if(legacy) { - if(storage_emulated[key] !== undefined) { - return storage_emulated[key]; - } - - return null; - } else { - return storage_native.getItem(key); - } - }; - - this.setItem = function(key, data) { - if(legacy) { - if(!(key in storage_emulated)) { - this.length++; - } - - storage_emulated[key] = (data + ''); - } else { - storage_native.setItem(key, data); - this.length = storage_native.length; - } - }; - - this.removeItem = function(key) { - if(legacy) { - if(key in storage_emulated) { - this.length--; - delete storage_emulated[key]; - } - } else { - storage_native.removeItem(key); - this.length = storage_native.length; - } - }; - - this.clear = function() { - if(legacy) { - this.length = 0; - storage_emulated = {}; - } else { - storage_native.clear(); - this.length = storage_native.length; - } - }; - - this.length = legacy ? 0 : storage_native.length; - } catch(e) { - Console.error('DataStore._adapter', e); - } - - }; - - - /** - * Temporary: sessionStorage class alias for direct access - */ - self.storageDB = new self._adapter( - (window.sessionStorage ? sessionStorage : null), - self._db_emulated - ); - - - /** - * Persistent: localStorage class alias for direct access - */ - self.storagePersistent = new self._adapter( - (window.localStorage ? localStorage : null), - self._persistent_emulated - ); - - - /** - * Temporary: returns whether it is available or not - * @public - * @return {boolean} - */ - self.hasDB = function() { - - var has_db = false; - - try { - self.storageDB.setItem('hasdb_check', 'ok'); - self.storageDB.removeItem('hasdb_check'); - - has_db = true; - } catch(e) { - Console.error('DataStore.hasDB', e); - } finally { - return has_db; - } - - }; - - - /** - * Temporary: used to read a database entry - * @public - * @param {string} dbID - * @param {string} type - * @param {string} id - * @return {object} - */ - self.getDB = function(dbID, type, id) { - - try { - try { - return self.storageDB.getItem(dbID + '_' + type + '_' + id); - } - - catch(e) { - Console.error('Error while getting a temporary database entry (' + dbID + ' -> ' + type + ' -> ' + id + ')', e); - } - - return null; - } catch(e) { - Console.error('DataStore.getDB', e); - } - - }; - - - /** - * Temporary: used to update a database entry - * @public - * @param {string} dbID - * @param {string} type - * @param {string} id - * @param {type} value - * @return {boolean} - */ - self.setDB = function(dbID, type, id, value) { - - try { - try { - self.storageDB.setItem(dbID + '_' + type + '_' + id, value); - - return true; - } - - catch(e) { - Console.error('Error while writing a temporary database entry (' + dbID + ' -> ' + type + ' -> ' + id + ')', e); - } - - return false; - } catch(e) { - Console.error('DataStore.setDB', e); - } - - }; - - - /** - * Temporary: used to remove a database entry - * @public - * @param {string} dbID - * @param {string} type - * @param {string} id - * @return {undefined} - */ - self.removeDB = function(dbID, type, id) { - - try { - try { - self.storageDB.removeItem(dbID + '_' + type + '_' + id); - - return true; - } - - catch(e) { - Console.error('Error while removing a temporary database entry (' + dbID + ' -> ' + type + ' -> ' + id + ')', e); - } - - return false; - } catch(e) { - Console.error('DataStore.removeDB', e); - } - - }; - - - /** - * Temporary: used to check a database entry exists - * @public - * @param {string} dbID - * @param {string} type - * @param {string} id - * @return {boolean} - */ - self.existDB = function(dbID, type, id) { - - try { - return self.getDB(dbID, type, id) !== null; - } catch(e) { - Console.error('DataStore.existDB', e); - } - - }; - - - /** - * Temporary: used to clear all the database - * @public - * @return {boolean} - */ - self.resetDB = function() { - - try { - try { - self.storageDB.clear(); - - Console.info('Temporary database cleared.'); - - return true; - } - - catch(e) { - Console.error('Error while clearing temporary database', e); - - return false; - } - } catch(e) { - Console.error('DataStore.resetDB', e); - } - - }; - - - /** - * Persistent: returns whether it is available or not - * @public - * @return {boolean} - */ - self.hasPersistent = function() { - - var has_persistent = false; - - try { - // Try to write something - self.storagePersistent.setItem('haspersistent_check', 'ok'); - self.storagePersistent.removeItem('haspersistent_check'); - - has_persistent = true; - } catch(e) { - Console.error('DataStore.hasPersistent', e); - } finally { - return has_persistent; - } - - }; - - - /** - * Persistent: used to read a database entry - * @public - * @param {string} dbID - * @param {string} type - * @param {string} id - * @return {object} - */ - self.getPersistent = function(dbID, type, id) { - - try { - try { - return self.storagePersistent.getItem(dbID + '_' + type + '_' + id); - } - - catch(e) { - Console.error('Error while getting a persistent database entry (' + dbID + ' -> ' + type + ' -> ' + id + ')', e); - - return null; - } - } catch(e) { - Console.error('DataStore.getPersistent', e); - } - - }; - - - /** - * Persistent: used to update a database entry - * @public - * @param {string} dbID - * @param {string} type - * @param {string} id - * @param {string} value - * @return {boolean} - */ - self.setPersistent = function(dbID, type, id, value) { - - try { - try { - self.storagePersistent.setItem(dbID + '_' + type + '_' + id, value); - - return true; - } - - // Database might be full - catch(e) { - Console.warn('Retrying: could not write a persistent database entry (' + dbID + ' -> ' + type + ' -> ' + id + ')', e); - - // Flush it! - self.flushPersistent(); - - // Set the item again - try { - self.storagePersistent.setItem(dbID + ' -> ' + type + '_' + id, value); - - return true; - } - - // New error! - catch(_e) { - Console.error('Aborted: error while writing a persistent database entry (' + dbID + ' -> ' + type + ' -> ' + id + ')', _e); - } - } - - return false; - } catch(e) { - Console.error('DataStore.setPersistent', e); - } - - }; - - - /** - * Persistent: used to remove a database entry - * @public - * @param {string} dbID - * @param {string} type - * @param {string} id - * @return {boolean} - */ - self.removePersistent = function(dbID, type, id) { - - try { - try { - self.storagePersistent.removeItem(dbID + '_' + type + '_' + id); - - return true; - } - - catch(e) { - Console.error('Error while removing a persistent database entry (' + dbID + ' -> ' + type + ' -> ' + id + ')', e); - } - - return false; - } catch(e) { - Console.error('DataStore.removePersistent', e); - } - - }; - - - /** - * Persistent: used to check a database entry exists - * @public - * @param {string} dbID - * @param {string} type - * @param {string} id - * @return {boolean} - */ - self.existPersistent = function(dbID, type, id) { - - try { - return self.getPersistent(dbID, type, id) !== null; - } catch(e) { - Console.error('DataStore.existPersistent', e); - } - - }; - - - /** - * Persistent: used to clear all the database - * @public - * @param {type} name - * @return {boolean} - */ - self.resetPersistent = function() { - - try { - try { - self.storagePersistent.clear(); - - Console.info('Persistent database cleared.'); - - return true; - } - - catch(e) { - Console.error('Error while clearing persistent database', e); - } - - return false; - } catch(e) { - Console.error('DataStore.resetPersistent', e); - } - - }; - - - /** - * Persistent: used to flush the database - * @public - * @param {type} name - * @return {boolean} - */ - self.flushPersistent = function() { - - try { - try { - // Get the stored session entry - var session = self.getPersistent('global', 'session', 1); - - // Reset the persistent database - self.resetPersistent(); - - // Restaure the stored session entry - if(session) { - self.setPersistent('global', 'session', 1, session); - } - - Console.info('Persistent database flushed.'); - - return true; - } - - catch(e) { - Console.error('Error while flushing persistent database', e); - } - - return false; - } catch(e) { - Console.error('DataStore.flushPersistent', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); - -var JappixDataStore = DataStore; \ No newline at end of file diff --git a/source/app/javascripts/date.js b/source/app/javascripts/date.js deleted file mode 100644 index 977b677..0000000 --- a/source/app/javascripts/date.js +++ /dev/null @@ -1,454 +0,0 @@ -/* - -Jappix - An open social platform -These are the date related JS scripts for Jappix - -------------------------------------------------- - -License: dual-licensed under AGPL and MPLv2 -Author: Valérian Saliou - -*/ - -// Bundle -var DateUtils = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Variables */ - self.last_activity = 0; - self.presence_last_activity = 0; - - - /** - * Gets a stamp from a date - * @public - * @param {Date} date - * @return {number} - */ - self.extractStamp = function(date) { - - try { - return Math.round(date.getTime() / 1000); - } catch(e) { - Console.error('DateUtils.extractStamp', e); - } - - }; - - - /** - * Gets the time from a date - * @public - * @param {Date} date - * @return {string} - */ - self.extractTime = function(date) { - - try { - return date.toLocaleTimeString(); - } catch(e) { - Console.error('DateUtils.extractTime', e); - } - - }; - - - /** - * Gets the actual date stamp - * @public - * @return {number} - */ - self.getTimeStamp = function() { - - try { - return self.extractStamp(new Date()); - } catch(e) { - Console.error('DateUtils.getTimeStamp', e); - } - - }; - - - /** - * Gets the last user activity in seconds - * @public - * @return {number} - */ - self.getLastActivity = function() { - - try { - // Last activity not yet initialized? - if(self.last_activity === 0) { - return 0; - } - - return self.getTimeStamp() - self.last_activity; - } catch(e) { - Console.error('DateUtils.getLastActivity', e); - } - - }; - - - /** - * Gets the last user activity as a date - * @public - * @return {string} - */ - self.getLastActivityDate = function() { - - try { - var last_activity = self.last_activity || self.getTimeStamp(); - - var last_date = new Date(); - last_date.setTime(last_activity * 1000); - - return self.getDatetime(last_date, 'utc'); - } catch(e) { - Console.error('DateUtils.getLastActivityDate', e); - } - - }; - - - /** - * Gets the last user available presence in seconds - * @public - * @return {number} - */ - self.getPresenceLast = function() { - - try { - // Last presence stamp not yet initialized? - if(self.presence_last_activity === 0) { - return 0; - } - - return self.getTimeStamp() - self.presence_last_activity; - } catch(e) { - Console.error('DateUtils.getPresenceLast', e); - } - - }; - - - /** - * Generates a normalized datetime - * @public - * @param {Date} date - * @param {string} location - * @return {string} - */ - self.getDatetime = function(date, location) { - - /* FROM : http://trac.jwchat.org/jsjac/browser/branches/jsjac_1.0/jsextras.js?rev=221 */ - - var year, month, day, hours, minutes, seconds; - var date_string = null; - - try { - if(location == 'utc') { - // UTC date - year = date.getUTCFullYear(); - month = date.getUTCMonth(); - day = date.getUTCDate(); - hours = date.getUTCHours(); - minutes = date.getUTCMinutes(); - seconds = date.getUTCSeconds(); - } else { - // Local date - year = date.getFullYear(); - month = date.getMonth(); - day = date.getDate(); - hours = date.getHours(); - minutes = date.getMinutes(); - seconds = date.getSeconds(); - } - - // Generates the date string - date_string = year + '-'; - date_string += Common.padZero(month + 1) + '-'; - date_string += Common.padZero(day) + 'T'; - date_string += Common.padZero(hours) + ':'; - date_string += Common.padZero(minutes) + ':'; - date_string += Common.padZero(seconds) + 'Z'; - - // Returns the date string - return date_string; - } catch(e) { - Console.error('DateUtils.getDatetime', e); - } - - }; - - - /** - * Generates the time for XMPP - * @public - * @param {string} location - * @return {string} - */ - self.getXMPPTime = function(location) { - - try { - return self.getDatetime( - (new Date()), - location - ); - } catch(e) { - Console.error('DateUtils.getXMPPTime', e); - } - - }; - - - /** - * Generates then human time - * @public - * @return {string} - */ - self.getCompleteTime = function() { - - try { - var init = new Date(); - - var time = Common.padZero(init.getHours()) + ':'; - time += Common.padZero(init.getMinutes()) + ':'; - time += Common.padZero(init.getSeconds()); - - return time; - } catch(e) { - Console.error('DateUtils.getCompleteTime', e); - } - - }; - - - /** - * Gets the TZO of a date - * @public - * @return {string} - */ - self.getTZO = function() { - - try { - // Get the date - var date = new Date(); - var offset = date.getTimezoneOffset(); - - // Default vars - var sign = ''; - var hours = 0; - var minutes = 0; - - // Process a neutral offset - if(offset < 0) { - offset = offset * -1; - sign = '+'; - } - - // Get the values - var n_date = new Date(offset * 60 * 1000); - hours = n_date.getHours() - 1; - minutes = n_date.getMinutes(); - - // Process the TZO - tzo = sign + Common.padZero(hours) + ':' + Common.padZero(minutes); - - // Return the processed value - return tzo; - } catch(e) { - Console.error('DateUtils.getTZO', e); - } - - }; - - - /** - * Returns a date representing the difference of time between 2 timestamps - * @public - * @param {string} now_stamp - * @param {string} past_stamp - * @return {Date} - */ - self.difference = function(now_stamp, past_stamp) { - - try { - return (new Date()).clearTime().addSeconds( - past_stamp > 0 ? now_stamp - past_stamp : 0 - ); - } catch(e) { - Console.error('DateUtils.difference', e); - } - - }; - - - /** - * Parses a XMPP date (yyyy-mm-dd, hh-mm-ss) into an human-readable one - * @public - * @param {string} to_parse - * @return {string} - */ - self.parse = function(to_parse) { - - try { - var date = Date.jab2date(to_parse); - var parsed = date.toLocaleDateString() + ' (' + date.toLocaleTimeString() + ')'; - - return parsed; - } catch(e) { - Console.error('DateUtils.parse', e); - } - - }; - - - /** - * Parses a XMPP date (yyyy-mm-dd) into an human-readable one - * @public - * @param {string} to_parse - * @return {string} - */ - self.parseDay = function(to_parse) { - - try { - var date = Date.jab2date(to_parse); - var parsed = date.toLocaleDateString(); - - return parsed; - } catch(e) { - Console.error('DateUtils.parseDay', e); - } - - }; - - - /** - * Parses a XMPP date (hh-mm-ss) into an human-readable one - * @public - * @param {string} to_parse - * @return {string} - */ - self.parseTime = function(to_parse) { - - try { - var date = Date.jab2date(to_parse); - var parsed = date.toLocaleTimeString(); - - return parsed; - } catch(e) { - Console.error('DateUtils.parseTime', e); - } - - }; - - - /** - * Parses a XMPP date stamp into a relative one - * @public - * @param {string} to_parse - * @return {string} - */ - self.relative = function(to_parse) { - - try { - // Get the current date - var current_date = Date.jab2date(self.getXMPPTime('utc')); - var current_day = current_date.getDate(); - var current_stamp = current_date.getTime(); - - // Parse the given date - var old_date = Date.jab2date(to_parse); - var old_day = old_date.getDate(); - var old_stamp = old_date.getTime(); - var old_time = old_date.toLocaleTimeString(); - - // Get the day number between the two dates - var days = Math.round((current_stamp - old_stamp) / 86400000); - - // Invalid date? - if(isNaN(old_stamp) || isNaN(days)) { - return self.getCompleteTime(); - } - - // Is it today? - if(current_day == old_day) { - return old_time; - } - - // It is yesterday? - if(days <= 1) { - return Common._e("Yesterday") + ' - ' + old_time; - } - - // Is it less than a week ago? - if(days <= 7) { - return Common.printf(Common._e("%s days ago"), days) + ' - ' + old_time; - } - - // Another longer period - return old_date.toLocaleDateString() + ' - ' + old_time; - } catch(e) { - Console.error('DateUtils.relative', e); - } - - }; - - - /** - * Reads a message delay - * @public - * @param {string} node - * @param {boolean} return_date - * @return {string|Date} - */ - self.readMessageDelay = function(node, return_date) { - - try { - // Initialize - var delay, d_delay; - - // Read the delay - d_delay = jQuery(node).find('delay[xmlns="' + NS_URN_DELAY + '"]:first').attr('stamp'); - - // Get delay - if(d_delay) { - // New delay (valid XEP) - delay = d_delay; - } else { - // Old delay (obsolete XEP!) - var x_delay = jQuery(node).find('x[xmlns="' + NS_DELAY + '"]:first').attr('stamp'); - - if(x_delay) { - delay = x_delay.replace(/^(\w{4})(\w{2})(\w{2})T(\w{2}):(\w{2}):(\w{2})Z?(\S+)?/, '$1-$2-$3T$4:$5:$6Z$7'); - } - } - - // Return a date object? - if(return_date === true && delay) { - return Date.jab2date(delay); - } - - return delay; - } catch(e) { - Console.error('DateUtils.readMessageDelay', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); - -var JappixDateUtils = DateUtils; \ No newline at end of file diff --git a/source/app/javascripts/datejs.js b/source/app/javascripts/datejs.js deleted file mode 100644 index 2d52e9a..0000000 --- a/source/app/javascripts/datejs.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Version: 1.0 Alpha-1 - * Build Date: 13-Nov-2007 - * Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved. - * License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. - * Website: http://www.datejs.com/ or http://www.coolite.com/datejs/ - */ -Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",longDate:"dddd, MMMM dd, yyyy",shortTime:"h:mm tt",longTime:"h:mm:ss tt",fullDateTime:"dddd, MMMM dd, yyyy h:mm:ss tt",sortableDateTime:"yyyy-MM-ddTHH:mm:ss",universalSortableDateTime:"yyyy-MM-dd HH:mm:ssZ",rfc1123:"ddd, dd MMM yyyy HH:mm:ss GMT",monthDay:"MMMM dd",yearMonth:"MMMM, yyyy"},regexPatterns:{jan:/^jan(uary)?/i,feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\+|after|from)/i,subtract:/^(\-|before|ago)/i,yesterday:/^yesterday/i,today:/^t(oday)?/i,tomorrow:/^tomorrow/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^min(ute)?s?/i,hour:/^h(ou)?rs?/i,week:/^w(ee)?k/i,month:/^m(o(nth)?s?)?/i,day:/^d(ays?)?/i,year:/^y((ea)?rs?)?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\.?m?\.?|p\.?m?\.?)/i,timezone:/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a|p)/i},abbreviatedTimeZoneStandard:{GMT:"-000",EST:"-0400",CST:"-0500",MST:"-0600",PST:"-0700"},abbreviatedTimeZoneDST:{GMT:"-000",EDT:"-0500",CDT:"-0600",MDT:"-0700",PDT:"-0800"}}; -Date.getMonthNumberFromName=function(name){var n=Date.CultureInfo.monthNames,m=Date.CultureInfo.abbreviatedMonthNames,s=name.toLowerCase();for(var i=0;idate)?1:(this=start.getTime()&&t<=end.getTime();};Date.prototype.addMilliseconds=function(value){this.setMilliseconds(this.getMilliseconds()+value);return this;};Date.prototype.addSeconds=function(value){return this.addMilliseconds(value*1000);};Date.prototype.addMinutes=function(value){return this.addMilliseconds(value*60000);};Date.prototype.addHours=function(value){return this.addMilliseconds(value*3600000);};Date.prototype.addDays=function(value){return this.addMilliseconds(value*86400000);};Date.prototype.addWeeks=function(value){return this.addMilliseconds(value*604800000);};Date.prototype.addMonths=function(value){var n=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+value);this.setDate(Math.min(n,this.getDaysInMonth()));return this;};Date.prototype.addYears=function(value){return this.addMonths(value*12);};Date.prototype.add=function(config){if(typeof config=="number"){this._orient=config;return this;} -var x=config;if(x.millisecond||x.milliseconds){this.addMilliseconds(x.millisecond||x.milliseconds);} -if(x.second||x.seconds){this.addSeconds(x.second||x.seconds);} -if(x.minute||x.minutes){this.addMinutes(x.minute||x.minutes);} -if(x.hour||x.hours){this.addHours(x.hour||x.hours);} -if(x.month||x.months){this.addMonths(x.month||x.months);} -if(x.year||x.years){this.addYears(x.year||x.years);} -if(x.day||x.days){this.addDays(x.day||x.days);} -return this;};Date._validate=function(value,min,max,name){if(typeof value!="number"){throw new TypeError(value+" is not a Number.");}else if(valuemax){throw new RangeError(value+" is not a valid value for "+name+".");} -return true;};Date.validateMillisecond=function(n){return Date._validate(n,0,999,"milliseconds");};Date.validateSecond=function(n){return Date._validate(n,0,59,"seconds");};Date.validateMinute=function(n){return Date._validate(n,0,59,"minutes");};Date.validateHour=function(n){return Date._validate(n,0,23,"hours");};Date.validateDay=function(n,year,month){return Date._validate(n,1,Date.getDaysInMonth(year,month),"days");};Date.validateMonth=function(n){return Date._validate(n,0,11,"months");};Date.validateYear=function(n){return Date._validate(n,1,9999,"seconds");};Date.prototype.set=function(config){var x=config;if(!x.millisecond&&x.millisecond!==0){x.millisecond=-1;} -if(!x.second&&x.second!==0){x.second=-1;} -if(!x.minute&&x.minute!==0){x.minute=-1;} -if(!x.hour&&x.hour!==0){x.hour=-1;} -if(!x.day&&x.day!==0){x.day=-1;} -if(!x.month&&x.month!==0){x.month=-1;} -if(!x.year&&x.year!==0){x.year=-1;} -if(x.millisecond!=-1&&Date.validateMillisecond(x.millisecond)){this.addMilliseconds(x.millisecond-this.getMilliseconds());} -if(x.second!=-1&&Date.validateSecond(x.second)){this.addSeconds(x.second-this.getSeconds());} -if(x.minute!=-1&&Date.validateMinute(x.minute)){this.addMinutes(x.minute-this.getMinutes());} -if(x.hour!=-1&&Date.validateHour(x.hour)){this.addHours(x.hour-this.getHours());} -if(x.month!==-1&&Date.validateMonth(x.month)){this.addMonths(x.month-this.getMonth());} -if(x.year!=-1&&Date.validateYear(x.year)){this.addYears(x.year-this.getFullYear());} -if(x.day!=-1&&Date.validateDay(x.day,this.getFullYear(),this.getMonth())){this.addDays(x.day-this.getDate());} -if(x.timezone){this.setTimezone(x.timezone);} -if(x.timezoneOffset){this.setTimezoneOffset(x.timezoneOffset);} -return this;};Date.prototype.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this;};Date.prototype.isLeapYear=function(){var y=this.getFullYear();return(((y%4===0)&&(y%100!==0))||(y%400===0));};Date.prototype.isWeekday=function(){return!(this.is().sat()||this.is().sun());};Date.prototype.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth());};Date.prototype.moveToFirstDayOfMonth=function(){return this.set({day:1});};Date.prototype.moveToLastDayOfMonth=function(){return this.set({day:this.getDaysInMonth()});};Date.prototype.moveToDayOfWeek=function(day,orient){var diff=(day-this.getDay()+7*(orient||+1))%7;return this.addDays((diff===0)?diff+=7*(orient||+1):diff);};Date.prototype.moveToMonth=function(month,orient){var diff=(month-this.getMonth()+12*(orient||+1))%12;return this.addMonths((diff===0)?diff+=12*(orient||+1):diff);};Date.prototype.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/86400000);};Date.prototype.getWeekOfYear=function(firstDayOfWeek){var y=this.getFullYear(),m=this.getMonth(),d=this.getDate();var dow=firstDayOfWeek||Date.CultureInfo.firstDayOfWeek;var offset=7+1-new Date(y,0,1).getDay();if(offset==8){offset=1;} -var daynum=((Date.UTC(y,m,d,0,0,0)-Date.UTC(y,0,1,0,0,0))/86400000)+1;var w=Math.floor((daynum-offset+7)/7);if(w===dow){y--;var prevOffset=7+1-new Date(y,0,1).getDay();if(prevOffset==2||prevOffset==8){w=53;}else{w=52;}} -return w;};Date.prototype.isDST=function(){console.log('isDST');return this.toString().match(/(E|C|M|P)(S|D)T/)[2]=="D";};Date.prototype.getTimezone=function(){return Date.getTimezoneAbbreviation(this.getUTCOffset,this.isDST());};Date.prototype.setTimezoneOffset=function(s){var here=this.getTimezoneOffset(),there=Number(s)*-6/10;this.addMinutes(there-here);return this;};Date.prototype.setTimezone=function(s){return this.setTimezoneOffset(Date.getTimezoneOffset(s));};Date.prototype.getUTCOffset=function(){var n=this.getTimezoneOffset()*-10/6,r;if(n<0){r=(n-10000).toString();return r[0]+r.substr(2);}else{r=(n+10000).toString();return"+"+r.substr(1);}};Date.prototype.getDayName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedDayNames[this.getDay()]:Date.CultureInfo.dayNames[this.getDay()];};Date.prototype.getMonthName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedMonthNames[this.getMonth()]:Date.CultureInfo.monthNames[this.getMonth()];};Date.prototype._toString=Date.prototype.toString;Date.prototype.toString=function(format){var self=this;var p=function p(s){return(s.toString().length==1)?"0"+s:s;};return format?format.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(format){switch(format){case"hh":return p(self.getHours()<13?self.getHours():(self.getHours()-12));case"h":return self.getHours()<13?self.getHours():(self.getHours()-12);case"HH":return p(self.getHours());case"H":return self.getHours();case"mm":return p(self.getMinutes());case"m":return self.getMinutes();case"ss":return p(self.getSeconds());case"s":return self.getSeconds();case"yyyy":return self.getFullYear();case"yy":return self.getFullYear().toString().substring(2,4);case"dddd":return self.getDayName();case"ddd":return self.getDayName(true);case"dd":return p(self.getDate());case"d":return self.getDate().toString();case"MMMM":return self.getMonthName();case"MMM":return self.getMonthName(true);case"MM":return p((self.getMonth()+1));case"M":return self.getMonth()+1;case"t":return self.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case"tt":return self.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case"zzz":case"zz":case"z":return"";}}):this._toString();}; -Date.now=function(){return new Date();};Date.today=function(){return Date.now().clearTime();};Date.prototype._orient=+1;Date.prototype.next=function(){this._orient=+1;return this;};Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this;};Date.prototype._is=false;Date.prototype.is=function(){this._is=true;return this;};Number.prototype._dateElement="day";Number.prototype.fromNow=function(){var c={};c[this._dateElement]=this;return Date.now().add(c);};Number.prototype.ago=function(){var c={};c[this._dateElement]=this*-1;return Date.now().add(c);};(function(){var $D=Date.prototype,$N=Number.prototype;var dx=("sunday monday tuesday wednesday thursday friday saturday").split(/\s/),mx=("january february march april may june july august september october november december").split(/\s/),px=("Millisecond Second Minute Hour Day Week Month Year").split(/\s/),de;var df=function(n){return function(){if(this._is){this._is=false;return this.getDay()==n;} -return this.moveToDayOfWeek(n,this._orient);};};for(var i=0;i0&&!last){try{q=d.call(this,r[1]);}catch(ex){last=true;}}else{last=true;} -if(!last&&q[1].length===0){last=true;} -if(!last){var qx=[];for(var j=0;j0){rx[0]=rx[0].concat(p[0]);rx[1]=p[1];}} -if(rx[1].length1){args=Array.prototype.slice.call(arguments);}else if(arguments[0]instanceof Array){args=arguments[0];} -if(args){for(var i=0,px=args.shift();i2)?n:(n+(((n+2000)Date.getDaysInMonth(this.year,this.month)){throw new RangeError(this.day+" is not a valid value for days.");} -var r=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);if(this.timezone){r.set({timezone:this.timezone});}else if(this.timezoneOffset){r.set({timezoneOffset:this.timezoneOffset});} -return r;},finish:function(x){x=(x instanceof Array)?flattenAndCompact(x):[x];if(x.length===0){return null;} -for(var i=0;i' + Common._e("User directory") + '' + - - '
' + - '
' + - '
' + Common._e("Server to query") + '
' + - - '' + - '
' + - - '
' + - '
' + - - '
' + - '
' + - - '' + Common._e("Close") + '' + - '
'; - - // Create the popup - Popup.create('directory', html); - - // Associate the events - self.instance(); - - // Start a search! - self.start(); - } catch(e) { - Console.error('Directory.open', e); - } finally { - return false; - } - - }; - - - /** - * Quits the directory popup - * @public - * @return {boolean} - */ - self.close = function() { - - try { - // Destroy the popup - Popup.destroy('directory'); - } catch(e) { - Console.error('Directory.close', e); - } finally { - return false; - } - - }; - - - /** - * Launches a directory search - * @public - * @return {boolean} - */ - self.start = function() { - - try { - // Get the server to query - var server = $('#directory .directory-server-input').val(); - - // Launch the search! - DataForm.go($('#directory .directory-server-input').val(), 'search', '', '', 'directory'); - - Console.log('Directory search launched: ' + server); - } catch(e) { - Console.error('Directory.start', e); - } finally { - return false; - } - - }; - - - /** - * Plugin launcher - * @public - * @return {undefined} - */ - self.instance = function() { - - try { - // Click event - $('#directory .bottom .finish').click(self.close); - - // Keyboard event - $('#directory .directory-server-input').keyup(function(e) { - if(e.keyCode == 13) { - // No value? - if(!$(this).val()) { - $(this).val(HOST_VJUD); - } - - // Start the directory search - self.start(); - - return false; - } - }); - } catch(e) { - Console.error('Directory.instance', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/discovery.js b/source/app/javascripts/discovery.js deleted file mode 100644 index ef419ba..0000000 --- a/source/app/javascripts/discovery.js +++ /dev/null @@ -1,241 +0,0 @@ -/* - -Jappix - An open social platform -These are the discovery JS scripts for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var Discovery = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Opens the discovery popup - * @public - * @return {boolean} - */ - self.open = function() { - - try { - // Popup HTML content - var html = - '
' + Common._e("Service discovery") + '
' + - - '
' + - '
' + - '
' + Common._e("Server to query") + '
' + - - '' + - '
' + - - '
' + - '' + - - '
' + - '

' + Common._e("Authentications") + '

' + - '
' + - - '
' + - '

' + Common._e("Automation") + '

' + - '
' + - - '
' + - '

' + Common._e("Clients") + '

' + - '
' + - - '
' + - '

' + Common._e("Collaboration") + '

' + - '
' + - - '
' + - '

' + Common._e("Components") + '

' + - '
' + - - '
' + - '

' + Common._e("Rooms") + '

' + - '
' + - - '
' + - '

' + Common._e("Directories") + '

' + - '
' + - - '
' + - '

' + Common._e("Gateways") + '

' + - '
' + - - '
' + - '

' + Common._e("News") + '

' + - '
' + - - '
' + - '

' + Common._e("Hierarchy") + '

' + - '
' + - - '
' + - '

' + Common._e("Proxies") + '

' + - '
' + - - '
' + - '

' + Common._e("Publication/Subscription") + '

' + - '
' + - - '
' + - '

' + Common._e("Server") + '

' + - '
' + - - '
' + - '

' + Common._e("Storage") + '

' + - '
' + - - '
' + - '

' + Common._e("Others") + '

' + - '
' + - - '
' + - '

' + Common._e("Loading") + '

' + - '
' + - '
' + - '
' + - - '
' + - '
' + - - '' + Common._e("Close") + '' + - '
'; - - // Create the popup - Popup.create('discovery', html); - - // Associate the events - self.instance(); - - // We request a disco to the default server - self.start(); - } catch(e) { - Console.error('Discovery.open', e); - } finally { - return false; - } - - }; - - - /** - * Quits the discovery popup - * @public - * @return {boolean} - */ - self.close = function() { - - try { - // Destroy the popup - Popup.destroy('discovery'); - } catch(e) { - Console.error('Discovery.close', e); - } finally { - return false; - } - - }; - - - /** - * Launches a discovery - * @public - * @return {boolean} - */ - self.start = function() { - - /* REF: http://xmpp.org/extensions/xep-0030.html */ - - try { - // We get the server to query - var discoServer = $('#discovery .disco-server-input').val(); - - // We launch the items query - DataForm.go(discoServer, 'browse', '', '', 'discovery'); - - Console.log('Service discovery launched: ' + discoServer); - } catch(e) { - Console.error('Discovery.start', e); - } finally { - return false; - } - - }; - - - /** - * Cleans the discovery results - * @public - * @return {boolean} - */ - self.clean = function() { - - try { - // We remove the results - $('#discovery .discovery-oneresult, #discovery .oneinstructions, #discovery .onetitle, #discovery .no-results').remove(); - - // We clean the user info - $('#discovery .disco-server-info').text(''); - - // We hide the wait icon, the no result alert and the results - $('#discovery .wait, #discovery .disco-category').hide(); - } catch(e) { - Console.error('Discovery.clean', e); - } - - }; - - - /** - * Plugin launcher - * @public - * @return {undefined} - */ - self.instance = function() { - - try { - // Click event - $('#discovery .bottom .finish').click(self.close); - - // Keyboard event - $('#discovery .disco-server-input').keyup(function(e) { - if(e.keyCode == 13) { - // No value? - if(!$(this).val()) { - $(this).val(HOST_MAIN); - } - - // Start the discovery - self.start(); - - return false; - } - }); - } catch(e) { - Console.error('Discovery.instance', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/errors.js b/source/app/javascripts/errors.js deleted file mode 100644 index f1a651c..0000000 --- a/source/app/javascripts/errors.js +++ /dev/null @@ -1,210 +0,0 @@ -/* - -Jappix - An open social platform -These are the error functions for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var Errors = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Shows the given error output - * @public - * @param {string} condition - * @param {string} reason - * @param {string} type - * @return {undefined} - */ - self.show = function(condition, reason, type) { - - try { - // Enough data to output the error - if(condition || reason) { - // Initialize the error text - var eText = ''; - - // Any error condition - if(condition) { - eText += condition; - } - - // Any error type - if(type && eText) { - eText += ' (' + type + ')'; - } - - // Any error reason - if(reason) { - if(eText) { - eText += ' - '; - } - - eText += reason; - } - - // We reveal the error - Board.openThisError(1); - - // Create the error text - $('#board .one-board.error[data-id="1"] span').text(eText); - } - - // Not enough data to output the error: output a generic board - else { - Board.openThisError(2); - } - } catch(e) { - Console.error('Errors.show', e); - } - - }; - - - /** - * Handles the error from a packet and return true if any error - * @public - * @param {object} packet - * @return {boolean} - */ - self.handle = function(packet) { - - /* REF: http://xmpp.org/extensions/xep-0086.html */ - - try { - // Initialize - var type, code, reason, condition; - var node = $(packet); - - // First level error (connection error) - if(node.is('error')) { - // Get the value - code = node.attr('code'); - - // Specific error reason - switch(code) { - case '401': - reason = Common._e("Authorization failed"); - break; - - case '409': - reason = Common._e("Registration failed, please choose a different username"); - break; - - case '503': - reason = Common._e("Service unavailable"); - break; - - case '500': - reason = Common._e("Internal server error, try later"); - break; - - default: - reason = node.find('text').text(); - break; - } - - // Remove the general wait item (security) - Interface.removeGeneralWait(); - - // Show reconnect pane - if(Connection.current_session && Connection.connected) { - // Anonymous? - if(Utils.isAnonymous()) { - Connection.createReconnect('anonymous'); - } else { - Connection.createReconnect('normal'); - } - } - - // Show the homepage (security) - else if(!Connection.current_session || !Connection.connected) { - $('#home').show(); - Interface.title('home'); - } - - // Still connected? (security) - if(Common.isConnected()) { - con.disconnect(); - } - - Console.error('First level error received.'); - } - - // Second level error (another error) - else if(node.find('error').size()) { - type = node.find('error').attr('type'); - reason = node.find('error text').text(); - condition = packet.getElementsByTagName('error').item(0).childNodes.item(0).nodeName.replace(/-/g, ' '); - - Console.error('Second level error received.'); - } else { - return false; - } - - // Show the error board - self.show(condition, reason, type); - - // Return there's an error - return true; - } catch(e) { - Console.error('Errors.handle', e); - } - - }; - - - /** - * Handles the error reply of a packet - * @public - * @param {object} packet - * @return {boolean} - */ - self.handleReply = function(packet) { - - try { - return self.handle(packet.getNode()); - } catch(e) { - Console.error('Errors.handleReply', e); - } - - }; - - - /** - * Handles the error reply for a message - * @public - * @param {object} packet - * @return {boolean} - */ - self.handleMessage = function(packet) { - - try { - if(!self.handleReply(packet)) { - Message.handle(packet); - } - } catch(e) { - Console.error('Errors.handleMessage', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/favorites.js b/source/app/javascripts/favorites.js deleted file mode 100644 index ffbbe17..0000000 --- a/source/app/javascripts/favorites.js +++ /dev/null @@ -1,785 +0,0 @@ -/* - -Jappix - An open social platform -These are the favorites JS scripts for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou - -*/ - -// Bundle -var Favorites = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Opens the favorites popup - * @public - * @return {undefined} - */ - self.open = function() { - - try { - // Popup HTML content - var html = - '
' + Common._e("Manage favorite rooms") + '
' + - - '
' + - '
' + - '
' + - '
' + - - Common._e("Change favorites") + - '
' + - - '' + - '
' + - - '
' + - '
' + - '
' + - '
' + Common._e("Select a favorite") + '
' + - - '' + - '
' + - - '
' + - '
' + - '' + - - '' + - '
' + - - '
' + - '' + - - '' + - '
' + - - '
' + - '' + - - '' + - '
' + - - '
' + - '' + - - '' + - '
' + - - '
' + - '' + - - '' + - '
' + - - '
' + - '' + - - '' + - '
' + - - '' + - '
' + - '
' + - - '' + - '
' + - '
' + - - '
' + - '
' + - - '' + Common._e("Close") + '' + - '
'; - - // Create the popup - Popup.create('favorites', html); - - // Load the favorites - self.load(); - - // Associate the events - self.instance(); - } catch(e) { - Console.error('Favorites.open', e); - } - - }; - - - /** - * Resets the favorites elements - * @public - * @return {undefined} - */ - self.reset = function() { - - try { - var path_sel = $('#favorites'); - - path_sel.find('.wait'); - path_sel.find('.fedit-terminate').hide(); - path_sel.find('.fedit-add').show(); - - path_sel.find('.fsearch-oneresult').remove(); - path_sel.find('input').val(''); - path_sel.find('.please-complete').removeClass('please-complete'); - - path_sel.find('.fedit-nick').val(Name.getNick()); - path_sel.find('.fsearch-head-server').val(HOST_MUC); - path_sel.find('.fedit-server').val(HOST_MUC); - - path_sel.find('.fedit-autojoin').removeAttr('checked'); - } catch(e) { - Console.error('Favorites.reset', e); - } - - }; - - - /** - * Quits the favorites popup - * @public - * @return {boolean} - */ - self.quit = function() { - - try { - // Destroy the popup - Popup.destroy('favorites'); - } catch(e) { - Console.error('Favorites.quit', e); - } finally { - return false; - } - - }; - - - /** - * Adds a room to the favorites - * @public - * @param {string} room_xid - * @param {string} room_name - * @return {boolean} - */ - self.addThis = function(room_xid, room_name) { - - try { - // Button path - var button_sel = $('#favorites .fsearch-results div[data-xid="' + escape(room_xid) + '"] a.one-button'); - - // Add a remove button instead of the add one - button_sel.filter('.add').replaceWith( - '' + Common._e("Remove") + '' - ); - - // Click event - button_sel.filter('.remove').click(function() { - return self.removeThis(room_xid, room_name); - }); - - // Hide the add button in the (opened?) groupchat - $('#' + hex_md5(room_xid) + ' .tools-add').hide(); - - // Add the database entry - self.display( - room_xid, - Common.explodeThis(' (', room_name, 0), Name.getNick(), '0', '' - ); - - // Publish the favorites - self.publish(); - } catch(e) { - Console.error('Favorites.addThis', e); - } finally { - return false; - } - - }; - - - /** - * Removes a room from the favorites - * @public - * @param {string} room_xid - * @param {string} room_name - * @return {boolean} - */ - self.removeThis = function(room_xid, room_name) { - - try { - // Button path - var button_sel = $('#favorites .fsearch-results div[data-xid="' + escape(room_xid) + '"] a.one-button'); - - // Add a remove button instead of the add one - button_sel.filter('.remove').replaceWith('' + Common._e("Add") + ''); - - // Click event - button_sel.filter('.add').click(function() { - return self.addThis(room_xid, room_name); - }); - - // Show the add button in the (opened?) groupchat - $('#' + hex_md5(room_xid) + ' .tools-add').show(); - - // Remove the favorite - self.remove(room_xid, true); - - // Publish the favorites - self.publish(); - } catch(e) { - Console.error('Favorites.removeThis', e); - } finally { - return false; - } - - }; - - - /** - * Edits a favorite - * @public - * @return {undefined} - */ - self.edit = function() { - - try { - // Path to favorites - var favorites_sel = $('#favorites'); - - // Reset the favorites - self.reset(); - - // Show the edit/remove button, hide the others - favorites_sel.find('.fedit-terminate').hide(); - favorites_sel.find('.fedit-edit').show(); - favorites_sel.find('.fedit-remove').show(); - - // We retrieve the values - var xid = favorites_sel.find('.fedit-head-select').val(); - var data_sel = $(Common.XMLFromString( - DataStore.getDB(Connection.desktop_hash, 'favorites', xid) - )); - - // If this is not the default room - if(xid != 'none') { - // We apply the values - favorites_sel.find('.fedit-title').val(data_sel.find('name').text()); - favorites_sel.find('.fedit-nick').val(data_sel.find('nick').text()); - favorites_sel.find('.fedit-chan').val(Common.getXIDNick(xid)); - favorites_sel.find('.fedit-server').val(Common.getXIDHost(xid)); - favorites_sel.find('.fedit-password').val(data_sel.find('password').text()); - - if(data_sel.find('autojoin').text() == 'true') { - favorites_sel.find('.fedit-autojoin').attr('checked', true); - } - } - } catch(e) { - Console.error('Favorites.edit', e); - } - - }; - - - /** - * Terminate a favorite editing - * @public - * @param {string} type - * @return {boolean} - */ - self.terminateThis = function(type) { - - try { - // Path to favorites - var favorites_sel = $('#favorites'); - - // We get the values of the current edited groupchat - var old_xid = favorites_sel.find('.fedit-head-select').val(); - - var title = favorites_sel.find('.fedit-title').val(); - var nick = favorites_sel.find('.fedit-nick').val(); - var room = favorites_sel.find('.fedit-chan').val(); - var server = favorites_sel.find('.fedit-server').val(); - var xid = room + '@' + server; - var password = favorites_sel.find('.fedit-password').val(); - var autojoin = 'false'; - - if(favorites_sel.find('.fedit-autojoin').filter(':checked').size()) { - autojoin = 'true'; - } - - // We check the missing values and send this if okay - if((type == 'add') || (type == 'edit')) { - if(title && nick && room && server) { - // Remove the edited room - if(type == 'edit') { - self.remove(old_xid, true); - } - - // Display the favorites - self.display(xid, title, nick, autojoin, password); - - // Reset the inputs - self.reset(); - } else { - favorites_sel.find('input[required]').each(function() { - var select = $(this); - - if(!select.val()) { - $(document).oneTime(10, function() { - select.addClass('please-complete').focus(); - }); - } else { - select.removeClass('please-complete'); - } - }); - } - } else if(type == 'remove') { - self.remove(old_xid, true); - - // Reset the inputs - self.reset(); - } - - // Publish the new favorites - self.publish(); - - Console.info('Action on this bookmark: ' + room + '@' + server + ' / ' + type); - } catch(e) { - Console.error('Favorites.terminateThis', e); - } finally { - return false; - } - - }; - - - /** - * Removes a favorite - * @public - * @param {string} xid - * @param {boolean} database - * @return {undefined} - */ - self.remove = function(xid, database) { - - try { - // We remove the target favorite everywhere needed - $('.buddy-conf-groupchat-select option[value="' + xid + '"]').remove(); - $('.fedit-head-select option[value="' + xid + '"]').remove(); - - // Must remove it from database? - if(database) { - DataStore.removeDB(Connection.desktop_hash, 'favorites', xid); - } - } catch(e) { - Console.error('Favorites.remove', e); - } - - }; - - - /** - * Sends a favorite to the XMPP server - * @public - * @return {undefined} - */ - self.publish = function() { - - try { - var iq = new JSJaCIQ(); - iq.setType('set'); - - var query = iq.setQuery(NS_PRIVATE); - var storage = query.appendChild(iq.buildNode('storage', { - 'xmlns': NS_BOOKMARKS - })); - - // We generate the XML - var db_regex = new RegExp(('^' + Connection.desktop_hash + '_') + 'favorites_(.+)'); - - for(var i = 0; i < DataStore.storageDB.length; i++) { - // Get the pointer values - var current = DataStore.storageDB.key(i); - - // If the pointer is on a stored favorite - if(current.match(db_regex)) { - var data_sel = $(Common.XMLFromString( - DataStore.storageDB.getItem(current) - )); - - var xid = data_sel.find('xid').text(); - var rName = data_sel.find('name').text(); - var nick = data_sel.find('nick').text(); - var password = data_sel.find('password').text(); - var autojoin = data_sel.find('autojoin').text(); - - // We create the node for this groupchat - var item = storage.appendChild( - iq.buildNode('conference', { - 'name': rName, - 'jid': xid, - 'autojoin': autojoin, - xmlns: NS_BOOKMARKS - }) - ); - - item.appendChild(iq.buildNode('nick', { - xmlns: NS_BOOKMARKS - }, nick)); - - if(password) { - item.appendChild(iq.buildNode('password', { - xmlns: NS_BOOKMARKS - }, password)); - } - - Console.info('Bookmark sent: ' + xid); - } - } - - con.send(iq); - } catch(e) { - Console.error('Favorites.publish', e); - } - - }; - - - /** - * Gets a list of the MUC items on a given server - * @public - * @return {undefined} - */ - self.getGCList = function() { - - try { - var path_sel = $('#favorites'); - var groupchat_server = $('.fsearch-head-server').val(); - - // We reset some things - path_sel.find('.fsearch-oneresult').remove(); - path_sel.find('.fsearch-noresults').hide(); - path_sel.find('.wait').show(); - - var iq = new JSJaCIQ(); - iq.setType('get'); - iq.setTo(groupchat_server); - - iq.setQuery(NS_DISCO_ITEMS); - - con.send(iq, self.handleGCList); - } catch(e) { - Console.error('Favorites.getGCList', e); - } - - }; - - - /** - * Handles the MUC items list - * @public - * @param {object} iq - * @return {undefined} - */ - self.handleGCList = function(iq) { - - try { - var path_sel = $('#favorites'); - var from = Common.fullXID(Common.getStanzaFrom(iq)); - - if(!iq || (iq.getType() != 'result')) { - Board.openThisError(3); - - path_sel.find('.wait').hide(); - - Console.error('Error while retrieving the rooms: ' + from); - } - - else { - var handleXML = iq.getQuery(); - - if($(handleXML).find('item').size()) { - // Initialize the HTML code - var html = ''; - - $(handleXML).find('item').each(function() { - var this_sel = $(this); - - var room_xid = this_sel.attr('jid'); - var room_name = this_sel.attr('name'); - - if(room_xid && room_name) { - // Escaped values - var escaped_xid = Utils.encodeOnclick(room_xid); - var escaped_name = Utils.encodeOnclick(room_name); - - // Initialize the room HTML - html += '
' + - '
' + room_name.htmlEnc() + '
' + - '' + Common._e("Join") + ''; - - // This room is yet a favorite - if(DataStore.existDB(Connection.desktop_hash, 'favorites', room_xid)) { - html += '' + - Common._e("Remove") + - ''; - } else { - html += '' + - Common._e("Add") + - ''; - } - - // Close the room HTML - html += '
'; - } - }); - - // Append this code to the popup - path_sel.find('.fsearch-results').append(html); - } else { - path_sel.find('.fsearch-noresults').show(); - } - - Console.info('Rooms retrieved: ' + from); - } - - path_sel.find('.wait').hide(); - } catch(e) { - Console.error('Favorites.handleGCList', e); - } - - }; - - - /** - * Joins a groupchat from favorites - * @public - * @param {string} room - * @return {boolean} - */ - self.join = function(room) { - - try { - self.quit(); - - Chat.checkCreate( - room, - 'groupchat', - '', - '', - Common.getXIDNick(room) - ); - } catch(e) { - Console.error('Favorites.join', e); - } finally { - return false; - } - - }; - - - /** - * Displays a given favorite - * @public - * @param {string} xid - * @param {string} name - * @param {string} nick - * @param {boolean} autojoin - * @param {string} password - * @return {undefined} - */ - self.display = function(xid, name, nick, autojoin, password) { - - try { - // Generate the HTML code - var html = ''; - - // Remove the existing favorite - self.remove(xid, false); - - // We complete the select forms - $('#roster .gc-join-first-option, #favorites .fedit-head-select-first-option').after(html); - - // We store the informations - var value = '' + - '' + xid.htmlEnc() + '' + - '' + name.htmlEnc() + '' + - '' + nick.htmlEnc() + '' + - '' + autojoin.htmlEnc() + '' + - '' + password.htmlEnc() + '' + - ''; - - DataStore.setDB(Connection.desktop_hash, 'favorites', xid, value); - } catch(e) { - Console.error('Favorites.display', e); - } - - }; - - - /** - * Loads the favorites for the popup - * @public - * @return {undefined} - */ - self.load = function() { - - try { - // Initialize the HTML code - var html = ''; - - // Read the database - var db_regex = new RegExp(('^' + Connection.desktop_hash + '_') + 'favorites_(.+)'); - - for(var i = 0; i < DataStore.storageDB.length; i++) { - // Get the pointer values - var current = DataStore.storageDB.key(i); - - // If the pointer is on a stored favorite - if(current.match(db_regex)) { - var data = Common.XMLFromString(DataStore.storageDB.getItem(current)); - - // Add the current favorite to the HTML code - html += ''; - } - } - - // Generate specific HTML code - var favorites_bubble = '' + html; - - var favorites_popup = '' + html; - - // Append the HTML code - $('#roster .buddy-conf-groupchat-select').html(favorites_bubble); - $('#favorites .fedit-head-select').html(favorites_popup); - } catch(e) { - Console.error('Favorites.load', e); - } - - }; - - - /** - * Plugin launcher - * @public - * @return {undefined} - */ - self.instance = function() { - - try { - var favorites_sel = $('#favorites'); - - // Keyboard events - favorites_sel.find('.fsearch-head-server').keyup(function(e) { - if(e.keyCode == 13) { - var this_sel = $(this); - - // No value? - if(!this_sel.val()) { - this_sel.val(HOST_MUC); - } - - // Get the list - self.getGCList(); - } - }); - - favorites_sel.find('.fedit-line input').keyup(function(e) { - if(e.keyCode == 13) { - // Edit a favorite - if(favorites_sel.find('.fedit-edit').is(':visible')) { - self.terminateThis('edit'); - } else { - self.terminateThis('add'); - } - } - }); - - // Change events - $('.fedit-head-select').change(self.edit); - - // Click events - favorites_sel.find('.room-switcher').click(function() { - favorites_sel.find('.favorites-content').hide(); - self.reset(); - }); - - favorites_sel.find('.room-list').click(function() { - favorites_sel.find('.favorites-edit').show(); - }); - - favorites_sel.find('.room-search').click(function() { - favorites_sel.find('.favorites-search').show(); - self.getGCList(); - }); - - favorites_sel.find('.fedit-add').click(function() { - return self.terminateThis('add'); - }); - - favorites_sel.find('.fedit-edit').click(function() { - return self.terminateThis('edit'); - }); - - favorites_sel.find('.fedit-remove').click(function() { - return self.terminateThis('remove'); - }); - - favorites_sel.find('.bottom .finish').click(function() { - return self.quit(); - }); - } catch(e) { - Console.error('Favorites.instance', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/features.js b/source/app/javascripts/features.js deleted file mode 100644 index 2e7ba1e..0000000 --- a/source/app/javascripts/features.js +++ /dev/null @@ -1,457 +0,0 @@ -/* - -Jappix - An open social platform -This is the server features JS script for Jappix - -------------------------------------------------- - -License: AGPL -Author: Valérian Saliou, Maranda - -*/ - -// Bundle -var Features = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Constants */ - self.SERVER_NAMES = [ - 'metronome', - 'prosody', - 'ejabberd', - 'jabberd', - 'openfire', - 'tigase', - 'isode' - ]; - - - /* Variables */ - self.server_name = null; - - - /** - * Gets the features of a server - * @public - * @return {undefined} - */ - self.get = function() { - - /* REF: http://xmpp.org/extensions/xep-0030.html */ - - try { - // Get the main values - var to = Utils.getServer(); - var caps = con.server_caps; - var xml = null; - - // Try to get the stored data - if(caps) { - xml = Common.XMLFromString( - DataStore.getPersistent('global', 'caps', caps) - ); - } - - // Any stored data? - if(xml) { - self.handle(xml); - - Console.log('Read server CAPS from cache.'); - } else { - // Not stored (or no CAPS)! - var iq = new JSJaCIQ(); - - iq.setTo(to); - iq.setType('get'); - iq.setQuery(NS_DISCO_INFO); - - con.send(iq, Caps.handleDiscoInfos); - - Console.log('Read server CAPS from network.'); - } - } catch(e) { - Console.error('Features.get', e); - } - - }; - - - /** - * Handles the features of a server - * @public - * @param {string} xml - * @return {boolean} - */ - self.handle = function(xml) { - - try { - // Selector - var selector = $(xml); - - // Functions - var check_feature_fn = function(namespace) { - // This weird selector fixes an IE8 bug... - return (selector.find('feature').filter(function() { - return ($(this).attr('var') == namespace); - }).size() > 0 ? true : false); - }; - - // Markers - var namespaces = [NS_PUBSUB, NS_PUBSUB_CN, NS_URN_MAM, NS_COMMANDS, NS_URN_CARBONS, NS_URN_CORRECT]; - - var identity = selector.find('identity'); - - var cur_feature; - var features = { - // This weird selector fixes the same IE8 bug as above... - 'pep': (identity.filter(function() { - var this_sel = $(this); - return (this_sel.attr('category') == 'pubsub' && this_sel.attr('type') == 'pep'); - }).size() && true) - }; - - $.each(namespaces, function(n, namespace) { - features[namespace] = check_feature_fn(namespace); - - if(features[namespace] === true) { - self.enable(namespace); - } - }); - - // Retrieve server identity - self.server_name = self._normalizeServerName( - identity.filter('[category="server"]').attr('name') - ); - - // Enable the pep elements if available - if(features.pep === true) { - // Update our database - self.enable('pep'); - - // Get the PEP nodes to initiate - Microblog.getInit(); - PEP.getInitGeoloc(); - - // Get the notifications - Notification.get(); - - // Geolocate the user - PEP.geolocate(); - - // Enable microblogging send tools - Microblog.wait('sync'); - $('.postit.attach').css('display', 'block'); - - Console.info('XMPP server supports PEP.'); - } else { - Microblog.wait('unsync'); - - Console.warn('XMPP server does not support PEP.'); - } - - // Hide the private life fieldset if nothing to show - if(features.pep === false && features[NS_URN_MAM] === false) { - $('#options fieldset.privacy').hide(); - } - - // Apply the features - self.apply('talk'); - - // Process the roster height - if(features.pep === true) { - Roster.adapt(); - } - - // Enable Message Carbons? - if(features[NS_URN_CARBONS] === true) { - Carbons.enable(); - } - } catch(e) { - Console.error('Features.handle', e); - } finally { - return false; - } - - }; - - - /** - * The function to apply the features to an element - * @public - * @param {string} id - * @return {undefined} - */ - self.apply = function(id) { - - try { - // Path to the elements - var path = '#' + id + ' .'; - - // PEP features - if(self.enabledPEP()) { - $(path + 'pep-hidable').show(); - } - - // PubSub features - if(self.enabledPubSub()) { - $(path + 'pubsub-hidable').show(); - } - - // PubSub Config-Node features - if(self.enabledPubSubCN()) { - $(path + 'pubsub-hidable-cn').show(); - } - - // MAM features - if(self.enabledMAM()) { - $(path + 'mam-hidable').show(); - $(path + 'mam-showable').hide(); - } - - // MAM Purge - if(self.enabledMAMPurge()) { - $(path + 'mam-purge-hidable').show(); - } - - // Message correction features - if(self.enabledCorrection()) { - $(path + 'correction-hidable').show(); - } - - // Commands features - if(self.enabledCommands()) { - $(path + 'commands-hidable').show(); - } - - // XMPP links (browser feature) - if(navigator.registerProtocolHandler) { - $(path + 'xmpplinks-hidable').show(); - } - } catch(e) { - Console.error('Features.apply', e); - } - - }; - - - /** - * Enables a feature - * @public - * @param {string} feature - * @return {undefined} - */ - self.enable = function(feature) { - - try { - DataStore.setDB(Connection.desktop_hash, 'feature', feature, 'true'); - } catch(e) { - Console.error('Features.enable', e); - } - - }; - - - /** - * Checks if a feature is enabled - * @public - * @param {string} feature - * @return {boolean} - */ - self.isEnabled = function(feature) { - - try { - return DataStore.getDB(Connection.desktop_hash, 'feature', feature) === 'true'; - } catch(e) { - Console.error('Features.isEnabled', e); - } - - }; - - - /** - * Returns the XMPP server PEP support - * @public - * @return {boolean} - */ - self.enabledPEP = function() { - - try { - return self.isEnabled('pep'); - } catch(e) { - Console.error('Features.enabledPEP', e); - } - - }; - - - /** - * Returns the XMPP server PubSub support - * @public - * @return {boolean} - */ - self.enabledPubSub = function() { - - try { - return self.isEnabled(NS_PUBSUB); - } catch(e) { - Console.error('Features.enabledPubSub', e); - } - - }; - - - /** - * Returns the XMPP server PubSub Config-Node support - * @public - * @return {boolean} - */ - self.enabledPubSubCN = function() { - - try { - return self.isEnabled(NS_PUBSUB_CN); - } catch(e) { - Console.error('Features.enabledPubSubCN', e); - } - - }; - - - /** - * Returns the XMPP server MAM support - * @public - * @return {boolean} - */ - self.enabledMAM = function() { - - try { - return self.isEnabled(NS_URN_MAM); - } catch(e) { - Console.error('Features.enabledMAM', e); - } - - }; - - - /** - * Returns Metronome MAM Purge support - * @public - * @return {boolean} - */ - self.enabledMAMPurge = function() { - - try { - if(self.isEnabled(NS_URN_MAM)) { - return self.isEnabled(NS_METRONOME_MAM_PURGE); - } else { - return false; - } - } catch(e) { - Console.error('Features.enabledMAMPurge', e); - } - - }; - - - /** - * Returns the XMPP server Carbons support - * @public - * @return {boolean} - */ - self.enabledCarbons = function() { - - try { - return self.isEnabled(NS_URN_CARBONS); - } catch(e) { - Console.error('Features.enabledCarbons', e); - } - - }; - - - /** - * Returns the XMPP server commands support - * @public - * @return {boolean} - */ - self.enabledCommands = function() { - - try { - return self.isEnabled(NS_COMMANDS); - } catch(e) { - Console.error('Features.enabledCommands', e); - } - - }; - - - /** - * Returns the XMPP server correction support - * @public - * @return {boolean} - */ - self.enabledCorrection = function() { - - try { - return self.isEnabled(NS_URN_CORRECT); - } catch(e) { - Console.error('Features.enabledCorrection', e); - } - - }; - - - /** - * Normalizes the XMPP server name - * @private - * @return {string} - */ - self._normalizeServerName = function(name) { - - try { - var cur_r; - - for(var i in self.SERVER_NAMES) { - cur_r = new RegExp(self.SERVER_NAMES[i], 'gi'); - - if(cur_r.exec(name) !== null) { - name = self.SERVER_NAMES[i]; - break; - } - } - } catch(e) { - Console.error('Features._normalizeServerName', e); - } finally { - return name; - } - - }; - - - /** - * Returns the XMPP server name - * @public - * @return {string} - */ - self.getServerName = function() { - - try { - return self.server_name; - } catch(e) { - Console.error('Features.getServerName', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/filter.js b/source/app/javascripts/filter.js deleted file mode 100644 index bda2f2e..0000000 --- a/source/app/javascripts/filter.js +++ /dev/null @@ -1,491 +0,0 @@ -/* - -Jappix - An open social platform -These are the filtering JS script for Jappix - -------------------------------------------------- - -License: AGPL -Authors: Valérian Saliou, Maranda - -*/ - -// Bundle -var Filter = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Constants */ - self.message_regex = { - 'commands': { - 'me': /((^)|((.+)(>)))(\/me )([^<]+)/ - }, - - 'emotes': { - 'angry': [ - /(:-?@)($|\s|<)/gi, - '$2' - ], - - 'bat': [ - /(:-?\[)($|\s|<)/gi, - '$2' - ], - - 'beer': [ - /(\(B\))($|\s|<)/g, - '$2' - ], - - 'biggrin': [ - /((:-?D)|(XD))($|\s|<)/gi, - '$4' - ], - - 'blush': [ - /(:-?\$)($|\s|<)/gi, - '$2' - ], - - 'boy': [ - /(\(Z\))($|\s|<)/g, - '$2' - ], - - 'brflower': [ - /(\(W\))($|\s|<)/g, - '$2' - ], - - 'brheart': [ - /((<\/3)|(\(U\)))($|\s|<)/g, - '$4' - ], - - 'coffee': [ - /(\(C\))($|\s|<)/g, - '$2' - ], - - 'coolglasses': [ - /((8-\))|(\(H\)))($|\s|<)/g, - '$4' - ], - - 'cry': [ - /(:'-?\()($|\s|<)/gi, - '$2' - ], - - 'cuffs': [ - /(\(%\))($|\s|<)/g, - '$2' - ], - - 'devil': [ - /(\]:-?>)($|\s|<)/gi, - '$2' - ], - - 'drink': [ - /(\(D\))($|\s|<)/g, - '$2' - ], - - 'flower': [ - /(@}->--)($|\s|<)/gi, - '$2' - ], - - 'frowning': [ - /((:-?\/)|(:-?S))($|\s|<)/gi, - '$4' - ], - - 'girl': [ - /(\(X\))($|\s|<)/g, - '$2' - ], - - 'heart': [ - /((<3)|(\(L\)))($|\s|<)/g, - '$4' - ], - - 'hugleft': [ - /(\(}\))($|\s|<)/g, - '$2' - ], - - 'hugright': [ - /(\({\))($|\s|<)/g, - '$2' - ], - - 'kis': [ - /(:-?{})($|\s|<)/gi, - '$2' - ], - - 'lamp': [ - /(\(I\))($|\s|<)/g, - '$2' - ], - - 'lion': [ - /(:-?3)($|\s|<)/gi, - '$2' - ], - - 'mail': [ - /(\(E\))($|\s|<)/g, - '$2' - ], - - 'moon': [ - /(\(S\))($|\s|<)/g, - '$2' - ], - - 'music': [ - /(\(8\))($|\s|<)/g, - '$2' - ], - - 'oh': [ - /((=-?O)|(:-?O))($|\s|<)/gi, - '$4' - ], - - 'phone': [ - /(\(T\))($|\s|<)/g, - '$2' - ], - - 'photo': [ - /(\(P\))($|\s|<)/g, - '$2' - ], - - 'puke': [ - /(:-?!)($|\s|<)/gi, - '$2' - ], - - 'pussy': [ - /(\(@\))($|\s|<)/g, - '$2' - ], - - 'rainbow': [ - /(\(R\))($|\s|<)/g, - '$2' - ], - - 'smile': [ - /(:-?\))($|\s|<)/gi, - '$2' - ], - - 'star': [ - /(\(\*\))($|\s|<)/g, - '$2' - ], - - 'stare': [ - /(:-?\|)($|\s|<)/gi, - '$2' - ], - - 'thumbdown': [ - /(\(N\))($|\s|<)/g, - '$2' - ], - - 'thumbup': [ - /(\(Y\))($|\s|<)/g, - '$2' - ], - - 'tongue': [ - /(:-?P)($|\s|<)/gi, - '$2' - ], - - 'unhappy': [ - /(:-?\()($|\s|<)/gi, - '$2' - ], - - 'wink': [ - /(;-?\))($|\s|<)/gi, - '$2' - ] - - }, - - 'formatting': { - 'bold': [ - /(^|\s|>|\()((\*)([^<>'"\*]+)(\*))($|\s|<|\))/gi, - '$1$2$6' - ], - - 'italic': [ - /(^|\s|>|\()((\/)([^<>'"\/]+)(\/))($|\s|<|\))/gi, - '$1$2$6' - ], - - 'underline': [ - /(^|\s|>|\()((_)([^<>'"_]+)(_))($|\s|<|\))/gi, - '$1$2$6' - ] - } - - }; - - self.xhtml_allow = { - 'elements': [ - 'a', - 'abbr', - 'acronym', - 'address', - 'blockquote', - 'body', - 'br', - 'cite', - 'code', - 'dd', - 'dfn', - 'div', - 'dt', - 'em', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'head', - 'html', - 'kbd', - 'li', - 'ol', - 'p', - 'pre', - 'q', - 'samp', - 'span', - 'strong', - 'title', - 'ul', - 'var' - ], - - 'attributes': [ - 'accesskey', - 'alt', - 'charset', - 'cite', - 'class', - 'height', - 'href', - 'hreflang', - 'id', - 'longdesc', - 'profile', - 'rel', - 'rev', - 'src', - 'style', - 'tabindex', - 'title', - 'type', - 'uri', - 'version', - 'width', - 'xml:lang', - 'xmlns' - ] - }; - - - /** - * Generates a given emoticon HTML code - * @public - * @param {string} image - * @param {string} text - * @param {string} after - * @return {string} - */ - self.emoteImage = function(image, text, after) { - - try { - return ' ' + Common.encodeQuotes(text) + ' ' + after; - } catch(e) { - Console.error('Filter.emoteImage', e); - } - - }; - - - /** - * Filters a given message - * @public - * @param {string} message - * @param {string} nick - * @param {string} html_escape - * @return {string} - */ - self.message = function(message, nick, html_escape) { - - try { - var filtered = message; - - // We encode the HTML special chars - if(html_escape) { - filtered = filtered.htmlEnc(); - } - - // Security: don't filter huge messages (avoids crash attacks) - if(filtered.length < 10000) { - // /me command - filtered = filtered.replace(self.message_regex.commands.me, nick + ' $7'); - - // We replace the smilies text into images - var cur_emote; - - for(var cur_emote_name in self.message_regex.emotes) { - cur_emote = self.message_regex.emotes[cur_emote_name]; - - filtered = filtered.replace( - cur_emote[0], - self.emoteImage( - cur_emote_name, - '$1', - cur_emote[1] - ) - ); - } - - // Text formatting - var cur_formatting; - - for(var cur_formatting_name in self.message_regex.formatting) { - cur_formatting = self.message_regex.formatting[cur_formatting_name]; - - filtered = filtered.replace( - cur_formatting[0], - cur_formatting[1] - ); - } - - // Add the links - if(html_escape) { - filtered = Links.apply(filtered, 'desktop'); - } - - // Filter integratebox links - filtered = IntegrateBox.filter(filtered); - } - - return filtered; - } catch(e) { - Console.error('Filter.message', e); - } - - }; - - - /** - * Returns whether XHTML body exists or not - * @public - * @param {DOM} xhtml_sel - * @return {boolean} - */ - self.has_xhtml_body = function(xhtml_sel) { - - var has_xhtml_body = false; - - try { - xhtml_sel.find('*').each(function() { - if($(this).text()) { - has_xhtml_body = true; - return false; - } - }); - } catch(e) { - Console.error('Filter.has_xhtml_body', e); - } finally { - return has_xhtml_body; - } - - }; - - - /** - * Filters a xHTML message to be displayed in Jappix - * @public - * @param {string} code - * @return {string} - */ - self.xhtml = function(code) { - - try { - var code_sel = $(code); - - // Check if Filter for XHTML-IM images is enabled - if(DataStore.getDB(Connection.desktop_hash, 'options', 'no-xhtml-images') != '1') { - self.xhtml_allow.elements.push("img"); - } - - // Remove forbidden elements - code_sel.find('html body *').each(function() { - // This element is not authorized - if(!Utils.existArrayValue(self.xhtml_allow.elements, (this).nodeName.toLowerCase())) { - $(this).remove(); - } - }); - - // Remove forbidden attributes - code_sel.find('html body *').each(function() { - // Put a pointer on this element (jQuery way & normal way) - var cSelector = $(this); - var cElement = (this); - - // Loop the attributes of the current element - $(cElement.attributes).each(function(index) { - // Read the current attribute - var cAttr = cElement.attributes[index]; - var cName = cAttr.name; - var cVal = cAttr.value; - - // This attribute is not authorized, or contains JS code - if(!Utils.existArrayValue(self.xhtml_allow.attributes, cName.toLowerCase()) || - ((cVal.toLowerCase()).match(/(^|"|')javascript:/))) { - cSelector.removeAttr(cName); - } - }); - }); - - // Filter some other elements - code_sel.find('a').attr('target', '_blank'); - - return code_sel.find('html body').html(); - } catch(e) { - Console.error('Filter.xhtml', e); - } - - }; - - - /** - * Return class scope - */ - return self; - -})(); \ No newline at end of file diff --git a/source/app/javascripts/groupchat.js b/source/app/javascripts/groupchat.js deleted file mode 100644 index 21ed7da..0000000 --- a/source/app/javascripts/groupchat.js +++ /dev/null @@ -1,865 +0,0 @@ -/* - -Jappix - An open social platform -These are the groupchat JS scripts for Jappix - -------------------------------------------------- - -License: AGPL -Authors: Valérian Saliou, Maranda, Eric - -*/ - -// Bundle -var Groupchat = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /* Variables */ - self.join_suggest = []; - - - /** - * Apply generate events - * @private - * @param {object} input_sel - * @param {string} hash - * @param {string} room - * @return {undefined} - */ - self._createEvents = function(input_sel, hash, room) { - - try { - self._createEventsInput(input_sel, hash); - self._createEventsKey(input_sel, hash, room); - } catch(e) { - Console.error('Groupchat._createEvents', e); - } - - }; - - - /** - * Apply generate events (input) - * @private - * @param {object} input_sel - * @param {string} hash - * @return {undefined} - */ - self._createEventsInput = function(input_sel, hash) { - - try { - // Focus event - input_sel.focus(function() { - // Clean notifications for this chat - Interface.chanCleanNotify(hash); - - // Store focus on this chat! - Interface.chat_focus_hash = hash; - }); - - // Blur event - input_sel.blur(function() { - // Reset storage about focus on this chat! - if(Interface.chat_focus_hash == hash) { - Interface.chat_focus_hash = null; - } - - // Reset autocompletion - Autocompletion.reset(hash); - }); - } catch(e) { - Console.error('Groupchat._createEventsInput', e); - } - - }; - - - /** - * Apply generate events (key) - * @private - * @param {object} input_sel - * @param {string} hash - * @param {string} room - * @return {undefined} - */ - self._createEventsKey = function(input_sel, hash, room) { - - try { - // Lock to the input - input_sel.keydown(function(e) { - // Enter key - if(e.keyCode == 13) { - // If shift key (without any others modifiers) was pressed, add a new line - if(e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { - input_sel.val(input_sel.val() + '\n'); - } else { - if(Correction.isIn(room) === true) { - var corrected_value = input_sel.val().trim(); - - if(corrected_value) { - // Send the corrected message - Correction.send(room, 'groupchat', corrected_value); - } - - Correction.leave(room); - } else { - // Send the message - Message.send(hash, 'groupchat'); - - // Reset the composing database entry - DataStore.setDB(Connection.desktop_hash, 'chatstate', room, 'off'); - } - } - - return false; - } - - // Remove chars (leave correction) - else if(e.keyCode == 8) { - // Leave correction mode? (another way, by flushing input value progressively) - if(Correction.isIn(room) === true && !input_sel.val()) { - Correction.leave(room); - } - } - - // Tabulation key (without any modifiers) - else if(!e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey && e.keyCode == 9) { - Autocompletion.create(hash); - - return false; - } - - // Reset the autocompleter - else { - Autocompletion.reset(hash); - } - }); - - input_sel.keyup(function(e) { - if(e.keyCode == 27) { - // Escape key - input_sel.val(''); - - // Leave correction mode? (simple escape way) - if(Correction.isIn(room) === true) { - Correction.leave(room); - } - } else { - Correction.detect(room, input_sel); - } - }); - } catch(e) { - Console.error('Groupchat._createEventsKey', e); - } - - }; - - - /** - * Apply suggest check events - * @private - * @return {undefined} - */ - self._suggestCheckEvents = function() { - - try { - // Click events - $('#suggest .content a.one').click(function() { - var this_sel = $(this); - - // Add/remove the active class - this_sel.toggleClass('active'); - - // We require at least one room to be chosen - if(Common.exists('#suggest .content a.one.active')) { - $('#suggest a.next').removeClass('disabled'); - } else { - $('#suggest a.next').addClass('disabled'); - } - - return false; - }); - - $('#suggest a.next').click(function() { - var this_sel = $(this); - - // Disabled? - if(this_sel.hasClass('disabled')) { - return false; - } - - // Store groupchats to join? - if(this_sel.is('.continue')) { - $('#suggest .content a.one.active').each(function() { - self.join_suggest.push( - $(this).attr('data-xid') - ); - }); - } - - // Switch to talk UI - $('#suggest').remove(); - Connection.triggerConnected(); - - return false; - }); - } catch(e) { - Console.error('Groupchat._suggestCheckEvents', e); - } - - }; - - - /** - * Displays the MUC admin elements - * @public - * @param {string} affiliation - * @param {string} id - * @param {string} xid - * @param {number} statuscode - * @return {undefined} - */ - self.openAdmin = function(affiliation, id, xid, statuscode) { - - try { - // We must be in the "login" mode - if(Utils.isAnonymous()) { - return; - } - - // We check if the user is a room owner or administrator to give him privileges - if(affiliation == 'owner' || affiliation == 'admin') { - $('#' + id + ' .tools-mucadmin').show(); - } - - // We check if the room hasn't been yet created - if(statuscode == 201) { - Board.openThisInfo(4); - } - - // We add the click event - $('#' + id + ' .tools-mucadmin').click(function() { - MUCAdmin.open(xid, affiliation); - }); - } catch(e) { - Console.error('Groupchat.openAdmin', e); - } - - }; - - - /** - * Initializes a connection with a MUC groupchat - * @public - * @param {string} room - * @param {string} nickname - * @param {string} password - * @return {boolean} - */ - self.getMUC = function(room, nickname, password) { - - try { - // Room hash - var hash = hex_md5(room); - - // Reset the elements - $('#' + hash + ' .muc-ask').remove(); - $('#' + hash + ' .compose').show(); - - // No nickname? - if(!nickname) { - // Get some values - if(!Utils.isAnonymous()) { - nickname = Name.getNick(); - } else { - nickname = ANONYMOUS_NICK; - } - - // If the nickname could not be retrieved, ask it - if(!nickname) { - self.generateMUCAsk('nickname', room, hash, nickname, password); - } - } - - // Got our nickname? - if(nickname) { - // Get our general presence - var show = DataStore.getDB(Connection.desktop_hash, 'presence-show', 1); - var status = DataStore.getDB(Connection.desktop_hash, 'options', 'presence-status'); - - // Set my nick - $('#' + hash).attr('data-nick', escape(nickname)); - - // Send the appropriate presence - Presence.send(room + '/' + nickname, '', show, status, '', true, password, self.handleMUC); - } - } catch(e) { - Console.error('Groupchat.getMUC', e); - } finally { - return false; - } - - }; - - - /** - * Handles the MUC main elements - * @public - * @param {object} presence - * @return {undefined} - */ - self.handleMUC = function(presence) { - - try { - // We get the xml content - var xml = presence.getNode(); - var from = Common.fullXID(Common.getStanzaFrom(presence)); - var room = Common.bareXID(from); - var nickname = Common.thisResource(from); - var hash = hex_md5(room); - var id = presence.getID(); - - // No ID: must fix M-Link bug - if(id === null) { - id = 1; - presence.setID(id); - } - - Console.info('First MUC presence: ' + from); - - // Catch the errors - if(!Errors.handle(xml)) { - // Define some stuffs - var muc_user = $(xml).find('x[xmlns="' + NS_MUC_USER + '"]'); - var affiliation = muc_user.find('item').attr('affiliation'); - var statuscode = parseInt(muc_user.find('status').attr('code')); - - // Handle my presence - Presence.handle(presence); - - // Configure the new room - if(affiliation == 'owner' || affiliation == 'admin') { - self._initialConfiguration(id, room); - } - - // Check if I am a room owner - self.openAdmin(affiliation, hash, room, statuscode); - - // Tell the MUC we can notify the incoming presences - $(document).oneTime('15s', function() { - $('#' + hash).attr('data-initial', 'true'); - }); - - // Enable the chatting input - $(document).oneTime(10, function() { - $('#' + hash + ' .message-area').removeAttr('disabled').focus(); - }); - } - - // A password is required - else if($(xml).find('error[type="auth"] not-authorized').size()) { - self.generateMUCAsk('password', room, hash, nickname); - } - - // There's a nickname conflict - else if($(xml).find('error[type="cancel"] conflict').size()) { - self.generateMUCAsk('nickname', room, hash); - } - } catch(e) { - Console.error('Groupchat.handleMUC', e); - } - - }; - - - /** - * Generates a correct MUC asker - * @public - * @param {string} type - * @param {string} room - * @param {string} hash - * @param {string} nickname - * @param {string} password - * @return {undefined} - */ - self.generateMUCAsk = function(type, room, hash, nickname, password) { - - try { - // Generate the path to the elements - var path_to = '#' + hash + ' .muc-ask'; - - // Define the label text - var label_text; - - switch(type) { - case 'nickname': - label_text = Common._e("Nickname"); - break; - - case 'password': - label_text = Common._e("Password"); - break; - } - - // Create the HTML markup - $('#' + hash + ' .compose').hide(); - - $('#' + hash).append( - '
' + - '' + - '' + - '
' - ); - - // When a key is pressed in the input - $(path_to + ' input').keyup(function(e) { - var value_input = $(this).val(); - - // Enter key pressed - if(e.keyCode == 13) { - // $.trim() fixes #304 - if(type == 'nickname' && $.trim(value_input)) { - nickname = $.trim(value_input); - return self.getMUC(room, nickname, password); - } - - if(type == 'password' && value_input) { - password = value_input; - return self.getMUC(room, nickname, password); - } - } - }); - - // Focus on the input - $(document).oneTime(10, function() { - $(path_to + ' input').focus(); - }); - } catch(e) { - Console.error('Groupchat.generateMUCAsk', e); - } - - }; - - - /** - * Creates a new groupchat - * @public - * @param {string} hash - * @param {string} room - * @param {string} chan - * @param {string} nickname - * @param {string} password - * @return {undefined} - */ - self.create = function(hash, room, chan, nickname, password) { - - /* REF: http://xmpp.org/extensions/xep-0045.html */ - - try { - Console.info('New groupchat: ' + room); - - // Create the chat content - Chat.generate('groupchat', hash, room, chan); - - // Create the chat switcher - Chat.generateSwitch('groupchat', hash, room, chan); - - // The icons-hover functions - Tooltip.icons(room, hash); - - // Click event on the add tool - $('#' + hash + ' .tools-add').click(function() { - // Hide the icon (to tell the user all is okay) - $(this).hide(); - - // Add the groupchat to the user favorites - Favorites.addThis(room, chan); - }); - - // Must show the add button? - if(!DataStore.existDB(Connection.desktop_hash, 'favorites', room)) { - $('#' + hash + ' .tools-add').show(); - } - - // The event handlers - var input_sel = $('#' + hash + ' .message-area'); - self._createEvents(input_sel, hash, room); - - // Chatstate events - ChatState.events(input_sel, room, hash, 'groupchat'); - - // Get the current muc informations and content - self.getMUC(room, nickname, password); - } catch(e) { - Console.error('Groupchat.create', e); - } - - }; - - - /** - * Generates a groupchat to join array - * @public - * @return {object} - */ - self.arrayJoin = function() { - - try { - // Values array - var muc_arr = [GROUPCHATS_JOIN]; - var new_arr = []; - - // Try to split it - if(GROUPCHATS_JOIN.indexOf(',') != -1) { - muc_arr = GROUPCHATS_JOIN.split(','); - } - - for(var i in muc_arr) { - // Get the current value - var muc_current = $.trim(muc_arr[i]); - - // No current value? - if(!muc_current) { - continue; - } - - // Filter the current value - muc_current = Common.generateXID(muc_current, 'groupchat'); - - // Add the current value - if(!Utils.existArrayValue(new_arr, muc_current)) { - new_arr.push(muc_current); - } - } - - return new_arr; - } catch(e) { - Console.error('Groupchat.arrayJoin', e); - } - - }; - - - /** - * Joins the defined groupchats - * @public - * @return {undefined} - */ - self.joinConf = function() { - - try { - // Nothing to join? - if(!self.join_suggest) { - return; - } - - // Join the chats - if(self.join_suggest.length) { - for(var g in self.join_suggest) { - Chat.checkCreate(self.join_suggest[g], 'groupchat'); - } - } - } catch(e) { - Console.error('Groupchat.joinConf', e); - } - - }; - - - /** - * Checks suggest utility - * @public - * @return {undefined} - */ - self.suggestCheck = function() { - - try { - var groupchat_arr = self.arrayJoin(); - - // Must suggest the user? - if((GROUPCHATS_SUGGEST == 'on') && groupchat_arr.length) { - if(Common.exists('#suggest')) { - return; - } - - // Create HTML code - var html = '
'; - html += '
' + Common._e("Suggested chatrooms") + '
'; - - html += ''; - - html += '
'; - html += ''; - html += ''; - html += '
'; - html += '
'; - - // Append HTML code - $('body').append(html); - - // Attach events - self._suggestCheckEvents(); - } else { - self.join_suggest = groupchat_arr; - - Connection.triggerConnected(); - } - } catch(e) { - Console.error('Groupchat.suggestCheck', e); - } - - }; - - - /** - * Bans a user from given room - * @public - * @param {string} room_xid - * @param {string} ban_xid - * @param {string} reason - * @return {object} - */ - self.banUser = function(room_xid, ban_xid, reason) { - - try { - // We check if the user exists - if(!ban_xid) { - Board.openThisInfo(6); - - Console.warn('Could not ban user with XID: ' + ban_xid + ' from room: ' + room_xid); - } else { - // We generate the ban IQ - var iq = new JSJaCIQ(); - iq.setTo(room_xid); - iq.setType('set'); - - var iqQuery = iq.setQuery(NS_MUC_ADMIN); - var item = iqQuery.appendChild(iq.buildNode('item', { - 'affiliation': 'outcast', - 'jid': ban_xid, - 'xmlns': NS_MUC_ADMIN - })); - - if(reason) { - item.appendChild(iq.buildNode('reason', { - 'xmlns': NS_MUC_ADMIN - }, reason)); - } - - con.send(iq, Errors.handleReply); - - Console.log('Banned user with XID: ' + ban_xid + ' from room: ' + room_xid); - } - } catch(e) { - Console.error('Groupchat.banUser', e); - } - - }; - - - /** - * Kicks a user from given room - * @public - * @param {string} room_xid - * @param {string} kick_xid - * @param {string} nick - * @param {string} reason - * @return {object} - */ - self.kickUser = function(room_xid, kick_xid, nick, reason) { - - try { - // We check if the user exists - if(!room_xid) { - Board.openThisInfo(6); - - Console.warning('Could not kick user "' + nick + '" from room: ' + room_xid); - } else { - // We generate the kick IQ - var iq = new JSJaCIQ(); - iq.setTo(room_xid); - iq.setType('set'); - - var iqQuery = iq.setQuery(NS_MUC_ADMIN); - var item = iqQuery.appendChild(iq.buildNode('item', { - 'nick': nick, - 'role': 'none', - 'xmlns': NS_MUC_ADMIN - })); - - if(reason) { - item.appendChild(iq.buildNode('reason', { - 'xmlns': NS_MUC_ADMIN - }, reason)); - } - - con.send(iq, Errors.handleReply); - - Console.info('Kicked user "' + nick + '" from room: ' + room_xid); - } - } catch(e) { - Console.error('Groupchat.kickUser', e); - } - - }; - - - /** - * Promotes an user as groupchat moderator - * @public - * @param {string} muc_xid - * @param {string} user_xid - * @return {object} - */ - self.promoteModerator = function(muc_xid, user_xid) { - - try { - MUCAdmin.setAffiliation(muc_xid, user_xid, 'admin'); - } catch(e) { - Console.error('Groupchat.promoteModerator', e); - } - - }; - - - /** - * Demotes an user as being groupchat moderator - * @public - * @param {string} muc_xid - * @param {string} user_xid - * @return {object} - */ - self.demoteModerator = function(muc_xid, user_xid) { - - try { - MUCAdmin.setAffiliation(muc_xid, user_xid, 'none'); - } catch(e) { - Console.error('Groupchat.demoteModerator', e); - } - - }; - - - /** - * Returns user affiliation in groupchat - * @public - * @param {string} muc_xid - * @param {string} nick - * @return {object} - */ - self.affiliationUser = function(muc_xid, nick) { - - try { - // Initial data - var affiliations = ['none', 'member', 'admin', 'owner']; - var affiliation = { - code: 0, - name: affiliations[0] - }; - - // Get user data - var user_sel = $('#' + hex_md5(muc_xid) + ' .list .user[data-nick="' + escape(nick) + '"]'); - - if(user_sel.size()) { - var user_affiliation = user_sel.attr('data-affiliation'); - - if(user_affiliation && Utils.existArrayValue(affiliations, user_affiliation)) { - affiliation.code = Utils.indexArrayValue(affiliations, user_affiliation); - affiliation.name = user_affiliation; - } - } - - return affiliation; - } catch(e) { - Console.error('Groupchat.affiliationUser', e); - } - - }; - - - /** - * Returns our affiliation in groupchat - * @public - * @param {string} muc_xid - * @return {object} - */ - self.affiliationMe = function(muc_xid) { - - try { - // Get my nick - var my_nick = unescape($('#' + hex_md5(muc_xid)).attr('data-nick') || ''); - - // Return my affiliation - return self.affiliationUser(muc_xid, my_nick); - } catch(e) { - Console.error('Groupchat.affiliationMe', e); - } - - }; - - /** - * Sends initial configuration of the room - * @private - * @param {string} pid - * @param {string} xid - * @return {undefined} - */ - self._initialConfiguration = function(pid, xid) { - - try { - var iq = new JSJaCIQ(); - - iq.setTo(xid); - iq.setType('set'); - iq.setID('first-muc-config-' + pid); - - var iqQuery = iq.setQuery(NS_MUC_OWNER); - - // Configure room with nil(null) fields - var iqX = iqQuery.appendChild(iq.buildNode('x', { - 'xmlns': NS_XDATA, - 'type': 'submit' - })); - - // Build a new field node - var iqField = iqX.appendChild(iq.buildNode('field', { - 'var': 'FORM_TYPE', - 'type': 'hidden', - 'xmlns': NS_XDATA - })); - - iqField.appendChild(iq.buildNode('value', { - 'xmlns': NS_XDATA - }, NS_MUC_CONFIG)); - - con.send(iq); - - Console.info('Groupchat._initialConfiguration', 'Sent initial room configuration: ' + xid); - } catch(e) { - Console.error('Groupchat._initialConfiguration', e); - } - }; - - - - /** - * Return class scope - */ - return self; - -})(); diff --git a/source/app/javascripts/home.js b/source/app/javascripts/home.js deleted file mode 100644 index 06f8672..0000000 --- a/source/app/javascripts/home.js +++ /dev/null @@ -1,526 +0,0 @@ -/* - -Jappix - An open social platform -These are the homepage JS scripts for Jappix - -------------------------------------------------- - -License: AGPL -Authors: Valérian Saliou, LinkMauve - -*/ - -// Bundle -var Home = (function () { - - /** - * Alias of this - * @private - */ - var self = {}; - - - /** - * Apply change events - * @private - * @param {object} current_sel - * @param {string} div - * @return {undefined} - */ - self._eventsChange = function(current_sel, div) { - - try { - // Create the attached events - switch(div) { - // Login tool - case 'loginer': - current_sel.find('a.to-anonymous').click(function() { - return self.change('anonymouser'); - }); - - current_sel.find('a.advanced').click(self.showAdvanced); - current_sel.find('form').submit(self.loginForm); - - break; - - // Anonymous login tool - case 'anonymouser': - current_sel.find('a.to-home').click(function() { - return self.change('loginer'); - }); - - current_sel.find('form').submit(Connection.doAnonymous); - - // Keyup event on anonymous join's room input - current_sel.find('input.room').keyup(function() { - var value = $(this).val(); - var report_sel = current_sel.find('.report'); - var span_sel = current_sel.find('span'); - - if(!value) { - report_sel.hide(); - span_sel.text(''); - } else { - report_sel.show(); - span_sel.text(JAPPIX_LOCATION + '?r=' + value); - } - }); - - break; - - // Register tool - case 'registerer': - // Server input change - $('#home input.server').keyup(function(e) { - if($.trim($(this).val()) == HOST_MAIN) { - $('#home .captcha_grp').show(); - $('#home input.captcha').removeAttr('disabled'); - } else { - $('#home .captcha_grp').hide(); - $('#home input.captcha').attr('disabled', true); - } - }); - - // Register input placeholder - // FIXME: breaks IE compatibility - //$('#home input[placeholder]').placeholder(); - - // Register form submit - current_sel.find('form').submit(self.registerForm); - - break; - } - } catch(e) { - Console.error('Home._eventsChange', e); - } - - }; - - - /** - * Create obsolete form - * @private - * @param {string} home - * @param {string} locale - * @return {undefined} - */ - self._obsolete = function(home, locale) { - - try { - // Add the code - $(locale).after( - '
' + - '

' + Common._e("Your browser is out of date!") + '

' + - - '' + - '' + - '' + - '' + - '' + - '
' - ); - - // Display it later - $(home + '.obsolete').oneTime('1s', function() { - $(this).slideDown(); - }); - - Console.warn('Jappix does not support this browser!'); - } catch(e) { - Console.error('Home._obsolete', e); - } - - }; - - - /** - * Allows the user to switch the difference home page elements - * @public - * @param {string} div - * @return {boolean} - */ - self.change = function(div) { - - try { - // Path to - var home = '#home .'; - var right = home + 'right '; - var current = right + '.homediv.' + div; - - // We switch the div - $(right + '.homediv, ' + right + '.top').hide(); - $(right + '.' + div).show(); - - // We reset the homedivs - $(home + 'homediv:not(.default), ' + home + 'top:not(.default)').remove(); - - // Get the HTML code to display - var disable_form = ''; - var lock_host = ''; - var code = ''; - - // Apply the previous link - switch(div) { - case 'loginer': - case 'anonymouser': - case 'registerer': - if(!Common.exists(right + '.top.sub')) { - // Append the HTML code for previous link - $(right + '.top.default').after('

«

'); - - // Click event on previous link - $(home + 'top.sub a.previous').click(function() { - return self.change('default'); - }); - } - - break; - } - - // Apply the form - switch(div) { - // Login tool - case 'loginer': - lock_host = Utils.disableInput(LOCK_HOST, 'on'); - code = '

' + Common.printf(Common._e("Login to your existing XMPP account. You can also use the %s to join a groupchat."), '' + Common._e("anonymous mode") + '') + '

' + - - '
' + - '
' + - '' + Common._e("Required") + '' + - - '' + - '@' + - '' + - '' + - '' + - '' + - '
' + - - '' + Common._e("Advanced") + '' + - - '
' + - '' + Common._e("Advanced") + '' + - - '' + - '' + - '' + - '' + - '
' + - - '
' + - '' + - - '
' + - '
' + - '
'; - - break; - - // Anonymous login tool - case 'anonymouser': - disable_form = Utils.disableInput(ANONYMOUS, 'off'); - code = '

' + Common.printf(Common._e("Enter the groupchat you want to join and the nick you want to have. You can also go back to the %s."), '' + Common._e("login page") + '') + '

'; - - if(LEGAL) { - code += '

' + Common.printf(Common._e("By using our service, you accept %s."), '' + Common._e("our terms of use") + '') + '

'; - } - - code += '
' + - '
' + - '' + Common._e("Required") + '' + - - '' + - '' + - - '' + - '' + - '
' + - - '' + - '
' + - - '
' + - Common._e("Share this link with your friends:") + ' ' + - '
'; - - break; - - // Register tool - case 'registerer': - disable_form = Utils.disableInput(REGISTRATION, 'off'); - - if(!disable_form) { - lock_host = Utils.disableInput(LOCK_HOST, 'on'); - } - - code = '

' + Common._e("Register a new XMPP account to join your friends on your own social cloud. That's simple!") + '

'; - - if(LEGAL) { - code += '

' + Common.printf(Common._e("By using our service, you accept %s."), '' + Common._e("our terms of use") + '') + '

'; - } - - code += '
' + - '
' + - '' + Common._e("Required") + '' + - - '' + - '@' + - '' + - ''; - - if(REGISTER_API == 'on') { - code += '
' + - '' + - '
'; - } - - code += '
' + - - '' + - '
'; - - break; - } - - // Form disabled? - if(disable_form) { - code += '
' + - Common._e("This tool has been disabled!") + - '
'; - } - - // Create this HTML code - if(code && !Common.exists(current)) { - $(right + '.homediv.default').after( - '
' + code + '
' - ); - - self._eventsChange( - $(current), - div - ); - } - - // We focus on the first input - $(document).oneTime(10, function() { - $(right + 'input:visible:first').focus(); - }); - } catch(e) { - Console.error('Home.change', e); - } finally { - return false; - } - - }; - - - /** - * Allows the user to display the advanced login options - * @public - * @return {boolean} - */ - self.showAdvanced = function() { - - try { - // Hide the link - $('#home a.advanced').hide(); - - // Show the fieldset - $('#home fieldset.advanced').show(); - } catch(e) { - Console.error('Home.showAdvanced', e); - } finally { - return false; - } - - }; - - - /** - * Reads the login form values - * @public - * @return {boolean} - */ - self.loginForm = function() { - - try { - // We get the values - var path_sel = $('#home .loginer'); - - var lServer = path_sel.find('.server').val(); - var lNick = Common.nodeprep(path_sel.find('.nick').val()); - var lPass = path_sel.find('.password').val(); - var lResource = path_sel.find('.resource').val(); - var lPriority = path_sel.find('.priority').val(); - var lRemember = path_sel.find('.remember').filter(':checked').size(); - - // Enough values? - if(lServer && lNick && lPass && lResource && lPriority) { - Connection.doLogin(lNick, lServer, lPass, lResource, lPriority, lRemember); - } else { - $(lPath + 'input[type="text"], ' + lPath + 'input[type="password"]').each(function() { - var select = $(this); - - if(!select.val()) { - $(document).oneTime(10, function() { - select.addClass('please-complete').focus(); - }); - } else { - select.removeClass('please-complete'); - } - }); - } - } catch(e) { - Console.error('Home.loginForm', e); - } finally { - return false; - } - - }; - - - /** - * Reads the register form values - * @public - * @return {boolean} - */ - self.registerForm = function() { - - try { - var path = '#home .registerer'; - var path_sel = $(path); - - // Remove the success info - path_sel.find('.success').remove(); - - // Get the values - var username = Common.nodeprep(path_sel.find('.nick').val()); - var domain = path_sel.find('.server').val(); - var pass = path_sel.find('.password').val(); - var spass = path_sel.find('.spassword').val(); - var captcha = path_sel.find('.captcha').val(); - - // Enough values? - if(domain && username && pass && spass && (pass == spass) && !((REGISTER_API == 'on') && (domain == HOST_MAIN) && !captcha)) { - // We remove the not completed class to avoid problems - $('#home .registerer input').removeClass('please-complete'); - - // Fire the register event! - Connection.doRegister(username, domain, pass, captcha); - } - - // Something is missing? - else { - $(path + ' input[type="text"], ' + path + ' input[type="password"]').each(function() { - var select = $(this); - - if(!select.val() || (select.is('#spassword') && pass && (pass != spass))) { - $(document).oneTime(10, function() { - select.addClass('please-complete').focus(); - }); - } else { - select.removeClass('please-complete'); - } - }); - } - } catch(e) { - Console.error('Home.registerForm', e); - } finally { - return false; - } - - }; - - - /** - * Plugin launcher - * @public - * @param {type} name - * @return {undefined} - */ - self.launch = function() { - - try { - $(document).ready(function() { - // Define the vars - var home = '#home '; - var button = home + 'button'; - var corp = home + '.corporation'; - var aboutus = home + '.aboutus'; - var locale = home + '.locale'; - - // Removes the