diff --git a/conf/nginx.conf b/conf/nginx.conf
index cc966b89..abdbbefe 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,4 +1,4 @@
-location YNH_WWW_PATH / {
+location YNH_WWW_PATH {
# Path to source
alias YNH_WWW_ALIAS/ ;
diff --git a/sources/addon/adultphotoflag b/sources/addon/adultphotoflag
deleted file mode 120000
index 024e70fd..00000000
--- a/sources/addon/adultphotoflag
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/adultphotoflag
\ No newline at end of file
diff --git a/sources/addon/bbmath b/sources/addon/bbmath
deleted file mode 120000
index 8e149947..00000000
--- a/sources/addon/bbmath
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/bbmath
\ No newline at end of file
diff --git a/sources/addon/bookmarker b/sources/addon/bookmarker
deleted file mode 120000
index 5ded7cf2..00000000
--- a/sources/addon/bookmarker
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/bookmarker
\ No newline at end of file
diff --git a/sources/addon/buglink b/sources/addon/buglink
deleted file mode 120000
index 2d77f27a..00000000
--- a/sources/addon/buglink
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/buglink
\ No newline at end of file
diff --git a/sources/addon/calc b/sources/addon/calc
deleted file mode 120000
index 44461b0f..00000000
--- a/sources/addon/calc
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/calc
\ No newline at end of file
diff --git a/sources/addon/chords b/sources/addon/chords
deleted file mode 120000
index 9b5afa56..00000000
--- a/sources/addon/chords
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/chords
\ No newline at end of file
diff --git a/sources/addon/custom_home b/sources/addon/custom_home
deleted file mode 120000
index bcf608f3..00000000
--- a/sources/addon/custom_home
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/custom_home
\ No newline at end of file
diff --git a/sources/addon/diaspora b/sources/addon/diaspora
deleted file mode 120000
index 18fe8f4e..00000000
--- a/sources/addon/diaspora
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/diaspora
\ No newline at end of file
diff --git a/sources/addon/diaspost b/sources/addon/diaspost
deleted file mode 120000
index c9ae3e9e..00000000
--- a/sources/addon/diaspost
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/diaspost
\ No newline at end of file
diff --git a/sources/addon/dirstats b/sources/addon/dirstats
deleted file mode 120000
index 2b3a3bd5..00000000
--- a/sources/addon/dirstats
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/dirstats
\ No newline at end of file
diff --git a/sources/addon/donate b/sources/addon/donate
deleted file mode 120000
index 2c392ad6..00000000
--- a/sources/addon/donate
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/donate
\ No newline at end of file
diff --git a/sources/addon/dwpost b/sources/addon/dwpost
deleted file mode 120000
index 435ef3a1..00000000
--- a/sources/addon/dwpost
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/dwpost
\ No newline at end of file
diff --git a/sources/addon/embedly b/sources/addon/embedly
deleted file mode 120000
index 2bf8e1e6..00000000
--- a/sources/addon/embedly
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/embedly
\ No newline at end of file
diff --git a/sources/addon/extcron b/sources/addon/extcron
deleted file mode 120000
index 0e8d5b10..00000000
--- a/sources/addon/extcron
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/extcron
\ No newline at end of file
diff --git a/sources/addon/flattrwidget b/sources/addon/flattrwidget
deleted file mode 120000
index fc9233d8..00000000
--- a/sources/addon/flattrwidget
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/flattrwidget
\ No newline at end of file
diff --git a/sources/addon/fortunate b/sources/addon/fortunate
deleted file mode 120000
index 9b6e449b..00000000
--- a/sources/addon/fortunate
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/fortunate
\ No newline at end of file
diff --git a/sources/addon/frphotos b/sources/addon/frphotos
deleted file mode 120000
index a48db497..00000000
--- a/sources/addon/frphotos
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/frphotos
\ No newline at end of file
diff --git a/sources/addon/hexit b/sources/addon/hexit
deleted file mode 120000
index 003aeca3..00000000
--- a/sources/addon/hexit
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/hexit
\ No newline at end of file
diff --git a/sources/addon/ijpost b/sources/addon/ijpost
deleted file mode 120000
index a2c28c85..00000000
--- a/sources/addon/ijpost
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/ijpost
\ No newline at end of file
diff --git a/sources/addon/irc b/sources/addon/irc
deleted file mode 120000
index 96bb702f..00000000
--- a/sources/addon/irc
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/irc
\ No newline at end of file
diff --git a/sources/addon/jappixmini b/sources/addon/jappixmini
deleted file mode 120000
index 57a425f2..00000000
--- a/sources/addon/jappixmini
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/jappixmini
\ No newline at end of file
diff --git a/sources/addon/js_upload b/sources/addon/js_upload
deleted file mode 120000
index 954a68cb..00000000
--- a/sources/addon/js_upload
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/js_upload
\ No newline at end of file
diff --git a/sources/addon/ldapauth b/sources/addon/ldapauth
deleted file mode 120000
index 9110cc08..00000000
--- a/sources/addon/ldapauth
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/ldapauth
\ No newline at end of file
diff --git a/sources/addon/libertree b/sources/addon/libertree
deleted file mode 120000
index ad355bb4..00000000
--- a/sources/addon/libertree
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/libertree
\ No newline at end of file
diff --git a/sources/addon/likebanner b/sources/addon/likebanner
deleted file mode 120000
index bcaf7710..00000000
--- a/sources/addon/likebanner
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/likebanner
\ No newline at end of file
diff --git a/sources/addon/ljpost b/sources/addon/ljpost
deleted file mode 120000
index 2912d56a..00000000
--- a/sources/addon/ljpost
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/ljpost
\ No newline at end of file
diff --git a/sources/addon/mahjongg b/sources/addon/mahjongg
deleted file mode 120000
index aed1a8be..00000000
--- a/sources/addon/mahjongg
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/mahjongg
\ No newline at end of file
diff --git a/sources/addon/mailhost b/sources/addon/mailhost
deleted file mode 120000
index 926de865..00000000
--- a/sources/addon/mailhost
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/mailhost
\ No newline at end of file
diff --git a/sources/addon/morechoice b/sources/addon/morechoice
deleted file mode 120000
index eede88f3..00000000
--- a/sources/addon/morechoice
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/morechoice
\ No newline at end of file
diff --git a/sources/addon/moremoods b/sources/addon/moremoods
deleted file mode 120000
index 26462449..00000000
--- a/sources/addon/moremoods
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/moremoods
\ No newline at end of file
diff --git a/sources/addon/nofed b/sources/addon/nofed
deleted file mode 120000
index e47fa5f9..00000000
--- a/sources/addon/nofed
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/nofed
\ No newline at end of file
diff --git a/sources/addon/nsabait b/sources/addon/nsabait
deleted file mode 120000
index dbc91b1f..00000000
--- a/sources/addon/nsabait
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/nsabait
\ No newline at end of file
diff --git a/sources/addon/nsfw b/sources/addon/nsfw
deleted file mode 120000
index 45f9d6e5..00000000
--- a/sources/addon/nsfw
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/nsfw
\ No newline at end of file
diff --git a/sources/addon/openclipatar b/sources/addon/openclipatar
deleted file mode 120000
index 1aca7361..00000000
--- a/sources/addon/openclipatar
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/openclipatar
\ No newline at end of file
diff --git a/sources/addon/openstreetmap b/sources/addon/openstreetmap
deleted file mode 120000
index 502e623f..00000000
--- a/sources/addon/openstreetmap
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/openstreetmap
\ No newline at end of file
diff --git a/sources/addon/piwik b/sources/addon/piwik
deleted file mode 120000
index 1c02b005..00000000
--- a/sources/addon/piwik
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/piwik
\ No newline at end of file
diff --git a/sources/addon/planets b/sources/addon/planets
deleted file mode 120000
index 623f5cf0..00000000
--- a/sources/addon/planets
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/planets
\ No newline at end of file
diff --git a/sources/addon/pumpio b/sources/addon/pumpio
deleted file mode 120000
index 8d2db101..00000000
--- a/sources/addon/pumpio
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/pumpio
\ No newline at end of file
diff --git a/sources/addon/qrator b/sources/addon/qrator
deleted file mode 120000
index dfc52e0a..00000000
--- a/sources/addon/qrator
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/qrator
\ No newline at end of file
diff --git a/sources/addon/rainbowtag b/sources/addon/rainbowtag
deleted file mode 120000
index 382135e6..00000000
--- a/sources/addon/rainbowtag
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/rainbowtag
\ No newline at end of file
diff --git a/sources/addon/randpost b/sources/addon/randpost
deleted file mode 120000
index 7d19da3e..00000000
--- a/sources/addon/randpost
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/randpost
\ No newline at end of file
diff --git a/sources/addon/redphotos b/sources/addon/redphotos
deleted file mode 120000
index 5f4aade9..00000000
--- a/sources/addon/redphotos
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/redphotos
\ No newline at end of file
diff --git a/sources/addon/redred b/sources/addon/redred
deleted file mode 120000
index 3970fca4..00000000
--- a/sources/addon/redred
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/redred
\ No newline at end of file
diff --git a/sources/addon/rtof b/sources/addon/rtof
deleted file mode 120000
index 1571f258..00000000
--- a/sources/addon/rtof
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/rtof
\ No newline at end of file
diff --git a/sources/addon/sendzid b/sources/addon/sendzid
deleted file mode 120000
index e1b1d238..00000000
--- a/sources/addon/sendzid
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/sendzid
\ No newline at end of file
diff --git a/sources/addon/smiley_pack b/sources/addon/smiley_pack
deleted file mode 120000
index 971efecf..00000000
--- a/sources/addon/smiley_pack
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/smiley_pack
\ No newline at end of file
diff --git a/sources/addon/smileybutton b/sources/addon/smileybutton
deleted file mode 120000
index 51d06824..00000000
--- a/sources/addon/smileybutton
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/smileybutton
\ No newline at end of file
diff --git a/sources/addon/startpage b/sources/addon/startpage
deleted file mode 120000
index be49638d..00000000
--- a/sources/addon/startpage
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/startpage
\ No newline at end of file
diff --git a/sources/addon/statistics_json b/sources/addon/statistics_json
deleted file mode 120000
index cdd6ca3e..00000000
--- a/sources/addon/statistics_json
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/statistics_json
\ No newline at end of file
diff --git a/sources/addon/statusnet b/sources/addon/statusnet
deleted file mode 120000
index 3297a173..00000000
--- a/sources/addon/statusnet
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/statusnet
\ No newline at end of file
diff --git a/sources/addon/superblock b/sources/addon/superblock
deleted file mode 120000
index f2b1ef07..00000000
--- a/sources/addon/superblock
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/superblock
\ No newline at end of file
diff --git a/sources/addon/tictac b/sources/addon/tictac
deleted file mode 120000
index a65e7d37..00000000
--- a/sources/addon/tictac
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/tictac
\ No newline at end of file
diff --git a/sources/addon/torch b/sources/addon/torch
deleted file mode 120000
index 10bbde90..00000000
--- a/sources/addon/torch
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/torch
\ No newline at end of file
diff --git a/sources/addon/tour b/sources/addon/tour
deleted file mode 120000
index 2e83e52d..00000000
--- a/sources/addon/tour
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/tour
\ No newline at end of file
diff --git a/sources/addon/twitter b/sources/addon/twitter
deleted file mode 120000
index 6286a41c..00000000
--- a/sources/addon/twitter
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/twitter
\ No newline at end of file
diff --git a/sources/addon/upload_limits b/sources/addon/upload_limits
deleted file mode 120000
index ad196540..00000000
--- a/sources/addon/upload_limits
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/upload_limits
\ No newline at end of file
diff --git a/sources/addon/visage b/sources/addon/visage
deleted file mode 120000
index 9ba0502a..00000000
--- a/sources/addon/visage
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/visage
\ No newline at end of file
diff --git a/sources/addon/wppost b/sources/addon/wppost
deleted file mode 120000
index 2f23099f..00000000
--- a/sources/addon/wppost
+++ /dev/null
@@ -1 +0,0 @@
-../extend/addon/official/wppost
\ No newline at end of file
diff --git a/sources/addons/.gitignore b/sources/addons/.gitignore
new file mode 100644
index 00000000..5dade782
--- /dev/null
+++ b/sources/addons/.gitignore
@@ -0,0 +1,24 @@
+favicon.*
+.htconfig.php
+\#*
+*.log
+*.out
+*.version*
+favicon.*
+*~
+
+#ignore reports, should be generted with every build
+report/
+
+#ignore config files from eclipse, we don't want IDE files in our repository
+.project
+.buildpath
+.externalToolBuilders
+.settings
+#ignore OSX .DS_Store files
+.DS_Store
+
+/nbproject/private/
+
+#Kdevelop project files
+*.kdev4
diff --git a/sources/addons/README.md b/sources/addons/README.md
new file mode 100644
index 00000000..ffb55595
--- /dev/null
+++ b/sources/addons/README.md
@@ -0,0 +1,6 @@
+hubzilla-addons
+================
+
+These are addons for hubzilla sites (see https://github.com/redmatrix/hubzilla )
+
+
diff --git a/sources/addons/adultphotoflag/adultphotoflag.php b/sources/addons/adultphotoflag/adultphotoflag.php
new file mode 100755
index 00000000..a8b1371a
--- /dev/null
+++ b/sources/addons/adultphotoflag/adultphotoflag.php
@@ -0,0 +1,28 @@
+
+
+ */
+
+function adultphotoflag_load() {
+ register_hook('get_features','addon/adultphotoflag/adultphotoflag.php','adultphotoflag_get_features');
+}
+
+function adultphotoflag_unload() {
+ unregister_hook('get_features','addon/adultphotoflag/adultphotoflag.php','adultphotoflag_get_features');
+}
+
+function adultphotoflag_get_features(&$a,&$b) {
+
+ $b['tools'][] = array(
+ 'adult_photo_flagging',
+ t('Flag Adult Photos'),
+ t('Provide photo edit option to hide inappropriate photos from default album view'),false);
+
+}
+
diff --git a/sources/addons/bbmath/README b/sources/addons/bbmath/README
new file mode 100644
index 00000000..e2e9f62c
--- /dev/null
+++ b/sources/addons/bbmath/README
@@ -0,0 +1,3 @@
+Adds a new tag, [tex] that can be used in bbcode. Note that you still also have to use $...$ to get equations correct, i.e. [tex] doesn't eneter math-mode by default.
+
+Requires images and tmp directory in your Red root directory (e.g. /var/www/red). Must be writable by server (e.g chown -R www-data tmp images). Also requires latex and imagemagick to be installed.
diff --git a/sources/addons/bbmath/bbmath.php b/sources/addons/bbmath/bbmath.php
new file mode 100644
index 00000000..118772dd
--- /dev/null
+++ b/sources/addons/bbmath/bbmath.php
@@ -0,0 +1,22 @@
+
+ *
+ */
+
+require_once('phplatex.php');
+function bbmath_load() {
+ register_hook('bbcode','addon/bbmath/bbmath.php','bbmath_bbcode');
+
+}
+function bbmath_unload() {
+ unregister_hook('bbcode','addon/bbmath/bbmath.php','bbmath_bbcode');
+}
+
+function bbmath_bbcode($a,&$text) {
+ $text = preg_replace_callback('|\[tex\](.*?)\[/tex\]|',function($m) { return texify($m[1]); },$text);
+}
diff --git a/sources/addons/bbmath/gpl.txt b/sources/addons/bbmath/gpl.txt
new file mode 100644
index 00000000..d511905c
--- /dev/null
+++ b/sources/addons/bbmath/gpl.txt
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ 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
+this service 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.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+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
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the 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 a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE 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.
+
+ 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
+convey 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 General Public License as published by
+ the Free Software Foundation; either version 2 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/sources/addons/bbmath/phplatex.php b/sources/addons/bbmath/phplatex.php
new file mode 100644
index 00000000..cf10cd94
--- /dev/null
+++ b/sources/addons/bbmath/phplatex.php
@@ -0,0 +1,139 @@
+300) $dpi=300;
+
+ $back=phplatex_colorhex($br,$bg,$bb);
+ $fore=phplatex_colorhex($r,$g,$b);
+
+ # Figure out TeX, either to get the right cache entry or to, you know, compile
+ # Semi-common (ams) symbol packages are included.
+ $totex = "\\documentclass[14pt,landscape]{extarticle}\n".
+ "\\usepackage{color}\n".
+ "\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n".
+ $extraprelude."\n".
+ "\\pagestyle{empty}\n". #removes header/footer; necessary for trim
+ "\\begin{document}\n".
+ "\\color[rgb]{".$r.",".$g.",".$b."}\n".
+ "\\pagecolor[rgb]{".$br.",".$bg.",".$bb."}\n".
+ $string."\n".
+ "\\end{document}\n";
+
+ $strhash = sha1($totex).'.'.$dpi; #file cache entry string: 40-char hash string plus size
+ $stralt = str_replace("&","&", preg_replace("/[\"\n]/","",$string)); #stuck in the alt and title attributes
+ #May need some extra safety.
+ $heredir=getcwd();
+
+ #Experiment: Tries to adjust vertical positioning, so that rendered TeX text looks natural enough inline with HTML text
+ #Only descenders are really a problem since HTML's leeway is upwards.
+ #TODO: This can always use more work.
+ # Avoid using characters that are part of TeX commands.
+ # Some things vary per font, e.g. the slash. In the default CM it is a descender, in Times and others it isn't.
+ $ascenders ="/(b|d|f|h|i|j|k|l|t|A|B|C|D|E|F|G|H|I|J|L|K|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|\[|\]|\\{|\\}|\(|\)|\/|0|1|2|3|4|5|6|7|8|9|\\#|\*|\?|'|\\\\'|\\\\`|\\\\v)/";
+ $monoliners="/(a|c|e|m|n|o|r|s|u|v|w|x|z|-|=|\+|:|.)/";
+ $descenders="/(g|j|p|\/|q|y|Q|,|;|\[|\]|\\{|\\}|\(|\)|\#|\\\\LaTeX|\\\\TeX|\\\\c\{)/";
+ $deepdescenders="/(\[|\]|\\{|\\}|\(|\)|\\int)/";
+
+ $ba = preg_match_all($ascenders, $string,$m);
+ $bm = preg_match_all($monoliners, $string,$m);
+ $bd = preg_match_all($descenders, $string,$m);
+ $dd = preg_match_all($deepdescenders, $string,$m);
+ if ($dd>0) $verticalalign="vertical-align: -25%"; # deep descenders: move down
+ else if ($bd>0 && $ba==0) $verticalalign="vertical-align: -15%"; # descenders: move down
+ else if ($bd==0 && $ba>0) $verticalalign="vertical-align: 0%"; # ascenders only: move up/do nothing?
+ else if ($bd==0 && $ba==0) $verticalalign="vertical-align: 0%"; # neither vertical-align: 0%
+ else $verticalalign="vertical-align: -15%"; # both ascender and regular descender
+
+ #check image cache, return link if exists
+ #the vertical-align is to fix text baseline/descender(/tail) details in and on-average sort of way
+ if (file_exists($heredir.'/images/'.$strhash.'.'.$imgfmt))
+ return '';
+
+
+ #chdir to have superfluous files be created in tmp. (you stiill have to empty this yourself)
+ error_reporting(0); # not checking existence myself, that would be double.
+ if (chdir("tmp")===FALSE) { return '[directory access error, fix permissions]'; } #I should chech whether file creation is allowed to give a nice error for that problem case
+ error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); # TODO: set old value
+
+ $tfn = tempnam(getcwd(), 'PTX'); #file in tmp dir
+
+ #write temporary .tex file
+ if ( ($tex = fopen($tfn.'.tex', "w"))==FALSE) { return '[file access error] '.phplatex_cleantmp($tfn,$heredir); }
+ fwrite($tex, $totex);
+ fclose($tex);
+
+
+ #Run latex to create a .dvi. Have it try to fix minor errors instead of breaking/pausing on them.
+ exec($path_to_latex.' --interaction=nonstopmode '.$tfn.'.tex');
+ if (!file_exists($tfn.".dvi")) {
+ $log = file_get_contents($tfn.'.log'); #The log always exists, but now it's actually interesting since it'll contain an error
+ return '[latex error, code follows]
'.$totex.'
Log file:
'.$log.'
'.phplatex_cleantmp($tfn,$heredir);
+ }
+
+
+ #DVI -> PostScript. Since dvips uses lpr, which may be configured to actually print by default, force writing to a file with -o
+ exec($path_to_dvips.' '.$tfn.'.dvi -o '.$tfn.'.ps');
+ if ( !file_exists($tfn.'.ps')) {
+ return '[dvi2ps error] '.phplatex_cleantmp($tfn,$heredir);
+ }
+
+
+ #PostScript -> image. Trim based on corner pixel, and set transparent color.
+ exec($path_to_convert.' -transparent-color "#'.$back.'" -colorspace RGB -density '.$dpi.' -trim +page '.$tfn.'.ps -transparent "#'.$back.'" '.$tfn.'.'.$imgfmt);
+ #Note: +page OR -page +0+0 OR +repage moves the image to the cropped area (kills offset)
+ #Older code tried: exec('/usr/bin/mogrify -density 90 -trim +page -format $imgfmt '.$tfn.'.ps');
+ # It seems some versions of convert may not have -trim. Old versions?
+
+ if (!file_exists($tfn.'.'.$imgfmt)) {
+ return '[image convert error] '.phplatex_cleantmp($tfn,$heredir);
+ }
+
+ #Copy result image to chache.
+ copy($tfn.'.'.$imgfmt, $heredir.'/images/'.$strhash.'.'.$imgfmt);
+
+ #Clean up temporary files, and return link to just-created image
+ return phplatex_cleantmp($tfn,$heredir).'';
+}
+?>
diff --git a/sources/addons/bookmarker/bookmarker.php b/sources/addons/bookmarker/bookmarker.php
new file mode 100755
index 00000000..41a86350
--- /dev/null
+++ b/sources/addons/bookmarker/bookmarker.php
@@ -0,0 +1,41 @@
+
+ *
+ */
+
+function bookmarker_install() {
+ register_hook('prepare_body', 'addon/bookmarker/bookmarker.php', 'bookmarker_prepare_body', 10);
+}
+
+
+function bookmarker_uninstall() {
+ unregister_hook('prepare_body', 'addon/bookmarker/bookmarker.php', 'bookmarker_prepare_body');
+}
+
+function bookmarker_prepare_body(&$a,&$b) {
+
+
+ if(get_pconfig(local_channel(),'bookmarker','disable'))
+ return;
+
+ if(! strpos($b['html'],'bookmark-identifier'))
+ return;
+
+ if(! function_exists('redbasic_init'))
+ return;
+
+ $id = $b['item']['id'];
+ if(local_channel())
+ $link = ' ';
+ else
+ $link = ' ';
+
+ $b['html'] = str_replace('#^',$link,$b['html']);
+
+}
diff --git a/sources/addons/buglink/bug-x.gif b/sources/addons/buglink/bug-x.gif
new file mode 100755
index 00000000..10936caa
Binary files /dev/null and b/sources/addons/buglink/bug-x.gif differ
diff --git a/sources/addons/buglink/buglink.php b/sources/addons/buglink/buglink.php
new file mode 100755
index 00000000..a237601b
--- /dev/null
+++ b/sources/addons/buglink/buglink.php
@@ -0,0 +1,15 @@
+
+ */
+
+
+function buglink_load() { register_hook('page_end', 'addon/buglink/buglink.php', 'buglink_active'); }
+
+
+function buglink_unload() { unregister_hook('page_end', 'addon/buglink/buglink.php', 'buglink_active'); }
+
+function buglink_active(&$a,&$b) { $b .= '
'; }
diff --git a/sources/addons/buglink/lang/C/messages.po b/sources/addons/buglink/lang/C/messages.po
new file mode 100644
index 00000000..260c583a
--- /dev/null
+++ b/sources/addons/buglink/lang/C/messages.po
@@ -0,0 +1,22 @@
+# ADDON buglink
+# Copyright (C)
+# This file is distributed under the same license as the Friendica buglink addon package.
+#
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-27 05:01-0500\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: buglink.php:15
+msgid "Report Bug"
+msgstr ""
diff --git a/sources/addons/buglink/lang/ca/strings.php b/sources/addons/buglink/lang/ca/strings.php
new file mode 100644
index 00000000..01fc9adb
--- /dev/null
+++ b/sources/addons/buglink/lang/ca/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Informar de problema";
diff --git a/sources/addons/buglink/lang/cs/strings.php b/sources/addons/buglink/lang/cs/strings.php
new file mode 100644
index 00000000..a1cd51f4
--- /dev/null
+++ b/sources/addons/buglink/lang/cs/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Nahlásit chybu";
diff --git a/sources/addons/buglink/lang/de/strings.php b/sources/addons/buglink/lang/de/strings.php
new file mode 100644
index 00000000..cf96a178
--- /dev/null
+++ b/sources/addons/buglink/lang/de/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Fehlerreport erstellen";
diff --git a/sources/addons/buglink/lang/eo/strings.php b/sources/addons/buglink/lang/eo/strings.php
new file mode 100644
index 00000000..00d95a40
--- /dev/null
+++ b/sources/addons/buglink/lang/eo/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Skribi cimraporton";
diff --git a/sources/addons/buglink/lang/es/strings.php b/sources/addons/buglink/lang/es/strings.php
new file mode 100644
index 00000000..fe632488
--- /dev/null
+++ b/sources/addons/buglink/lang/es/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Informe de errores";
diff --git a/sources/addons/buglink/lang/fr/strings.php b/sources/addons/buglink/lang/fr/strings.php
new file mode 100644
index 00000000..0075fb0d
--- /dev/null
+++ b/sources/addons/buglink/lang/fr/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Signaler un bug";
diff --git a/sources/addons/buglink/lang/is/strings.php b/sources/addons/buglink/lang/is/strings.php
new file mode 100644
index 00000000..7b3823a6
--- /dev/null
+++ b/sources/addons/buglink/lang/is/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Tilkynna bilun";
diff --git a/sources/addons/buglink/lang/it/strings.php b/sources/addons/buglink/lang/it/strings.php
new file mode 100644
index 00000000..90df28fe
--- /dev/null
+++ b/sources/addons/buglink/lang/it/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Segnala un Bug";
diff --git a/sources/addons/buglink/lang/nb-no/strings.php b/sources/addons/buglink/lang/nb-no/strings.php
new file mode 100644
index 00000000..ec212e9a
--- /dev/null
+++ b/sources/addons/buglink/lang/nb-no/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "";
diff --git a/sources/addons/buglink/lang/pl/strings.php b/sources/addons/buglink/lang/pl/strings.php
new file mode 100644
index 00000000..8229e7a6
--- /dev/null
+++ b/sources/addons/buglink/lang/pl/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Zgłoś problem";
diff --git a/sources/addons/buglink/lang/pt-br/strings.php b/sources/addons/buglink/lang/pt-br/strings.php
new file mode 100644
index 00000000..6283d77e
--- /dev/null
+++ b/sources/addons/buglink/lang/pt-br/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Relate um Bug";
diff --git a/sources/addons/buglink/lang/ru/strings.php b/sources/addons/buglink/lang/ru/strings.php
new file mode 100644
index 00000000..c4223648
--- /dev/null
+++ b/sources/addons/buglink/lang/ru/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Сообщить об ошибке";
diff --git a/sources/addons/buglink/lang/sv/strings.php b/sources/addons/buglink/lang/sv/strings.php
new file mode 100644
index 00000000..ab4fa67a
--- /dev/null
+++ b/sources/addons/buglink/lang/sv/strings.php
@@ -0,0 +1,2 @@
+strings["Report Bug"] = "报案程序错误";
diff --git a/sources/addons/calc/calc.apd b/sources/addons/calc/calc.apd
new file mode 100644
index 00000000..8171ce06
--- /dev/null
+++ b/sources/addons/calc/calc.apd
@@ -0,0 +1,3 @@
+url: $baseurl/calc
+name: Calculator
+photo: $baseurl/addon/calc/calc.png
diff --git a/sources/addons/calc/calc.php b/sources/addons/calc/calc.php
new file mode 100755
index 00000000..2935b4a2
--- /dev/null
+++ b/sources/addons/calc/calc.php
@@ -0,0 +1,368 @@
+
+ */
+
+
+function calc_load() {
+ register_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
+}
+
+function calc_unload() {
+ unregister_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
+
+}
+
+function calc_app_menu($a,&$b) {
+ $b['app_menu'][] = '
+
+EOT;
+return $o;
+
+}
diff --git a/sources/addons/calc/calc.png b/sources/addons/calc/calc.png
new file mode 100644
index 00000000..e7d15c8c
Binary files /dev/null and b/sources/addons/calc/calc.png differ
diff --git a/sources/addons/chords/README.md b/sources/addons/chords/README.md
new file mode 100644
index 00000000..a45e9730
--- /dev/null
+++ b/sources/addons/chords/README.md
@@ -0,0 +1,9 @@
+Chord Generator
+===============
+
+Before enabling the plugin compile the chord generator binary.
+
+ g++ chord-generator.cpp -o chord
+
+The example is for Linux. Compilation instructions may vary on Windows or other platforms.
+
diff --git a/sources/addons/chords/chord b/sources/addons/chords/chord
new file mode 100755
index 00000000..b6c8a495
Binary files /dev/null and b/sources/addons/chords/chord differ
diff --git a/sources/addons/chords/chord-generator.cpp b/sources/addons/chords/chord-generator.cpp
new file mode 100755
index 00000000..6a7f2c09
--- /dev/null
+++ b/sources/addons/chords/chord-generator.cpp
@@ -0,0 +1,1133 @@
+//
+// I have been messing around with this program now for a couple weeks
+// and thought it might be useful to someone. Given a chord by name,
+// it generates all possible ways to play that chord on a guitar and
+// scores them based on things like finger span, root as bass note,
+// number of open strings, etc (see below). Then it prints the top
+// 50 it found (or more, you can set it). The program is pretty
+// configurable if you can stand to read the stuff at the top where
+// all the #define's are. Currently it prints out the score, and the
+// pieces that made up the score...you may want to get rid of the
+// extra info, but I found it interesting.
+//
+// It generates some wild chords and some interesting versions that
+// I have NEVER seen before. Probably a great program to find inversions
+// and stuff (especially if you lower the score given for having a root
+// note 1st). The program could easily be modified to do Drop D tuning
+// or any other alternate tuning, and I think it could do other instruments
+// without much change, but I have not tried.
+//
+// I have been having fun playing with this, if you make a changes or
+// fixes I would appreciate a copy. Other than that, this is public
+// domain, have a party. Oh yeah, the code is C++...
+//
+// Thanks,
+// Rick Eesley
+// re@warren.mentorg.com
+//
+//
+//
+// Chords can be built like: | = seperate fields, [ ... ] = range of values
+// <> = nothing
+//
+// [<--optional--->]
+// [<--repeating-->]
+// [A...G] | <> | <> | <> | # |
+// | # | min | maj | |
+// | b | m | add | |
+// | | sus2 | aug | |
+// | | sus4 | dim | |
+// | | dim | + | |
+// | | aug | - | |
+// | | | # |
+// | | | b |
+// | | | / |
+//
+// Legal chord names: A A7 Amaj7 Amaj9 Ammaj7 Aadd4 Asus2Add4 E7b13b11 ...
+// Does not do: C/G which is a c chord with a g root, just find a c
+// chord and pick out a g root you like for those...
+// Does not do: E5 (that's not a chord, just 2 notes)
+//
+//
+
+
+#undef DEBUG
+int lefty = 0;
+
+//////////////////////////////////////////////////////////////////////
+// Scoring a chord is influenced by these multipliers, change them around
+// to your own preferences
+//////////////////////////////////////////////////////////////////////
+
+//
+// Score for where this lands on the fretboard (Lower is better)
+// score += (15 - AverageFret) * POSITION_SCORE;
+#define POSITION_SCORE 20
+
+// Score for minimal span (ie: chord covering from fret 2 to fret 4 has
+// a span of 2. Open strings do NOT count in span, this is a measure
+// of whether a chord is playable
+// The maximum span allowed is set by the #define MAXSPAN
+// score += (MAXSPAN - span) * SPAN_SCORE;
+#define SPAN_SCORE 12
+
+// This score is for total Span (ie: includes open strings, which span
+// does not.
+// score += (15 - tspan) * TSPAN_SCORE;
+#define TSPAN_SCORE 3
+
+// This score is for number of open strings (I like them).
+// score += numberOfOpens * OPENS_SCORE
+#define OPENS_SCORE 10
+
+// This score multiplier is the score to add if the most bass string
+// is the root note
+// score += ROOT_SCORE
+#define ROOT_SCORE 50
+
+// This score multipier is used to penalize for adjacent notes
+// score += ADJ_SCORE * (5-adjNotes)
+// THe five is the max number of adjacent strings possible (duh...)
+#define ADJ_SCORE 9
+
+// This is the maximum finger reach, if this is bumped up to five or
+// more you get a zillion more fingers (mainly 'cause 5 takes you to
+// the notes on the next string...so leave it probably
+#define MAXSPAN 4
+
+// This is number of top scores to keep, something < 20 leaves out
+// too much, 100 is a lot to look at...but I am going with it...
+#define CHORDSTACK 250
+
+//
+// These are different types of scores, NUMSCORETYPES MUST be set to the
+// number of these types, so if any are added change it TOO!
+// Add any new scores onto the end, the total MUST be the 0th element
+//
+#define NUMSCORETYPES 7
+
+#define SCORE_TOTAL 0
+#define SCORE_SPAN 1
+#define SCORE_TOTALSPAN 2
+#define SCORE_OPENSTRINGS 3
+#define SCORE_FIRSTROOT 4
+#define SCORE_LOWONNECK 5
+#define SCORE_ADJNOTES 6
+
+// Just in case someone wants to port this to banjo or mandolin or something
+#define NUM_STRINGS 6
+
+
+#include
+#include
+#include
+#include
+
+/* A A# B C C# D D# E F F# G G# */
+/* A Bb B C Db D Eb E F Gb G Ab */
+/* 0 1 2 3 4 5 6 7 8 9 10 11 */
+
+/* STRINGS ARE: E=0, A=1, D=2, G=3, B=4, E=5 IN ORDER */
+
+// This can be reset for alternate tunings, this is EADGBE tuning
+// here:
+
+ int openStrings[NUM_STRINGS] = { 7, 0, 5, 10, 2, 7 };
+
+static char *strNotes[] = { "A ", "A#", "B ", "C ", "C#", "D ",
+ "D#", "E ", "F ", "F#", "G ", "G#" };
+
+//
+// This class contains a decode chord, and can take a string and turn
+// it into a chord. A chord is a triad or greater here. The code is
+// decoded from a string into notes in the c array (notes: are A=0, A#=1,
+// and so on. The longest chord you can possibly have is 12 notes which
+// would be every note in an octave, since chords are typical 3 to 5
+// notes, remaining notes in the c[] array are set to -1
+//
+class Chord
+{
+ public:
+ // String set to last error
+ char errorStr[64];
+
+ // Notes that are in the chord -1 should be ignored
+ int notes[12];
+
+ // NOtes that are optional have a 1, otherwise a zero
+ int optional[12];
+
+ // ------------------ MEMBER FUNCTIONS ----------------------------
+
+ // Clears last chord
+ void clear();
+
+ // Decodes input string into notes[] array, return error string
+ int findChord(char *s);
+
+ // Print last error message from chord parse
+ void printError();
+
+ // Prints out notes[] array to screen
+ void print(char *chordName);
+
+ // Is the note note in the chord
+ int inChord(int note);
+
+ // Is this chord covered by the array of notes (ie: Does the
+ // array contain all the notes of the chord
+ int covered(int *noteArray);
+
+ // Return the root note of the chord
+ int getRoot() { return notes[0]; }
+
+ // Given a chord string, return the note that starts it (and recognize
+ // sharps and flats (b and #)
+ int get_base(char *s);
+
+ // Get a note offset from another...
+ int note_offset(int base, int offset) {
+ if((! base) && (offset == (-1)))
+ return(11);
+ return ((base + offset) % 12);
+ }
+} ;
+
+//
+// This class holds a fingering for a chord, as well as a score for that
+// fingering. This class also keeps the CHORDSTACK (ie: 100) best version
+// of that chord to print out in sorted order (best score 1st).
+//
+class Fretboard
+{
+ public:
+
+ // Score of current chord, held in an array so we can track the
+ // components of the score (see the SCORE_ defines in the begining
+ // of this file
+ int score[NUMSCORETYPES];
+
+ // Fretboard of the current chord, fretboard[0] is the low (bass) E
+ // string. A fretboard value of 0 is an open string, -1 is an
+ // X'ed out string (not strung)
+ int fretboard[NUM_STRINGS];
+
+ // Notes of the current fretboard fingering for a chord
+ int notes[NUM_STRINGS];
+
+ // The best fret layouts so far based on score
+ int bestFrets[CHORDSTACK][NUM_STRINGS];
+
+ // The best fret layout note sets so far based on score
+ int bestNotes[CHORDSTACK][NUM_STRINGS];
+
+ // The best scores
+ int bestScores[CHORDSTACK][NUMSCORETYPES];
+
+ // Keep track of stack sDepth to speed it up!
+ int sDepth;
+
+ // ------------------ MEMBER FUNCTIONS ----------------------------
+
+ // Construct one
+ Fretboard();
+
+ // Given a chord (and the current fretboard state) score this doggie
+ // and leave the score value in score
+ void getScore(Chord &chord);
+
+ // Print the current Fretboard state (not the stack)
+ void print();
+
+ // Print the fretboard stack
+ void printStack();
+
+ // Iterate over different fretboard variations for a chord
+ void iterate(Chord &chord);
+
+ // Take the current fretboard state and put it into the stack
+ void addToBest();
+
+ // Get the span of the current chord, excluding open string
+ int getSpan();
+
+ // Get the span of the current chord, INCLUDING open string
+ int getTotalSpan();
+};
+
+//
+// Before building a chord, clear the notes and optional arrays
+//
+void
+Chord::clear()
+{
+ for (int i = 0; i < 12; i++)
+ {
+ notes[i] = -1;
+ optional[i] = 0;
+ }
+}
+
+//
+// Print out the last error string
+//
+void
+Chord::printError()
+{
+ printf("Error: %s\n", errorStr);
+}
+
+//
+// I dunno, our C++ compiler at work did not have strupr, so heres mine
+//
+void
+myStrupr(char *s)
+{
+ while (*s)
+ {
+ if (islower(*s))
+ *s = toupper(*s);
+ s++;
+ }
+}
+
+//
+// Decodes input string into notes[] array, return error string
+// always: 0 = root, 1 = 3rd, 2 = 5th
+// Also sets the optional array in parallel with the notes[]
+//
+int
+Chord::findChord(char *s)
+{
+ clear();
+
+ // up case the string
+ myStrupr(s);
+
+ // DECODE ROOT NOTE : A - G
+ notes[0] = get_base(s);
+ s++;
+
+ // CHECK FOR SHARP OR FLAT ROOT NOTE
+ if (*s == '#') s++;
+ if (*s == 'B') s++;
+
+ // MODIFY THE ROOT BY M, MIN, SUS2, SUS4, or diminished
+ if (!strncmp(s, "MIN", 3 ))
+ {
+ notes[1] = note_offset(notes[0], 3);
+ s += 3;
+ optional[2] = 1;
+ }
+ else if (!strncmp(s, "MAJ", 3))
+ {
+ // Do nothing, but stops program from seeing the
+ // first m in maj as a minor (see next line)...so give a normal 3rd
+ notes[1] = note_offset(notes[0], 4);
+ optional[2] = 1;
+ }
+ else if (!strncmp(s, "M", 1))
+ {
+ notes[1] = note_offset(notes[0], 3);
+ s += 1;
+ optional[2] = 1;
+ }
+ else if (!strncmp(s, "SUS", 1))
+ {
+ s += 3; // go past sus
+ if (*s == '2')
+ notes[1] = note_offset(notes[0], 2);
+ else if (*s == '4')
+ notes[1] = note_offset(notes[0], 5);
+ else
+ {
+ strcpy(errorStr, "sus must be followed by 2 or 4");
+ return 1;
+ }
+ s++; // Go past 2 or 4
+ optional[2] = 1;
+ }
+ else if ((!strncmp(s, "DIM", 3 )) && (!isdigit(s[3])))
+ {
+ // If it is diminished, just return (no other stuff allowed)/
+ notes[1] = note_offset(notes[0], 3);
+ notes[2] = note_offset(notes[0], 6);
+ notes[3] = note_offset(notes[0], 9);
+ return 0;
+ }
+ else if ((!strncmp(s, "AUG", 3 )) && (!isdigit(s[3])))
+ {
+ // If it is diminished, just return (no other stuff allowed)/
+ notes[1] = note_offset(notes[0], 4);
+ notes[2] = note_offset(notes[0], 8);
+ return 0;
+ }
+ else
+ {
+ notes[1] = note_offset(notes[0], 4);
+ // optional[1] = 1;
+ // optional[2] = 1;
+ }
+
+ notes[2] = note_offset(notes[0], 7);
+
+
+ // At this point, the 1,3,5 triad or variant is built, now add onto
+ // it until the string end is reached...
+ // Next note to add is index = 3...
+ int index = 3;
+ enum homeboy { NORMAL, MAJ, ADD, AUG, DIM } mtype ;
+ char lbuf[10];
+
+ while (*s)
+ {
+ // FIrst, check the mtype of modifier, ie: Aug, Maj, etc...
+ mtype = NORMAL;
+ if (!strncmp(s, "MAJ", 3))
+ {
+ mtype = MAJ;
+ s += 3;
+ }
+ else if (!strncmp(s, "ADD", 3))
+ {
+ mtype = ADD;
+ s += 3;
+ }
+ else if (!strncmp(s, "AUG", 3))
+ {
+ mtype = AUG ;
+ s += 3;
+ }
+ else if (!strncmp(s, "DIM", 3))
+ {
+ mtype = DIM;
+ s += 3;
+ }
+ else if ( *s == '+' )
+ {
+ mtype = AUG;
+ s += 1;
+ }
+ else if ( *s == '-' )
+ {
+ mtype = DIM;
+ s += 1;
+ }
+ else if ( *s == '#' )
+ {
+ mtype = AUG;
+ s += 1;
+ }
+ else if ( *s == 'B' )
+ {
+ mtype = DIM;
+ s += 1;
+ }
+ else if ( *s == '/' )
+ {
+ mtype = ADD;
+ s += 1;
+ }
+ // Now find the number...
+ if (isdigit(*s))
+ {
+ lbuf[0] = *s++;
+ lbuf[1] = '\0';
+ }
+ else
+ {
+ sprintf(errorStr, "Expecting number, got %s", s);
+ return 1;
+ }
+ // 2nd digit?
+ if (isdigit(*s))
+ {
+ lbuf[1] = *s++;
+ lbuf[2] = '\0';
+ }
+
+ int number = atoi(lbuf);
+
+ switch (number)
+ {
+ case 7 :
+ notes[index] = note_offset(notes[0], 10);
+ break;
+ case 9 :
+ notes[index] = note_offset(notes[0], 2);
+
+ // put the 7th in 2nd so it can be maj'ed if need be...
+ if ((mtype == NORMAL) || (mtype == MAJ))
+ {
+ index++;
+ notes[index] = note_offset(notes[0], 10);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+ }
+
+ break;
+ case 11 :
+ notes[index] = note_offset(notes[0], 5);
+
+ // put the 7th in 2nd so it can be maj'ed if need be...
+ if ((mtype == NORMAL) || (mtype == MAJ))
+ {
+ index++;
+ notes[index] = note_offset(notes[0], 10);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+ }
+
+ break;
+ case 13 :
+ notes[index] = note_offset(notes[0], 9);
+ index++;
+ notes[index] = note_offset(notes[0], 5);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+ index++;
+ notes[index] = note_offset(notes[0], 2);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+
+ // put the 7th in 2nd so it can be maj'ed if need be...
+ if ((mtype == NORMAL) || (mtype == MAJ))
+ {
+ index++;
+ notes[index] = note_offset(notes[0], 10);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+ }
+
+ break;
+ case 2:
+ notes[index] = note_offset(notes[0], 2);
+ break;
+ case 4:
+ notes[index] = note_offset(notes[0], 5);
+ break;
+ case 6:
+ notes[index] = note_offset(notes[0], 9);
+ break;
+ case 5:
+ notes[index] = note_offset(notes[0], 7);
+ break;
+ default:
+ sprintf(errorStr, "Cannot do number: %d\n", number);
+ return 1;
+ }
+
+ switch (mtype)
+ {
+ case DIM:
+ notes[index] = note_offset(notes[index], -1);
+ break;
+ case MAJ:
+ // It is a major, so not optional
+ optional[index] = 0;
+ case AUG :
+ notes[index] = note_offset(notes[index], 1);
+ break;
+ case NORMAL:
+ case ADD:
+ break;
+ default:
+ break;
+ }
+
+ index++;
+ }
+ return 0;
+}
+
+//
+// Print out chord by name
+//
+void
+Chord::print(char *cname)
+{
+ printf("Notes for chord '%s': ", cname);
+ for (int i = 0; i < 12; i++)
+ {
+ if (notes[i] != -1)
+ printf("%s ", strNotes[notes[i]]);
+ }
+ printf("\n\n");
+}
+
+//
+// Are all the notes in this chord covered by the notes in the
+// noteArray, it is not necessary to cover the notes in the optional
+// array of the chord
+//
+int
+Chord::covered(int *noteArray)
+{
+ // noteArray is an array of notes this chord has, it is NUM_STRINGS notes
+ // long (like a guitar fretboard dude...unused notes may be set
+ // to -1 (which wont compare since -1 is tossed...
+
+ for (int i = 0; i < 12; i++)
+ {
+ if (notes[i] != -1)
+ {
+ int gotIt = 0;
+ for (int j = 0; j < NUM_STRINGS; j++)
+ {
+ if (noteArray[j] == notes[i])
+ {
+ gotIt = 1;
+ break;
+ }
+ }
+ // If it was not found, and it is NOT optional, then it is
+ // not covered
+ if ((gotIt == 0) && (optional[i] == 0))
+ return 0;
+ }
+ }
+ return 1;
+}
+
+
+//
+// Is the given note in the chord
+//
+int
+Chord::inChord(int note)
+{
+ for (int i = 0; i < 12; i++)
+ {
+ // Check if we are off the end of the notes set
+ if (notes[i] == -1)
+ return 0;
+ // Check if the note was found
+ if (note == notes[i])
+ return 1;
+ }
+ // Did not find out, return 0
+ return 0;
+}
+
+//
+// Given a chord string, pick off the root (either C or C# or Cb)...and
+// return that integer value (A = 0)
+//
+int
+Chord::get_base(char *s)
+{
+
+ static int halfsteps[] = { 0, 2, 3, 5, 7, 8, 10 };
+
+ if ((*s < 'A') || (*s > 'G'))
+ return 0;
+
+ if (s[1] == '#')
+ return ( note_offset(halfsteps[s[0] - 'A'], 1));
+ else if (s[1] == 'B')
+ return ( note_offset(halfsteps[s[0] - 'A'], -1));
+ else
+ return ( halfsteps[s[0] - 'A']);
+}
+
+
+//
+// Print out the current fretboard
+//
+void
+Fretboard::print()
+{
+ printf("SCORE: %3d ", score[SCORE_TOTAL]);
+ printf(
+ " SPN: %2d TSPN: %2d OS: %2d ROOT: %2d LOW %2d ADJ %2d",
+ score[SCORE_SPAN], score[SCORE_TOTALSPAN], score[SCORE_OPENSTRINGS],
+ score[SCORE_FIRSTROOT], score[SCORE_LOWONNECK],
+ score[SCORE_ADJNOTES]);
+
+ printf(" FB: ");
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ if (fretboard[i] != -1)
+ printf(" %2d", fretboard[i]);
+ else
+ printf(" X");
+ }
+
+ printf(" NT: ");
+ for (int i = 0; i < NUM_STRINGS; i++)
+ if (notes[i] != -1)
+ printf(" %s", strNotes[notes[i]]);
+ else
+ printf(" X ");
+ printf("\n");
+}
+
+//
+// Construct a fretboard -- reset to the openStrings, clear the stack
+// and reset all the bestScores to -1
+//
+Fretboard::Fretboard()
+{
+ sDepth = 0;
+ score[0] = 0;
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ notes[i] = openStrings[i];
+ fretboard[i] = 0;
+ }
+ for (int i = 0; i < CHORDSTACK; i++)
+ {
+ bestScores[i][0] = -1;
+ }
+}
+
+//
+// Get the span of this chord, don't count open strings
+//
+int
+Fretboard::getSpan()
+{
+ int min = 100, max = 0;
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ // Dont count X strings or open strings
+ if (fretboard[i] <= 0)
+ continue;
+ if (fretboard[i] > max) max = fretboard[i];
+ if (fretboard[i] < min) min = fretboard[i];
+ }
+ if (min == 100)
+ // All open strings, took awhile to catch this bug
+ return 0;
+ else
+ return (max - min);
+}
+
+//
+// Get the span of this chord, DO count open strings
+//
+int
+Fretboard::getTotalSpan()
+{
+ int min = 100, max = 0;
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ // Dont count X strings
+ if (fretboard[i] < 0)
+ continue;
+ if (fretboard[i] > max) max = fretboard[i];
+ if (fretboard[i] < min) min = fretboard[i];
+ }
+ if (min == -1)
+ min = 0;
+ return (max - min);
+}
+
+//
+// Add this chord to the best (if there is room in the stack)
+//
+void
+Fretboard::addToBest()
+{
+ // CHORDSTACK is the sDepth of keepers...
+#ifdef DEBUG
+ printf("ATB: ");
+ this->print();
+#endif
+
+ int i;
+
+ // NOTE: at the start, bestScores is full of -1's, so any reall
+ // real score will be better (worst score is 0)
+ for (i = 0; i < sDepth; i++)
+ {
+ if (score[0] > bestScores[i][0])
+ break;
+ }
+
+ // If score was not better than any in the stack just return
+ if (i >= CHORDSTACK)
+ return ;
+ // MOve down old guys to make room for the new guy
+ for (int j = CHORDSTACK - 1; j >= i; j--)
+ {
+ for (int q = 0; q < NUM_STRINGS; q++)
+ {
+ bestFrets[j][q] = bestFrets[j - 1][q];
+ bestNotes[j][q] = bestNotes[j - 1][q];
+ }
+ for (int q = 0; q < NUMSCORETYPES; q++)
+ bestScores[j][q] = bestScores[j - 1][q];
+ }
+
+ for (int q = 0; q < NUM_STRINGS; q++)
+ {
+ bestFrets[i][q] = fretboard[q];
+ bestNotes[i][q] = notes[q];
+ }
+ for (int q = 0; q < NUMSCORETYPES; q++)
+ bestScores[i][q] = score[q];
+
+ sDepth++;
+ if (sDepth > CHORDSTACK)
+ sDepth--;
+}
+
+//
+// Print out the stack to the screen
+//
+void
+Fretboard::printStack()
+{
+ static char *strNotes[] = { "A ", "A#", "B ", "C ", "C#", "D ",
+ "D#", "E ", "F ", "F#", "G ", "G#" };
+
+
+ for (int f = 0; f < sDepth; f++)
+ {
+ printf("\n\n ");
+
+ if(lefty) {
+ for (int i = NUM_STRINGS - 1; i >= 0; i--)
+ if (bestNotes[f][i] != -1)
+ printf(" %s", strNotes[bestNotes[f][i]]);
+ else
+ printf(" X ");
+ }
+ else {
+ for (int i = 0; i < NUM_STRINGS; i++)
+ if (bestNotes[f][i] != -1)
+ printf(" %s", strNotes[bestNotes[f][i]]);
+ else
+ printf(" X ");
+ }
+ printf("\n");
+ if(lefty) {
+ for (int i = NUM_STRINGS - 1; i >= 0; i--)
+ if (bestFrets[f][i] != -1)
+ printf(" %2d", bestFrets[f][i]);
+ else
+ printf(" X");
+
+ }
+ else {
+ for (int i = 0; i < NUM_STRINGS; i++)
+
+ if (bestFrets[f][i] != -1)
+ printf(" %2d", bestFrets[f][i]);
+ else
+ printf(" X");
+ }
+
+ printf("\n\n");
+
+
+ int highest = 0;
+
+ for(int i = 0; i < NUM_STRINGS; i++)
+ if(bestFrets[f][i] > highest)
+ highest = bestFrets[f][i];
+
+ printf("\n");
+
+ for(int i = 0; i <= (highest + 1); i ++) {
+ if(lefty) {
+ for (int x = NUM_STRINGS-1; x >= 0; x--) {
+ if(i == 0) {
+ if(bestFrets[f][x] == -1)
+ printf(" X");
+ else
+ if(bestFrets[f][x] == 0)
+ printf(" 0");
+ else
+ printf(" ");
+ }
+ else {
+ if(bestFrets[f][x] == i)
+ printf(" *");
+ else
+ printf(" |");
+ }
+ }
+ }
+ else {
+
+ for (int x = 0; x < NUM_STRINGS; x++) {
+ if(i == 0) {
+ if(bestFrets[f][x] == -1)
+ printf(" X");
+ else
+ if(bestFrets[f][x] == 0)
+ printf(" 0");
+ else
+ printf(" ");
+ }
+ else {
+ if(bestFrets[f][x] == i)
+ printf(" *");
+ else
+ printf(" |");
+ }
+ }
+ }
+ printf("\n ---------------- %2d\n",i);
+
+
+
+
+ }
+ }
+}
+
+
+//
+// Get the score for this chord
+//
+void
+Fretboard::getScore(Chord &chord)
+{
+
+ // First, points for small span (excluding opens)
+ score[SCORE_SPAN] = (MAXSPAN - getSpan()) * SPAN_SCORE;
+
+ // Then, points for small total span
+ score[SCORE_TOTALSPAN] = (15 - getTotalSpan()) * 3;
+
+ score[SCORE_OPENSTRINGS] = 0;
+ // Points for open strings
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ if (fretboard[i] == 0)
+ {
+ score[SCORE_OPENSTRINGS] += OPENS_SCORE;
+ }
+ }
+
+ // Points for first string being the root ...
+ score[SCORE_FIRSTROOT] = 0;
+ int i;
+ for (i = 0; (fretboard[i] == -1) && (i < NUM_STRINGS) ; i++)
+ ;
+ if (notes[i] == chord.getRoot())
+ {
+ score[SCORE_FIRSTROOT] = ROOT_SCORE;
+ }
+
+ // Points for being low on the neck...
+ int sum = 0, cnt = 0;
+ for (i = 0; i < NUM_STRINGS; i++)
+ {
+ // Don't count X strings or open strings
+ if (fretboard[i] > 0)
+ {
+ sum += fretboard[i];
+ cnt++;
+ }
+ }
+ if (cnt)
+ score[SCORE_LOWONNECK] = (int)(15 - ((double) sum / (double) cnt))
+ * POSITION_SCORE;
+ else
+ score[SCORE_LOWONNECK] = 15 * POSITION_SCORE;
+
+
+ int adjNotes = 0;
+ for (i = 0; i < 5; i++)
+ {
+ if ((notes[i] != -1) && (notes[i] == notes[i + 1]))
+ adjNotes++;
+ }
+ score[SCORE_ADJNOTES] = (ADJ_SCORE * (5 - adjNotes));
+
+ // FInally, total up the score
+ score[SCORE_TOTAL] = 0;
+ for (i = 1; i < NUMSCORETYPES; i++)
+ score[SCORE_TOTAL] += score[i];
+}
+
+
+//
+// Iterate over all fretboard config's for this chord, call addToBest
+// with any good ones (ie: < span, etc etc...)
+//
+void
+Fretboard::iterate(Chord &chord)
+{
+ int string = 0;
+
+ // Start notes setup, increment up the neck for each string until
+ // you find a note that is in this chord (may be an open note)
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ while (! chord.inChord(notes[i]))
+ {
+ fretboard[i]++;
+ notes[i] = ( notes[i] + 1 ) % 12;
+ }
+ }
+
+ // Back up the first note one...so the loop will work
+ fretboard[0] = -1;
+
+ // While we are still on the fretboard!
+ while (string < NUM_STRINGS)
+ {
+
+ // increment the current string
+ fretboard[string]++;
+ if (fretboard[string] == 0)
+ notes[string] = openStrings[string];
+ else
+ notes[string] = ( notes[string] + 1 ) % 12;
+
+ while (! chord.inChord(notes[string]))
+ {
+ fretboard[string]++;
+ notes[string] = ( notes[string] + 1 ) % 12;
+ }
+
+ if (fretboard[string] > 15)
+ {
+
+ // Before turning over the 3rd string from the bass, try
+ // to make a chord with the bass string, and 2nd from
+ // bass string X'ed out...(ie: set to -1)
+ if (string == 0)
+ {
+
+ notes[0] = fretboard[0] = -1;
+ int span = getSpan();
+ if ((span < MAXSPAN) && chord.covered(notes))
+ {
+ getScore(chord);
+ addToBest();
+ }
+ }
+
+ if (string == 1)
+ {
+ int store = notes[0];
+ int fstore = fretboard[0];
+ notes[1] = fretboard[1] = -1;
+ notes[0] = fretboard[0] = -1;
+ int span = getSpan();
+ if ((span < MAXSPAN) && chord.covered(notes))
+ {
+ getScore(chord);
+ addToBest();
+ }
+ // Restore the notes you X'ed out
+ notes[0] = store;
+ fretboard[0] = fstore;
+ }
+
+ fretboard[string] = 0;
+ notes[string] = openStrings[string];
+ while (! chord.inChord(notes[string]))
+ {
+ fretboard[string]++;
+ notes[string] = chord.note_offset(notes[string], 1);
+ }
+ string++;
+ continue;
+ }
+
+#ifdef DEBUG
+ printf("TRY: "); this->print();
+#endif
+
+ string = 0;
+ int span = getSpan();
+ if (span >= MAXSPAN)
+ {
+#ifdef DEBUG
+ printf("Rejected for span\n");
+#endif
+ continue;
+ }
+ if (!chord.covered(notes))
+ {
+#ifdef DEBUG
+ printf("Rejected for coverage\n");
+#endif
+ continue;
+ }
+
+ getScore(chord);
+
+ addToBest();
+ }
+}
+
+//
+// uh, main
+//
+int main(int argc, char **argv)
+{
+ char buf[256], buf2[256];
+
+ if(argc > 1)
+ {
+ strcpy(buf, argv[1]);
+ if(argc > 3) {
+ if(! strcmp(argv[3],"lefty")) {
+ lefty = 1;
+
+ }
+
+
+ }
+
+ if(argc > 2) {
+ if(! strcmp(argv[2],"dadgad")) {
+ openStrings[0] = 5;
+ openStrings[1] = 0;
+ openStrings[2] = 5;
+ openStrings[3] = 10;
+ openStrings[4] = 0;
+ openStrings[5] = 5;
+ }
+ if(! strcmp(argv[2],"openg")) {
+ openStrings[0] = 5;
+ openStrings[1] = 10;
+ openStrings[2] = 5;
+ openStrings[3] = 10;
+ openStrings[4] = 2;
+ openStrings[5] = 5;
+
+ }
+ if(! strcmp(argv[2],"opene")) {
+ openStrings[0] = 7;
+ openStrings[1] = 2;
+ openStrings[2] = 7;
+ openStrings[3] = 11;
+ openStrings[4] = 2;
+ openStrings[5] = 7;
+
+ }
+ if(! strcmp(argv[2],"lefty")) {
+ lefty = 1;
+
+ }
+ }
+
+
+ // Allocate it for DOS/WINDOWS, to avoid stack overflow (weak)
+ Fretboard *fb = new Fretboard; ;
+ Chord chord;
+
+
+ // findChord upppercases the input string, so save a copy
+ strcpy(buf2, buf);
+
+ if (chord.findChord(buf))
+ {
+ chord.printError();
+
+ }
+ else {
+ chord.print(buf2);
+ fb->iterate(chord);
+
+ fb->printStack();
+ }
+ delete fb;
+ }
+ return 0;
+}
+
diff --git a/sources/addons/chords/chords.apd b/sources/addons/chords/chords.apd
new file mode 100644
index 00000000..2ab5b99d
--- /dev/null
+++ b/sources/addons/chords/chords.apd
@@ -0,0 +1,3 @@
+url: $baseurl/chords
+name: Guitar Chords
+photo: $baseurl/addon/chords/chords.png
diff --git a/sources/addons/chords/chords.php b/sources/addons/chords/chords.php
new file mode 100755
index 00000000..93bdbd94
--- /dev/null
+++ b/sources/addons/chords/chords.php
@@ -0,0 +1,129 @@
+
+ */
+
+
+function chords_load() {
+ register_hook('app_menu', 'addon/chords/chords.php', 'chords_app_menu');
+}
+
+function chords_unload() {
+ unregister_hook('app_menu', 'addon/chords/chords.php', 'chords_app_menu');
+
+}
+
+function chords_app_menu($a,&$b) {
+ $b['app_menu'][] = '
+This is a fairly comprehensive and complete guitar chord dictionary which will list most of the available ways to play a certain chord, starting from the base of the fingerboard up to a few frets beyond the twelfth fret (beyond which everything repeats). A couple of non-standard tunings are provided for the benefit of slide players, etc.
+
+
+Chord names start with a root note (A-G) and may include sharps (#) and flats (b). This software will parse most of the standard naming conventions such as maj, min, dim, sus(2 or 4), aug, with optional repeating elements.
+
+
+Valid examples include A, A7, Am7, Amaj7, Amaj9, Ammaj7, Aadd4, Asus2Add4, E7b13b11 ...
+
diff --git a/sources/addons/donate/donate.apd b/sources/addons/donate/donate.apd
new file mode 100644
index 00000000..eff602d3
--- /dev/null
+++ b/sources/addons/donate/donate.apd
@@ -0,0 +1,3 @@
+url: $baseurl/donate
+name: Support Hubzilla
+photo: $baseurl/addon/donate/donate.png
diff --git a/sources/addons/donate/donate.php b/sources/addons/donate/donate.php
new file mode 100644
index 00000000..1eb6d57d
--- /dev/null
+++ b/sources/addons/donate/donate.php
@@ -0,0 +1,75 @@
+' . t('The Redmatrix/Hubzilla projects are provided primarily by volunteers giving their time and expertise - and often paying out of pocket for services they share with others.') . '';
+$text .= '
' . t('There is no corporate funding and no ads, and we do not collect and sell your personal information. (We don\'t control your personal information - you do.)') . '
';
+$text .= '
' . t('Help support our ground-breaking work in decentralisation, web identity, and privacy.') . '
';
+
+$text .= '
' . t('Your donations keep servers and services running and also helps us to provide innovative new features and continued development.') . '
';
+
+$o = replace_macros(get_markup_template('donate.tpl','addon/donate'),array(
+ '$header' => t('Donate'),
+ '$text' => $text,
+ '$choice' => t('Choose a project, developer, or public hub to support with a one-time donation'),
+ '$onetime' => t('Donate Now'),
+ '$repeat' => t('Or become a project sponsor (Hubzilla Project only)'),
+ '$note' => t('Please indicate if you would like your first name or full name (or nothing) to appear in our sponsor listing'),
+ '$subscribe' => t('Sponsor'),
+ '$contributors' => $contributors,
+ '$sponsors' => $sponsors,
+ '$thanks' => t('Special thanks to: '),
+));
+
+call_hooks('donate_plugin',$o);
+
+return $o;
+
+}
diff --git a/sources/addons/donate/donate.png b/sources/addons/donate/donate.png
new file mode 100644
index 00000000..d932f001
Binary files /dev/null and b/sources/addons/donate/donate.png differ
diff --git a/sources/addons/donate/tipping.jpg b/sources/addons/donate/tipping.jpg
new file mode 100644
index 00000000..f370ece7
Binary files /dev/null and b/sources/addons/donate/tipping.jpg differ
diff --git a/sources/addons/donate/view/tpl/donate.tpl b/sources/addons/donate/view/tpl/donate.tpl
new file mode 100644
index 00000000..6382cc6f
--- /dev/null
+++ b/sources/addons/donate/view/tpl/donate.tpl
@@ -0,0 +1,64 @@
+
'
+ );
+
+ // Click event: chat cleaner
+ $(path + 'tools-clear').click(function() {
+ cleanChat(id);
+ });
+
+ // Click event: user-infos
+ $(path + 'tools-infos').click(function() {
+ openUserInfos(xid);
+ });
+}
+
+// Generates the chat switch elements
+function generateSwitch(type, id, xid, nick) {
+ // Path to the element
+ var chat_switch = '#page-switch .';
+
+ // Special code
+ var specialClass = ' unavailable';
+ var show_close = true;
+
+ // Groupchat
+ if(type == 'groupchat') {
+ specialClass = ' groupchat-default';
+
+ if(isAnonymous() && (xid == 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);
+}
+
+// Cleans given the chat lines
+function cleanChat(chat) {
+ $('#page-engine #' + chat + ' .content .one-group').remove();
+
+ $(document).oneTime(10, function() {
+ $('#page-engine #' + chat + ' .text .message-area').focus();
+ });
+}
+
+// Creates a new chat
+function chatCreate(hash, xid, nick, type) {
+ logThis('New chat: ' + xid, 3);
+
+ // Create the chat content
+ generateChat(type, hash, xid, nick);
+
+ // Create the chat switcher
+ generateSwitch(type, hash, xid, nick);
+
+ // If the user is not in our buddy-list
+ if(type == 'chat') {
+ // Add button
+ if(!exists('#buddy-list .buddy[data-xid=' + escape(xid) + ']'))
+ $('#' + hash + ' .tools-add').click(function() {
+ // Hide the icon (to tell the user all is okay)
+ $(this).hide();
+
+ // Send the subscribe request
+ addThisContact(xid, nick);
+ }).show();
+
+ // Archives button
+ else if(enabledArchives() || enabledArchives('auto') || enabledArchives('manual') || enabledArchives('manage'))
+ $('#' + hash + ' .tools-archives').click(function() {
+ // Open the archives popup
+ openArchives();
+
+ // Get the archives for this user
+ $('#archives .filter .friend').val(xid);
+ updateArchives();
+ }).show();
+ }
+
+ // We catch the user's informations (like this avatar, vcard, and so on...)
+ getUserInfos(hash, xid, nick, type);
+
+ // The icons-hover functions
+ tooltipIcons(xid, hash);
+
+ // The event handlers
+ var inputDetect = $('#page-engine #' + hash + ' .message-area');
+
+ inputDetect.focus(function() {
+ chanCleanNotify(hash);
+ })
+
+ inputDetect.keypress(function(e) {
+ // Enter key
+ if(e.keyCode == 13) {
+ // Add a new line
+ if(e.shiftKey)
+ inputDetect.val(inputDetect.val() + '\n');
+
+ // Send the message
+ else {
+ // Send the message
+ sendMessage(hash, 'chat');
+
+ // Reset the composing database entry
+ setDB('chatstate', xid, 'off');
+ }
+
+ return false;
+ }
+ });
+
+ // Chatstate events
+ eventsChatState(inputDetect, xid, hash);
+}
diff --git a/sources/addons/jappixmini/jappix/js/chatstate.js b/sources/addons/jappixmini/jappix/js/chatstate.js
new file mode 100644
index 00000000..de7e7966
--- /dev/null
+++ b/sources/addons/jappixmini/jappix/js/chatstate.js
@@ -0,0 +1,174 @@
+/*
+
+Jappix - An open social platform
+These are the chatstate JS script for Jappix
+
+-------------------------------------------------
+
+License: AGPL
+Author: Vanaryon
+Last revision: 25/08/11
+
+*/
+
+// Sends a given chatstate to a given entity
+function chatStateSend(state, xid, hash) {
+ 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') && !exists('#page-switch .' + hash + ' .unavailable'))) {
+ // Already sent?
+ if(getDB('currentchatstate', xid) == state)
+ return;
+
+ // Write the state
+ setDB('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);
+ }
+}
+
+// Displays a given chatstate in a given chat
+function displayChatState(state, hash, type) {
+ // Groupchat?
+ if(type == 'groupchat') {
+ resetChatState(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
+ resetChatState(hash, type);
+ $('#page-switch .' + hash + ' .name').addClass(state);
+
+ // We generate the chatstate text
+ var text = '';
+
+ switch(state) {
+ // Active
+ case 'active':
+ text = _e("Your friend is paying attention to the conversation.");
+
+ break;
+
+ // Composing
+ case 'composing':
+ text = _e("Your friend is writing a message...");
+
+ break;
+
+ // Paused
+ case 'paused':
+ text = _e("Your friend stopped writing a message.");
+
+ break;
+
+ // Inactive
+ case 'inactive':
+ text = _e("Your friend is doing something else.");
+
+ break;
+
+ // Gone
+ case 'gone':
+ text = _e("Your friend closed the chat.");
+
+ break;
+ }
+
+ // We reset the previous state
+ $('#' + hash + ' .chatstate').remove();
+
+ // We create the chatstate
+ $('#' + hash + ' .content').after('
' + text + '
');
+ }
+}
+
+// Resets the chatstate switcher marker
+function resetChatState(hash, type) {
+ // 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')
+ selector.removeClass('composing')
+ selector.removeClass('paused')
+ selector.removeClass('inactive')
+ selector.removeClass('gone');
+}
+
+// Adds the chatstate events
+function eventsChatState(target, xid, hash) {
+ target.keyup(function(e) {
+ if(e.keyCode != 13) {
+ // Composing a message
+ if($(this).val() && (getDB('chatstate', xid) != 'on')) {
+ // We change the state detect input
+ setDB('chatstate', xid, 'on');
+
+ // We send the friend a "composing" chatstate
+ chatStateSend('composing', xid, hash);
+ }
+
+ // Stopped composing a message
+ else if(!$(this).val() && (getDB('chatstate', xid) == 'on')) {
+ // We change the state detect input
+ setDB('chatstate', xid, 'off');
+
+ // We send the friend an "active" chatstate
+ chatStateSend('active', xid, hash);
+ }
+ }
+ });
+
+ target.change(function() {
+ // Reset the composing database entry
+ setDB('chatstate', xid, 'off');
+ });
+
+ target.focus(function() {
+ // Not needed
+ if(target.is(':disabled'))
+ return;
+
+ // Nothing in the input, user is active
+ if(!$(this).val())
+ chatStateSend('active', xid, hash);
+
+ // Something was written, user started writing again
+ else
+ chatStateSend('composing', xid, hash);
+ });
+
+ target.blur(function() {
+ // Not needed
+ if(target.is(':disabled'))
+ return;
+
+ // Nothing in the input, user is inactive
+ if(!$(this).val())
+ chatStateSend('inactive', xid, hash);
+
+ // Something was written, user paused
+ else
+ chatStateSend('paused', xid, hash);
+ });
+}
diff --git a/sources/addons/jappixmini/jappix/js/common.js b/sources/addons/jappixmini/jappix/js/common.js
new file mode 100644
index 00000000..ab10d6e7
--- /dev/null
+++ b/sources/addons/jappixmini/jappix/js/common.js
@@ -0,0 +1,311 @@
+/*
+
+Jappix - An open social platform
+These are the common JS script for Jappix
+
+-------------------------------------------------
+
+License: AGPL
+Authors: Vanaryon, olivierm
+Last revision: 24/06/11
+
+*/
+
+// Checks if an element exists in the DOM
+function exists(selector) {
+ if(jQuery(selector).size() > 0)
+ return true;
+ else
+ return false;
+}
+
+// Checks if Jappix is connected
+function isConnected() {
+ if((typeof con != 'undefined') && con && con.connected())
+ return true;
+
+ return false;
+}
+
+// Checks if Jappix has focus
+function isFocused() {
+ try {
+ if(document.hasFocus())
+ return true;
+
+ return false;
+ }
+
+ catch(e) {
+ return true;
+ }
+}
+
+// Generates the good XID
+function generateXID(xid, type) {
+ // XID needs to be transformed
+ if(xid && (xid.indexOf('@') == -1)) {
+ // Groupchat
+ if(type == 'groupchat')
+ return xid + '@' + HOST_MUC;
+
+ // One-to-one chat
+ if(xid.indexOf('.') == -1)
+ return xid + '@' + HOST_MAIN;
+
+ // It might be a gateway?
+ return xid;
+ }
+
+ // Nothing special (yet bare XID)
+ return xid;
+}
+
+// Gets the asked translated string
+function _e(string) {
+ return string;
+}
+
+// Replaces '%s' to a given value for a translated string
+function printf(string, value) {
+ return string.replace('%s', value);
+}
+
+// Properly explodes a string with a given character
+function explodeThis(toEx, toStr, i) {
+ // 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;
+}
+
+// Cuts the resource of a XID
+function cutResource(aXID) {
+ return explodeThis('/', aXID, 0);
+}
+
+// Gets the resource of a XID
+function thisResource(aXID) {
+ // Any resource?
+ if(aXID.indexOf('/') != -1)
+ return explodeThis('/', aXID, 1);
+
+ // No resource
+ return '';
+}
+
+// Does stringprep on a string
+function stringPrep(string) {
+ // Replacement arrays
+ var invalid = new Array('Š', 'š', 'Đ', 'đ', 'Ž', 'ž', 'Č', 'č', 'Ć', 'ć', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ý', 'þ', 'ÿ', 'Ŕ', 'ŕ');
+
+ var valid = new Array('S', 's', 'Dj', 'dj', 'Z', 'z', 'C', 'c', 'C', 'c', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'B', 'Ss', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'o', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'y', 'b', 'y', 'R', 'r');
+
+ // Compute a new string
+ for(i in invalid)
+ string = string.replace(invalid[i], valid[i]);
+
+ return string;
+}
+
+// Encodes quotes in a string
+function encodeQuotes(str) {
+ return (str + '').replace(/"/g, '"');
+}
+
+// Gets the bare XID from a XID
+function bareXID(xid) {
+ // Cut the resource
+ xid = cutResource(xid);
+
+ // Launch the stringprep
+ xid = stringPrep(xid);
+
+ // Set the XID to lower case
+ xid = xid.toLowerCase();
+
+ return xid;
+}
+
+// Gets the full XID from a XID
+function fullXID(xid) {
+ // Normalizes the XID
+ var full = bareXID(xid);
+ var resource = thisResource(xid);
+
+ // Any resource?
+ if(resource)
+ full += '/' + resource;
+
+ return full;
+}
+
+// Gets the nick from a XID
+function getXIDNick(aXID) {
+ return explodeThis('@', aXID, 0);
+}
+
+// Gets the host from a XID
+function getXIDHost(aXID) {
+ return explodeThis('@', aXID, 1);
+}
+
+// Checks if we are in developer mode
+function isDeveloper() {
+ if(DEVELOPER == 'on')
+ return true;
+
+ return false;
+}
+
+// Checks if anonymous mode is allowed
+function allowedAnonymous() {
+ if(ANONYMOUS == 'on')
+ return true;
+
+ return false;
+}
+
+// Checks if host is locked
+function lockHost() {
+ if(LOCK_HOST == 'on')
+ return true;
+
+ return false;
+}
+
+// Gets the full XID of the user
+function getXID() {
+ // Return the XID of the user
+ if(con.username && con.domain)
+ return con.username + '@' + con.domain;
+
+ return '';
+}
+
+// Generates the colors for a given user XID
+function generateColor(xid) {
+ 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;
+}
+
+// Checks if the XID is a gateway
+function isGateway(xid) {
+ if(xid.indexOf('@') != -1)
+ return false;
+
+ return true;
+}
+
+// Gets the from attribute of a stanza (overrides some servers like Prosody missing from attributes)
+function getStanzaFrom(stanza) {
+ var from = stanza.getFrom();
+
+ // No from, we assume this is our XID
+ if(!from)
+ from = getXID();
+
+ return from;
+}
+
+// Logs a given data in the console
+function logThis(data, level) {
+ // Console not available
+ if(!isDeveloper() || (typeof(console) == 'undefined'))
+ return false;
+
+ // Switch the log level
+ switch(level) {
+ // Debug
+ case 0:
+ console.debug(data);
+
+ break;
+
+ // Error
+ case 1:
+ console.error(data);
+
+ break;
+
+ // Warning
+ case 2:
+ console.warn(data);
+
+ break;
+
+ // Information
+ case 3:
+ console.info(data);
+
+ break;
+
+ // Default log level
+ default:
+ console.log(data);
+
+ break;
+ }
+
+ return true;
+}
+
+// Gets the current Jappix app. location
+function getJappixLocation() {
+ var url = window.location.href;
+
+ // If the URL has variables, remove them
+ if(url.indexOf('?') != -1)
+ url = url.split('?')[0];
+ if(url.indexOf('#') != -1)
+ url = url.split('#')[0];
+
+ // No "/" at the end
+ if(!url.match(/(.+)\/$/))
+ url += '/';
+
+ return url;
+}
+
+// Removes spaces at the beginning & the end of a string
+function trim(str) {
+ return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
+}
+
+// Adds a zero to a date when needed
+function padZero(i) {
+ // 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;
+}
diff --git a/sources/addons/jappixmini/jappix/js/connection.js b/sources/addons/jappixmini/jappix/js/connection.js
new file mode 100644
index 00000000..85a718c5
--- /dev/null
+++ b/sources/addons/jappixmini/jappix/js/connection.js
@@ -0,0 +1,526 @@
+/*
+
+Jappix - An open social platform
+These are the connection JS script for Jappix
+
+-------------------------------------------------
+
+License: AGPL
+Author: Vanaryon
+Last revision: 29/08/11
+
+*/
+
+// Does the user login
+var CURRENT_SESSION = false;
+
+function doLogin(lNick, lServer, lPass, lResource, lPriority, lRemember) {
+ try {
+ // We remove the not completed class to avoid problems
+ $('#home .loginer input').removeClass('please-complete');
+
+ // We add the login wait div
+ showGeneralWait();
+
+ // We define the http binding parameters
+ oArgs = new Object();
+
+ if(HOST_BOSH_MAIN)
+ oArgs.httpbase = HOST_BOSH_MAIN;
+ else
+ oArgs.httpbase = HOST_BOSH;
+
+ // We create the new http-binding connection
+ con = new JSJaCHttpBindingConnection(oArgs);
+
+ // And we handle everything that happen
+ setupCon(con);
+
+ // Generate a resource
+ var random_resource = getDB('session', 'resource');
+
+ if(!random_resource)
+ random_resource = lResource + ' (' + (new Date()).getTime() + ')';
+
+ // We retrieve what the user typed in the login inputs
+ oArgs = new Object();
+ oArgs.domain = trim(lServer);
+ oArgs.username = trim(lNick);
+ oArgs.resource = random_resource;
+ oArgs.pass = lPass;
+ oArgs.secure = true;
+ oArgs.xmllang = XML_LANG;
+
+ // Store the resource (for reconnection)
+ setDB('session', 'resource', random_resource);
+
+ // 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)
+ CURRENT_SESSION = session_xml;
+
+ // Remember me?
+ if(lRemember)
+ setDB('remember', 'session', 1);
+
+ // We store the infos of the user into the data-base
+ setDB('priority', 1, lPriority);
+
+ // We connect !
+ con.connect(oArgs);
+
+ // Change the page title
+ pageTitle('wait');
+
+ logThis('Jappix is connecting...', 3);
+ }
+
+ catch(e) {
+ // Logs errors
+ logThis('Error while logging in: ' + e, 1);
+
+ // Reset Jappix
+ destroyTalkPage();
+
+ // Open an unknown error
+ openThisError(2);
+ }
+
+ finally {
+ return false;
+ }
+}
+
+// Handles the user registration
+function handleRegistered() {
+ logThis('A new account has been registered.', 3);
+
+ // We remove the waiting image
+ removeGeneralWait();
+
+ // Reset the title
+ pageTitle('home');
+
+ // We show the success information
+ $('#home .registerer .success').fadeIn('fast');
+
+ // We quit the session
+ logout();
+}
+
+// Does the user registration
+function doRegister(username, domain, pass) {
+ logThis('Trying to register an account...', 3);
+
+ try {
+ // We define the http binding parameters
+ oArgs = new Object();
+
+ if(HOST_BOSH_MAIN)
+ oArgs.httpbase = HOST_BOSH_MAIN;
+ else
+ oArgs.httpbase = HOST_BOSH;
+
+ // We create the new http-binding connection
+ con = new JSJaCHttpBindingConnection(oArgs);
+
+ // We setup the connection !
+ con.registerHandler('onconnect', handleRegistered);
+ con.registerHandler('onerror', handleError);
+
+ // We retrieve what the user typed in the register inputs
+ oArgs = new Object();
+ oArgs.domain = trim(domain);
+ oArgs.username = trim(username);
+ oArgs.resource = JAPPIX_RESOURCE + ' Register (' + (new Date()).getTime() + ')';
+ oArgs.pass = pass;
+ oArgs.register = true;
+ oArgs.secure = true;
+ oArgs.xmllang = XML_LANG;
+
+ con.connect(oArgs);
+
+ // We change the registered information text
+ $('#home .homediv.registerer').append(
+ '
' +
+ _e("You have been registered, here is your XMPP address:") + ' ' + con.username.htmlEnc() + '@' + con.domain.htmlEnc() + ' - ' + _e("Login") + '' +
+ '
'
+ );
+
+ // Login link
+ $('#home .homediv.registerer .success a').click(function() {
+ return doLogin(con.username, con.domain, con.pass, con.resource, '10', false);
+ });
+
+ // Show the waiting image
+ showGeneralWait();
+
+ // Change the page title
+ pageTitle('wait');
+ }
+
+ catch(e) {
+ // Logs errors
+ logThis(e, 1);
+ }
+
+ finally {
+ return false;
+ }
+}
+
+// Does the user anonymous login
+function doAnonymous() {
+ logThis('Trying to login anonymously...', 3);
+
+ var aPath = '#home .anonymouser ';
+ var room = $(aPath + '.room').val();
+ var nick = $(aPath + '.nick').val();
+
+ // If the form is 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;
+ }
+
+ // We check if the form is entirely completed
+ else {
+ $(aPath + 'input[type=text]').each(function() {
+ var select = $(this);
+
+ if(!select.val())
+ $(document).oneTime(10, function() {
+ select.addClass('please-complete').focus();
+ });
+ else
+ select.removeClass('please-complete');
+ });
+ }
+
+ return false;
+}
+
+// Handles the user connected event
+var CONNECTED = false;
+
+function handleConnected() {
+ logThis('Jappix is now connected.', 3);
+
+ // Connection markers
+ CONNECTED = true;
+ RECONNECT_TRY = 0;
+ RECONNECT_TIMER = 0;
+
+ // We hide the home page
+ $('#home').hide();
+
+ // Not resumed?
+ if(!RESUME) {
+ // Remember the session?
+ if(getDB('remember', 'session'))
+ setPersistent('session', 1, CURRENT_SESSION);
+
+ // We show the chatting app.
+ createTalkPage();
+
+ // We reset the homepage
+ switchHome('default');
+
+ // We get all the other things
+ getEverything();
+
+ // Set last activity stamp
+ LAST_ACTIVITY = getTimeStamp();
+ }
+
+ // Resumed
+ else {
+ // Send our presence
+ presenceSend();
+
+ // Change the title
+ updateTitle();
+ }
+
+ // Remove the waiting item
+ removeGeneralWait();
+}
+
+// Handles the user disconnected event
+function handleDisconnected() {
+ logThis('Jappix is now disconnected.', 3);
+
+ // Normal disconnection
+ if(!CURRENT_SESSION && !CONNECTED)
+ destroyTalkPage();
+}
+
+// Setups the normal connection
+function setupCon(con) {
+ // We setup all the necessary handlers for the connection
+ con.registerHandler('message', handleMessage);
+ con.registerHandler('presence', handlePresence);
+ con.registerHandler('iq', handleIQ);
+ con.registerHandler('onconnect', handleConnected);
+ con.registerHandler('onerror', handleError);
+ con.registerHandler('ondisconnect', handleDisconnected);
+}
+
+// Logouts from the server
+function logout() {
+ // We are not connected
+ if(!isConnected())
+ return false;
+
+ // Disconnect from the XMPP server
+ con.disconnect();
+
+ logThis('Jappix is disconnecting...', 3);
+}
+
+// Terminates a session
+function terminate() {
+ if(!isConnected())
+ return;
+
+ // Clear temporary session storage
+ resetConMarkers();
+
+ // Show the waiting item (useful if BOSH is sloooow)
+ showGeneralWait();
+
+ // Change the page title
+ pageTitle('wait');
+
+ // Disconnect from the XMPP server
+ logout();
+}
+
+// Quitss a session
+function quit() {
+ if(!isConnected())
+ return;
+
+ // We show the waiting image
+ showGeneralWait();
+
+ // Change the page title
+ pageTitle('wait');
+
+ // We disconnect from the XMPP server
+ logout();
+}
+
+// Creates the reconnect pane
+var RECONNECT_TRY = 0;
+var RECONNECT_TIMER = 0;
+
+function createReconnect(mode) {
+ logThis('This is not a normal disconnection, show the reconnect pane...', 1);
+
+ // Reconnect pane not yet displayed?
+ if(!exists('#reconnect')) {
+ // Blur the focused input/textarea/select
+ $('input, select, textarea').blur();
+
+ // Create the HTML code
+ var html = '
' +
+ '
' +
+ _e("Due to a network issue, you were disconnected. What do you want to do now?");
+
+ // Can we cancel reconnection?
+ if(mode == 'normal')
+ html += '' + _e("Cancel") + '';
+
+ html += '' + _e("Reconnect") + '' +
+ '
'
+ );
+ });
+ }
+
+ 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(!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(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 +
+ '
'
+ );
+ }
+ });
+
+ return false;
+}
+
+// Gets the dataform type
+function getDataFormType(host, node, id) {
+ 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, handleThisBrowse);
+}
+
+// Handles the browse stanza
+function handleThisBrowse(iq) {
+ /* REF: http://xmpp.org/registrar/disco-categories.html */
+
+ var id = iq.getID();
+ var splitted = id.split('-');
+ var target = splitted[0];
+ var sessionID = target + '-' + splitted[1];
+ var from = fullXID(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(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(_e("Search"), _e("Join"), _e("Subscribe"), _e("Command"), _e("Browse"));
+
+ for(i in buttons) {
+ if(buttons[i])
+ 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(
+ '
',
+ ''
+ ]
+ },
+ defaults = {
+ flat: false,
+ starts: 1,
+ prev: '◀',
+ next: '▶',
+ lastSel: false,
+ mode: 'single',
+ view: 'days',
+ calendars: 1,
+ format: 'Y-m-d',
+ position: 'bottom',
+ eventName: 'click',
+ onRender: function(){return {};},
+ onChange: function(){return true;},
+ onShow: function(){return true;},
+ onBeforeShow: function(){return true;},
+ onHide: function(){return true;},
+ locale: {
+ days: [_e("Sunday"), _e("Monday"), _e("Tuesday"), _e("Wednesday"), _e("Thursday"), _e("Friday"), _e("Saturday"), _e("Sunday")],
+ daysShort: [cut(_e("Sunday"), 3), cut(_e("Monday"), 3), cut(_e("Tuesday"), 3), cut(_e("Wednesday"), 3), cut(_e("Thursday"), 3), cut(_e("Friday"), 3), cut(_e("Saturday"), 3), cut(_e("Sunday"), 3)],
+ daysMin: [cut(_e("Sunday"), 2), cut(_e("Monday"), 2), cut(_e("Tuesday"), 2), cut(_e("Wednesday"), 2), cut(_e("Thursday"), 2), cut(_e("Friday"), 2), cut(_e("Saturday"), 2), cut(_e("Sunday"), 2)],
+ months: [_e("January"), _e("February"), _e("March"), _e("April"), _e("May"), _e("June"), _e("July"), _e("August"), _e("September"), _e("October"), _e("November"), _e("December")],
+ monthsShort: [cut(_e("January"), 3), cut(_e("February"), 3), cut(_e("March"), 3), cut(_e("April"), 3), cut(_e("May"), 3), cut(_e("June"), 3), cut(_e("July"), 3), cut(_e("August"), 3), cut(_e("September"), 3), cut(_e("October"), 3), cut(_e("November"), 3), cut(_e("December"), 3)],
+ weekMin: ''
+ }
+ },
+ fill = function(el) {
+ var options = $(el).data('datepicker');
+ var cal = $(el);
+ var currentCal = Math.floor(options.calendars/2), date, data, dow, month, cnt = 0, week, days, indic, indic2, html, tblCal;
+ cal.find('td>table tbody').remove();
+ for (var i = 0; i < options.calendars; i++) {
+ date = new Date(options.current);
+ date.addMonths(-currentCal + i);
+ tblCal = cal.find('table').eq(i+1);
+ switch (tblCal[0].className) {
+ case 'datepickerViewDays':
+ dow = formatDate(date, 'B, Y');
+ break;
+ case 'datepickerViewMonths':
+ dow = date.getFullYear();
+ break;
+ case 'datepickerViewYears':
+ dow = (date.getFullYear()-6) + ' - ' + (date.getFullYear()+5);
+ break;
+ }
+ tblCal.find('thead tr:first th:eq(1) span').text(dow);
+ dow = date.getFullYear()-6;
+ data = {
+ data: [],
+ className: 'datepickerYears'
+ }
+ for ( var j = 0; j < 12; j++) {
+ data.data.push(dow + j);
+ }
+ html = tmpl(tpl.months.join(''), data);
+ date.setDate(1);
+ data = {weeks:[], test: 10};
+ month = date.getMonth();
+ var dow = (date.getDay() - options.starts) % 7;
+ date.addDays(-(dow + (dow < 0 ? 7 : 0)));
+ week = -1;
+ cnt = 0;
+ while (cnt < 42) {
+ indic = parseInt(cnt/7,10);
+ indic2 = cnt%7;
+ if (!data.weeks[indic]) {
+ week = date.getWeekNumber();
+ data.weeks[indic] = {
+ week: week,
+ days: []
+ };
+ }
+ data.weeks[indic].days[indic2] = {
+ text: date.getDate(),
+ classname: []
+ };
+ if (month != date.getMonth()) {
+ data.weeks[indic].days[indic2].classname.push('datepickerNotInMonth');
+ }
+ if (date.getDay() == 0) {
+ data.weeks[indic].days[indic2].classname.push('datepickerSunday');
+ }
+ if (date.getDay() == 6) {
+ data.weeks[indic].days[indic2].classname.push('datepickerSaturday');
+ }
+ var fromUser = options.onRender(date);
+ var val = date.valueOf();
+ if (fromUser.selected || options.date == val || $.inArray(val, options.date) > -1 || (options.mode == 'range' && val >= options.date[0] && val <= options.date[1])) {
+ data.weeks[indic].days[indic2].classname.push('datepickerSelected');
+ }
+ if (fromUser.disabled) {
+ data.weeks[indic].days[indic2].classname.push('datepickerDisabled');
+ }
+ if (fromUser.className) {
+ data.weeks[indic].days[indic2].classname.push(fromUser.className);
+ }
+ data.weeks[indic].days[indic2].classname = data.weeks[indic].days[indic2].classname.join(' ');
+ cnt++;
+ date.addDays(1);
+ }
+ html = tmpl(tpl.days.join(''), data) + html;
+ data = {
+ data: options.locale.monthsShort,
+ className: 'datepickerMonths'
+ };
+ html = tmpl(tpl.months.join(''), data) + html;
+ tblCal.append(html);
+ }
+ },
+ parseDate = function (date, format) {
+ if (date.constructor == Date) {
+ return new Date(date);
+ }
+ var parts = date.split(/\W+/);
+ var against = format.split(/\W+/), d, m, y, h, min, now = new Date();
+ for (var i = 0; i < parts.length; i++) {
+ switch (against[i]) {
+ case 'd':
+ case 'e':
+ d = parseInt(parts[i],10);
+ break;
+ case 'm':
+ m = parseInt(parts[i], 10)-1;
+ break;
+ case 'Y':
+ case 'y':
+ y = parseInt(parts[i], 10);
+ y += y > 100 ? 0 : (y < 29 ? 2000 : 1900);
+ break;
+ case 'H':
+ case 'I':
+ case 'k':
+ case 'l':
+ h = parseInt(parts[i], 10);
+ break;
+ case 'P':
+ case 'p':
+ if (/pm/i.test(parts[i]) && h < 12) {
+ h += 12;
+ } else if (/am/i.test(parts[i]) && h >= 12) {
+ h -= 12;
+ }
+ break;
+ case 'M':
+ min = parseInt(parts[i], 10);
+ break;
+ }
+ }
+ return new Date(
+ y === undefined ? now.getFullYear() : y,
+ m === undefined ? now.getMonth() : m,
+ d === undefined ? now.getDate() : d,
+ h === undefined ? now.getHours() : h,
+ min === undefined ? now.getMinutes() : min,
+ 0
+ );
+ },
+ formatDate = function(date, format) {
+ var m = date.getMonth();
+ var d = date.getDate();
+ var y = date.getFullYear();
+ var wn = date.getWeekNumber();
+ var w = date.getDay();
+ var s = {};
+ var hr = date.getHours();
+ var pm = (hr >= 12);
+ var ir = (pm) ? (hr - 12) : hr;
+ var dy = date.getDayOfYear();
+ if (ir == 0) {
+ ir = 12;
+ }
+ var min = date.getMinutes();
+ var sec = date.getSeconds();
+ var parts = format.split(''), part;
+ for ( var i = 0; i < parts.length; i++ ) {
+ part = parts[i];
+ switch (parts[i]) {
+ case 'a':
+ part = date.getDayName();
+ break;
+ case 'A':
+ part = date.getDayName(true);
+ break;
+ case 'b':
+ part = date.getMonthName();
+ break;
+ case 'B':
+ part = date.getMonthName(true);
+ break;
+ case 'C':
+ part = 1 + Math.floor(y / 100);
+ break;
+ case 'd':
+ part = (d < 10) ? ("0" + d) : d;
+ break;
+ case 'e':
+ part = d;
+ break;
+ case 'H':
+ part = (hr < 10) ? ("0" + hr) : hr;
+ break;
+ case 'I':
+ part = (ir < 10) ? ("0" + ir) : ir;
+ break;
+ case 'j':
+ part = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy;
+ break;
+ case 'k':
+ part = hr;
+ break;
+ case 'l':
+ part = ir;
+ break;
+ case 'm':
+ part = (m < 9) ? ("0" + (1+m)) : (1+m);
+ break;
+ case 'M':
+ part = (min < 10) ? ("0" + min) : min;
+ break;
+ case 'p':
+ case 'P':
+ part = pm ? "PM" : "AM";
+ break;
+ case 's':
+ part = Math.floor(date.getTime() / 1000);
+ break;
+ case 'S':
+ part = (sec < 10) ? ("0" + sec) : sec;
+ break;
+ case 'u':
+ part = w + 1;
+ break;
+ case 'w':
+ part = w;
+ break;
+ case 'y':
+ part = ('' + y).substr(2, 2);
+ break;
+ case 'Y':
+ part = y;
+ break;
+ }
+ parts[i] = part;
+ }
+ return parts.join('');
+ },
+ extendDate = function(options) {
+ if (Date.prototype.tempDate) {
+ return;
+ }
+ Date.prototype.tempDate = null;
+ Date.prototype.months = options.months;
+ Date.prototype.monthsShort = options.monthsShort;
+ Date.prototype.days = options.days;
+ Date.prototype.daysShort = options.daysShort;
+ Date.prototype.getMonthName = function(fullName) {
+ return this[fullName ? 'months' : 'monthsShort'][this.getMonth()];
+ };
+ Date.prototype.getDayName = function(fullName) {
+ return this[fullName ? 'days' : 'daysShort'][this.getDay()];
+ };
+ Date.prototype.addDays = function (n) {
+ this.setDate(this.getDate() + n);
+ this.tempDate = this.getDate();
+ };
+ Date.prototype.addMonths = function (n) {
+ if (this.tempDate == null) {
+ this.tempDate = this.getDate();
+ }
+ this.setDate(1);
+ this.setMonth(this.getMonth() + n);
+ this.setDate(Math.min(this.tempDate, this.getMaxDays()));
+ };
+ Date.prototype.addYears = function (n) {
+ if (this.tempDate == null) {
+ this.tempDate = this.getDate();
+ }
+ this.setDate(1);
+ this.setFullYear(this.getFullYear() + n);
+ this.setDate(Math.min(this.tempDate, this.getMaxDays()));
+ };
+ Date.prototype.getMaxDays = function() {
+ var tmpDate = new Date(Date.parse(this)),
+ d = 28, m;
+ m = tmpDate.getMonth();
+ d = 28;
+ while (tmpDate.getMonth() == m) {
+ d ++;
+ tmpDate.setDate(d);
+ }
+ return d - 1;
+ };
+ Date.prototype.getFirstDay = function() {
+ var tmpDate = new Date(Date.parse(this));
+ tmpDate.setDate(1);
+ return tmpDate.getDay();
+ };
+ Date.prototype.getWeekNumber = function() {
+ var tempDate = new Date(this);
+ tempDate.setDate(tempDate.getDate() - (tempDate.getDay() + 6) % 7 + 3);
+ var dms = tempDate.valueOf();
+ tempDate.setMonth(0);
+ tempDate.setDate(4);
+ return Math.round((dms - tempDate.valueOf()) / (604800000)) + 1;
+ };
+ Date.prototype.getDayOfYear = function() {
+ var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
+ var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
+ var time = now - then;
+ return Math.floor(time / 24*60*60*1000);
+ };
+ },
+ layout = function (el) {
+ var options = $(el).data('datepicker');
+ var cal = $('#' + options.id);
+ if (!options.extraHeight) {
+ var divs = $(el).find('div');
+ options.extraHeight = divs.get(0).offsetHeight + divs.get(1).offsetHeight;
+ options.extraWidth = divs.get(2).offsetWidth + divs.get(3).offsetWidth;
+ }
+ var tbl = cal.find('table:first').get(0);
+ var width = tbl.offsetWidth;
+ var height = tbl.offsetHeight;
+ cal.css({
+ width: width + options.extraWidth + 'px',
+ height: height + options.extraHeight + 'px'
+ }).find('div.datepickerContainer').css({
+ width: width + 'px',
+ height: height + 'px'
+ });
+ },
+ click = function(ev) {
+ if ($(ev.target).is('span')) {
+ ev.target = ev.target.parentNode;
+ }
+ var el = $(ev.target);
+ if (el.is('a')) {
+ ev.target.blur();
+ if (el.hasClass('datepickerDisabled')) {
+ return false;
+ }
+ var options = $(this).data('datepicker');
+ var parentEl = el.parent();
+ var tblEl = parentEl.parent().parent().parent();
+ var tblIndex = $('table', this).index(tblEl.get(0)) - 1;
+ var tmp = new Date(options.current);
+ var changed = false;
+ var fillIt = false;
+ if (parentEl.is('th')) {
+ if (parentEl.hasClass('datepickerWeek') && options.mode == 'range' && !parentEl.next().hasClass('datepickerDisabled')) {
+ var val = parseInt(parentEl.next().text(), 10);
+ tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
+ if (parentEl.next().hasClass('datepickerNotInMonth')) {
+ tmp.addMonths(val > 15 ? -1 : 1);
+ }
+ tmp.setDate(val);
+ options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
+ tmp.setHours(23,59,59,0);
+ tmp.addDays(6);
+ options.date[1] = tmp.valueOf();
+ fillIt = true;
+ changed = true;
+ options.lastSel = false;
+ } else if (parentEl.hasClass('datepickerMonth')) {
+ tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
+ switch (tblEl.get(0).className) {
+ case 'datepickerViewDays':
+ tblEl.get(0).className = 'datepickerViewMonths';
+ el.find('span').text(tmp.getFullYear());
+ break;
+ case 'datepickerViewMonths':
+ tblEl.get(0).className = 'datepickerViewYears';
+ el.find('span').text((tmp.getFullYear()-6) + ' - ' + (tmp.getFullYear()+5));
+ break;
+ case 'datepickerViewYears':
+ tblEl.get(0).className = 'datepickerViewDays';
+ el.find('span').text(formatDate(tmp, 'B, Y'));
+ break;
+ }
+ } else if (parentEl.parent().parent().is('thead')) {
+ switch (tblEl.get(0).className) {
+ case 'datepickerViewDays':
+ options.current.addMonths(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
+ break;
+ case 'datepickerViewMonths':
+ options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
+ break;
+ case 'datepickerViewYears':
+ options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -12 : 12);
+ break;
+ }
+ fillIt = true;
+ }
+ } else if (parentEl.is('td') && !parentEl.hasClass('datepickerDisabled')) {
+ switch (tblEl.get(0).className) {
+ case 'datepickerViewMonths':
+ options.current.setMonth(tblEl.find('tbody.datepickerMonths td').index(parentEl));
+ options.current.setFullYear(parseInt(tblEl.find('thead th.datepickerMonth span').text(), 10));
+ options.current.addMonths(Math.floor(options.calendars/2) - tblIndex);
+ tblEl.get(0).className = 'datepickerViewDays';
+ break;
+ case 'datepickerViewYears':
+ options.current.setFullYear(parseInt(el.text(), 10));
+ tblEl.get(0).className = 'datepickerViewMonths';
+ break;
+ default:
+ var val = parseInt(el.text(), 10);
+ tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
+ if (parentEl.hasClass('datepickerNotInMonth')) {
+ tmp.addMonths(val > 15 ? -1 : 1);
+ }
+ tmp.setDate(val);
+ switch (options.mode) {
+ case 'multiple':
+ val = (tmp.setHours(0,0,0,0)).valueOf();
+ if ($.inArray(val, options.date) > -1) {
+ $.each(options.date, function(nr, dat){
+ if (dat == val) {
+ options.date.splice(nr,1);
+ return false;
+ }
+ });
+ } else {
+ options.date.push(val);
+ }
+ break;
+ case 'range':
+ if (!options.lastSel) {
+ options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
+ }
+ val = (tmp.setHours(23,59,59,0)).valueOf();
+ if (val < options.date[0]) {
+ options.date[1] = options.date[0] + 86399000;
+ options.date[0] = val - 86399000;
+ } else {
+ options.date[1] = val;
+ }
+ options.lastSel = !options.lastSel;
+ break;
+ default:
+ options.date = tmp.valueOf();
+ break;
+ }
+ break;
+ }
+ fillIt = true;
+ changed = true;
+ }
+ if (fillIt) {
+ fill(this);
+ }
+ if (changed) {
+ options.onChange.apply(this, prepareDate(options));
+ }
+ }
+ return false;
+ },
+ prepareDate = function (options) {
+ var tmp;
+ if (options.mode == 'single') {
+ tmp = new Date(options.date);
+ return [formatDate(tmp, options.format), tmp, options.el];
+ } else {
+ tmp = [[],[], options.el];
+ $.each(options.date, function(nr, val){
+ var date = new Date(val);
+ tmp[0].push(formatDate(date, options.format));
+ tmp[1].push(date);
+ });
+ return tmp;
+ }
+ },
+ getViewport = function () {
+ var m = document.compatMode == 'CSS1Compat';
+ return {
+ l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
+ t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
+ w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
+ h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
+ };
+ },
+ isChildOf = function(parentEl, el, container) {
+ if (parentEl == el) {
+ return true;
+ }
+ if (parentEl.contains) {
+ return parentEl.contains(el);
+ }
+ if ( parentEl.compareDocumentPosition ) {
+ return !!(parentEl.compareDocumentPosition(el) & 16);
+ }
+ var prEl = el.parentNode;
+ while(prEl && prEl != container) {
+ if (prEl == parentEl)
+ return true;
+ prEl = prEl.parentNode;
+ }
+ return false;
+ },
+ show = function (ev) {
+ var cal = $('#' + $(this).data('datepickerId'));
+ if (!cal.is(':visible')) {
+ var calEl = cal.get(0);
+ fill(calEl);
+ var options = cal.data('datepicker');
+ options.onBeforeShow.apply(this, [cal.get(0)]);
+ var pos = $(this).offset();
+ var viewPort = getViewport();
+ var top = pos.top;
+ var left = pos.left;
+ var oldDisplay = $.curCSS(calEl, 'display');
+ cal.css({
+ visibility: 'hidden',
+ display: 'block'
+ });
+ layout(calEl);
+ switch (options.position){
+ case 'top':
+ top -= calEl.offsetHeight;
+ break;
+ case 'left':
+ left -= calEl.offsetWidth;
+ break;
+ case 'right':
+ left += this.offsetWidth;
+ break;
+ case 'bottom':
+ top += this.offsetHeight;
+ break;
+ }
+ if (top + calEl.offsetHeight > viewPort.t + viewPort.h) {
+ top = pos.top - calEl.offsetHeight;
+ }
+ if (top < viewPort.t) {
+ top = pos.top + this.offsetHeight + calEl.offsetHeight;
+ }
+ if (left + calEl.offsetWidth > viewPort.l + viewPort.w) {
+ left = pos.left - calEl.offsetWidth;
+ }
+ if (left < viewPort.l) {
+ left = pos.left + this.offsetWidth
+ }
+ cal.css({
+ visibility: 'visible',
+ display: 'block',
+ top: top + 'px',
+ left: left + 'px'
+ });
+ if (options.onShow.apply(this, [cal.get(0)]) != false) {
+ cal.show();
+ }
+ $(document).bind('mousedown', {cal: cal, trigger: this}, hide);
+ }
+ return false;
+ },
+ hide = function (ev) {
+ if (ev.target != ev.data.trigger && !isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
+ if (ev.data.cal.data('datepicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
+ ev.data.cal.hide();
+ }
+ $(document).unbind('mousedown', hide);
+ }
+ };
+ return {
+ init: function(options){
+ options = $.extend({}, defaults, options||{});
+ extendDate(options.locale);
+ options.calendars = Math.max(1, parseInt(options.calendars,10)||1);
+ options.mode = /single|multiple|range/.test(options.mode) ? options.mode : 'single';
+ return this.each(function(){
+ if (!$(this).data('datepicker')) {
+ options.el = this;
+ if (options.date.constructor == String) {
+ options.date = parseDate(options.date, options.format);
+ options.date.setHours(0,0,0,0);
+ }
+ if (options.mode != 'single') {
+ if (options.date.constructor != Array) {
+ options.date = [options.date.valueOf()];
+ if (options.mode == 'range') {
+ options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
+ }
+ } else {
+ for (var i = 0; i < options.date.length; i++) {
+ options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
+ }
+ if (options.mode == 'range') {
+ options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
+ }
+ }
+ } else {
+ options.date = options.date.valueOf();
+ }
+ if (!options.current) {
+ options.current = new Date();
+ } else {
+ options.current = parseDate(options.current, options.format);
+ }
+ options.current.setDate(1);
+ options.current.setHours(0,0,0,0);
+ var id = 'datepicker_' + parseInt(Math.random() * 1000), cnt;
+ options.id = id;
+ $(this).data('datepickerId', options.id);
+ var cal = $(tpl.wrapper).attr('id', id).bind('click', click).data('datepicker', options);
+ if (options.className) {
+ cal.addClass(options.className);
+ }
+ var html = '';
+ for (var i = 0; i < options.calendars; i++) {
+ cnt = options.starts;
+ if (i > 0) {
+ html += tpl.space;
+ }
+ html += tmpl(tpl.head.join(''), {
+ week: options.locale.weekMin,
+ prev: options.prev,
+ next: options.next,
+ day1: options.locale.daysMin[(cnt++)%7],
+ day2: options.locale.daysMin[(cnt++)%7],
+ day3: options.locale.daysMin[(cnt++)%7],
+ day4: options.locale.daysMin[(cnt++)%7],
+ day5: options.locale.daysMin[(cnt++)%7],
+ day6: options.locale.daysMin[(cnt++)%7],
+ day7: options.locale.daysMin[(cnt++)%7]
+ });
+ }
+ cal
+ .find('tr:first').append(html)
+ .find('table').addClass(views[options.view]);
+ fill(cal.get(0));
+ if (options.flat) {
+ cal.appendTo(this).show().css('position', 'relative');
+ layout(cal.get(0));
+ } else {
+ cal.appendTo(document.body);
+ $(this).bind(options.eventName, show);
+ }
+ }
+ });
+ },
+ showPicker: function() {
+ return this.each( function () {
+ if ($(this).data('datepickerId')) {
+ show.apply(this);
+ }
+ });
+ },
+ hidePicker: function() {
+ return this.each( function () {
+ if ($(this).data('datepickerId')) {
+ $('#' + $(this).data('datepickerId')).hide();
+ }
+ });
+ },
+ setDate: function(date, shiftTo){
+ return this.each(function(){
+ if ($(this).data('datepickerId')) {
+ var cal = $('#' + $(this).data('datepickerId'));
+ var options = cal.data('datepicker');
+ options.date = date;
+ if (options.date.constructor == String) {
+ options.date = parseDate(options.date, options.format);
+ options.date.setHours(0,0,0,0);
+ }
+ if (options.mode != 'single') {
+ if (options.date.constructor != Array) {
+ options.date = [options.date.valueOf()];
+ if (options.mode == 'range') {
+ options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
+ }
+ } else {
+ for (var i = 0; i < options.date.length; i++) {
+ options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
+ }
+ if (options.mode == 'range') {
+ options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
+ }
+ }
+ } else {
+ options.date = options.date.valueOf();
+ }
+ if (shiftTo) {
+ options.current = new Date (options.mode != 'single' ? options.date[0] : options.date);
+ }
+ fill(cal.get(0));
+ }
+ });
+ },
+ getDate: function(formated) {
+ if (this.size() > 0) {
+ return prepareDate($('#' + $(this).data('datepickerId')).data('datepicker'))[formated ? 0 : 1];
+ }
+ },
+ clear: function(){
+ return this.each(function(){
+ if ($(this).data('datepickerId')) {
+ var cal = $('#' + $(this).data('datepickerId'));
+ var options = cal.data('datepicker');
+ if (options.mode != 'single') {
+ options.date = [];
+ fill(cal.get(0));
+ }
+ }
+ });
+ },
+ fixLayout: function(){
+ return this.each(function(){
+ if ($(this).data('datepickerId')) {
+ var cal = $('#' + $(this).data('datepickerId'));
+ var options = cal.data('datepicker');
+ if (options.flat) {
+ layout(cal.get(0));
+ }
+ }
+ });
+ }
+ };
+ }();
+ $.fn.extend({
+ DatePicker: DatePicker.init,
+ DatePickerHide: DatePicker.hidePicker,
+ DatePickerShow: DatePicker.showPicker,
+ DatePickerSetDate: DatePicker.setDate,
+ DatePickerGetDate: DatePicker.getDate,
+ DatePickerClear: DatePicker.clear,
+ DatePickerLayout: DatePicker.fixLayout
+ });
+})(jQuery);
+
+(function(){
+ var cache = {};
+
+ this.tmpl = function tmpl(str, data){
+ // Figure out if we're getting a template, or if we need to
+ // load the template - and be sure to cache the result.
+ var fn = !/\W/.test(str) ?
+ cache[str] = cache[str] ||
+ tmpl(document.getElementById(str).innerHTML) :
+
+ // Generate a reusable function that will serve as a template
+ // generator (and which will be cached).
+ new Function("obj",
+ "var p=[],print=function(){p.push.apply(p,arguments);};" +
+
+ // Introduce the data as local variables using with(){}
+ "with(obj){p.push('" +
+
+ // Convert the template into pure JavaScript
+ str
+ .replace(/[\r\t\n]/g, " ")
+ .split("<%").join("\t")
+ .replace(/((^|%>)[^\t]*)'/g, "$1\r")
+ .replace(/\t=(.*?)%>/g, "',$1,'")
+ .split("\t").join("');")
+ .split("%>").join("p.push('")
+ .split("\r").join("\\'")
+ + "');}return p.join('');");
+
+ // Provide some basic currying to the user
+ return data ? fn( data ) : fn;
+ };
+})();
diff --git a/sources/addons/jappixmini/jappix/js/jquery.form.js b/sources/addons/jappixmini/jappix/js/jquery.form.js
new file mode 100644
index 00000000..2b853df4
--- /dev/null
+++ b/sources/addons/jappixmini/jappix/js/jquery.form.js
@@ -0,0 +1,785 @@
+/*!
+ * jQuery Form Plugin
+ * version: 2.49 (18-OCT-2010)
+ * @requires jQuery v1.3.2 or later
+ *
+ * Examples and documentation at: http://malsup.com/jquery/form/
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ */
+;(function($) {
+
+/*
+ Usage Note:
+ -----------
+ Do not use both ajaxSubmit and ajaxForm on the same form. These
+ functions are intended to be exclusive. Use ajaxSubmit if you want
+ to bind your own submit handler to the form. For example,
+
+ $(document).ready(function() {
+ $('#myForm').bind('submit', function(e) {
+ e.preventDefault(); // <-- important
+ $(this).ajaxSubmit({
+ target: '#output'
+ });
+ });
+ });
+
+ Use ajaxForm when you want the plugin to manage all the event binding
+ for you. For example,
+
+ $(document).ready(function() {
+ $('#myForm').ajaxForm({
+ target: '#output'
+ });
+ });
+
+ When using ajaxForm, the ajaxSubmit function will be invoked for you
+ at the appropriate time.
+*/
+
+/**
+ * ajaxSubmit() provides a mechanism for immediately submitting
+ * an HTML form using AJAX.
+ */
+$.fn.ajaxSubmit = function(options) {
+ // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
+ if (!this.length) {
+ log('ajaxSubmit: skipping submit process - no element selected');
+ return this;
+ }
+
+ if (typeof options == 'function') {
+ options = { success: options };
+ }
+
+ var url = $.trim(this.attr('action'));
+ if (url) {
+ // clean url (don't include hash vaue)
+ url = (url.match(/^([^#]+)/)||[])[1];
+ }
+ url = url || window.location.href || '';
+
+ options = $.extend(true, {
+ url: url,
+ type: this.attr('method') || 'GET',
+ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
+ }, options);
+
+ // hook for manipulating the form data before it is extracted;
+ // convenient for use with rich editors like tinyMCE or FCKEditor
+ var veto = {};
+ this.trigger('form-pre-serialize', [this, options, veto]);
+ if (veto.veto) {
+ log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
+ return this;
+ }
+
+ // provide opportunity to alter form data before it is serialized
+ if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
+ log('ajaxSubmit: submit aborted via beforeSerialize callback');
+ return this;
+ }
+
+ var n,v,a = this.formToArray(options.semantic);
+ if (options.data) {
+ options.extraData = options.data;
+ for (n in options.data) {
+ if(options.data[n] instanceof Array) {
+ for (var k in options.data[n]) {
+ a.push( { name: n, value: options.data[n][k] } );
+ }
+ }
+ else {
+ v = options.data[n];
+ v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
+ a.push( { name: n, value: v } );
+ }
+ }
+ }
+
+ // give pre-submit callback an opportunity to abort the submit
+ if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
+ log('ajaxSubmit: submit aborted via beforeSubmit callback');
+ return this;
+ }
+
+ // fire vetoable 'validate' event
+ this.trigger('form-submit-validate', [a, this, options, veto]);
+ if (veto.veto) {
+ log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
+ return this;
+ }
+
+ var q = $.param(a);
+
+ if (options.type.toUpperCase() == 'GET') {
+ options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
+ options.data = null; // data is null for 'get'
+ }
+ else {
+ options.data = q; // data is the query string for 'post'
+ }
+
+ var $form = this, callbacks = [];
+ if (options.resetForm) {
+ callbacks.push(function() { $form.resetForm(); });
+ }
+ if (options.clearForm) {
+ callbacks.push(function() { $form.clearForm(); });
+ }
+
+ // perform a load on the target only if dataType is not provided
+ if (!options.dataType && options.target) {
+ var oldSuccess = options.success || function(){};
+ callbacks.push(function(data) {
+ var fn = options.replaceTarget ? 'replaceWith' : 'html';
+ $(options.target)[fn](data).each(oldSuccess, arguments);
+ });
+ }
+ else if (options.success) {
+ callbacks.push(options.success);
+ }
+
+ options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
+ var context = options.context || options; // jQuery 1.4+ supports scope context
+ for (var i=0, max=callbacks.length; i < max; i++) {
+ callbacks[i].apply(context, [data, status, xhr || $form, $form]);
+ }
+ };
+
+ // are there files to upload?
+ var fileInputs = $('input:file', this).length > 0;
+ var mp = 'multipart/form-data';
+ var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
+
+ // options.iframe allows user to force iframe mode
+ // 06-NOV-09: now defaulting to iframe mode if file input is detected
+ if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
+ // hack to fix Safari hang (thanks to Tim Molendijk for this)
+ // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
+ if (options.closeKeepAlive) {
+ $.get(options.closeKeepAlive, fileUpload);
+ }
+ else {
+ fileUpload();
+ }
+ }
+ else {
+ $.ajax(options);
+ }
+
+ // fire 'notify' event
+ this.trigger('form-submit-notify', [this, options]);
+ return this;
+
+
+ // private function for handling file uploads (hat tip to YAHOO!)
+ function fileUpload() {
+ var form = $form[0];
+
+ if ($(':input[name=submit],:input[id=submit]', form).length) {
+ // if there is an input with a name or id of 'submit' then we won't be
+ // able to invoke the submit fn on the form (at least not x-browser)
+ alert('Error: Form elements must not have name or id of "submit".');
+ return;
+ }
+
+ var s = $.extend(true, {}, $.ajaxSettings, options);
+ s.context = s.context || s;
+ var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
+ window[fn] = function() {
+ var f = $io.data('form-plugin-onload');
+ if (f) {
+ f();
+ window[fn] = undefined;
+ try { delete window[fn]; } catch(e){}
+ }
+ }
+ var $io = $('');
+ var io = $io[0];
+
+ $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
+
+ var xhr = { // mock object
+ aborted: 0,
+ responseText: null,
+ responseXML: null,
+ status: 0,
+ statusText: 'n/a',
+ getAllResponseHeaders: function() {},
+ getResponseHeader: function() {},
+ setRequestHeader: function() {},
+ abort: function() {
+ this.aborted = 1;
+ $io.attr('src', s.iframeSrc); // abort op in progress
+ }
+ };
+
+ var g = s.global;
+ // trigger ajax global events so that activity/block indicators work like normal
+ if (g && ! $.active++) {
+ $.event.trigger("ajaxStart");
+ }
+ if (g) {
+ $.event.trigger("ajaxSend", [xhr, s]);
+ }
+
+ if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
+ if (s.global) {
+ $.active--;
+ }
+ return;
+ }
+ if (xhr.aborted) {
+ return;
+ }
+
+ var cbInvoked = false;
+ var timedOut = 0;
+
+ // add submitting element to data if we know it
+ var sub = form.clk;
+ if (sub) {
+ var n = sub.name;
+ if (n && !sub.disabled) {
+ s.extraData = s.extraData || {};
+ s.extraData[n] = sub.value;
+ if (sub.type == "image") {
+ s.extraData[n+'.x'] = form.clk_x;
+ s.extraData[n+'.y'] = form.clk_y;
+ }
+ }
+ }
+
+ // take a breath so that pending repaints get some cpu time before the upload starts
+ function doSubmit() {
+ // make sure form attrs are set
+ var t = $form.attr('target'), a = $form.attr('action');
+
+ // update form attrs in IE friendly way
+ form.setAttribute('target',id);
+ if (form.getAttribute('method') != 'POST') {
+ form.setAttribute('method', 'POST');
+ }
+ if (form.getAttribute('action') != s.url) {
+ form.setAttribute('action', s.url);
+ }
+
+ // ie borks in some cases when setting encoding
+ if (! s.skipEncodingOverride) {
+ $form.attr({
+ encoding: 'multipart/form-data',
+ enctype: 'multipart/form-data'
+ });
+ }
+
+ // support timout
+ if (s.timeout) {
+ setTimeout(function() { timedOut = true; cb(); }, s.timeout);
+ }
+
+ // add "extra" data to form if provided in options
+ var extraInputs = [];
+ try {
+ if (s.extraData) {
+ for (var n in s.extraData) {
+ extraInputs.push(
+ $('')
+ .appendTo(form)[0]);
+ }
+ }
+
+ // add iframe to doc and submit the form
+ $io.appendTo('body');
+ $io.data('form-plugin-onload', cb);
+ form.submit();
+ }
+ finally {
+ // reset attrs and remove "extra" input elements
+ form.setAttribute('action',a);
+ if(t) {
+ form.setAttribute('target', t);
+ } else {
+ $form.removeAttr('target');
+ }
+ $(extraInputs).remove();
+ }
+ }
+
+ if (s.forceSync) {
+ doSubmit();
+ }
+ else {
+ setTimeout(doSubmit, 10); // this lets dom updates render
+ }
+
+ var data, doc, domCheckCount = 50;
+
+ function cb() {
+ if (cbInvoked) {
+ return;
+ }
+
+ $io.removeData('form-plugin-onload');
+
+ var ok = true;
+ try {
+ if (timedOut) {
+ throw 'timeout';
+ }
+ // extract the server response from the iframe
+ doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
+
+ var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
+ log('isXml='+isXml);
+ if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
+ if (--domCheckCount) {
+ // in some browsers (Opera) the iframe DOM is not always traversable when
+ // the onload callback fires, so we loop a bit to accommodate
+ log('requeing onLoad callback, DOM not available');
+ setTimeout(cb, 250);
+ return;
+ }
+ // let this fall through because server response could be an empty document
+ //log('Could not access iframe DOM after mutiple tries.');
+ //throw 'DOMException: not available';
+ }
+
+ //log('response detected');
+ cbInvoked = true;
+ xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
+ xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
+ xhr.getResponseHeader = function(header){
+ var headers = {'content-type': s.dataType};
+ return headers[header];
+ };
+
+ var scr = /(json|script)/.test(s.dataType);
+ if (scr || s.textarea) {
+ // see if user embedded response in textarea
+ var ta = doc.getElementsByTagName('textarea')[0];
+ if (ta) {
+ xhr.responseText = ta.value;
+ }
+ else if (scr) {
+ // account for browsers injecting pre around json response
+ var pre = doc.getElementsByTagName('pre')[0];
+ var b = doc.getElementsByTagName('body')[0];
+ if (pre) {
+ xhr.responseText = pre.innerHTML;
+ }
+ else if (b) {
+ xhr.responseText = b.innerHTML;
+ }
+ }
+ }
+ else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
+ xhr.responseXML = toXml(xhr.responseText);
+ }
+ data = $.httpData(xhr, s.dataType);
+ }
+ catch(e){
+ log('error caught:',e);
+ ok = false;
+ xhr.error = e;
+ $.handleError(s, xhr, 'error', e);
+ }
+
+ // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
+ if (ok) {
+ s.success.call(s.context, data, 'success', xhr);
+ if (g) {
+ $.event.trigger("ajaxSuccess", [xhr, s]);
+ }
+ }
+ if (g) {
+ $.event.trigger("ajaxComplete", [xhr, s]);
+ }
+ if (g && ! --$.active) {
+ $.event.trigger("ajaxStop");
+ }
+ if (s.complete) {
+ s.complete.call(s.context, xhr, ok ? 'success' : 'error');
+ }
+
+ // clean up
+ setTimeout(function() {
+ $io.removeData('form-plugin-onload');
+ $io.remove();
+ xhr.responseXML = null;
+ }, 100);
+ }
+
+ function toXml(s, doc) {
+ if (window.ActiveXObject) {
+ doc = new ActiveXObject('Microsoft.XMLDOM');
+ doc.async = 'false';
+ doc.loadXML(s);
+ }
+ else {
+ doc = (new DOMParser()).parseFromString(s, 'text/xml');
+ }
+ return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
+ }
+ }
+};
+
+/**
+ * ajaxForm() provides a mechanism for fully automating form submission.
+ *
+ * The advantages of using this method instead of ajaxSubmit() are:
+ *
+ * 1: This method will include coordinates for elements (if the element
+ * is used to submit the form).
+ * 2. This method will include the submit element's name/value data (for the element that was
+ * used to submit the form).
+ * 3. This method binds the submit() method to the form for you.
+ *
+ * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
+ * passes the options argument along after properly binding events for submit elements and
+ * the form itself.
+ */
+$.fn.ajaxForm = function(options) {
+ // in jQuery 1.3+ we can fix mistakes with the ready state
+ if (this.length === 0) {
+ var o = { s: this.selector, c: this.context };
+ if (!$.isReady && o.s) {
+ log('DOM not ready, queuing ajaxForm');
+ $(function() {
+ $(o.s,o.c).ajaxForm(options);
+ });
+ return this;
+ }
+ // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
+ log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
+ return this;
+ }
+
+ return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
+ if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
+ e.preventDefault();
+ $(this).ajaxSubmit(options);
+ }
+ }).bind('click.form-plugin', function(e) {
+ var target = e.target;
+ var $el = $(target);
+ if (!($el.is(":submit,input:image"))) {
+ // is this a child element of the submit el? (ex: a span within a button)
+ var t = $el.closest(':submit');
+ if (t.length == 0) {
+ return;
+ }
+ target = t[0];
+ }
+ var form = this;
+ form.clk = target;
+ if (target.type == 'image') {
+ if (e.offsetX != undefined) {
+ form.clk_x = e.offsetX;
+ form.clk_y = e.offsetY;
+ } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
+ var offset = $el.offset();
+ form.clk_x = e.pageX - offset.left;
+ form.clk_y = e.pageY - offset.top;
+ } else {
+ form.clk_x = e.pageX - target.offsetLeft;
+ form.clk_y = e.pageY - target.offsetTop;
+ }
+ }
+ // clear form vars
+ setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
+ });
+};
+
+// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
+$.fn.ajaxFormUnbind = function() {
+ return this.unbind('submit.form-plugin click.form-plugin');
+};
+
+/**
+ * formToArray() gathers form element data into an array of objects that can
+ * be passed to any of the following ajax functions: $.get, $.post, or load.
+ * Each object in the array has both a 'name' and 'value' property. An example of
+ * an array for a simple login form might be:
+ *
+ * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
+ *
+ * It is this array that is passed to pre-submit callback functions provided to the
+ * ajaxSubmit() and ajaxForm() methods.
+ */
+$.fn.formToArray = function(semantic) {
+ var a = [];
+ if (this.length === 0) {
+ return a;
+ }
+
+ var form = this[0];
+ var els = semantic ? form.getElementsByTagName('*') : form.elements;
+ if (!els) {
+ return a;
+ }
+
+ var i,j,n,v,el,max,jmax;
+ for(i=0, max=els.length; i < max; i++) {
+ el = els[i];
+ n = el.name;
+ if (!n) {
+ continue;
+ }
+
+ if (semantic && form.clk && el.type == "image") {
+ // handle image inputs on the fly when semantic == true
+ if(!el.disabled && form.clk == el) {
+ a.push({name: n, value: $(el).val()});
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
+ }
+ continue;
+ }
+
+ v = $.fieldValue(el, true);
+ if (v && v.constructor == Array) {
+ for(j=0, jmax=v.length; j < jmax; j++) {
+ a.push({name: n, value: v[j]});
+ }
+ }
+ else if (v !== null && typeof v != 'undefined') {
+ a.push({name: n, value: v});
+ }
+ }
+
+ if (!semantic && form.clk) {
+ // input type=='image' are not found in elements array! handle it here
+ var $input = $(form.clk), input = $input[0];
+ n = input.name;
+ if (n && !input.disabled && input.type == 'image') {
+ a.push({name: n, value: $input.val()});
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
+ }
+ }
+ return a;
+};
+
+/**
+ * Serializes form data into a 'submittable' string. This method will return a string
+ * in the format: name1=value1&name2=value2
+ */
+$.fn.formSerialize = function(semantic) {
+ //hand off to jQuery.param for proper encoding
+ return $.param(this.formToArray(semantic));
+};
+
+/**
+ * Serializes all field elements in the jQuery object into a query string.
+ * This method will return a string in the format: name1=value1&name2=value2
+ */
+$.fn.fieldSerialize = function(successful) {
+ var a = [];
+ this.each(function() {
+ var n = this.name;
+ if (!n) {
+ return;
+ }
+ var v = $.fieldValue(this, successful);
+ if (v && v.constructor == Array) {
+ for (var i=0,max=v.length; i < max; i++) {
+ a.push({name: n, value: v[i]});
+ }
+ }
+ else if (v !== null && typeof v != 'undefined') {
+ a.push({name: this.name, value: v});
+ }
+ });
+ //hand off to jQuery.param for proper encoding
+ return $.param(a);
+};
+
+/**
+ * Returns the value(s) of the element in the matched set. For example, consider the following form:
+ *
+ *
+ *
+ * var v = $(':text').fieldValue();
+ * // if no values are entered into the text inputs
+ * v == ['','']
+ * // if values entered into the text inputs are 'foo' and 'bar'
+ * v == ['foo','bar']
+ *
+ * var v = $(':checkbox').fieldValue();
+ * // if neither checkbox is checked
+ * v === undefined
+ * // if both checkboxes are checked
+ * v == ['B1', 'B2']
+ *
+ * var v = $(':radio').fieldValue();
+ * // if neither radio is checked
+ * v === undefined
+ * // if first radio is checked
+ * v == ['C1']
+ *
+ * The successful argument controls whether or not the field element must be 'successful'
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
+ * The default value of the successful argument is true. If this value is false the value(s)
+ * for each element is returned.
+ *
+ * Note: This method *always* returns an array. If no valid value can be determined the
+ * array will be empty, otherwise it will contain one or more values.
+ */
+$.fn.fieldValue = function(successful) {
+ for (var val=[], i=0, max=this.length; i < max; i++) {
+ var el = this[i];
+ var v = $.fieldValue(el, successful);
+ if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
+ continue;
+ }
+ v.constructor == Array ? $.merge(val, v) : val.push(v);
+ }
+ return val;
+};
+
+/**
+ * Returns the value of the field element.
+ */
+$.fieldValue = function(el, successful) {
+ var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
+ if (successful === undefined) {
+ successful = true;
+ }
+
+ if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
+ (t == 'checkbox' || t == 'radio') && !el.checked ||
+ (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
+ tag == 'select' && el.selectedIndex == -1)) {
+ return null;
+ }
+
+ if (tag == 'select') {
+ var index = el.selectedIndex;
+ if (index < 0) {
+ return null;
+ }
+ var a = [], ops = el.options;
+ var one = (t == 'select-one');
+ var max = (one ? index+1 : ops.length);
+ for(var i=(one ? index : 0); i < max; i++) {
+ var op = ops[i];
+ if (op.selected) {
+ var v = op.value;
+ if (!v) { // extra pain for IE...
+ v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
+ }
+ if (one) {
+ return v;
+ }
+ a.push(v);
+ }
+ }
+ return a;
+ }
+ return $(el).val();
+};
+
+/**
+ * Clears the form data. Takes the following actions on the form's input fields:
+ * - input text fields will have their 'value' property set to the empty string
+ * - select elements will have their 'selectedIndex' property set to -1
+ * - checkbox and radio inputs will have their 'checked' property set to false
+ * - inputs of type submit, button, reset, and hidden will *not* be effected
+ * - button elements will *not* be effected
+ */
+$.fn.clearForm = function() {
+ return this.each(function() {
+ $('input,select,textarea', this).clearFields();
+ });
+};
+
+/**
+ * Clears the selected form elements.
+ */
+$.fn.clearFields = $.fn.clearInputs = function() {
+ return this.each(function() {
+ var t = this.type, tag = this.tagName.toLowerCase();
+ if (t == 'text' || t == 'password' || tag == 'textarea') {
+ this.value = '';
+ }
+ else if (t == 'checkbox' || t == 'radio') {
+ this.checked = false;
+ }
+ else if (tag == 'select') {
+ this.selectedIndex = -1;
+ }
+ });
+};
+
+/**
+ * Resets the form data. Causes all form elements to be reset to their original value.
+ */
+$.fn.resetForm = function() {
+ return this.each(function() {
+ // guard against an input with the name of 'reset'
+ // note that IE reports the reset function as an 'object'
+ if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
+ this.reset();
+ }
+ });
+};
+
+/**
+ * Enables or disables any matching elements.
+ */
+$.fn.enable = function(b) {
+ if (b === undefined) {
+ b = true;
+ }
+ return this.each(function() {
+ this.disabled = !b;
+ });
+};
+
+/**
+ * Checks/unchecks any matching checkboxes or radio buttons and
+ * selects/deselects and matching option elements.
+ */
+$.fn.selected = function(select) {
+ if (select === undefined) {
+ select = true;
+ }
+ return this.each(function() {
+ var t = this.type;
+ if (t == 'checkbox' || t == 'radio') {
+ this.checked = select;
+ }
+ else if (this.tagName.toLowerCase() == 'option') {
+ var $sel = $(this).parent('select');
+ if (select && $sel[0] && $sel[0].type == 'select-one') {
+ // deselect all other options
+ $sel.find('option').selected(false);
+ }
+ this.selected = select;
+ }
+ });
+};
+
+// helper fn for console logging
+// set $.fn.ajaxSubmit.debug to true to enable debug logging
+function log() {
+ if ($.fn.ajaxSubmit.debug) {
+ var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
+ if (window.console && window.console.log) {
+ window.console.log(msg);
+ }
+ else if (window.opera && window.opera.postError) {
+ window.opera.postError(msg);
+ }
+ }
+};
+
+})(jQuery);
diff --git a/sources/addons/jappixmini/jappix/js/jquery.js b/sources/addons/jappixmini/jappix/js/jquery.js
new file mode 100644
index 00000000..a4f11458
--- /dev/null
+++ b/sources/addons/jappixmini/jappix/js/jquery.js
@@ -0,0 +1,7179 @@
+/*!
+ * jQuery JavaScript Library v1.4.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Thu Nov 11 19:04:53 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Use the correct document accordingly with window argument (sandbox)
+var document = window.document;
+var jQuery = (function() {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+ rwhite = /\s/,
+
+ // Used for trimming whitespace
+ trimLeft = /^\s+/,
+ trimRight = /\s+$/,
+
+ // Check for non-word characters
+ rnonword = /\W/,
+
+ // Check for digits
+ rdigit = /\d/,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // JSON RegExp
+ rvalidchars = /^[\],:{}\s]*$/,
+ rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
+ rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
+ rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
+
+ // Useragent RegExp
+ rwebkit = /(webkit)[ \/]([\w.]+)/,
+ ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
+ rmsie = /(msie) ([\w.]+)/,
+ rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwn = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ trim = String.prototype.trim,
+ indexOf = Array.prototype.indexOf,
+
+ // [[Class]] -> type pairs
+ class2type = {};
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // The body element only exists once, optimize finding it
+ if ( selector === "body" && !context && document.body ) {
+ this.context = document;
+ this[0] = document.body;
+ this.selector = "body";
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ return jQuery.merge( this, selector );
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && !rnonword.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+ return jQuery.merge( this, selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery();
+
+ if ( jQuery.isArray( elems ) ) {
+ push.apply( ret, elems );
+
+ } else {
+ jQuery.merge( ret, elems );
+ }
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ var options, name, src, copy, copyIsArray, clone,
+ target = arguments[0] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+ if ( copyIsArray ) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray(src) ? src : [];
+
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Handle when the DOM is ready
+ ready: function( wait ) {
+ // A third-party is pushing the ready event forwards
+ if ( wait === true ) {
+ jQuery.readyWait--;
+ }
+
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 1 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if ( wait !== true && --jQuery.readyWait > 0 ) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn,
+ i = 0,
+ ready = readyList;
+
+ // Reset the list of functions
+ readyList = null;
+
+ while ( (fn = ready[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.trigger ) {
+ jQuery( document ).trigger( "ready" ).unbind( "ready" );
+ }
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ return setTimeout( jQuery.ready, 1 );
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return jQuery.type(obj) === "function";
+ },
+
+ isArray: Array.isArray || function( obj ) {
+ return jQuery.type(obj) === "array";
+ },
+
+ // A crude way of determining if an object is a window
+ isWindow: function( obj ) {
+ return obj && typeof obj === "object" && "setInterval" in obj;
+ },
+
+ isNaN: function( obj ) {
+ return obj == null || !rdigit.test( obj ) || isNaN( obj );
+ },
+
+ type: function( obj ) {
+ return obj == null ?
+ String( obj ) :
+ class2type[ toString.call(obj) ] || "object";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor &&
+ !hasOwn.call(obj, "constructor") &&
+ !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwn.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ error: function( msg ) {
+ throw msg;
+ },
+
+ parseJSON: function( data ) {
+ if ( typeof data !== "string" || !data ) {
+ return null;
+ }
+
+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
+ data = jQuery.trim( data );
+
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if ( rvalidchars.test(data.replace(rvalidescape, "@")
+ .replace(rvalidtokens, "]")
+ .replace(rvalidbraces, "")) ) {
+
+ // Try to use the native JSON parser first
+ return window.JSON && window.JSON.parse ?
+ window.JSON.parse( data ) :
+ (new Function("return " + data))();
+
+ } else {
+ jQuery.error( "Invalid JSON: " + data );
+ }
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ // Use native String.trim function wherever possible
+ trim: trim ?
+ function( text ) {
+ return text == null ?
+ "" :
+ trim.call( text );
+ } :
+
+ // Otherwise use our own trimming functionality
+ function( text ) {
+ return text == null ?
+ "" :
+ text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
+ var type = jQuery.type(array);
+
+ if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length,
+ j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [], retVal;
+ inv = !!inv;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ retVal = !!callback( elems[ i ], i );
+ if ( inv !== retVal ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Mutifunctional method to get and set values to a collection
+ // The value/s can be optionally by executed if its a function
+ access: function( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ jQuery.access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : undefined;
+ },
+
+ now: function() {
+ return (new Date()).getTime();
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ ua = ua.toLowerCase();
+
+ var match = rwebkit.exec( ua ) ||
+ ropera.exec( ua ) ||
+ rmsie.exec( ua ) ||
+ ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
+ [];
+
+ return { browser: match[1] || "", version: match[2] || "0" };
+ },
+
+ browser: {}
+});
+
+// Populate the class2type map
+jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// Verify that \s matches non-breaking spaces
+// (IE fails on this test)
+if ( !rwhite.test( "\xA0" ) ) {
+ trimLeft = /^[\s\xA0]+/;
+ trimRight = /[\s\xA0]+$/;
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch(e) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+// Expose jQuery to the global object
+return (window.jQuery = window.$ = jQuery);
+
+})();
+
+
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + jQuery.now();
+
+ div.style.display = "none";
+ div.innerHTML = "
a";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0],
+ select = document.createElement("select"),
+ opt = select.appendChild( document.createElement("option") );
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: opt.selected,
+
+ // Will be defined later
+ deleteExpando: true,
+ optDisabled: false,
+ checkClone: false,
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null,
+ inlineBlockNeedsLayout: false,
+ shrinkWrapBlocks: false,
+ reliableHiddenOffsets: true
+ };
+
+ // Make sure that the options inside disabled selects aren't marked as disabled
+ // (WebKit marks them as diabled)
+ select.disabled = true;
+ jQuery.support.optDisabled = !opt.disabled;
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ // Test to see if it's possible to delete an expando from an element
+ // Fails in Internet Explorer
+ try {
+ delete script.test;
+
+ } catch(e) {
+ jQuery.support.deleteExpando = false;
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ div = document.createElement("div");
+ div.innerHTML = "";
+
+ var fragment = document.createDocumentFragment();
+ fragment.appendChild( div.firstChild );
+
+ // WebKit doesn't clone checked state correctly in fragments
+ jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+
+ if ( "zoom" in div.style ) {
+ // Check if natively block-level elements act like inline-block
+ // elements when setting their display to 'inline' and giving
+ // them layout
+ // (IE < 8 does this)
+ div.style.display = "inline";
+ div.style.zoom = 1;
+ jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
+
+ // Check if elements with layout shrink-wrap their children
+ // (IE 6 does this)
+ div.style.display = "";
+ div.innerHTML = "";
+ jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
+ }
+
+ div.innerHTML = "
t
";
+ var tds = div.getElementsByTagName("td");
+
+ // Check if table cells still have offsetWidth/Height when they are set
+ // to display:none and there are still other visible table cells in a
+ // table row; if so, offsetWidth/Height are not reliable for use when
+ // determining if an element has been hidden directly using
+ // display:none (it is still safe to use offsets if a parent element is
+ // hidden; don safety goggles and see bug #4512 for more information).
+ // (only IE 8 fails this test)
+ jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
+
+ tds[0].style.display = "";
+ tds[1].style.display = "none";
+
+ // Check if empty table cells still have offsetWidth/Height
+ // (IE < 8 fail this test)
+ jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
+ div.innerHTML = "";
+
+ document.body.removeChild( div ).style.display = "none";
+ div = tds = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+
+
+var windowData = {},
+ rbrace = /^(?:\{.*\}|\[.*\])$/;
+
+jQuery.extend({
+ cache: {},
+
+ // Please use with caution
+ uuid: 0,
+
+ // Unique for each copy of jQuery on the page
+ expando: "jQuery" + jQuery.now(),
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ // Ban all objects except for Flash (which handle expandos)
+ "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var isNode = elem.nodeType,
+ id = isNode ? elem[ jQuery.expando ] : null,
+ cache = jQuery.cache, thisCache;
+
+ if ( isNode && !id && typeof name === "string" && data === undefined ) {
+ return;
+ }
+
+ // Get the data from the object directly
+ if ( !isNode ) {
+ cache = elem;
+
+ // Compute a unique ID for the element
+ } else if ( !id ) {
+ elem[ jQuery.expando ] = id = ++jQuery.uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ if ( isNode ) {
+ cache[ id ] = jQuery.extend(cache[ id ], name);
+
+ } else {
+ jQuery.extend( cache, name );
+ }
+
+ } else if ( isNode && !cache[ id ] ) {
+ cache[ id ] = {};
+ }
+
+ thisCache = isNode ? cache[ id ] : cache;
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var isNode = elem.nodeType,
+ id = isNode ? elem[ jQuery.expando ] : elem,
+ cache = jQuery.cache,
+ thisCache = isNode ? cache[ id ] : id;
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( isNode && jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ if ( isNode && jQuery.support.deleteExpando ) {
+ delete elem[ jQuery.expando ];
+
+ } else if ( elem.removeAttribute ) {
+ elem.removeAttribute( jQuery.expando );
+
+ // Completely remove the data cache
+ } else if ( isNode ) {
+ delete cache[ id ];
+
+ // Remove all fields from the object
+ } else {
+ for ( var n in elem ) {
+ delete elem[ n ];
+ }
+ }
+ }
+ },
+
+ // A method for determining if a DOM node can handle the data expando
+ acceptData: function( elem ) {
+ if ( elem.nodeName ) {
+ var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
+
+ if ( match ) {
+ return !(match === true || elem.getAttribute("classid") !== match);
+ }
+ }
+
+ return true;
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ var data = null;
+
+ if ( typeof key === "undefined" ) {
+ if ( this.length ) {
+ var attr = this[0].attributes, name;
+ data = jQuery.data( this[0] );
+
+ for ( var i = 0, l = attr.length; i < l; i++ ) {
+ name = attr[i].name;
+
+ if ( name.indexOf( "data-" ) === 0 ) {
+ name = name.substr( 5 );
+ dataAttr( this[0], name, data[ name ] );
+ }
+ }
+ }
+
+ return data;
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ // Try to fetch any internally stored data first
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ data = dataAttr( this[0], key, data );
+ }
+
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+
+ } else {
+ return this.each(function() {
+ var $this = jQuery( this ),
+ args = [ parts[0], value ];
+
+ $this.triggerHandler( "setData" + parts[1] + "!", args );
+ jQuery.data( this, key, value );
+ $this.triggerHandler( "changeData" + parts[1] + "!", args );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+
+function dataAttr( elem, key, data ) {
+ // If nothing was found internally, try to fetch any
+ // data from the HTML5 data-* attribute
+ if ( data === undefined && elem.nodeType === 1 ) {
+ data = elem.getAttribute( "data-" + key );
+
+ if ( typeof data === "string" ) {
+ try {
+ data = data === "true" ? true :
+ data === "false" ? false :
+ data === "null" ? null :
+ !jQuery.isNaN( data ) ? parseFloat( data ) :
+ rbrace.test( data ) ? jQuery.parseJSON( data ) :
+ data;
+ } catch( e ) {}
+
+ // Make sure we set the data so it isn't changed later
+ jQuery.data( elem, key, data );
+
+ } else {
+ data = undefined;
+ }
+ }
+
+ return data;
+}
+
+
+
+
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ),
+ fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+
+
+
+
+var rclass = /[\n\t]/g,
+ rspaces = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /^(?:href|src|style)$/,
+ rtype = /^(?:button|input)$/i,
+ rfocusable = /^(?:button|input|object|select|textarea)$/i,
+ rclickable = /^a(?:rea)?$/i,
+ rradiocheck = /^(?:radio|checkbox)$/i;
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return jQuery.access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspaces );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ",
+ setClass = elem.className;
+
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ setClass += " " + classNames[c];
+ }
+ }
+ elem.className = jQuery.trim( setClass );
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split( rspaces );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = jQuery.trim( className );
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value,
+ isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className,
+ i = 0,
+ self = jQuery( this ),
+ state = stateVal,
+ classNames = value.split( rspaces );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( !arguments.length ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ // attributes.value is undefined in Blackberry 4.7 but
+ // uses .value. See #6932
+ var val = elem.attributes.value;
+ return !val || val.specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ // Don't return options that are disabled or in a disabled optgroup
+ if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
+ (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
+
+ // Get the specific value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == null ) {
+ val = "";
+ } else if ( typeof val === "number" ) {
+ val += "";
+ } else if ( jQuery.isArray(val) ) {
+ val = jQuery.map(val, function (value) {
+ return value == null ? "" : value + "";
+ });
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ // 'in' checks fail in Blackberry 4.7 #6931
+ if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ jQuery.error( "type property can't be changed" );
+ }
+
+ if ( value === null ) {
+ if ( elem.nodeType === 1 ) {
+ elem.removeAttribute( name );
+ }
+
+ } else {
+ elem[ name ] = value;
+ }
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ // Ensure that missing attributes return undefined
+ // Blackberry 4.7 returns "" from getAttribute #6938
+ if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
+ return undefined;
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+});
+
+
+
+
+var rnamespaces = /\.(.*)$/,
+ rformElems = /^(?:textarea|input|select)$/i,
+ rperiod = /\./g,
+ rspace = / /g,
+ rescape = /[^\w\s.|`]/g,
+ fcleanup = function( nm ) {
+ return nm.replace(rescape, "\\$&");
+ },
+ focusCounts = { focusin: 0, focusout: 0 };
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ if ( handler === false ) {
+ handler = returnFalse;
+ } else if ( !handler ) {
+ // Fixes bug #7229. Fix recommended by jdalton
+ return;
+ }
+
+ var handleObjIn, handleObj;
+
+ if ( handler.handler ) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // Init the element's event structure
+ var elemData = jQuery.data( elem );
+
+ // If no elemData is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !elemData ) {
+ return;
+ }
+
+ // Use a key less likely to result in collisions for plain JS objects.
+ // Fixes bug #7150.
+ var eventKey = elem.nodeType ? "events" : "__events__",
+ events = elemData[ eventKey ],
+ eventHandle = elemData.handle;
+
+ if ( typeof events === "function" ) {
+ // On plain objects events is a fn that holds the the data
+ // which prevents this data from being JSON serialized
+ // the function does not need to be called, it just contains the data
+ eventHandle = events.handle;
+ events = events.events;
+
+ } else if ( !events ) {
+ if ( !elem.nodeType ) {
+ // On plain objects, create a fn that acts as the holder
+ // of the values to avoid JSON serialization of event data
+ elemData[ eventKey ] = elemData = function(){};
+ }
+
+ elemData.events = events = {};
+ }
+
+ if ( !eventHandle ) {
+ elemData.handle = eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native events in IE.
+ eventHandle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split(" ");
+
+ var type, i = 0, namespaces;
+
+ while ( (type = types[ i++ ]) ) {
+ handleObj = handleObjIn ?
+ jQuery.extend({}, handleObjIn) :
+ { handler: handler, data: data };
+
+ // Namespaced event handlers
+ if ( type.indexOf(".") > -1 ) {
+ namespaces = type.split(".");
+ type = namespaces.shift();
+ handleObj.namespace = namespaces.slice(0).sort().join(".");
+
+ } else {
+ namespaces = [];
+ handleObj.namespace = "";
+ }
+
+ handleObj.type = type;
+ if ( !handleObj.guid ) {
+ handleObj.guid = handler.guid;
+ }
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = jQuery.event.special[ type ] || {};
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = [];
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, eventHandle, false );
+
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, eventHandle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ special.add.call( elem, handleObj );
+
+ if ( !handleObj.handler.guid ) {
+ handleObj.handler.guid = handler.guid;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers.push( handleObj );
+
+ // Keep track of which events have been used, for global triggering
+ jQuery.event.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler, pos ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ if ( handler === false ) {
+ handler = returnFalse;
+ }
+
+ var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
+ eventKey = elem.nodeType ? "events" : "__events__",
+ elemData = jQuery.data( elem ),
+ events = elemData && elemData[ eventKey ];
+
+ if ( !elemData || !events ) {
+ return;
+ }
+
+ if ( typeof events === "function" ) {
+ elemData = events;
+ events = events.events;
+ }
+
+ // types is actually an event object here
+ if ( types && types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Unbind all events for the element
+ if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
+ types = types || "";
+
+ for ( type in events ) {
+ jQuery.event.remove( elem, type + types );
+ }
+
+ return;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(" ");
+
+ while ( (type = types[ i++ ]) ) {
+ origType = type;
+ handleObj = null;
+ all = type.indexOf(".") < 0;
+ namespaces = [];
+
+ if ( !all ) {
+ // Namespaced event handlers
+ namespaces = type.split(".");
+ type = namespaces.shift();
+
+ namespace = new RegExp("(^|\\.)" +
+ jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
+ }
+
+ eventType = events[ type ];
+
+ if ( !eventType ) {
+ continue;
+ }
+
+ if ( !handler ) {
+ for ( j = 0; j < eventType.length; j++ ) {
+ handleObj = eventType[ j ];
+
+ if ( all || namespace.test( handleObj.namespace ) ) {
+ jQuery.event.remove( elem, origType, handleObj.handler, j );
+ eventType.splice( j--, 1 );
+ }
+ }
+
+ continue;
+ }
+
+ special = jQuery.event.special[ type ] || {};
+
+ for ( j = pos || 0; j < eventType.length; j++ ) {
+ handleObj = eventType[ j ];
+
+ if ( handler.guid === handleObj.guid ) {
+ // remove the given handler for the given type
+ if ( all || namespace.test( handleObj.namespace ) ) {
+ if ( pos == null ) {
+ eventType.splice( j--, 1 );
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, handleObj );
+ }
+ }
+
+ if ( pos != null ) {
+ break;
+ }
+ }
+ }
+
+ // remove generic event handler if no more handlers exist
+ if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ jQuery.removeEvent( elem, type, elemData.handle );
+ }
+
+ ret = null;
+ delete events[ type ];
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ if ( jQuery.isEmptyObject( events ) ) {
+ var handle = elemData.handle;
+ if ( handle ) {
+ handle.elem = null;
+ }
+
+ delete elemData.events;
+ delete elemData.handle;
+
+ if ( typeof elemData === "function" ) {
+ jQuery.removeData( elem, eventKey );
+
+ } else if ( jQuery.isEmptyObject( elemData ) ) {
+ jQuery.removeData( elem );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[ jQuery.expando ] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( jQuery.event.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = elem.nodeType ?
+ jQuery.data( elem, "handle" ) :
+ (jQuery.data( elem, "__events__" ) || {}).handle;
+
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var parent = elem.parentNode || elem.ownerDocument;
+
+ // Trigger an inline bound script
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ event.preventDefault();
+ }
+ }
+
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (inlineError) {}
+
+ if ( !event.isPropagationStopped() && parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+
+ } else if ( !event.isDefaultPrevented() ) {
+ var old,
+ target = event.target,
+ targetType = type.replace( rnamespaces, "" ),
+ isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
+ special = jQuery.event.special[ targetType ] || {};
+
+ if ( (!special._default || special._default.call( elem, event ) === false) &&
+ !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
+
+ try {
+ if ( target[ targetType ] ) {
+ // Make sure that we don't accidentally re-trigger the onFOO events
+ old = target[ "on" + targetType ];
+
+ if ( old ) {
+ target[ "on" + targetType ] = null;
+ }
+
+ jQuery.event.triggered = true;
+ target[ targetType ]();
+ }
+
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (triggerError) {}
+
+ if ( old ) {
+ target[ "on" + targetType ] = old;
+ }
+
+ jQuery.event.triggered = false;
+ }
+ }
+ },
+
+ handle: function( event ) {
+ var all, handlers, namespaces, namespace_re, events,
+ namespace_sort = [],
+ args = jQuery.makeArray( arguments );
+
+ event = args[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ all = event.type.indexOf(".") < 0 && !event.exclusive;
+
+ if ( !all ) {
+ namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+ namespace_sort = namespaces.slice(0).sort();
+ namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
+ }
+
+ event.namespace = event.namespace || namespace_sort.join(".");
+
+ events = jQuery.data(this, this.nodeType ? "events" : "__events__");
+
+ if ( typeof events === "function" ) {
+ events = events.events;
+ }
+
+ handlers = (events || {})[ event.type ];
+
+ if ( events && handlers ) {
+ // Clone the handlers to prevent manipulation
+ handlers = handlers.slice(0);
+
+ for ( var j = 0, l = handlers.length; j < l; j++ ) {
+ var handleObj = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace_re.test( handleObj.namespace ) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handleObj.handler;
+ event.data = handleObj.data;
+ event.handleObj = handleObj;
+
+ var ret = handleObj.handler.apply( this, args );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+ }
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ jQuery.expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ // Fixes #1925 where srcElement might not be defined either
+ event.target = event.srcElement || document;
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement,
+ body = document.body;
+
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
+ event.which = event.charCode != null ? event.charCode : event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( handleObj ) {
+ jQuery.event.add( this,
+ liveConvert( handleObj.origType, handleObj.selector ),
+ jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
+ },
+
+ remove: function( handleObj ) {
+ jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
+ }
+ },
+
+ beforeunload: {
+ setup: function( data, namespaces, eventHandle ) {
+ // We only want to do this special case on windows
+ if ( jQuery.isWindow( this ) ) {
+ this.onbeforeunload = eventHandle;
+ }
+ },
+
+ teardown: function( namespaces, eventHandle ) {
+ if ( this.onbeforeunload === eventHandle ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.removeEvent = document.removeEventListener ?
+ function( elem, type, handle ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, handle, false );
+ }
+ } :
+ function( elem, type, handle ) {
+ if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, handle );
+ }
+ };
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = jQuery.now();
+
+ // Mark it as fixed
+ this[ jQuery.expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+
+ // otherwise set the returnValue property of the original event to false (IE)
+ } else {
+ e.returnValue = false;
+ }
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ parent = parent.parentNode;
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) { }
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+ jQuery.event.special.submit = {
+ setup: function( data, namespaces ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit", function( e ) {
+ var elem = e.target,
+ type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ e.liveFired = undefined;
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
+ var elem = e.target,
+ type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ e.liveFired = undefined;
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ teardown: function( namespaces ) {
+ jQuery.event.remove( this, ".specialSubmit" );
+ }
+ };
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+ var changeFilters,
+
+ getVal = function( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+ },
+
+ testChange = function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( data === undefined || val === data ) {
+ return;
+ }
+
+ if ( data != null || val ) {
+ e.type = "change";
+ e.liveFired = undefined;
+ return jQuery.event.trigger( e, arguments[1], elem );
+ }
+ };
+
+ jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ beforedeactivate: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information
+ beforeactivate: function( e ) {
+ var elem = e.target;
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ },
+
+ setup: function( data, namespaces ) {
+ if ( this.type === "file" ) {
+ return false;
+ }
+
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
+ }
+
+ return rformElems.test( this.nodeName );
+ },
+
+ teardown: function( namespaces ) {
+ jQuery.event.remove( this, ".specialChange" );
+
+ return rformElems.test( this.nodeName );
+ }
+ };
+
+ changeFilters = jQuery.event.special.change.filters;
+
+ // Handle when the input is .focus()'d
+ changeFilters.focus = changeFilters.beforeactivate;
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ if ( focusCounts[fix]++ === 0 ) {
+ document.addEventListener( orig, handler, true );
+ }
+ },
+ teardown: function() {
+ if ( --focusCounts[fix] === 0 ) {
+ document.removeEventListener( orig, handler, true );
+ }
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.trigger( e, null, e.target );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) || data === false ) {
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ if ( type === "unload" && name !== "one" ) {
+ this.one( type, data, fn );
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ jQuery.event.add( this[i], type, handler, data );
+ }
+ }
+
+ return this;
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ jQuery.event.remove( this[i], type, fn );
+ }
+ }
+
+ return this;
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.live( types, data, fn, selector );
+ },
+
+ undelegate: function( selector, types, fn ) {
+ if ( arguments.length === 0 ) {
+ return this.unbind( "live" );
+
+ } else {
+ return this.die( types, null, fn, selector );
+ }
+ },
+
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments,
+ i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ }
+});
+
+var liveMap = {
+ focus: "focusin",
+ blur: "focusout",
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+};
+
+jQuery.each(["live", "die"], function( i, name ) {
+ jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
+ var type, i = 0, match, namespaces, preType,
+ selector = origSelector || this.selector,
+ context = origSelector ? this : jQuery( this.context );
+
+ if ( typeof types === "object" && !types.preventDefault ) {
+ for ( var key in types ) {
+ context[ name ]( key, data, types[key], selector );
+ }
+
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ types = (types || "").split(" ");
+
+ while ( (type = types[ i++ ]) != null ) {
+ match = rnamespaces.exec( type );
+ namespaces = "";
+
+ if ( match ) {
+ namespaces = match[0];
+ type = type.replace( rnamespaces, "" );
+ }
+
+ if ( type === "hover" ) {
+ types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
+ continue;
+ }
+
+ preType = type;
+
+ if ( type === "focus" || type === "blur" ) {
+ types.push( liveMap[ type ] + namespaces );
+ type = type + namespaces;
+
+ } else {
+ type = (liveMap[ type ] || type) + namespaces;
+ }
+
+ if ( name === "live" ) {
+ // bind live handler
+ for ( var j = 0, l = context.length; j < l; j++ ) {
+ jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
+ { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
+ }
+
+ } else {
+ // unbind live handler
+ context.unbind( "live." + liveConvert( type, selector ), fn );
+ }
+ }
+
+ return this;
+ };
+});
+
+function liveHandler( event ) {
+ var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
+ elems = [],
+ selectors = [],
+ events = jQuery.data( this, this.nodeType ? "events" : "__events__" );
+
+ if ( typeof events === "function" ) {
+ events = events.events;
+ }
+
+ // Make sure we avoid non-left-click bubbling in Firefox (#3861)
+ if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
+ return;
+ }
+
+ if ( event.namespace ) {
+ namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
+ }
+
+ event.liveFired = this;
+
+ var live = events.live.slice(0);
+
+ for ( j = 0; j < live.length; j++ ) {
+ handleObj = live[j];
+
+ if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
+ selectors.push( handleObj.selector );
+
+ } else {
+ live.splice( j--, 1 );
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ close = match[i];
+
+ for ( j = 0; j < live.length; j++ ) {
+ handleObj = live[j];
+
+ if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
+ elem = close.elem;
+ related = null;
+
+ // Those two events require additional checking
+ if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
+ event.type = handleObj.preType;
+ related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, handleObj: handleObj, level: close.level });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+
+ if ( maxLevel && match.level > maxLevel ) {
+ break;
+ }
+
+ event.currentTarget = match.elem;
+ event.data = match.handleObj.data;
+ event.handleObj = match.handleObj;
+
+ ret = match.handleObj.origHandler.apply( match.elem, arguments );
+
+ if ( ret === false || event.isPropagationStopped() ) {
+ maxLevel = match.level;
+
+ if ( ret === false ) {
+ stop = false;
+ }
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( data, fn ) {
+ if ( fn == null ) {
+ fn = data;
+ data = null;
+ }
+
+ return arguments.length > 0 ?
+ this.bind( name, data, fn ) :
+ this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ jQuery(window).bind("unload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+
+
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function() {
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function( selector, context, results, seed ) {
+ results = results || [];
+ context = context || document;
+
+ var origContext = context;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var m, set, checkSet, extra, ret, cur, pop, i,
+ prune = true,
+ contextXML = Sizzle.isXML( context ),
+ parts = [],
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ do {
+ chunker.exec( "" );
+ m = chunker.exec( soFar );
+
+ if ( m ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+ } while ( m );
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+
+ ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ?
+ Sizzle.filter( ret.expr, ret.set )[0] :
+ ret.set[0];
+ }
+
+ if ( context ) {
+ ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+
+ set = ret.expr ?
+ Sizzle.filter( ret.expr, ret.set ) :
+ ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray( set );
+
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ cur = parts.pop();
+ pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ Sizzle.error( cur || selector );
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+
+ } else if ( context && context.nodeType === 1 ) {
+ for ( i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+
+ } else {
+ for ( i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function( results ) {
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort( sortOrder );
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[ i - 1 ] ) {
+ results.splice( i--, 1 );
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function( expr, set ) {
+ return Sizzle( expr, null, null, set );
+};
+
+Sizzle.matchesSelector = function( node, expr ) {
+ return Sizzle( expr, null, null, [node] ).length > 0;
+};
+
+Sizzle.find = function( expr, context, isXML ) {
+ var set;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var match,
+ type = Expr.order[i];
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice( 1, 1 );
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName( "*" );
+ }
+
+ return { set: set, expr: expr };
+};
+
+Sizzle.filter = function( expr, set, inplace, not ) {
+ var match, anyFound,
+ old = expr,
+ result = [],
+ curLoop = set,
+ isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var found, item,
+ filter = Expr.filter[ type ],
+ left = match[1];
+
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+
+ } else {
+ curLoop[i] = false;
+ }
+
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ Sizzle.error( expr );
+
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+Sizzle.error = function( msg ) {
+ throw "Syntax error, unrecognized expression: " + msg;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+
+ leftMatch: {},
+
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+
+ attrHandle: {
+ href: function( elem ) {
+ return elem.getAttribute( "href" );
+ }
+ },
+
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test( part ),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+
+ ">": function( checkSet, part ) {
+ var elem,
+ isPartStr = typeof part === "string",
+ i = 0,
+ l = checkSet.length;
+
+ if ( isPartStr && !/\W/.test( part ) ) {
+ part = part.toLowerCase();
+
+ for ( ; i < l; i++ ) {
+ elem = checkSet[i];
+
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+
+ } else {
+ for ( ; i < l; i++ ) {
+ elem = checkSet[i];
+
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+
+ "": function(checkSet, part, isXML){
+ var nodeCheck,
+ doneName = done++,
+ checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+ nodeCheck = part;
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
+ },
+
+ "~": function( checkSet, part, isXML ) {
+ var nodeCheck,
+ doneName = done++,
+ checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test( part ) ) {
+ part = part.toLowerCase();
+ nodeCheck = part;
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
+ }
+ },
+
+ find: {
+ ID: function( match, context, isXML ) {
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ return m && m.parentNode ? [m] : [];
+ }
+ },
+
+ NAME: function( match, context ) {
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [],
+ results = context.getElementsByName( match[1] );
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+
+ TAG: function( match, context ) {
+ return context.getElementsByTagName( match[1] );
+ }
+ },
+ preFilter: {
+ CLASS: function( match, curLoop, inplace, result, not, isXML ) {
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+
+ ID: function( match ) {
+ return match[1].replace(/\\/g, "");
+ },
+
+ TAG: function( match, curLoop ) {
+ return match[1].toLowerCase();
+ },
+
+ CHILD: function( match ) {
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+
+ ATTR: function( match, curLoop, inplace, result, not, isXML ) {
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+
+ PSEUDO: function( match, curLoop, inplace, result, not ) {
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+
+ return false;
+ }
+
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+
+ POS: function( match ) {
+ match.unshift( true );
+
+ return match;
+ }
+ },
+
+ filters: {
+ enabled: function( elem ) {
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+
+ disabled: function( elem ) {
+ return elem.disabled === true;
+ },
+
+ checked: function( elem ) {
+ return elem.checked === true;
+ },
+
+ selected: function( elem ) {
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+
+ return elem.selected === true;
+ },
+
+ parent: function( elem ) {
+ return !!elem.firstChild;
+ },
+
+ empty: function( elem ) {
+ return !elem.firstChild;
+ },
+
+ has: function( elem, i, match ) {
+ return !!Sizzle( match[3], elem ).length;
+ },
+
+ header: function( elem ) {
+ return (/h\d/i).test( elem.nodeName );
+ },
+
+ text: function( elem ) {
+ return "text" === elem.type;
+ },
+ radio: function( elem ) {
+ return "radio" === elem.type;
+ },
+
+ checkbox: function( elem ) {
+ return "checkbox" === elem.type;
+ },
+
+ file: function( elem ) {
+ return "file" === elem.type;
+ },
+ password: function( elem ) {
+ return "password" === elem.type;
+ },
+
+ submit: function( elem ) {
+ return "submit" === elem.type;
+ },
+
+ image: function( elem ) {
+ return "image" === elem.type;
+ },
+
+ reset: function( elem ) {
+ return "reset" === elem.type;
+ },
+
+ button: function( elem ) {
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+
+ input: function( elem ) {
+ return (/input|select|textarea|button/i).test( elem.nodeName );
+ }
+ },
+ setFilters: {
+ first: function( elem, i ) {
+ return i === 0;
+ },
+
+ last: function( elem, i, match, array ) {
+ return i === array.length - 1;
+ },
+
+ even: function( elem, i ) {
+ return i % 2 === 0;
+ },
+
+ odd: function( elem, i ) {
+ return i % 2 === 1;
+ },
+
+ lt: function( elem, i, match ) {
+ return i < match[3] - 0;
+ },
+
+ gt: function( elem, i, match ) {
+ return i > match[3] - 0;
+ },
+
+ nth: function( elem, i, match ) {
+ return match[3] - 0 === i;
+ },
+
+ eq: function( elem, i, match ) {
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function( elem, match, i, array ) {
+ var name = match[1],
+ filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
+
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var j = 0, l = not.length; j < l; j++ ) {
+ if ( not[j] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+
+ } else {
+ Sizzle.error( "Syntax error, unrecognized expression: " + name );
+ }
+ },
+
+ CHILD: function( elem, match ) {
+ var type = match[1],
+ node = elem;
+
+ switch ( type ) {
+ case "only":
+ case "first":
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ if ( type === "first" ) {
+ return true;
+ }
+
+ node = elem;
+
+ case "last":
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ return true;
+
+ case "nth":
+ var first = match[2],
+ last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+
+ if ( first === 0 ) {
+ return diff === 0;
+
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+
+ ID: function( elem, match ) {
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+
+ TAG: function( elem, match ) {
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+
+ CLASS: function( elem, match ) {
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+
+ ATTR: function( elem, match ) {
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+
+ POS: function( elem, match, i, array ) {
+ var name = match[2],
+ filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS,
+ fescape = function(all, num){
+ return "\\" + (num - 0 + 1);
+ };
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
+}
+
+var makeArray = function( array, results ) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+// Also verifies that the returned array holds DOM nodes
+// (which is not the case in the Blackberry browser)
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
+
+// Provide a fallback method if it does not work
+} catch( e ) {
+ makeArray = function( array, results ) {
+ var i = 0,
+ ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+
+ } else {
+ for ( ; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder, siblingCheck;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ return a.compareDocumentPosition(b) & 4 ? -1 : 1;
+ };
+
+} else {
+ sortOrder = function( a, b ) {
+ var al, bl,
+ ap = [],
+ bp = [],
+ aup = a.parentNode,
+ bup = b.parentNode,
+ cur = aup;
+
+ // The nodes are identical, we can exit early
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+
+ // If the nodes are siblings (or identical) we can do a quick check
+ } else if ( aup === bup ) {
+ return siblingCheck( a, b );
+
+ // If no parents were found then the nodes are disconnected
+ } else if ( !aup ) {
+ return -1;
+
+ } else if ( !bup ) {
+ return 1;
+ }
+
+ // Otherwise they're somewhere else in the tree so we need
+ // to build up a full list of the parentNodes for comparison
+ while ( cur ) {
+ ap.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ cur = bup;
+
+ while ( cur ) {
+ bp.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ al = ap.length;
+ bl = bp.length;
+
+ // Start walking down the tree looking for a discrepancy
+ for ( var i = 0; i < al && i < bl; i++ ) {
+ if ( ap[i] !== bp[i] ) {
+ return siblingCheck( ap[i], bp[i] );
+ }
+ }
+
+ // We ended someplace up the tree so do a sibling check
+ return i === al ?
+ siblingCheck( a, bp[i], -1 ) :
+ siblingCheck( ap[i], b, 1 );
+ };
+
+ siblingCheck = function( a, b, ret ) {
+ if ( a === b ) {
+ return ret;
+ }
+
+ var cur = a.nextSibling;
+
+ while ( cur ) {
+ if ( cur === b ) {
+ return -1;
+ }
+
+ cur = cur.nextSibling;
+ }
+
+ return 1;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+Sizzle.getText = function( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += Sizzle.getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+};
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date()).getTime(),
+ root = document.documentElement;
+
+ form.innerHTML = "";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function( match, context, isXML ) {
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+
+ return m ?
+ m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
+ [m] :
+ undefined :
+ [];
+ }
+ };
+
+ Expr.filter.ID = function( elem, match ) {
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+
+ // release memory in IE
+ root = form = null;
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function( match, context ) {
+ var results = context.getElementsByTagName( match[1] );
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "";
+
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+
+ Expr.attrHandle.href = function( elem ) {
+ return elem.getAttribute( "href", 2 );
+ };
+ }
+
+ // release memory in IE
+ div = null;
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle,
+ div = document.createElement("div"),
+ id = "__sizzle__";
+
+ div.innerHTML = "";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function( query, context, extra, seed ) {
+ context = context || document;
+
+ // Make sure that attribute selectors are quoted
+ query = query.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && !Sizzle.isXML(context) ) {
+ if ( context.nodeType === 9 ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(qsaError) {}
+
+ // qSA works strangely on Element-rooted queries
+ // We can work around this by specifying an extra ID on the root
+ // and working up from there (Thanks to Andrew Dupont for the technique)
+ // IE 8 doesn't work on object elements
+ } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+ var old = context.getAttribute( "id" ),
+ nid = old || id;
+
+ if ( !old ) {
+ context.setAttribute( "id", nid );
+ }
+
+ try {
+ return makeArray( context.querySelectorAll( "#" + nid + " " + query ), extra );
+
+ } catch(pseudoError) {
+ } finally {
+ if ( !old ) {
+ context.removeAttribute( "id" );
+ }
+ }
+ }
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ // release memory in IE
+ div = null;
+ })();
+}
+
+(function(){
+ var html = document.documentElement,
+ matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
+ pseudoWorks = false;
+
+ try {
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ matches.call( document.documentElement, "[test!='']:sizzle" );
+
+ } catch( pseudoError ) {
+ pseudoWorks = true;
+ }
+
+ if ( matches ) {
+ Sizzle.matchesSelector = function( node, expr ) {
+ // Make sure that attribute selectors are quoted
+ expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
+
+ if ( !Sizzle.isXML( node ) ) {
+ try {
+ if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
+ return matches.call( node, expr );
+ }
+ } catch(e) {}
+ }
+
+ return Sizzle(expr, null, null, [node]).length > 0;
+ };
+ }
+})();
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function( match, context, isXML ) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ // release memory in IE
+ div = null;
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+
+ if ( elem ) {
+ var match = false;
+
+ elem = elem[dir];
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+
+ if ( elem ) {
+ var match = false;
+
+ elem = elem[dir];
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+if ( document.documentElement.contains ) {
+ Sizzle.contains = function( a, b ) {
+ return a !== b && (a.contains ? a.contains(b) : true);
+ };
+
+} else if ( document.documentElement.compareDocumentPosition ) {
+ Sizzle.contains = function( a, b ) {
+ return !!(a.compareDocumentPosition(b) & 16);
+ };
+
+} else {
+ Sizzle.contains = function() {
+ return false;
+ };
+}
+
+Sizzle.isXML = function( elem ) {
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function( selector, context ) {
+ var match,
+ tmpSet = [],
+ later = "",
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
+
+
+})();
+
+
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ isSimple = /^.[^:#\[\.,]*$/,
+ slice = Array.prototype.slice,
+ POS = jQuery.expr.match.POS;
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ),
+ length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ var ret = [], i, l, cur = this[0];
+
+ if ( jQuery.isArray( selectors ) ) {
+ var match, selector,
+ matches = {},
+ level = 1;
+
+ if ( cur && selectors.length ) {
+ for ( i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur, level: level });
+ }
+ }
+
+ cur = cur.parentNode;
+ level++;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ cur = this[i];
+
+ while ( cur ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
+ ret.push( cur );
+ break;
+
+ } else {
+ cur = cur.parentNode;
+ if ( !cur || !cur.ownerDocument || cur === context ) {
+ break;
+ }
+ }
+ }
+ }
+
+ ret = ret.length > 1 ? jQuery.unique(ret) : ret;
+
+ return this.pushStack( ret, "closest", selectors );
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return elems.length === 1 ?
+ jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
+ jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [],
+ cur = elem[ dir ];
+
+ while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ var retVal = !!qualifier.call( elem, i, elem );
+ return retVal === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, filtered );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+}
+
+
+
+
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
+ rtagName = /<([\w:]+)/,
+ rtbody = /\s]+\/)>/g,
+ wrapMap = {
+ option: [ 1, "" ],
+ legend: [ 1, "" ],
+ thead: [ 1, "
", "
" ],
+ tr: [ 2, "
", "
" ],
+ td: [ 3, "
", "
" ],
+ col: [ 2, "
", "
" ],
+ area: [ 1, "" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize and ';
+
+ $files = getFiles($h, $l, $t, $g, $f);
+
+ if (is_string($files))
+ printf($pattern, $files);
+ else {
+ $c = count($files)-1;
+ for($i=0; $i<=$c; $i++) {
+ if ($i)
+ echo ' ';
+ printf($pattern, $files[$i]);
+ if ($i != $c)
+ echo "\n";
+ }
+ }
+}
+
+// The function to check if anonymous mode is authorized
+function anonymousMode() {
+ if(isset($_GET['r']) && !empty($_GET['r']) && HOST_ANONYMOUS && (ANONYMOUS == 'on'))
+ return true;
+ else
+ return false;
+}
+
+// The function to quickly translate a string
+function _e($string) {
+ echo T_gettext($string);
+}
+
+// The function to check the encrypted mode
+function sslCheck() {
+ if(ENCRYPTION == 'on')
+ return true;
+ else
+ return false;
+}
+
+// The function to return the encrypted link
+function sslLink() {
+ // Using HTTPS?
+ if(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))
+ $link = ''.T_('Unencrypted').'';
+
+ // Using HTTP?
+ else
+ $link = ''.T_('Encrypted').'';
+
+ return $link;
+}
+
+// The function to get the Jappix static URL
+function staticURL() {
+ // Check for HTTPS
+ $protocol = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
+
+ // Full URL
+ $url = $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
+
+ return $url;
+}
+
+// The function to get the Jappix location (only from Get API!)
+function staticLocation() {
+ // Filter the URL
+ return preg_replace('/((.+)\/)php\/get\.php(\S)+$/', '$1', staticURL());
+}
+
+// The function to include a translation file
+function includeTranslation($locale, $domain) {
+ T_setlocale(LC_MESSAGES, $locale);
+ T_bindtextdomain($domain, JAPPIX_BASE.'/lang');
+ T_bind_textdomain_codeset($domain, 'UTF-8');
+ T_textdomain($domain);
+}
+
+// The function to check the cache presence
+function hasCache($hash) {
+ if(file_exists(JAPPIX_BASE.'/store/cache/'.$hash.'.cache'))
+ return true;
+ else
+ return false;
+}
+
+// The function to check if developer mode is enabled
+function isDeveloper() {
+ if(DEVELOPER == 'on')
+ return true;
+ else
+ return false;
+}
+
+// The function to get a file extension
+function getFileExt($name) {
+ return strtolower(preg_replace('/^(.+)(\.)([^\.]+)$/i', '$3', $name));
+}
+
+// The function to get a file type
+function getFileType($ext) {
+ switch($ext) {
+ // Images
+ case 'jpg':
+ case 'jpeg':
+ case 'png':
+ case 'bmp':
+ case 'gif':
+ case 'tif':
+ case 'svg':
+ case 'psp':
+ case 'xcf':
+ $file_type = 'image';
+
+ break;
+
+ // Videos
+ case 'ogv':
+ case 'mkv':
+ case 'avi':
+ case 'mov':
+ case 'mp4':
+ case 'm4v':
+ case 'wmv':
+ case 'asf':
+ case 'mpg':
+ case 'mpeg':
+ case 'ogm':
+ case 'rmvb':
+ case 'rmv':
+ case 'qt':
+ case 'flv':
+ case 'ram':
+ case '3gp':
+ case 'avc':
+ $file_type = 'video';
+
+ break;
+
+ // Sounds
+ case 'oga':
+ case 'ogg':
+ case 'mka':
+ case 'flac':
+ case 'mp3':
+ case 'wav':
+ case 'm4a':
+ case 'wma':
+ case 'rmab':
+ case 'rma':
+ case 'bwf':
+ case 'aiff':
+ case 'caf':
+ case 'cda':
+ case 'atrac':
+ case 'vqf':
+ case 'au':
+ case 'aac':
+ case 'm3u':
+ case 'mid':
+ case 'mp2':
+ case 'snd':
+ case 'voc':
+ $file_type = 'audio';
+
+ break;
+
+ // Documents
+ case 'pdf':
+ case 'odt':
+ case 'ott':
+ case 'sxw':
+ case 'stw':
+ case 'ots':
+ case 'sxc':
+ case 'stc':
+ case 'sxi':
+ case 'sti':
+ case 'pot':
+ case 'odp':
+ case 'ods':
+ case 'doc':
+ case 'docx':
+ case 'docm':
+ case 'xls':
+ case 'xlsx':
+ case 'xlsm':
+ case 'xlt':
+ case 'ppt':
+ case 'pptx':
+ case 'pptm':
+ case 'pps':
+ case 'odg':
+ case 'otp':
+ case 'sxd':
+ case 'std':
+ case 'std':
+ case 'rtf':
+ case 'txt':
+ case 'htm':
+ case 'html':
+ case 'shtml':
+ case 'dhtml':
+ case 'mshtml':
+ $file_type = 'document';
+
+ break;
+
+ // Packages
+ case 'tgz':
+ case 'gz':
+ case 'tar':
+ case 'ar':
+ case 'cbz':
+ case 'jar':
+ case 'tar.7z':
+ case 'tar.bz2':
+ case 'tar.gz':
+ case 'tar.lzma':
+ case 'tar.xz':
+ case 'zip':
+ case 'xz':
+ case 'rar':
+ case 'bz':
+ case 'deb':
+ case 'rpm':
+ case '7z':
+ case 'ace':
+ case 'cab':
+ case 'arj':
+ case 'msi':
+ $file_type = 'package';
+
+ break;
+
+ // Others
+ default:
+ $file_type = 'other';
+
+ break;
+ }
+
+ return $file_type;
+}
+
+// The function to get the MIME type of a file
+function getFileMIME($path) {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $cmime = finfo_file($finfo, $path);
+ finfo_close($finfo);
+
+ return $cmime;
+}
+
+// The function to keep the current GET vars
+function keepGet($current, $no_get) {
+ // Get the HTTP GET vars
+ $request = $_SERVER['REQUEST_URI'];
+
+ if(strrpos($request, '?') === false)
+ $get = '';
+
+ else {
+ $uri = explode('?', $request);
+ $get = $uri[1];
+ }
+
+ // Remove the items we don't want here
+ $proper = str_replace('&', '&', $get);
+ $proper = preg_replace('/((^)|(&))(('.$current.'=)([^&]+))/i', '', $proper);
+
+ // Nothing at the end?
+ if(!$proper)
+ return '';
+
+ // We have no defined GET var
+ if($no_get) {
+ // Remove the first "&" if it appears
+ if(preg_match('/^(&(amp;)?)/i', $proper))
+ $proper = preg_replace('/^(&(amp;)?)/i', '', $proper);
+
+ // Add the first "?"
+ $proper = '?'.$proper;
+ }
+
+ // Add a first "&" if there is no one and no defined GET var
+ else if(!$no_get && (substr($proper, 0, 1) != '&') && (substr($proper, 0, 5) != '&'))
+ $proper = '&'.$proper;
+
+ return $proper;
+}
+
+// Escapes regex special characters for in-regex usage
+function escapeRegex($string) {
+ return preg_replace('/[-[\]{}()*+?.,\\^$|#]/', '\\$&', $string);
+}
+
+// Generates the security HTML code
+function securityHTML() {
+ return '
+
+
+
+
+ Jappix - Forbidden
+
+
+
+
Forbidden
+
This is a private folder
+
+
+';
+}
+
+// Checks if a relative server path is safe
+function isSafe($path) {
+ // Mhh, someone is about to nasty stuffs (previous folder, or executable scripts)
+ if(preg_match('/\.\.\//', $path) || preg_match('/index\.html?$/', $path) || preg_match('/(\.)((php([0-9]+)?)|(aspx?)|(cgi)|(rb)|(py)|(pl)|(jsp)|(ssjs)|(lasso)|(dna)|(tpl)|(smx)|(cfm))$/i', $path))
+ return false;
+
+ return true;
+}
+
+// Set the good unity for a size in bytes
+function formatBytes($bytes, $precision = 2) {
+ $units = array('B', 'KB', 'MB', 'GB', 'TB');
+
+ $bytes = max($bytes, 0);
+ $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
+ $pow = min($pow, count($units) - 1);
+
+ $bytes /= pow(1024, $pow);
+
+ return round($bytes, $precision) . ' ' . $units[$pow];
+}
+
+// Converts a human-readable bytes value to a computer one
+function humanToBytes($string) {
+ // Values array
+ $values = array(
+ 'K' => '000',
+ 'M' => '000000',
+ 'G' => '000000000',
+ 'T' => '000000000000',
+ 'P' => '000000000000000',
+ 'E' => '000000000000000000',
+ 'Z' => '000000000000000000000',
+ 'Y' => '000000000000000000000000'
+ );
+
+ // Filter the string
+ foreach($values as $key => $zero)
+ $string = str_replace($key, $zero, $string);
+
+ // Converts the string into an integer
+ $string = intval($string);
+
+ return $string;
+}
+
+// Get the maximum file upload size
+function uploadMaxSize() {
+ // Not allowed to upload files?
+ if(ini_get('file_uploads') != 1)
+ return 0;
+
+ // Upload maximum file size
+ $upload = humanToBytes(ini_get('upload_max_filesize'));
+
+ // POST maximum size
+ $post = humanToBytes(ini_get('post_max_size'));
+
+ // Return the lowest value
+ if($upload <= $post)
+ return $upload;
+
+ return $post;
+}
+
+// Normalizes special chars
+function normalizeChars($string) {
+ $table = array(
+ 'Š'=>'S', 'š'=>'s', 'Đ'=>'Dj', 'đ'=>'dj', 'Ž'=>'Z', 'ž'=>'z', 'Č'=>'C', 'č'=>'c', 'Ć'=>'C', 'ć'=>'c',
+ 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
+ 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O',
+ 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss',
+ 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e',
+ 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o',
+ 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b',
+ 'ÿ'=>'y', 'Ŕ'=>'R', 'ŕ'=>'r'
+ );
+
+ return strtr($string, $table);
+}
+
+// Filters the XML special chars for the SVG drawer
+function filterSpecialXML($string) {
+ // Strange thing: when $string = 'Mises à jour' -> bug! but 'Mise à jour' -> ok!
+ $string = normalizeChars($string);
+
+ // Encodes with HTML special chars
+ $string = htmlspecialchars($string);
+
+ return $string;
+}
+
+// Writes the current visit in the total file
+function writeTotalVisit() {
+ // Get the current time stamp
+ $stamp = time();
+
+ // Initialize the defaults
+ $array = array(
+ 'total' => 0,
+ 'stamp' => $stamp
+ );
+
+ // Try to read the saved data
+ $total_data = readXML('access', 'total');
+
+ // Get the XML file values
+ if($total_data) {
+ // Initialize the visits reading
+ $read_xml = new SimpleXMLElement($total_data);
+
+ // Loop the visit elements
+ foreach($read_xml->children() as $current_child)
+ $array[$current_child->getName()] = intval($current_child);
+ }
+
+ // Increment the total number of visits
+ $array['total']++;
+
+ // Generate the new XML data
+ $total_xml =
+ ''.$array['total'].'
+ '.$array['stamp'].''
+ ;
+
+ // Re-write the new values
+ writeXML('access', 'total', $total_xml);
+}
+
+// Writes the current visit in the months file
+function writeMonthsVisit() {
+ // Get the current month
+ $month = intval(date('m'));
+
+ // Define the stats array
+ $array = array();
+
+ // January to August period
+ if($month <= 8) {
+ for($i = 1; $i <= 8; $i++)
+ $array['month_'.$i] = 0;
+ }
+
+ // August to September period
+ else {
+ $i = 8;
+ $j = 1;
+
+ while($j <= 3) {
+ // Last year months
+ if(($i >= 8) && ($i <= 12))
+ $array['month_'.$i++] = 0;
+
+ // First year months
+ else
+ $array['month_'.$j++] = 0;
+ }
+ }
+
+ // Try to read the saved data
+ $months_data = readXML('access', 'months');
+
+ // Get the XML file values
+ if($months_data) {
+ // Initialize the visits reading
+ $read_xml = new SimpleXMLElement($months_data);
+
+ // Loop the visit elements
+ foreach($read_xml->children() as $current_child) {
+ $current_month = $current_child->getName();
+
+ // Parse the current month id
+ $current_id = intval(preg_replace('/month_([0-9]+)/i', '$1', $current_month));
+
+ // Is this month still valid?
+ if((($month <= 8) && ($current_id <= $month)) || (($month >= 8) && ($current_id >= 8) && ($current_id <= $month)))
+ $array[$current_month] = intval($current_child);
+ }
+ }
+
+ // Increment the current month value
+ $array['month_'.$month]++;
+
+ // Generate the new XML data
+ $months_xml = '';
+
+ foreach($array as $array_key => $array_value)
+ $months_xml .= "\n".' <'.$array_key.'>'.$array_value.''.$array_key.'>';
+
+ // Re-write the new values
+ writeXML('access', 'months', $months_xml);
+}
+
+// Writes the current visit to the storage file
+function writeVisit() {
+ // Write total visits
+ writeTotalVisit();
+
+ // Write months visits
+ writeMonthsVisit();
+}
+
+// Returns the default background array
+function defaultBackground() {
+ // Define the default values
+ $background_default = array(
+ 'type' => 'default',
+ 'image_file' => '',
+ 'image_repeat' => 'repeat-x',
+ 'image_horizontal' => 'center',
+ 'image_vertical' => 'top',
+ 'image_adapt' => 'off',
+ 'image_color' => '#cae1e9',
+ 'color_color' => '#cae1e9'
+ );
+
+ return $background_default;
+}
+
+// Reads the notice configuration
+function readNotice() {
+ // Read the notice configuration XML
+ $notice_data = readXML('conf', 'notice');
+
+ // Define the default values
+ $notice_default = array(
+ 'type' => 'none',
+ 'notice' => ''
+ );
+
+ // Stored data array
+ $notice_conf = array();
+
+ // Read the stored values
+ if($notice_data) {
+ // Initialize the notice configuration XML data
+ $notice_xml = new SimpleXMLElement($notice_data);
+
+ // Loop the notice configuration elements
+ foreach($notice_xml->children() as $notice_child)
+ $notice_conf[$notice_child->getName()] = utf8_decode($notice_child);
+ }
+
+ // Checks no value is missing in the stored configuration
+ foreach($notice_default as $notice_name => $notice_value) {
+ if(!isset($notice_conf[$notice_name]) || empty($notice_conf[$notice_name]))
+ $notice_conf[$notice_name] = $notice_default[$notice_name];
+ }
+
+ return $notice_conf;
+}
+
+// The function to get the admin users
+function getUsers() {
+ // Try to read the XML file
+ $data = readXML('conf', 'users');
+ $array = array();
+
+ // Any data?
+ if($data) {
+ $read = new SimpleXMLElement($data);
+
+ // Check the submitted user exists
+ foreach($read->children() as $child) {
+ // Get the node attributes
+ $attributes = $child->attributes();
+
+ // Push the attributes to the global array (converted into strings)
+ $array[$attributes['name'].''] = $attributes['password'].'';
+ }
+ }
+
+ return $array;
+}
+
+// Manages users
+function manageUsers($action, $array) {
+ // Try to read the old XML file
+ $users_array = getUsers();
+
+ // What must we do?
+ switch($action) {
+ // Add some users
+ case 'add':
+ foreach($array as $array_user => $array_password)
+ $users_array[$array_user] = genStrongHash($array_password);
+
+ break;
+
+ // Remove some users
+ case 'remove':
+ foreach($array as $array_user) {
+ // Not the last user?
+ if(count($users_array) > 1)
+ unset($users_array[$array_user]);
+ }
+
+ break;
+ }
+
+ // Regenerate the XML
+ $users_xml = '';
+
+ foreach($users_array as $users_name => $users_password)
+ $users_xml .= "\n".' ';
+
+ // Write the main configuration
+ writeXML('conf', 'users', $users_xml);
+}
+
+// Resize an image with GD
+function resizeImage($path, $ext, $width, $height) {
+ // No GD?
+ if(!function_exists('gd_info'))
+ return false;
+
+ try {
+ // Initialize GD
+ switch($ext) {
+ case 'png':
+ $img_resize = imagecreatefrompng($path);
+
+ break;
+
+ case 'gif':
+ $img_resize = imagecreatefromgif($path);
+
+ break;
+
+ default:
+ $img_resize = imagecreatefromjpeg($path);
+ }
+
+ // Get the image size
+ $img_size = getimagesize($path);
+ $img_width = $img_size[0];
+ $img_height = $img_size[1];
+
+ // Necessary to change the image width
+ if($img_width > $width && ($img_width > $img_height)) {
+ // Process the new sizes
+ $new_width = $width;
+ $img_process = (($new_width * 100) / $img_width);
+ $new_height = (($img_height * $img_process) / 100);
+ }
+
+ // Necessary to change the image height
+ else if($img_height > $height && ($img_width < $img_height)) {
+ // Process the new sizes
+ $new_height = $height;
+ $img_process = (($new_height * 100) / $img_height);
+ $new_width = (($img_width * $img_process) / 100);
+ }
+
+ // Else, just use the old sizes
+ else {
+ $new_width = $img_width;
+ $new_height = $img_height;
+ }
+
+ // Create the new image
+ $new_img = imagecreatetruecolor($new_width, $new_height);
+
+ // Must keep alpha pixels?
+ if(($ext == 'png') || ($ext == 'gif')){
+ imagealphablending($new_img, false);
+ imagesavealpha($new_img, true);
+
+ // Set transparent pixels
+ $transparent = imagecolorallocatealpha($new_img, 255, 255, 255, 127);
+ imagefilledrectangle($new_img, 0, 0, $new_width, $new_height, $transparent);
+ }
+
+ // Copy the new image
+ imagecopyresampled($new_img, $img_resize, 0, 0, 0, 0, $new_width, $new_height, $img_size[0], $img_size[1]);
+
+ // Destroy the old data
+ imagedestroy($img_resize);
+ unlink($path);
+
+ // Write the new image
+ switch($ext) {
+ case 'png':
+ imagepng($new_img, $path);
+
+ break;
+
+ case 'gif':
+ imagegif($new_img, $path);
+
+ break;
+
+ default:
+ imagejpeg($new_img, $path, 85);
+ }
+
+ return true;
+ }
+
+ catch(Exception $e) {
+ return false;
+ }
+}
+
+?>
diff --git a/sources/addons/jappixmini/jappix/php/generate-chat.php b/sources/addons/jappixmini/jappix/php/generate-chat.php
new file mode 100644
index 00000000..19c8e71c
--- /dev/null
+++ b/sources/addons/jappixmini/jappix/php/generate-chat.php
@@ -0,0 +1,235 @@
+'.$avatar.'';
+ else
+ $avatar = '';
+
+ // Generates an human-readable date
+ $date = explode('T', $date);
+ $date = explode('-', $date[0]);
+ $date = $date[2].'/'.$date[1].'/'.$date[0];
+
+ // Generate some values
+ $content_dir = '../store/logs/';
+ $filename = 'chat_log-'.md5($xid.time());
+ $filepath = $content_dir.$filename.'.html';
+
+ // Generate Jappix logo Base64 code
+ $logo = base64_encode(file_get_contents(JAPPIX_BASE.'/img/sprites/logs.png'));
+
+ // Create the HTML code
+ $new_text_inter =
+'
+
+
+
+
+ '.$nick.' ('.$xid.')
+
+
+
+
+