sagenb-1.0.1/ 0000775 0000000 0000000 00000000000 13114362624 0012752 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/.gitignore 0000664 0000000 0000000 00000000407 13114362624 0014743 0 ustar 00root root 0000000 0000000 # Boring file regexps:
*.scssc
*.sassc
*~
/.hg
/.hgtags
*.orig
*.patch
*.pyc
*.pyo
/*.gitk-tmp*
# sage files to ignore:
/build
/dist
MANIFEST
PKG-INFO
release_notes.txt
/sass/src/.sass-cache
/sagenb/data/jmol
/sagenb.egg-info
sagenb/data/jsmath/fonts
/setup.cfg
sagenb-1.0.1/COPYING 0000664 0000000 0000000 00000105662 13114362624 0014017 0 ustar 00root root 0000000 0000000 sagenb - a web interface for the Sage mathematical software system
Copyright (c) 2009-2013, sagenb contributors (see `git log`)
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 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License (below) for more details.
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU 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. But first, please read
.
sagenb-1.0.1/Changes 0000664 0000000 0000000 00000005261 13114362624 0014251 0 ustar 00root root 0000000 0000000 1.0 May 24 2017
- variours py3 compatibility changes
- absolute imports
- see https://github.com/sagemath/sagenb/commits/master
for complete list
0.13 May 9 2016
- fix location of stylesheet with Sphinx 1.4
- improvements towards Python 3 compatibility
0.12 Apr 7 2016
- package sagenb as a normal Python package
- remove bundled mathjax
0.11.7 Feb 23 2016
- change imports for Sage changes
- small documentation fixes
- use new Sage documentation variables
0.11.6.1 Dec 14 2015
- fix doctests
0.11.6 Dec 12 2015
- pexpect upgrade
- fixes for autoescape
0.11.5 Dec 02 2015
- Ukrainian translation
- security update in Jinja2
- file move update and other smaller changes
0.11.4 Jan 29 2015
- Email default changed to empty list
0.11.3 Jan 22 2015
- Spanish language update
- some smaller fixes
- allow custom server_pool communication directory
- update various instructions and manifest
0.11.2 Dec 22 2014
- Improved language support
- Fixed several bugs
- init.sage works again
- Email configuration for crash report
0.11.1 Nov 10 2014
- Live documentation fixes
- Release Manager and other developer instruction updates
0.11.0 Oct 27 2014
- Update default color selector in interacts
- Update jQuery
- Update to Jsmol for js 3d graphic default (trac #16004)
- Make snapshots work again
- A few other minor fixes
0.10.8.3 Sep 21 2014
- New Spanish translation
- New French translation
- Update sagenb and documentation for new development workflow
- Numerous bug fixes for settings, jmol, user management, and text fields
0.10.8.2 Feb 03 2014
- Change doctest (#197)
0.10.8.1 Feb 03 2014
- Fix a bug in import of latex macros for mathjax (#195)
0.10.8 Dec 29 2013
- Add Flask-OldSessions to dependency list and fix #184
- Restrict pytz version to at most 2013b
0.10.7.3 Dec 22 2013
- Minor fix for trac ticket #15510
- Fix for Issue #135
- unicode "open your browser" message
- change URL for bug reports to sagemath.com/report-issue
0.10.7.2 Aug 08 2013
- Minor fix for trac ticket 14469
0.10.7.1 Jun 25 2013
- revert published worksheet sanitization as it is not optional
0.10.7 Jun 24 2013
- Update license to GPLv3+ from GPLv2+
- Update MathJax to 2.2
- Allow new doctest continuation format in livedocs
- Sanitization for published worksheets
- Various bug fixes
0.10.6 Apr 27 2013
- Allow more actions in live documentation.
- Add tools for converting sws files to rst files.
- Add parameter "doc_timeout" for controlling timeouts of live worksheets.
0.10.5 Apr 01 2013
- Add support for LDAP authentication.
- Remove the old notebook.
sagenb-1.0.1/HACKING.rst 0000664 0000000 0000000 00000005627 13114362624 0014562 0 ustar 00root root 0000000 0000000 ================================
Development of the Sage notebook
================================
Unlike most other parts of Sage (as of January 2013), development of
sagenb is done on a moving target, namely a git repository on GitHub.
Rather than making changes to the version of sagenb that came with your
copy of Sage, please first clone `the sagenb git repository`_ and
install it into your copy of Sage before you start coding. Details on
how to do this are as follows.
#. Install `the latest development version of Sage`_ from sagemath.org.
#. Sign up for an account at github.com, if you don't already have one,
and log in; set up your SSH keys for authentication as directed by
the instructions.
#. Create your own fork of sagenb on the GitHub website. To do this, go
to `the sagenb git repository`_ page and click on "Fork" in the
upper right corner of the webpage.
#. Clone your fork of sagenb to somewhere on your local disk, for
example ``~/src/sagenb-git``::
$ cd ~/src
$ git clone git@github.com:/sagenb sagenb-git
#. Where ``SAGE_ROOT`` represents the base path of your Sage
installation, perform the following commands. If you have more than one
sagenb installation in ``SAGE_ROOT/local/lib/python2.7/site-packages``,
then change directory into the latest version::
$ cd SAGE_ROOT/local/lib/python2.7/site-packages/
$ mv sagenb sagenb-old
$ ln -s ~/src/sagenb-git/sagenb sagenb # or wherever your clone is
$ cd ~/src/sagenb-git
$ SAGE_ROOT/sage --python setup.py develop
$ ln -s SAGE_ROOT/sage/local/share/mathjax sagenb/data/mathjax
#. You can also add the `sagenb`_ git repository as a remote branch
called ``upstream``::
$ git remote add upstream git@github.com:sagemath/sagenb
$ git remote update upstream
This will allow you to update your local repository as other
people's changes are merged. Such an operation might look something
like this::
$ git remote update upstream # learn what has changed
$ git checkout master # move to local master
$ git merge upstream/master # merge changes to local master
This completes the installation process. Now you can modify files in
your ``sagenb-git`` directory and submit your modifications to us using pull
requests on GitHub. (A full walkthrough of using git and GitHub are
beyond the scope of this file -- for more information see `the relevant
section in the Sage manual`_.)
If you ever need to switch to using another Sage installation for your
sagenb development, you only need to repeat step 5 with the new value of
``SAGE_ROOT``.
.. _the sagenb git repository: http://github.com/sagemath/sagenb
.. _the latest development version of Sage:
http://sagemath.org/download-latest.html
.. _the relevant section in the Sage manual:
http://sagemath.org/doc/developer/sagenb/index.html
sagenb-1.0.1/INSTALL.rst 0000664 0000000 0000000 00000001674 13114362624 0014622 0 ustar 00root root 0000000 0000000 =================================
Installation of the Sage notebook
=================================
Currently, standalone usage of the Sage notebook is not supported,
though this is one of our goals for the future. For now, please use
sagenb with a copy of `Sage`_.
The `latest version of Sage`_ should come with a somewhat recent version
of the Sage notebook, and the `latest development version of Sage`_
a possibly more recent version.
Alternatively, see HACKING.rst for instructions on how to install the
truly latest, development version of sagenb into an already installed
copy of Sage. This is only recommended for people who want to modify the
code of sagenb, since the development version may be buggy or otherwise
unsuitable for daily use (standard disclaimer).
.. _Sage: http://sagemath.org/
.. _latest version of Sage: http://sagemath.org/download.html
.. _latest development version of Sage:
http://sagemath.org/download-latest.html
sagenb-1.0.1/MANIFEST.in 0000664 0000000 0000000 00000000337 13114362624 0014513 0 ustar 00root root 0000000 0000000 graft sagenb
graft sass
graft util
prune sass/src/.sass-cache
include *.txt *.rst *.md MANIFEST.in .gitignore dist.sh COPYING Changes
prune .git
global-exclude *.pyc *.pyo *.orig *.rej *~ \#* *\# *.sassc *.scssc *.DS_Store
sagenb-1.0.1/README.rst 0000664 0000000 0000000 00000010704 13114362624 0014443 0 ustar 00root root 0000000 0000000 .. nodoctest
.. This README does not explain how to handle installation into versions
of Sage which do not yet ship the flask notebook, as the packaging of
the notebook's dependencies is still in flux. Please see
http://code.google.com/r/jasongrout-flask-sagenb/ for more
information. # XXX 2011-12-22
This is the standalone Sage Notebook.
Most of the notebook does not depend on having Sage installed. Only
a few miscellaneous functions are imported from Sage. We welcome help in
making the notebook completely independent from Sage, or indeed, any
other help with the Sage notebook. Sage notebook development discussions
happen on the sage-notebook_ mailing list.
.. _sage-notebook: http://groups.google.com/group/sage-notebook
Installation
============
Install Sage, then do ``sage -python setup.py install`` in the current
directory. Then run the notebook from within Sage as follows::
sage: import sagenb.notebook.notebook_object as nb
sage: nb.notebook(directory="mynotebook")
This will create a directory ``mynotebook.sagenb``, and all notebook
data is stored in that directory.
SSL support
-----------
SSL is required for OpenID and HTTPS support in the notebook. OpenID
only requires Python's built-in SSL support, whereas HTTPS support also
requires the Python library pyOpenSSL. In order to ensure that these are
installed, please follow the instructions in Sage's own README file
(look for the section about SSL). If you don't intend to use OpenID for
user logins, or HTTPS for connecting to the server, you can safely
ignore this section. In particular, if you're installing a copy of Sage
for your personal use only, you probably won't need OpenID or HTTPS
support in the notebook.
LDAP authentication
-------------------
HTTPS support in the Python library is required to download and install
files, in order to install LDAP authentication support. To enable HTTPS
support read the section on SSL in Sage's own README file. Enabling LDAP
authentication also requires one to install the LDAP development headers.
You can install the LDAP development headers to your system by using your
package manager. For instance, on a Debian/Ubuntu Linux system you may
install LDAP and SSL by running the following command::
$ sudo apt-get install libldap2-dev libsasl2-dev libssl-dev
Next, use the following commands to install the python-ldap package in
Sage::
$ /path/to/sage -sh
$ easy_install python-ldap
Once python-ldap is installed, (re)start the notebook server and the
options to setup LDAP authentication will be visible in the "Notebook
Settings" section of the "Settings."
Development
===========
Development and issue tracking of sagenb happens primarily on
Github at https://github.com/sagemath/sagenb, with certain
discussions at the sage-notebook Google group
https://groups.google.com/forum/#!forum/sage-notebook.
Instructions for getting started with sagenb development
are found in the file ``HACKING.rst``, including how to link
a local clone of the source to an existing Sage installation.
See the Sage Developer's guide, part of the Sage documentation, at
http://www.sagemath.org/doc/developer/index.html for some further
instructions. There is also a useful, if somewhat outdated, overview
of the directory structure, evaluation and serving flow at
http://wiki.sagemath.org/devel/SageNotebook
Stylesheets (CSS)
-----------------
See ``sass/readme.txt`` for information about how to
use sagenb's SCSS files to update its CSS *properly*.
Localization
------------
The Sage notebook has various localizations available, and
welcomes updates to those as well as new ones. The current
localizations are available in ``sagenb/translations``.
The file ``util/translations.py`` encapsulates much of the
Python Babel localization utility in an easy-to-use
interface meant for the Sage notebook. We recommend its
use to update and create new translations. Full help
is available by running the file in the Sage Python
shell with the ``-h`` argument::
cd $SAGENB_ROOT
sage -python ./util/translations.py -h
A more advanced introduction is in preparation.
Release Instructions
--------------------
Currently, sagenb is an upstream project from Sage proper.
That means any new sagenb release needs to be packaged properly
in order to be included in Sage.
Read ``ReleaseInstr.md`` for step-by-step details on how
to create such a release, including minor changes
needed on the Sage side to ``build/pkgs/sagenb/package-version.txt``
and the checksum file.
sagenb-1.0.1/ReleaseInstr.md 0000664 0000000 0000000 00000010266 13114362624 0015701 0 ustar 00root root 0000000 0000000 ## Steps to create a Sagenb package
Throughout the steps below, replace `` with the actual version,
for example, `0.10.8.3`. Also, we will assume that
`github.org/sagemath/sagenb` is present as `upstream` remote repository
in your local `SAGENB_ROOT`.
1. It wouldn't hurt to make sure the notebook actually runs
before you start, or alerting to any major changes needed
in localizations, either.
1. Any new or updated dependencies should be corrected in the file
`setup.py`.
1. Change into the sagenb git directory, and update to the latest
`upstream/master`. We assume that all the required merges to the
`upstream/master` have happened already and that your master is
at a previous or current commit (same hash) of `upstream/master`;
if not, use `git merge upstream/master` instead of `git rebase`.
```sh
cd SAGENB_ROOT
git checkout master
git fetch upstream
git rebase upstream/master
```
1. Edit `Changes` file to highlight the main changes. Edit `setup.py` to
update the version for Sagenb (this is *important*). Example diff:
```diff
--- a/setup.py
+++ b/setup.py
@@ -44,7 +44,7 @@ if __name__ == '__main__':
distutils.log.set_threshold(distutils.log.DEBUG)
code = setup(name = 'sagenb',
- version = '0.10.8.2',
+ version = '0.10.8.3',
description = 'The Sage Notebook',
license = 'GNU General Public License (GPL) v3+',
author = 'William Stein et al.',
```
1. Commit the updated version change.
```sh
git add Changes
git add setup.py
git commit -m "Update Sagenb version to "
```
1. Create the sagenb tarball:
```sh
./dist.sh
```
1. Let Sage know about the new sagenb and update its checksums, and then
try out the new sagenb and test it. Here we are not yet committing,
in case of any errors.
```sh
cd SAGE_ROOT
echo "" > build/pkgs/sagenb/package-version.txt
./sage --fix-pkg-checksums
./sage -tp --long --sagenb # test sagenb
make ptestlong # test sage
```
If you are not using your sagenb repository directly inside
Sage as described in the file HACKING.rst, you may need to
use the following command before actually testing it out.
```sh
./sage -f sagenb # if necessary to install the new sagenb
```
1. (Optional) Check that the Selenium tests pass.
1. (Optional) If you encounter errors or realize there was a mistake,
you can try to fix them back in sagenb, after reverting the last
change (the updated sagenb version).
```sh
cd SAGENB_ROOT
git reset --mixed HEAD^
git commit -m 'Fix doctests' # or whatever is appropriate
git add Changes
git add setup.py
git commit
```
Now return to the previous steps for creating the distribution and
new tar files, update checksums etc. as needed, and then proceed.
1. Now we can create a branch for the ticket ``, commit our changes,
and push to Trac. Warning: do not use `git commit -a`
unless you are sure (see `git status`) that you don't have anything else
in your directory that shouldn't be added; otherwise do `git add` the
correct files first.
```sh
git checkout develop -b ticket/ # or "git trac create" or "git trac checkout", etc
git commit -a -m "Upgrade sagenb to version "
./sage -tp --long --sagenb # test sagenb again
make ptestlong # test sage again if need be
git trac push
```
You will want to upload the sagenb tar.bz2 file somewhere convenient
and put a link to it on the appropriate Trac ticket as well.
1. Now that everything is fine, update the sagenb in Github with the new
changes.
```sh
cd SAGENB_ROOT
git tag
git push upstream master
git checkout release
git merge
git push upstream release
git push upstream --tags # This will automatically create sagenb.tar.gz in Github
```
sagenb-1.0.1/dist.sh 0000775 0000000 0000000 00000000167 13114362624 0014260 0 ustar 00root root 0000000 0000000 #!/usr/bin/env bash
# This script creates a new tarball for SageNB.
rm -rf dist
exec ./setup.py sdist --format=bztar
sagenb-1.0.1/sagenb/ 0000775 0000000 0000000 00000000000 13114362624 0014211 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/__init__.py 0000664 0000000 0000000 00000000066 13114362624 0016324 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*
# init
from . import storage
sagenb-1.0.1/sagenb/babel.cfg 0000664 0000000 0000000 00000000744 13114362624 0015744 0 ustar 00root root 0000000 0000000 #To find translatable strings,
#run on terminal: pybabel -v extract -F /path/to/babel.cfg /path/to/project -o name_of_project.pot
#It'll create the file /path/to/project/name_of_project.pot
[python: **/sagenb/notebook/**.py]
[python: **/sagenb/flask_version/**.py]
[jinja2: **/sagenb/data/sage/html/**.html]
encoding = utf-8
extensions=jinja2.ext.autoescape,jinja2.ext.with_
[jinja2: **/sagenb/data/sage/js/**.js]
encoding = utf-8
extensions=jinja2.ext.autoescape,jinja2.ext.with_
sagenb-1.0.1/sagenb/data/ 0000775 0000000 0000000 00000000000 13114362624 0015122 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/graph_editor/ 0000775 0000000 0000000 00000000000 13114362624 0017571 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/graph_editor/README.txt 0000664 0000000 0000000 00000005364 13114362624 0021277 0 ustar 00root root 0000000 0000000 SAGE GRAPH EDITOR
AUTHORS:
- Radoslav Kirov
- Mitesh Patel
The following files in this directory are needed to run the graph
editor:
a. sage/graphs/graph_editor.py
b. graph_editor.html
c. graph_editor.js
d. processing.editor.min.js
What do they do? Evaluating graph_editor(G) in an input cell
generates the code/markup for an inline frame, which the notebook
inserts into the corresponding output cell. The iframe loads (b) as
its content. In turn, (b) draws in jQuery / UI, the layout algorithms
in (c), and the HTML5 canvas rendering engine in (d).
Here's how the server and editor communicate with each other:
Server -> Editor:
The Python function graph_to_js() in (a) makes a string
representation of the relevant graph data (currently, adjacency
lists and vertex coordinates) and puts it in a hidden HTML input
element. This element goes into the relevant cell's output.
How does the editor find the data? The function just adds the
cell ID to the editor's URL, e.g.,
[...]/graph_editor.html?cell_id=7. When the iframe loads, the
setup code in graph_editor.js extracts the ID, gets the data, and
creates a visual representation of the graph. Processing.js
supplies the graphics and dynamic primitives, i.e., for drawing
circles and lines, controlling animation, etc.
Editor -> Server:
When the user clicks "Save", the notebook gets the latest graph
data, formats it for the Sage library's graph methods (e.g., the
Graph constructor and Graph.set_pos), optionally replaces the
cell's input (see the replace_input option in (a)), and evaluates
the cell.
File (d) is slightly modified version of the JS library Processing.JS
(http://processingjs.org/). The only change is that mouse events are
attached to the whole document, rather than to the current element.
attach(curElement,"mousemove",function(e)...
----> attach(document,"mousemove",function(e)...
This makes it possible to drag vertices outside the canvas for the
erasing maneuver.
For reference, the original Processing.JS library and its minified
source files are also included here:
e. processing.js
f. processing.min.js
There's also an un-minified (http://jsbeautifier.org/) version of
processing.editor.min.js:
g. processing.editor.js
Possibilities for the future:
* Improved or alternate layout algorithms. The function
Edge.prototype.shrink., in graph_editor.js, runs the current spring
model.
* Directed graphs! We could use Bezier curves here.
* Edge and vertex colors.
* Edge and vertex labels.
* Use JSON for the graph data. This is much safer than eval. It
would also help if it were possible to construct Graphs directly
from stringified JSON objects.
Have fun!
sagenb-1.0.1/sagenb/data/graph_editor/graph_editor.html 0000664 0000000 0000000 00000004660 13114362624 0023134 0 ustar 00root root 0000000 0000000
Graph Editor
live:
variable name:
strength:
length:
move vertex
Vertices are draggable.
create vertex
Click on empty space not too close to existing vertices.
select a vertex
Click on existing vertex.
create/erase edge
Select the first vertex. Click on another vertex (different than the selected one) to turn on/off (toggle) the edge between them.
keep the selected vertex
Hold 'SHIFT' to perserve the selected vertex after creating/erasing an edge.
delete vertex
Double click on vertex or drag to the edge for the frame (be careful, there is no UNDO yet!).
sagenb-1.0.1/sagenb/data/graph_editor/graph_editor.js 0000664 0000000 0000000 00000021762 13114362624 0022606 0 ustar 00root root 0000000 0000000 /*global $, document, p: true, Processing, top, window */
/*jslint white: false, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, strict: true, newcap: true, immed: true */
"use strict";
var edge_list = [], nodes = [], NODES, EDGES, SIZE, NEW_RADIUS,
DOUBLECLICK, LIVE, SPRING, FIXED_LENGTH,
selected_node, dragged_node, dragging_flag, last_click_time,
initial_x, initial_y, p, edges = [], num_vertices = null, pos = null;
NODES = 10;
EDGES = 20;
SIZE = 350;
NEW_RADIUS = 20;
DOUBLECLICK = 250;
LIVE = false;
SPRING = 0.999;
FIXED_LENGTH = 100.0;
function rand(a, b) {
return a + Math.floor(Math.random() * (b - a));
}
function Node(x, y) {
this.x = x;
this.y = y;
this.size = 7;
}
Node.prototype.display = function () {
p.stroke(0);
if (this.selected) {
p.fill(255, 0, 0);
p.ellipse(this.x, this.y, this.size, this.size);
} else {
p.fill(0);
p.ellipse(this.x, this.y, this.size, this.size);
}
};
Node.prototype.distance_to = function (x, y) {
return Math.sqrt(Math.pow((x - this.x), 2) + Math.pow((y - this.y), 2));
};
Node.prototype.is_hit = function (x, y) {
return Math.abs(x - this.x) < this.size &&
Math.abs(y - this.y) < this.size;
};
function Edge(node1, node2) {
this.node1 = node1;
this.node2 = node2;
}
Edge.prototype.shrink = function () {
var d, gx, gy, mx, my;
mx = (this.node1.x + this.node2.x) / 2;
my = (this.node1.y + this.node2.y) / 2;
if (this.node1 !== dragged_node) {
d = this.node1.distance_to(mx, my);
gx = mx + (this.node1.x - mx) / d * FIXED_LENGTH / 2;
gy = my + (this.node1.y - my) / d * FIXED_LENGTH / 2;
this.node1.x = gx + (this.node1.x - gx) * SPRING;
this.node1.y = gy + (this.node1.y - gy) * SPRING;
}
if (this.node2 !== dragged_node) {
d = this.node2.distance_to(mx, my);
gx = mx + (this.node2.x - mx) / d * FIXED_LENGTH / 2;
gy = my + (this.node2.y - my) / d * FIXED_LENGTH / 2;
this.node2.x = gx + (this.node2.x - gx) * SPRING;
this.node2.y = gy + (this.node2.y - gy) * SPRING;
}
};
Edge.prototype.display = function () {
if (this.node1.x > SIZE || this.node1.y > SIZE ||
this.node1.x < 0 || this.node1.y < 0 ||
this.node2.x > SIZE || this.node2.y > SIZE ||
this.node2.x < 0 || this.node2.y < 0) {
p.stroke(255, 0, 0);
} else {
if (this.node1.selected || this.node2.selected) {
p.stroke(0, 0, 200);
} else {
p.stroke(0);
}
}
p.line(this.node1.x, this.node1.y, this.node2.x, this.node2.y);
};
function add_node(node) {
if (nodes.indexOf(node) === -1) {
nodes.push(node);
}
}
function remove_node(node) {
var edge, i, index;
for (i = edge_list.length - 1; i > -1; i -= 1) {
edge = edge_list[i];
if (edge.node1 === node || edge.node2 === node) {
edge_list.splice(i, 1);
}
}
index = nodes.indexOf(node);
if (index !== -1) {
nodes.splice(index, 1);
}
}
function add_edge_between_nodes(node1, node2) {
if (node1 === node2) {
// Only simple graphs are implemented so far.
return;
}
edge_list.push(new Edge(node1, node2));
if (nodes.indexOf(node1) === -1) {
nodes.add(node1);
}
if (nodes.indexOf(node2) === -1) {
nodes.add(node2);
}
}
function toggle_edge(node1, node2) {
var edge, existing = false, i, new_edge;
if (node1 === node2) {
// Only simple graphs are implemented so far.
return;
}
new_edge = new Edge(node1, node2);
for (i = edge_list.length - 1; i > -1; i -= 1) {
edge = edge_list[i];
if ((edge.node1 === new_edge.node1 && edge.node2 === new_edge.node2) ||
(edge.node1 === new_edge.node2 && edge.node2 === new_edge.node1)) {
existing = true;
break;
}
}
if (existing) {
edge_list.splice(i, 1);
} else {
edge_list.push(new_edge);
}
}
function set_graph() {
var i, n1, n2;
if (!pos) {
for (i = 0; i < NODES; i += 1) {
add_node(new Node(rand(0, SIZE), rand(0, SIZE)));
}
for (i = 0; i < EDGES; i += 1) {
n1 = rand(0, NODES);
n2 = rand(0, NODES);
add_edge_between_nodes(nodes[n1], nodes[n2]);
}
}
for (i = 0; i < num_vertices; i += 1) {
if (pos) {
add_node(new Node(pos[i][0] * 8 * SIZE / 10 + SIZE / 10,
pos[i][1] * 8 * SIZE / 10 + SIZE / 10));
} else {
add_node(new Node(rand(0, SIZE), rand(0, SIZE)));
}
}
for (i = 0; i < edges.length; i += 1) {
add_edge_between_nodes(nodes[edges[i][0]], nodes[edges[i][1]]);
}
p.draw();
}
function display_graph() {
var i;
for (i = 0; i < edge_list.length; i += 1) {
edge_list[i].display();
if (LIVE) {
edge_list[i].shrink();
}
}
for (i = 0; i < nodes.length; i += 1) {
nodes[i].display();
}
}
function setup() {
p.size(SIZE, SIZE);
set_graph();
p.rectMode(p.RADIUS);
p.ellipseMode(p.RADIUS);
p.noLoop();
}
function update_sliders() {
SPRING = (1 - 1e-2) + 1e-4 * (100 - $('#val_edge').val());
FIXED_LENGTH = $('#val_fixed_length').val();
}
function draw() {
update_sliders();
p.background(255);
display_graph();
}
function toggle_live() {
if (LIVE) {
LIVE = false;
p.noLoop();
} else {
LIVE = true;
p.loop();
}
}
function mousePressed() {
var clicked_node, closest_distance, i, new_distance;
if (!LIVE) {
p.loop();
}
for (i = 0; i < nodes.length; i += 1) {
if (nodes[i].is_hit(p.mouseX, p.mouseY)) {
clicked_node = nodes[i];
break;
}
}
if (!clicked_node) {
closest_distance = SIZE;
for (i = 0; i < nodes.length; i += 1) {
new_distance = nodes[i].distance_to(p.mouseX, p.mouseY);
if (new_distance < closest_distance) {
closest_distance = new_distance;
}
}
if (closest_distance > NEW_RADIUS) {
add_node(new Node(p.mouseX, p.mouseY));
}
return;
} else {
dragged_node = clicked_node;
initial_x = dragged_node.x;
initial_y = dragged_node.y;
}
}
function mouseDragged() {
if (dragged_node) {
dragging_flag = true;
dragged_node.x = p.mouseX;
dragged_node.y = p.mouseY;
}
}
function mouseReleased() {
if (dragged_node) {
if (dragging_flag) {
dragging_flag = false;
if (dragged_node.x > SIZE || dragged_node.y > SIZE ||
dragged_node.x < 0 || dragged_node.y < 0) {
remove_node(dragged_node);
if (selected_node === dragged_node) {
selected_node = false;
}
dragged_node = false;
}
} else {
if (p.millis() - last_click_time < DOUBLECLICK) {
remove_node(dragged_node);
if (selected_node === dragged_node) {
selected_node = false;
}
} else if (selected_node) {
toggle_edge(selected_node, dragged_node);
if (!p.keyPressed) {
selected_node.selected = false;
selected_node = false;
} else {
if (selected_node === dragged_node) {
selected_node.selected = false;
selected_node = false;
}
}
} else {
selected_node = dragged_node;
selected_node.selected = true;
}
}
dragged_node = false;
last_click_time = p.millis();
p.redraw();
}
if (!LIVE) {
p.noLoop();
}
}
function mouse_out() {
if (dragged_node) {
dragged_node.x = initial_x;
dragged_node.y = initial_y;
dragged_node = false;
}
}
function positions_dict() {
var i, out;
out = "{";
for (i = 0; i < nodes.length; i += 1) {
out += i + ":[" + nodes[i].x + "," + (SIZE - nodes[i].y) + "],";
}
return out.substring(0, out.length - 1) + "}";
}
function adjacency_lists_dict() {
var edge, empty, i, j, node, out;
out = "{";
for (i = 0; i < nodes.length; i += 1) {
out += i + ":[";
node = nodes[i];
empty = true;
for (j = 0; j < edge_list.length; j += 1) {
edge = edge_list[j];
if (edge.node1 === node) {
if (!empty) {
out += ",";
}
empty = false;
out += nodes.indexOf(edge.node2);
}
if (edge.node2 === node) {
if (!empty) {
out+=",";
}
empty = false;
out += nodes.indexOf(edge.node1);
}
}
out += "],";
}
return out.substring(0, out.length - 1) + "}";
}
function update_sage() {
return [adjacency_lists_dict(), positions_dict(), $('#graph_name').val()];
}
$(document).ready(function () {
var cell_id, cell_outer, loc;
// Retrieve graph data and name from parent document.
loc = window.location.href;
cell_id = parseInt(loc.slice(loc.search('cell_id=') + 8), 10);
cell_outer = $('#cell_outer_' + cell_id, top.document);
eval($('#graph_data_' + cell_id, cell_outer).val());
$('#graph_name').val($('#graph_name_' + cell_id, cell_outer).val());
// Set up processing.js.
p = Processing($('#canvas')[0], '');
p.setup = setup;
p.draw = draw;
p.mouseDragged = mouseDragged;
p.mousePressed = mousePressed;
p.mouseReleased = mouseReleased;
p.init();
$('#help').hide();
$('#help_button').click(function () {
$('#help').toggle();
});
$('#live').click(function() {
toggle_live();
});
$('#slider_edge').slider({
min: 0,
max: 100,
value: 50,
slide: function(event, ui) {
$('#val_edge').val(ui.value);
}
});
$('#slider_fixed_length').slider({
min: 0,
max: 200,
value: 100,
slide: function(event, ui) {
$('#val_fixed_length').val(ui.value);
}
});
});
sagenb-1.0.1/sagenb/data/graph_editor/processing.editor.js 0000664 0000000 0000000 00000117206 13114362624 0023577 0 ustar 00root root 0000000 0000000 (function() {
this.Processing = function Processing(aElement, aCode) {
if (typeof aElement == "string") aElement = document.getElementById(aElement);
var p = buildProcessing(aElement);
if (aCode) p.init(aCode);
return p;
};
function log() {
try {
console.log.apply(console, arguments);
} catch(e) {
try {
opera.postError.apply(opera, arguments);
} catch(e) {}
}
}
var parse = Processing.parse = function parse(aCode, p) {
aCode = aCode.replace(/\/\/ .*\n/g, "\n");
aCode = aCode.replace(/([^\s])%([^\s])/g, "$1 % $2");
aCode = aCode.replace(/(?:static )?(\w+ )(\w+)\s*(\([^\)]*\)\s*{)/g, function(all, type, name, args) {
if (name == "if" || name == "for" || name == "while") {
return all;
} else {
return "Processing." + name + " = function " + name + args;
}
});
aCode = aCode.replace(/\.length\(\)/g, ".length");
aCode = aCode.replace(/([\(,]\s*)(\w+)((?:\[\])+| )\s*(\w+\s*[\),])/g, "$1$4");
aCode = aCode.replace(/([\(,]\s*)(\w+)((?:\[\])+| )\s*(\w+\s*[\),])/g, "$1$4");
aCode = aCode.replace(/new (\w+)((?:\[([^\]]*)\])+)/g, function(all, name, args) {
return "new ArrayList(" + args.slice(1, -1).split("][").join(", ") + ")";
});
aCode = aCode.replace(/(?:static )?\w+\[\]\s*(\w+)\[?\]?\s*=\s*{.*?};/g, function(all) {
return all.replace(/{/g, "[").replace(/}/g, "]");
});
var intFloat = /(\n\s*(?:int|float)(?:\[\])?(?:\s*|[^\(]*?,\s*))([a-z]\w*)(;|,)/i;
while (intFloat.test(aCode)) {
aCode = aCode.replace(new RegExp(intFloat), function(all, type, name, sep) {
return type + " " + name + " = 0" + sep;
});
}
aCode = aCode.replace(/(?:static )?(\w+)((?:\[\])+| ) *(\w+)\[?\]?(\s*[=,;])/g, function(all, type, arr, name, sep) {
if (type == "return") return all;
else return "var " + name + sep;
});
aCode = aCode.replace(/=\s*{((.|\s)*?)};/g, function(all, data) {
return "= [" + data.replace(/{/g, "[").replace(/}/g, "]") + "]";
});
aCode = aCode.replace(/static\s*{((.|\n)*?)}/g, function(all, init) {
return init;
});
aCode = aCode.replace(/super\(/g, "superMethod(");
var classes = ["int", "float", "boolean", "string"];
function ClassReplace(all, name, extend, vars, last) {
classes.push(name);
var static = "";
vars = vars.replace(/final\s+var\s+(\w+\s*=\s*.*?;)/g, function(all, set) {
static += " " + name + "." + set;
return "";
});
return "function " + name + "() {with(this){\n " + (extend ? "var __self=this;function superMethod(){extendClass(__self,arguments," + extend + ");}\n" : "") + vars.replace(/,\s?/g, ";\n this.").replace(/\b(var |final |public )+\s*/g, "this.").replace(/this.(\w+);/g, "this.$1 = null;") + (extend ? "extendClass(this, " + extend + ");\n" : "") + "" + (typeof last == "string" ? last : name + "(");
}
var matchClasses = /(?:public |abstract |static )*class (\w+)\s*(?:extends\s*(\w+)\s*)?{\s*((?:.|\n)*?)\b\1\s*\(/g;
var matchNoCon = /(?:public |abstract |static )*class (\w+)\s*(?:extends\s*(\w+)\s*)?{\s*((?:.|\n)*?)(Processing)/g;
aCode = aCode.replace(matchClasses, ClassReplace);
aCode = aCode.replace(matchNoCon, ClassReplace);
var matchClass = //,
m;
while ((m = aCode.match(matchClass))) {
var left = RegExp.leftContext,
allRest = RegExp.rightContext,
rest = nextBrace(allRest),
className = m[1],
staticVars = m[2] || "";
allRest = allRest.slice(rest.length + 1);
rest = rest.replace(new RegExp("\\b" + className + "\\(([^\\)]*?)\\)\\s*{", "g"), function(all, args) {
args = args.split(/,\s*?/);
if (args[0].match(/^\s*$/)) args.shift();
var fn = "if ( arguments.length == " + args.length + " ) {\n";
for (var i = 0; i < args.length; i++) {
fn += " var " + args[i] + " = arguments[" + i + "];\n";
}
return fn;
});
rest = rest.replace(/(?:public )?Processing.\w+ = function (\w+)\((.*?)\)/g, function(all, name, args) {
return "ADDMETHOD(this, '" + name + "', function(" + args + ")";
});
var matchMethod = /ADDMETHOD([\s\S]*?{)/,
mc;
var methods = "";
while ((mc = rest.match(matchMethod))) {
var prev = RegExp.leftContext,
allNext = RegExp.rightContext,
next = nextBrace(allNext);
methods += "addMethod" + mc[1] + next + "});"
rest = prev + allNext.slice(next.length + 1);
}
rest = methods + rest;
aCode = left + rest + "\n}}" + staticVars + allRest;
}
aCode = aCode.replace(/Processing.\w+ = function addMethod/g, "addMethod");
function nextBrace(right) {
var rest = right;
var position = 0;
var leftCount = 1,
rightCount = 0;
while (leftCount != rightCount) {
var nextLeft = rest.indexOf("{");
var nextRight = rest.indexOf("}");
if (nextLeft < nextRight && nextLeft != -1) {
leftCount++;
rest = rest.slice(nextLeft + 1);
position += nextLeft + 1;
} else {
rightCount++;
rest = rest.slice(nextRight + 1);
position += nextRight + 1;
}
}
return right.slice(0, position - 1);
}
aCode = aCode.replace(/\(int\)/g, "0|");
aCode = aCode.replace(new RegExp("\\((" + classes.join("|") + ")(\\[\\])?\\)", "g"), "");
aCode = aCode.replace(/(\d+)f/g, "$1");
aCode = aCode.replace(/('[a-zA-Z0-9]')/g, "$1.charCodeAt(0)");
aCode = aCode.replace(/#([a-f0-9]{6})/ig, function(m, hex) {
var num = toNumbers(hex);
return "color(" + num[0] + "," + num[1] + "," + num[2] + ")";
});
function toNumbers(str) {
var ret = [];
str.replace(/(..)/g, function(str) {
ret.push(parseInt(str, 16));
});
return ret;
}
return aCode;
};
function buildProcessing(curElement) {
var p = {};
p.PI = Math.PI;
p.TWO_PI = 2 * p.PI;
p.HALF_PI = p.PI / 2;
p.P3D = 3;
p.CORNER = 0;
p.RADIUS = 1;
p.CENTER_RADIUS = 1;
p.CENTER = 2;
p.POLYGON = 2;
p.QUADS = 5;
p.TRIANGLES = 6;
p.POINTS = 7;
p.LINES = 8;
p.TRIANGLE_STRIP = 9;
p.TRIANGLE_FAN = 4;
p.QUAD_STRIP = 3;
p.CORNERS = 10;
p.CLOSE = true;
p.RGB = 1;
p.HSB = 2;
p.CENTER = 88888880;
p.CODED = 88888888;
p.UP = 88888870;
p.RIGHT = 88888871;
p.DOWN = 88888872;
p.LEFT = 88888869;
p.codedKeys = [69, 70, 71, 72];
var curContext = curElement.getContext("2d");
var doFill = true;
var doStroke = true;
var loopStarted = false;
var hasBackground = false;
var doLoop = true;
var looping = 0;
var curRectMode = p.CORNER;
var curEllipseMode = p.CENTER;
var inSetup = false;
var inDraw = false;
var curBackground = "rgba(204,204,204,1)";
var curFrameRate = 1000;
var curShape = p.POLYGON;
var curShapeCount = 0;
var curvePoints = [];
var curTightness = 0;
var opacityRange = 255;
var redRange = 255;
var greenRange = 255;
var blueRange = 255;
var pathOpen = false;
var mousePressed = false;
var keyPressed = false;
var firstX, firstY, secondX, secondY, prevX, prevY;
var curColorMode = p.RGB;
var curTint = -1;
var curTextSize = 12;
var curTextFont = "Arial";
var getLoaded = false;
var start = (new Date).getTime();
p.pmouseX = 0;
p.pmouseY = 0;
p.mouseX = 0;
p.mouseY = 0;
p.mouseButton = 0;
p.mouseDragged = undefined;
p.mouseMoved = undefined;
p.mousePressed = undefined;
p.mouseReleased = undefined;
p.keyPressed = undefined;
p.keyReleased = undefined;
p.draw = undefined;
p.setup = undefined;
p.width = curElement.width - 0;
p.height = curElement.height - 0;
p.frameCount = 0;
p.ajax = function(url) {
if (window.XMLHttpRequest) {
AJAX = new XMLHttpRequest();
} else {
AJAX = new ActiveXObject("Microsoft.XMLHTTP");
}
if (AJAX) {
AJAX.open("GET", url, false);
AJAX.send(null);
return AJAX.responseText;
} else {
return false;
}
}
p.loadStrings = function loadStrings(url) {
return p.ajax(url).split("\n");
};
p.color = function color(aValue1, aValue2, aValue3, aValue4) {
var aColor = "";
if (arguments.length == 3) {
aColor = p.color(aValue1, aValue2, aValue3, opacityRange);
} else if (arguments.length == 4) {
var a = aValue4 / opacityRange;
a = isNaN(a) ? 1 : a;
if (curColorMode == p.HSB) {
var rgb = HSBtoRGB(aValue1, aValue2, aValue3);
var r = rgb[0],
g = rgb[1],
b = rgb[2];
} else {
var r = getColor(aValue1, redRange);
var g = getColor(aValue2, greenRange);
var b = getColor(aValue3, blueRange);
}
aColor = "rgba(" + r + "," + g + "," + b + "," + a + ")";
} else if (typeof aValue1 == "string") {
aColor = aValue1;
if (arguments.length == 2) {
var c = aColor.split(",");
c[3] = (aValue2 / opacityRange) + ")";
aColor = c.join(",");
}
} else if (arguments.length == 2) {
aColor = p.color(aValue1, aValue1, aValue1, aValue2);
} else if (typeof aValue1 == "number") {
aColor = p.color(aValue1, aValue1, aValue1, opacityRange);
} else {
aColor = p.color(redRange, greenRange, blueRange, opacityRange);
}
function HSBtoRGB(h, s, b) {
h = (h / redRange) * 100;
s = (s / greenRange) * 100;
b = (b / blueRange) * 100;
if (s == 0) {
return [b, b, b];
} else {
var hue = h % 360;
var f = hue % 60;
var br = Math.round(b / 100 * 255);
var p = Math.round((b * (100 - s)) / 10000 * 255);
var q = Math.round((b * (6000 - s * f)) / 600000 * 255);
var t = Math.round((b * (6000 - s * (60 - f))) / 600000 * 255);
switch (Math.floor(hue / 60)) {
case 0:
return [br, t, p];
case 1:
return [q, br, p];
case 2:
return [p, br, t];
case 3:
return [p, q, br];
case 4:
return [t, p, br];
case 5:
return [br, p, q];
}
}
}
function getColor(aValue, range) {
return Math.round(255 * (aValue / range));
}
return aColor;
}
p.red = function(aColor) {
return parseInt(verifyChannel(aColor).slice(5));
};
p.green = function(aColor) {
return parseInt(verifyChannel(aColor).split(",")[1]);
};
p.blue = function(aColor) {
return parseInt(verifyChannel(aColor).split(",")[2]);
};
p.alpha = function(aColor) {
return parseInt(parseFloat(verifyChannel(aColor).split(",")[3]) * 255);
};
function verifyChannel(aColor) {
if (aColor.constructor == Array) {
return aColor;
} else {
return p.color(aColor);
}
}
p.lerpColor = function lerpColor(c1, c2, amt) {
var colors1 = p.color(c1).split(",");
var r1 = parseInt(colors1[0].split("(")[1]);
var g1 = parseInt(colors1[1]);
var b1 = parseInt(colors1[2]);
var a1 = parseFloat(colors1[3].split(")")[0]);
var colors2 = p.color(c2).split(",");
var r2 = parseInt(colors2[0].split("(")[1]);
var g2 = parseInt(colors2[1]);
var b2 = parseInt(colors2[2]);
var a2 = parseFloat(colors2[3].split(")")[0]);
var r = parseInt(p.lerp(r1, r2, amt));
var g = parseInt(p.lerp(g1, g2, amt));
var b = parseInt(p.lerp(b1, b2, amt));
var a = parseFloat(p.lerp(a1, a2, amt));
aColor = "rgba(" + r + "," + g + "," + b + "," + a + ")";
return aColor;
}
p.nf = function(num, pad) {
var str = "" + num;
while (pad - str.length) str = "0" + str;
return str;
};
p.AniSprite = function(prefix, frames) {
this.images = [];
this.pos = 0;
for (var i = 0; i < frames; i++) {
this.images.push(prefix + p.nf(i, ("" + frames).length) + ".gif");
}
this.display = function(x, y) {
p.image(this.images[this.pos], x, y);
if (++this.pos >= frames) this.pos = 0;
};
this.getWidth = function() {
return getImage(this.images[0]).width;
};
this.getHeight = function() {
return getImage(this.images[0]).height;
};
};
function buildImageObject(obj) {
var pixels = obj.data;
var data = p.createImage(obj.width, obj.height);
if (data.__defineGetter__ && data.__lookupGetter__ && !data.__lookupGetter__("pixels")) {
var pixelsDone;
data.__defineGetter__("pixels", function() {
if (pixelsDone) return pixelsDone;
pixelsDone = [];
for (var i = 0; i < pixels.length; i += 4) {
pixelsDone.push(p.color(pixels[i], pixels[i + 1], pixels[i + 2], pixels[i + 3]));
}
return pixelsDone;
});
} else {
data.pixels = [];
for (var i = 0; i < pixels.length; i += 4) {
data.pixels.push(p.color(pixels[i], pixels[i + 1], pixels[i + 2], pixels[i + 3]));
}
}
return data;
}
p.createImage = function createImage(w, h, mode) {
var data = {};
data.width = w;
data.height = h;
data.data = [];
if (curContext.createImageData) {
data = curContext.createImageData(w, h);
}
data.pixels = new Array(w * h);
data.get = function(x, y) {
return this.pixels[w * y + x];
};
data._mask = null;
data.mask = function(img) {
this._mask = img;
};
data.loadPixels = function() {};
data.updatePixels = function() {};
return data;
};
p.createGraphics = function createGraphics(w, h) {
var canvas = document.createElement("canvas");
var ret = buildProcessing(canvas);
ret.size(w, h);
ret.canvas = canvas;
return ret;
};
p.beginDraw = function beginDraw() {};
p.endDraw = function endDraw() {};
p.tint = function tint(rgb, a) {
curTint = a;
};
function getImage(img) {
if (typeof img == "string") {
return document.getElementById(img);
}
if (img.img || img.canvas) {
return img.img || img.canvas;
}
for (var i = 0, l = img.pixels.length; i < l; i++) {
var pos = i * 4;
var c = (img.pixels[i] || "rgba(0,0,0,1)").slice(5, -1).split(",");
img.data[pos] = parseInt(c[0]);
img.data[pos + 1] = parseInt(c[1]);
img.data[pos + 2] = parseInt(c[2]);
img.data[pos + 3] = parseFloat(c[3]) * 100;
}
var canvas = document.createElement("canvas") canvas.width = img.width;
canvas.height = img.height;
var context = canvas.getContext("2d");
context.putImageData(img, 0, 0);
img.canvas = canvas;
return canvas;
}
p.image = function image(img, x, y, w, h) {
x = x || 0;
y = y || 0;
var obj = getImage(img);
if (curTint >= 0) {
var oldAlpha = curContext.globalAlpha;
curContext.globalAlpha = curTint / opacityRange;
}
if (arguments.length == 3) {
curContext.drawImage(obj, x, y);
} else {
curContext.drawImage(obj, x, y, w, h);
}
if (curTint >= 0) {
curContext.globalAlpha = oldAlpha;
}
if (img._mask) {
var oldComposite = curContext.globalCompositeOperation;
curContext.globalCompositeOperation = "darker";
p.image(img._mask, x, y);
curContext.globalCompositeOperation = oldComposite;
}
};
p.exit = function exit() {
clearInterval(looping);
};
p.save = function save(file) {};
p.loadImage = function loadImage(file) {
var img = document.getElementById(file);
if (!img) return;
var h = img.height,
w = img.width;
var canvas = document.createElement("canvas");
canvas.width = w;
canvas.height = h;
var context = canvas.getContext("2d");
context.drawImage(img, 0, 0);
var data = buildImageObject(context.getImageData(0, 0, w, h));
data.img = img;
return data;
};
p.loadFont = function loadFont(name) {
return {
name: name,
width: function(str) {
if (curContext.mozMeasureText) return curContext.mozMeasureText(typeof str == "number" ? String.fromCharCode(str) : str) / curTextSize;
else return 0;
}
};
};
p.textFont = function textFont(name, size) {
curTextFont = name;
p.textSize(size);
};
p.textSize = function textSize(size) {
if (size) {
curTextSize = size;
}
};
p.textAlign = function textAlign() {};
p.text = function text(str, x, y) {
if (str && curContext.mozDrawText) {
curContext.save();
curContext.mozTextStyle = curTextSize + "px " + curTextFont.name;
curContext.translate(x, y);
curContext.mozDrawText(typeof str == "number" ? String.fromCharCode(str) : str);
curContext.restore();
}
};
p.print = function print(output) {
alert(output);
}
p.println = p.print;
p.char = function char(key) {
return key;
};
p.map = function map(value, istart, istop, ostart, ostop) {
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
};
String.prototype.replaceAll = function(re, replace) {
return this.replace(new RegExp(re, "g"), replace);
};
p.Point = function Point(x, y) {
this.x = x;
this.y = y;
this.copy = function() {
return new Point(x, y);
}
};
p.Random = function() {
var haveNextNextGaussian = false;
var nextNextGaussian;
this.nextGaussian = function() {
if (haveNextNextGaussian) {
haveNextNextGaussian = false;
return nextNextGaussian;
} else {
var v1, v2, s;
do {
v1 = 2 * p.random(1) - 1;
v2 = 2 * p.random(1) - 1;
s = v1 * v1 + v2 * v2;
} while (s >= 1 || s == 0);
var multiplier = Math.sqrt(-2 * Math.log(s) / s);
nextNextGaussian = v2 * multiplier;
haveNextNextGaussian = true;
return v1 * multiplier;
}
};
};
p.ArrayList = function ArrayList(size, size2, size3) {
var array = new Array(0 | size);
if (size2) {
for (var i = 0; i < size; i++) {
array[i] = [];
for (var j = 0; j < size2; j++) {
var a = array[i][j] = size3 ? new Array(size3) : 0;
for (var k = 0; k < size3; k++) {
a[k] = 0;
}
}
}
} else {
for (var i = 0; i < size; i++) {
array[i] = 0;
}
}
array.size = function() {
return this.length;
};
array.get = function(i) {
return this[i];
};
array.remove = function(i) {
return this.splice(i, 1);
};
array.add = function(item) {
return this.push(item);
};
array.clone = function() {
var a = new ArrayList(size);
for (var i = 0; i < size; i++) {
a[i] = this[i];
}
return a;
};
array.isEmpty = function() {
return !this.length;
};
array.clear = function() {
this.length = 0;
};
return array;
};
p.colorMode = function colorMode(mode, range1, range2, range3, range4) {
curColorMode = mode;
if (arguments.length >= 4) {
redRange = range1;
greenRange = range2;
blueRange = range3;
}
if (arguments.length == 5) {
opacityRange = range4;
}
if (arguments.length == 2) {
p.colorMode(mode, range1, range1, range1, range1);
}
};
p.beginShape = function beginShape(type) {
curShape = type;
curShapeCount = 0;
curvePoints = [];
};
p.endShape = function endShape(close) {
if (curShapeCount != 0) {
if (close || doFill) curContext.lineTo(firstX, firstY);
if (doFill) curContext.fill();
if (doStroke) curContext.stroke();
curContext.closePath();
curShapeCount = 0;
pathOpen = false;
}
if (pathOpen) {
if (doFill) curContext.fill();
if (doStroke) curContext.stroke();
curContext.closePath();
curShapeCount = 0;
pathOpen = false;
}
};
p.vertex = function vertex(x, y, x2, y2, x3, y3) {
if (curShapeCount == 0 && curShape != p.POINTS) {
pathOpen = true;
curContext.beginPath();
curContext.moveTo(x, y);
firstX = x;
firstY = y;
} else {
if (curShape == p.POINTS) {
p.point(x, y);
} else if (arguments.length == 2) {
if (curShape != p.QUAD_STRIP || curShapeCount != 2) curContext.lineTo(x, y);
if (curShape == p.TRIANGLE_STRIP) {
if (curShapeCount == 2) {
p.endShape(p.CLOSE);
pathOpen = true;
curContext.beginPath();
curContext.moveTo(prevX, prevY);
curContext.lineTo(x, y);
curShapeCount = 1;
}
firstX = prevX;
firstY = prevY;
}
if (curShape == p.TRIANGLE_FAN && curShapeCount == 2) {
p.endShape(p.CLOSE);
pathOpen = true;
curContext.beginPath();
curContext.moveTo(firstX, firstY);
curContext.lineTo(x, y);
curShapeCount = 1;
}
if (curShape == p.QUAD_STRIP && curShapeCount == 3) {
curContext.lineTo(prevX, prevY);
p.endShape(p.CLOSE);
pathOpen = true;
curContext.beginPath();
curContext.moveTo(prevX, prevY);
curContext.lineTo(x, y);
curShapeCount = 1;
}
if (curShape == p.QUAD_STRIP) {
firstX = secondX;
firstY = secondY;
secondX = prevX;
secondY = prevY;
}
} else if (arguments.length == 4) {
if (curShapeCount > 1) {
curContext.moveTo(prevX, prevY);
curContext.quadraticCurveTo(firstX, firstY, x, y);
curShapeCount = 1;
}
} else if (arguments.length == 6) {
curContext.bezierCurveTo(x, y, x2, y2, x3, y3);
}
}
prevX = x;
prevY = y;
curShapeCount++;
if (curShape == p.LINES && curShapeCount == 2 || (curShape == p.TRIANGLES) && curShapeCount == 3 || (curShape == p.QUADS) && curShapeCount == 4) {
p.endShape(p.CLOSE);
}
};
p.curveVertex = function(x, y, x2, y2) {
if (curvePoints.length < 3) {
curvePoints.push([x, y]);
} else {
var b = [],
s = 1 - curTightness;
curvePoints.push([x, y]);
b[0] = [curvePoints[1][0], curvePoints[1][1]];
b[1] = [curvePoints[1][0] + (s * curvePoints[2][0] - s * curvePoints[0][0]) / 6, curvePoints[1][1] + (s * curvePoints[2][1] - s * curvePoints[0][1]) / 6];
b[2] = [curvePoints[2][0] + (s * curvePoints[1][0] - s * curvePoints[3][0]) / 6, curvePoints[2][1] + (s * curvePoints[1][1] - s * curvePoints[3][1]) / 6];
b[3] = [curvePoints[2][0], curvePoints[2][1]];
if (!pathOpen) {
p.vertex(b[0][0], b[0][1]);
} else {
curShapeCount = 1;
}
p.vertex(b[1][0], b[1][1], b[2][0], b[2][1], b[3][0], b[3][1]);
curvePoints.shift();
}
};
p.curveTightness = function(tightness) {
curTightness = tightness;
};
p.bezierVertex = p.vertex;
p.rectMode = function rectMode(aRectMode) {
curRectMode = aRectMode;
};
p.imageMode = function() {};
p.ellipseMode = function ellipseMode(aEllipseMode) {
curEllipseMode = aEllipseMode;
};
p.dist = function dist(x1, y1, x2, y2) {
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
};
p.year = function year() {
return (new Date).getYear() + 1900;
};
p.month = function month() {
return (new Date).getMonth();
};
p.day = function day() {
return (new Date).getDay();
};
p.hour = function hour() {
return (new Date).getHours();
};
p.minute = function minute() {
return (new Date).getMinutes();
};
p.second = function second() {
return (new Date).getSeconds();
};
p.millis = function millis() {
return (new Date).getTime() - start;
};
p.ortho = function ortho() {};
p.translate = function translate(x, y) {
curContext.translate(x, y);
};
p.scale = function scale(x, y) {
curContext.scale(x, y || x);
};
p.rotate = function rotate(aAngle) {
curContext.rotate(aAngle);
};
p.pushMatrix = function pushMatrix() {
curContext.save();
};
p.popMatrix = function popMatrix() {
curContext.restore();
};
p.redraw = function redraw() {
if (hasBackground) {
p.background();
}
p.frameCount++;
inDraw = true;
p.pushMatrix();
p.draw();
p.popMatrix();
inDraw = false;
};
p.loop = function loop() {
if (loopStarted) return;
looping = setInterval(function() {
try {
if (!p.paused) {
p.redraw();
}
} catch(e) {
clearInterval(looping);
throw e;
}
},
1000 / curFrameRate);
loopStarted = true;
};
p.frameRate = function frameRate(aRate) {
curFrameRate = aRate;
};
p.background = function background(img) {
if (arguments.length) {
if (img && img.img) {
curBackground = img;
} else {
curBackground = p.color.apply(this, arguments);
}
}
if (curBackground.img) {
p.image(curBackground, 0, 0);
} else {
var oldFill = curContext.fillStyle;
curContext.fillStyle = curBackground + "";
curContext.fillRect(0, 0, p.width, p.height);
curContext.fillStyle = oldFill;
}
};
p.clear = function clear(x, y, width, height) {
arguments.length == 0 ? curContext.clearRect(0, 0, p.width, p.height) : curContext.clearRect(x, y, width, height);
}
p.str = function str(aNumber) {
return aNumber + '';
}
p.sq = function sq(aNumber) {
return aNumber * aNumber;
};
p.sqrt = function sqrt(aNumber) {
return Math.sqrt(aNumber);
};
p.ngsqrt = function ngsqrt(aNumber) {
if (aNumber <= 0) {
return Math.sqrt(-aNumber);
} else {
return Math.sqrt(aNumber);
}
};
p.int = function int(aNumber) {
return Math.floor(aNumber);
};
p.min = function min(aNumber, aNumber2) {
return Math.min(aNumber, aNumber2);
};
p.max = function max(aNumber, aNumber2) {
return Math.max(aNumber, aNumber2);
};
p.ceil = function ceil(aNumber) {
return Math.ceil(aNumber);
};
p.round = function round(aNumber) {
return Math.round(aNumber);
};
p.norm = function norm(aNumber, low, high) {
var range = high - low;
return ((1 / range) * aNumber) - ((1 / range) * low);
};
p.lerp = function lerp(value1, value2, amt) {
var range = value2 - value1;
return (range * amt) + value1;
}
p.floor = function floor(aNumber) {
return Math.floor(aNumber);
};
p.float = function float(aNumber) {
return parseFloat(aNumber);
};
p.byte = function byte(aNumber) {
return aNumber || 0;
};
p.random = function random(aMin, aMax) {
return arguments.length == 2 ? aMin + (Math.random() * (aMax - aMin)) : Math.random() * aMin;
};
p.noise = function(x, y, z) {
return arguments.length >= 2 ? PerlinNoise_2D(x, y) : PerlinNoise_2D(x, x);
};
function Noise(x, y) {
var n = x + y * 57;
n = (n << 13) ^ n;
return Math.abs(1.0 - (((n * ((n * n * 15731) + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0));
};
function SmoothedNoise(x, y) {
var corners = (Noise(x - 1, y - 1) + Noise(x + 1, y - 1) + Noise(x - 1, y + 1) + Noise(x + 1, y + 1)) / 16;
var sides = (Noise(x - 1, y) + Noise(x + 1, y) + Noise(x, y - 1) + Noise(x, y + 1)) / 8;
var center = Noise(x, y) / 4;
return corners + sides + center;
};
function InterpolatedNoise(x, y) {
var integer_X = Math.floor(x);
var fractional_X = x - integer_X;
var integer_Y = Math.floor(y);
var fractional_Y = y - integer_Y;
var v1 = SmoothedNoise(integer_X, integer_Y);
var v2 = SmoothedNoise(integer_X + 1, integer_Y);
var v3 = SmoothedNoise(integer_X, integer_Y + 1);
var v4 = SmoothedNoise(integer_X + 1, integer_Y + 1);
var i1 = Interpolate(v1, v2, fractional_X);
var i2 = Interpolate(v3, v4, fractional_X);
return Interpolate(i1, i2, fractional_Y);
}
function PerlinNoise_2D(x, y) {
var total = 0;
var p = 0.25;
var n = 3;
for (var i = 0; i <= n; i++) {
var frequency = Math.pow(2, i);
var amplitude = Math.pow(p, i);
total = total + InterpolatedNoise(x * frequency, y * frequency) * amplitude;
}
return total;
}
function Interpolate(a, b, x) {
var ft = x * p.PI;
var f = (1 - p.cos(ft)) * .5;
return a * (1 - f) + b * f;
}
p.abs = function abs(aNumber) {
return Math.abs(aNumber);
};
p.cos = function cos(aNumber) {
return Math.cos(aNumber);
};
p.sin = function sin(aNumber) {
return Math.sin(aNumber);
};
p.pow = function pow(aNumber, aExponent) {
return Math.pow(aNumber, aExponent);
};
p.constrain = function constrain(aNumber, aMin, aMax) {
return Math.min(Math.max(aNumber, aMin), aMax);
};
p.sqrt = function sqrt(aNumber) {
return Math.sqrt(aNumber);
};
p.atan2 = function atan2(aNumber, aNumber2) {
return Math.atan2(aNumber, aNumber2);
};
p.radians = function radians(aAngle) {
return (aAngle / 180) * p.PI;
};
p.degrees = function degrees(aAngle) {
aAngle = (aAngle * 180) / p.PI;
if (aAngle < 0) {
aAngle = 360 + aAngle
}
return aAngle;
};
p.size = function size(aWidth, aHeight) {
var fillStyle = curContext.fillStyle;
var strokeStyle = curContext.strokeStyle;
curElement.width = p.width = aWidth;
curElement.height = p.height = aHeight;
curContext.fillStyle = fillStyle;
curContext.strokeStyle = strokeStyle;
};
p.noStroke = function noStroke() {
doStroke = false;
};
p.noFill = function noFill() {
doFill = false;
};
p.smooth = function smooth() {};
p.noSmooth = function noSmooth() {};
p.noLoop = function noLoop() {
clearInterval(looping);
loopStarted = false;
doLoop = false;
};
p.fill = function fill() {
doFill = true;
curContext.fillStyle = p.color.apply(this, arguments);
};
p.stroke = function stroke() {
doStroke = true;
curContext.strokeStyle = p.color.apply(this, arguments);
};
p.strokeWeight = function strokeWeight(w) {
curContext.lineWidth = w;
};
p.point = function point(x, y) {
var oldFill = curContext.fillStyle;
curContext.fillStyle = curContext.strokeStyle;
curContext.fillRect(Math.round(x), Math.round(y), 1, 1);
curContext.fillStyle = oldFill;
};
p.get = function get(x, y) {
if (arguments.length == 0) {
var c = p.createGraphics(p.width, p.height);
c.image(curContext, 0, 0);
return c;
}
if (!getLoaded) {
getLoaded = buildImageObject(curContext.getImageData(0, 0, p.width, p.height));
}
return getLoaded.get(x, y);
};
p.set = function set(x, y, obj) {
if (obj && obj.img) {
p.image(obj, x, y);
} else {
var oldFill = curContext.fillStyle;
var color = obj;
curContext.fillStyle = color;
curContext.fillRect(Math.round(x), Math.round(y), 1, 1);
curContext.fillStyle = oldFill;
}
};
p.arc = function arc(x, y, width, height, start, stop) {
if (width <= 0) return;
if (curEllipseMode == p.CORNER) {
x += width / 2;
y += height / 2;
}
curContext.moveTo(x, y);
curContext.beginPath();
curContext.arc(x, y, curEllipseMode == p.CENTER_RADIUS ? width : width / 2, start, stop, false);
if (doStroke) curContext.stroke();
curContext.lineTo(x, y);
if (doFill) curContext.fill();
curContext.closePath();
};
p.line = function line(x1, y1, x2, y2) {
curContext.lineCap = "round";
curContext.beginPath();
curContext.moveTo(x1 || 0, y1 || 0);
curContext.lineTo(x2 || 0, y2 || 0);
curContext.stroke();
curContext.closePath();
};
p.bezier = function bezier(x1, y1, x2, y2, x3, y3, x4, y4) {
curContext.lineCap = "butt";
curContext.beginPath();
curContext.moveTo(x1, y1);
curContext.bezierCurveTo(x2, y2, x3, y3, x4, y4);
curContext.stroke();
curContext.closePath();
};
p.triangle = function triangle(x1, y1, x2, y2, x3, y3) {
p.beginShape();
p.vertex(x1, y1);
p.vertex(x2, y2);
p.vertex(x3, y3);
p.endShape();
};
p.quad = function quad(x1, y1, x2, y2, x3, y3, x4, y4) {
curContext.lineCap = "square";
p.beginShape();
p.vertex(x1, y1);
p.vertex(x2, y2);
p.vertex(x3, y3);
p.vertex(x4, y4);
p.endShape();
};
p.rect = function rect(x, y, width, height) {
if (width == 0 && height == 0) return;
curContext.beginPath();
var offsetStart = 0;
var offsetEnd = 0;
if (curRectMode == p.CORNERS) {
width -= x;
height -= y;
}
if (curRectMode == p.RADIUS) {
width *= 2;
height *= 2;
}
if (curRectMode == p.CENTER || curRectMode == p.RADIUS) {
x -= width / 2;
y -= height / 2;
}
curContext.rect(Math.round(x) - offsetStart, Math.round(y) - offsetStart, Math.round(width) + offsetEnd, Math.round(height) + offsetEnd);
if (doFill) curContext.fill();
if (doStroke) curContext.stroke();
curContext.closePath();
};
p.ellipse = function ellipse(x, y, width, height) {
x = x || 0;
y = y || 0;
if (width <= 0 && height <= 0) return;
curContext.beginPath();
if (curEllipseMode == p.RADIUS) {
width *= 2;
height *= 2;
}
var offsetStart = 0;
if (width == height) {
curContext.arc(x - offsetStart, y - offsetStart, width / 2, 0, Math.PI * 2, false);
} else {
var w = width / 2;
var h = height / 2;
var C = 0.5522847498307933;
var c_x = C * w;
var c_y = C * h;
curContext.moveTo(x + w, y);
curContext.bezierCurveTo(x + w, y - c_y, x + c_x, y - h, x, y - h);
curContext.bezierCurveTo(x - c_x, y - h, x - w, y - c_y, x - w, y);
curContext.bezierCurveTo(x - w, y + c_y, x - c_x, y + h, x, y + h);
curContext.bezierCurveTo(x + c_x, y + h, x + w, y + c_y, x + w, y);
}
if (doFill) curContext.fill();
if (doStroke) curContext.stroke();
curContext.closePath();
};
p.link = function(href, target) {
window.location = href;
};
p.loadPixels = function() {
p.pixels = buildImageObject(curContext.getImageData(0, 0, p.width, p.height)).pixels;
};
p.updatePixels = function() {
var colors = /(\d+),(\d+),(\d+),(\d+)/;
var pixels = {};
pixels.width = p.width;
pixels.height = p.height;
pixels.data = [];
if (curContext.createImageData) {
pixels = curContext.createImageData(p.width, p.height);
}
var data = pixels.data;
var pos = 0;
for (var i = 0, l = p.pixels.length; i < l; i++) {
var c = (p.pixels[i] || "rgba(0,0,0,1)").match(colors);
data[pos] = parseInt(c[1]);
data[pos + 1] = parseInt(c[2]);
data[pos + 2] = parseInt(c[3]);
data[pos + 3] = parseFloat(c[4]) * 255;
pos += 4;
}
curContext.putImageData(pixels, 0, 0);
};
p.extendClass = function extendClass(obj, args, fn) {
if (arguments.length == 3) {
fn.apply(obj, args);
} else {
args.call(obj);
}
};
p.addMethod = function addMethod(object, name, fn) {
if (object[name]) {
var args = fn.length;
var oldfn = object[name];
object[name] = function() {
if (arguments.length == args) return fn.apply(this, arguments);
else return oldfn.apply(this, arguments);
};
} else {
object[name] = fn;
}
};
p.init = function init(code) {
p.stroke(0);
p.fill(255);
curContext.translate(0.5, 0.5);
if (code) {
(function(Processing) {
with(p) {
eval(parse(code, p));
}
})(p);
}
if (p.setup) {
inSetup = true;
p.setup();
}
inSetup = false;
if (p.draw) {
if (!doLoop) {
p.redraw();
} else {
p.loop();
}
}
attach(document, "mousemove", function(e) {
var scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
var scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
p.pmouseX = p.mouseX;
p.pmouseY = p.mouseY;
p.mouseX = e.clientX - curElement.offsetLeft + scrollX;
p.mouseY = e.clientY - curElement.offsetTop + scrollY;
if (p.mouseMoved) {
p.mouseMoved();
}
if (mousePressed && p.mouseDragged) {
p.mouseDragged();
}
});
attach(curElement, "mousedown", function(e) {
mousePressed = true;
switch (e.which) {
case 1:
p.mouseButton = p.LEFT;
break;
case 2:
p.mouseButton = p.CENTER;
break;
case 3:
p.mouseButton = p.RIGHT;
break;
}
if (typeof p.mousePressed == "function") {
p.mousePressed();
} else {
p.mousePressed = true;
}
});
attach(curElement, "contextmenu", function(e) {
e.preventDefault();
e.stopPropagation();
});
attach(document, "mouseup", function(e) {
mousePressed = false;
if (typeof p.mousePressed != "function") {
p.mousePressed = false;
}
if (p.mouseReleased) {
p.mouseReleased();
}
});
attach(document, "keydown", function(e) {
keyPressed = true;
p.key = e.keyCode + 32;
var i;
for (i = 0; i < p.codedKeys.length; i++) {
if (p.key == p.codedKeys[i]) {
switch (p.key) {
case 70:
p.keyCode = p.UP;
break;
case 71:
p.keyCode = p.RIGHT;
break;
case 72:
p.keyCode = p.DOWN;
break;
case 69:
p.keyCode = p.LEFT;
break;
}
p.key = p.CODED;
}
}
if (e.shiftKey) {
p.key = String.fromCharCode(p.key).toUpperCase().charCodeAt(0);
}
if (typeof p.keyPressed == "function") {
p.keyPressed();
} else {
p.keyPressed = true;
}
});
attach(document, "keyup", function(e) {
keyPressed = false;
if (typeof p.keyPressed != "function") {
p.keyPressed = false;
}
if (p.keyReleased) {
p.keyReleased();
}
});
function attach(elem, type, fn) {
if (elem.addEventListener) elem.addEventListener(type, fn, false);
else elem.attachEvent("on" + type, fn);
}
};
return p;
}
})();
sagenb-1.0.1/sagenb/data/graph_editor/processing.js 0000664 0000000 0000000 00000217213 13114362624 0022311 0 ustar 00root root 0000000 0000000 /*
P R O C E S S I N G - 0 . 0 . J S
a port of the Processing visualization language
License : MIT
Developer : John Resig: http://ejohn.org
Web Site : http://processingjs.org
Java Version : http://processing.org
Github Repo. : http://github.com/jeresig/processing-js
Bug Tracking : http://processing-js.lighthouseapp.com
Mozilla POW! : http://wiki.Mozilla.org/Education/Projects/ProcessingForTheWeb
Maintained by : Seneca: http://zenit.senecac.on.ca/wiki/index.php/Processing.js
Hyper-Metrix: http://hyper-metrix.com/#Processing
*/
(function(){
// Attach Processing to the window
this.Processing = function Processing( aElement, aCode ){
// Get the DOM element if string was passed
if( typeof aElement == "string" ){
aElement = document.getElementById( aElement );
}
// Build an Processing functions and env. vars into 'p'
var p = buildProcessing( aElement );
// Send aCode Processing syntax to be converted to JavaScript
if( aCode ){ p.init( aCode ); }
return p;
};
// IE Unfriendly AJAX Method
var ajax=function( url ){
var AJAX;
if( AJAX = new XMLHttpRequest() ){
AJAX.open( "GET", url, false );
AJAX.send( null );
return AJAX.responseText;
}else{
return false;
}
};
// Automatic Initialization Method
var init = function(){
var canvas = document.getElementsByTagName( 'canvas' ),
datasrc = undefined;
for( var i = 0; l = i < canvas.length; i++ ){
if( datasrc = canvas[ i ].getAttribute( 'datasrc' ) ){
Processing( canvas[ i ], ajax( datasrc ) );
}
}
};
addEventListener( 'DOMContentLoaded', function(){ init(); }, false );
// Parse Processing (Java-like) syntax to JavaScript syntax with Regex
var parse = Processing.parse = function parse( aCode, p ){
// Remove end-of-line comments
aCode = aCode.replace( /\/\/ .*\n/g, "\n" );
// Weird parsing errors with %
aCode = aCode.replace( /([^\s])%([^\s])/g, "$1 % $2" );
// Simple convert a function-like thing to function
aCode = aCode.replace( /(?:static )?(\w+ )(\w+)\s*(\([^\)]*\)\s*{)/g, function( all, type, name, args ){
if ( name == "if" || name == "for" || name == "while" ) {
return all;
} else {
return "Processing." + name + " = function " + name + args;
}
});
// Attach import() to p{} bypassing JS command, allowing for extrernal library loading
aCode = aCode.replace( /import \(|import\(/g, "p.Import(" );
// Force .length() to be .length
aCode = aCode.replace( /\.length\(\)/g, ".length" );
// foo( int foo, float bar )
aCode = aCode.replace( /([\(,]\s*)(\w+)((?:\[\])+| )\s*(\w+\s*[\),])/g, "$1$4" );
aCode = aCode.replace( /([\(,]\s*)(\w+)((?:\[\])+| )\s*(\w+\s*[\),])/g, "$1$4" );
// float[] foo = new float[5];
aCode = aCode.replace( /new (\w+)((?:\[([^\]]*)\])+)/g, function( all, name, args ){
return "new ArrayList(" + args.slice(1,-1).split("][").join(", ") + ")";
});
// What does this do?
aCode = aCode.replace( /(?:static )?\w+\[\]\s*(\w+)\[?\]?\s*=\s*{.*?};/g, function( all ){
return all.replace( /{/g, "[").replace(/}/g, "]" );
});
// int|float foo;
var intFloat = /(\n\s*(?:int|float)(?:\[\])?(?:\s*|[^\(]*?,\s*))([a-z]\w*)(;|,)/i;
while( intFloat.test(aCode) ){
aCode = aCode.replace( new RegExp( intFloat ), function( all, type, name, sep ){
return type + " " + name + " = 0" + sep;
});
}
// float foo = 5;
aCode = aCode.replace( /(?:static )?(\w+)((?:\[\])+| ) *(\w+)\[?\]?(\s*[=,;])/g, function( all, type, arr, name, sep ){
if ( type == "return" )
return all;
else
return "var " + name + sep;
});
// Fix Array[] foo = {...} to [...]
aCode = aCode.replace( /=\s*{((.|\s)*?)};/g, function(all,data){
return "= [" + data.replace(/{/g, "[").replace(/}/g, "]") + "]";
});
// super() is a reserved word
aCode = aCode.replace( /super\(/g, "superMethod(" );
var classes = [ "int", "float", "boolean", "string" ];
function ClassReplace( all, name, extend, vars, last ){
classes.push( name );
var static = "";
vars = vars.replace( /final\s+var\s+(\w+\s*=\s*.*?;)/g, function( all, set ){
static += " " + name + "." + set;
return "";
});
// Move arguments up from constructor and wrap contents with
// a with(this), and unwrap constructor
return "function " + name + "() {with(this){\n " +
( extend ? "var __self=this;function superMethod(){extendClass(__self,arguments," + extend + ");}\n" : "" ) +
// Replace var foo = 0; with this.foo = 0;
// and force var foo; to become this.foo = null;
vars
.replace( /,\s?/g, ";\n this." )
.replace( /\b(var |final |public )+\s*/g, "this." )
.replace( /\b(var |final |public )+\s*/g, "this." )
.replace( /this.(\w+);/g, "this.$1 = null;" ) +
( extend ? "extendClass(this, " + extend + ");\n" : "" ) +
"" + ( typeof last == "string" ? last : name + "(" );
}
var matchClasses = /(?:public |abstract |static )*class (\w+)\s*(?:extends\s*(\w+)\s*)?{\s*((?:.|\n)*?)\b\1\s*\(/g;
var matchNoCon = /(?:public |abstract |static )*class (\w+)\s*(?:extends\s*(\w+)\s*)?{\s*((?:.|\n)*?)(Processing)/g;
aCode = aCode.replace( matchClasses, ClassReplace );
aCode = aCode.replace( matchNoCon, ClassReplace );
var matchClass = //, m;
while ( ( m = aCode.match( matchClass ) ) ){
var left = RegExp.leftContext,
allRest = RegExp.rightContext,
rest = nextBrace( allRest ),
className = m[ 1 ],
staticVars = m[ 2 ] || "";
allRest = allRest.slice( rest.length + 1 );
rest = rest.replace( new RegExp("\\b" + className + "\\(([^\\)]*?)\\)\\s*{", "g"), function( all, args ){
args = args.split( /,\s*?/ );
if( args[ 0 ].match( /^\s*$/ ) ){
args.shift();
}
var fn = "if ( arguments.length == " + args.length + " ) {\n";
for ( var i = 0; i < args.length; i++ ) {
fn += " var " + args[ i ] + " = arguments["+ i +"];\n";
}
return fn;
});
// Fix class method names
// this.collide = function() { ... }
// and add closing } for with(this) ...
rest = rest.replace( /(?:public )?Processing.\w+ = function (\w+)\((.*?)\)/g, function( all, name, args ){
return "ADDMETHOD(this, '" + name + "', function(" + args + ")";
});
var matchMethod = /ADDMETHOD([\s\S]*?{)/, mc;
var methods = "";
while ( ( mc = rest.match( matchMethod ) ) ){
var prev = RegExp.leftContext,
allNext = RegExp.rightContext,
next = nextBrace(allNext);
methods += "addMethod" + mc[ 1 ] + next + "});";
rest = prev + allNext.slice( next.length + 1 );
}
rest = methods + rest;
aCode = left + rest + "\n}}" + staticVars + allRest;
}
// Do some tidying up, where necessary
aCode = aCode.replace( /Processing.\w+ = function addMethod/g, "addMethod" );
function nextBrace( right ) {
var rest = right,
position = 0,
leftCount = 1,
rightCount = 0;
while( leftCount != rightCount ) {
var nextLeft = rest.indexOf( "{" ),
nextRight = rest.indexOf( "}" );
if( nextLeft < nextRight && nextLeft != - 1 ) {
leftCount++;
rest = rest.slice( nextLeft + 1 );
position += nextLeft + 1;
}else{
rightCount++;
rest = rest.slice( nextRight + 1 );
position += nextRight + 1;
}
}
return right.slice( 0, position - 1 );
}
// Handle (int) Casting
aCode = aCode.replace( /\(int\)/g, "0|" );
// Remove Casting
aCode = aCode.replace( new RegExp("\\((" + classes.join("|") + ")(\\[\\])?\\)", "g"), "" );
// Convert 3.0f to just 3.0
aCode = aCode.replace( /(\d+)f[^a-zA-Z0-9]/g, "$1" );
// Force numbers to exist //
//aCode = aCode.replace(/([^.])(\w+)\s*\+=/g, "$1$2 = ($2||0) +");
//! // Force characters-as-bytes to work --> Ping: Andor
aCode = aCode.replace(/('[a-zA-Z0-9]')/g, "$1.charCodeAt(0)");
// Convert #aaaaaa into color
aCode = aCode.replace(/#([a-f0-9]{6})/ig, function(m, hex){
var num = toNumbers(hex);
return "DefaultColor(" + num[0] + "," + num[1] + "," + num[2] + ")";
});
function toNumbers( str ){
var ret = [];
str.replace( /(..)/g, function( str ){
ret.push( parseInt( str, 16 ) );
});
return ret;
}
return aCode;
};
// Attach Processing functions to 'p'
function buildProcessing( curElement ){
// Create the 'p' object
var p = {};
// Set Processing defaults / environment variables
p.name = 'Processing.js Instance';
p.PI = Math.PI;
p.TWO_PI = 2 * p.PI;
p.HALF_PI = p.PI / 2;
p.P3D = 3;
p.CORNER = 0;
p.RADIUS = 1;
p.CENTER_RADIUS = 1;
p.CENTER = 2;
p.POLYGON = 2;
p.QUADS = 5;
p.TRIANGLES = 6;
p.POINTS = 7;
p.LINES = 8;
p.TRIANGLE_STRIP = 9;
p.TRIANGLE_FAN = 4;
p.QUAD_STRIP = 3;
p.CORNERS = 10;
p.CLOSE = true;
p.RGB = 1;
p.HSB = 2;
// KeyCode table
p.CENTER = 88888880;
p.CODED = 88888888;
p.UP = 88888870;
p.RIGHT = 88888871;
p.DOWN = 88888872;
p.LEFT = 88888869;
//! // Description required...
p.codedKeys = [ 69, 70, 71, 72 ];
// "Private" variables used to maintain state
var curContext = curElement.getContext( "2d" ),
doFill = true,
doStroke = true,
loopStarted = false,
hasBackground = false,
doLoop = true,
looping = 0,
curRectMode = p.CORNER,
curEllipseMode = p.CENTER,
inSetup = false,
inDraw = false,
curBackground = "rgba( 204, 204, 204, 1 )",
curFrameRate = 1000,
curMsPerFrame = 1,
curShape = p.POLYGON,
curShapeCount = 0,
curvePoints = [],
curTightness = 0,
opacityRange = 255,
redRange = 255,
greenRange = 255,
blueRange = 255,
pathOpen = false,
mousePressed = false,
keyPressed = false,
curColorMode = p.RGB;
curTint = - 1,
curTextSize = 12,
curTextFont = "Arial",
getLoaded = false,
start = ( new Date ).getTime();
var firstX,
firstY,
secondX,
secondY,
prevX,
prevY;
// Store a line for println(), print() handline
p.ln = "";
// Glyph path storage for textFonts
p.glyphTable = {};
// Global vars for tracking mouse position
p.pmouseX = 0;
p.pmouseY = 0;
p.mouseX = 0;
p.mouseY = 0;
p.mouseButton = 0;
p.mouseDown = false;
// Undefined event handlers to be replaced by user when needed
p.mouseClicked = undefined;
p.mouseDragged = undefined;
p.mouseMoved = undefined;
p.mousePressed = undefined;
p.mouseReleased = undefined;
p.keyPressed = undefined;
p.keyReleased = undefined;
p.draw = undefined;
p.setup = undefined;
// The height/width of the canvas
p.width = curElement.width - 0;
p.height = curElement.height - 0;
// The current animation frame
p.frameCount = 0;
////////////////////////////////////////////////////////////////////////////
// Array handling
////////////////////////////////////////////////////////////////////////////
p.shorten = function( ary ){
var newary = new Array();
// copy array into new array
var len = ary.length;
for( var i = 0; i < len; i++ ){
newary[ i ] = ary[ i ];
}
newary.pop();
return newary;
}
p.expand = function( ary, newSize ){
var newary = new Array();
var len = ary.length
for( var i = 0; i < len; i++ ){
newary[ i ] = ary[ i ];
}
if( arguments.length == 1 ){
// double size of array
newary.length *= 2;
}else if( arguments.length == 2 ){
// size is newSize
newary.length = newSize;
}
return newary;
}
p.ArrayList = function ArrayList( size, size2, size3 ){
var array = new Array( 0 | size );
if( size2 ){
for( var i = 0; i < size; i++ ){
array[ i ] = [];
for( var j = 0; j < size2; j++ ){
var a = array[ i ][ j ] = size3 ? new Array( size3 ) : 0 ;
for( var k = 0; k < size3; k++ ){ a[ k ] = 0; }
}
}
}else{
for( var i = 0; i < size; i++ ){ array[ i ] = 0; }
}
array.get = function( i ){ return this[ i ]; };
array.add = function( item ){ return this.push( item ); };
array.size = function( ){ return this.length; };
array.clear = function( ){ this.length = 0; };
array.remove = function( i ){ return this.splice( i, 1 ); };
array.isEmpty = function( ){ return !this.length; };
array.clone = function( ){
var a = new ArrayList( size );
for( var i = 0; i < size; i++ ){
a[ i ] = this[ i ];
}
return a;
};
return array;
};
////////////////////////////////////////////////////////////////////////////
// Color functions
////////////////////////////////////////////////////////////////////////////
// In case I ever need to do HSV conversion:
// http://srufaculty.sru.edu/david.dailey/javascript/js/5rml.js
p.color = function color( aValue1, aValue2, aValue3, aValue4 ) {
var aColor = "";
if ( arguments.length == 3 ) {
aColor = p.color( aValue1, aValue2, aValue3, opacityRange );
} else if ( arguments.length == 4 ) {
var a = aValue4 / opacityRange;
a = isNaN(a) ? 1 : a;
if ( curColorMode == p.HSB ) {
var rgb = HSBtoRGB(aValue1, aValue2, aValue3);
var r = rgb[0], g = rgb[1], b = rgb[2];
} else {
var r = getColor(aValue1, redRange);
var g = getColor(aValue2, greenRange);
var b = getColor(aValue3, blueRange);
}
aColor = "rgba(" + r + "," + g + "," + b + "," + a + ")";
} else if ( typeof aValue1 == "string" ) {
aColor = aValue1;
if ( arguments.length == 2 ) {
var c = aColor.split(",");
c[3] = (aValue2 / opacityRange) + ")";
aColor = c.join(",");
}
} else if ( arguments.length == 2 ) {
aColor = p.color( aValue1, aValue1, aValue1, aValue2 );
} else if ( typeof aValue1 == "number" && aValue1 < 256 && aValue1 >= 0) {
aColor = p.color( aValue1, aValue1, aValue1, opacityRange );
} else if ( typeof aValue1 == "number" ) {
var intcolor = 0;
if( aValue1 < 0 ){
intcolor = 4294967296 - ( aValue1 * -1 );
}else{
intcolor = aValue1;
}
var ac = Math.floor((intcolor % 4294967296) / 16777216);
var rc = Math.floor((intcolor % 16777216) / 65536);
var gc = Math.floor((intcolor % 65536) / 256);
var bc = intcolor % 256;
aColor = p.color( rc, gc, bc, ac );
} else {
aColor = p.color( redRange, greenRange, blueRange, opacityRange );
}
// HSB conversion function from Mootools, MIT Licensed
function HSBtoRGB(h, s, b) {
h = (h / redRange) * 360;
s = (s / greenRange) * 100;
b = (b / blueRange) * 100;
var br = Math.round(b / 100 * 255);
if (s == 0){
return [br, br, br];
} else {
var hue = h % 360;
var f = hue % 60;
var p = Math.round((b * (100 - s)) / 10000 * 255);
var q = Math.round((b * (6000 - s * f)) / 600000 * 255);
var t = Math.round((b * (6000 - s * (60 - f))) / 600000 * 255);
switch (Math.floor(hue / 60)){
case 0: return [br, t, p];
case 1: return [q, br, p];
case 2: return [p, br, t];
case 3: return [p, q, br];
case 4: return [t, p, br];
case 5: return [br, p, q];
}
}
}
function getColor( aValue, range ) {
return Math.round(255 * (aValue / range));
}
return aColor;
}
p.red = function( aColor ){ return parseInt( verifyChannel( aColor ).slice( 5 ) ); };
p.green = function( aColor ){ return parseInt( verifyChannel( aColor ).split( "," )[ 1 ] ); };
p.blue = function( aColor ){ return parseInt( verifyChannel( aColor ).split( "," )[ 2 ] ); };
p.alpha = function( aColor ){ return parseInt( parseFloat( verifyChannel( aColor ).split( "," )[ 3 ] ) * 255 ); };
function verifyChannel( aColor ){
if( aColor.constructor == Array ){
return aColor;
} else {
return p.color( aColor );
}
}
p.lerpColor = function lerpColor( c1, c2, amt ){
// Get RGBA values for Color 1 to floats
var colors1 = p.color( c1 ).split( "," );
var r1 = parseInt( colors1[ 0 ].split( "(" )[ 1 ] );
var g1 = parseInt( colors1[ 1 ] );
var b1 = parseInt( colors1[ 2 ] );
var a1 = parseFloat( colors1[ 3 ].split( ")" )[ 0 ] );
// Get RGBA values for Color 2 to floats
var colors2 = p.color( c2 ).split( "," );
var r2 = parseInt( colors2[ 0 ].split( "(" )[ 1 ] );
var g2 = parseInt( colors2[ 1 ] );
var b2 = parseInt( colors2[ 2 ] );
var a2 = parseFloat( colors2[ 3 ].split( ")" )[ 0 ] );
// Return lerp value for each channel, INT for color, Float for Alpha-range
var r = parseInt( p.lerp( r1, r2, amt ) );
var g = parseInt( p.lerp( g1, g2, amt ) );
var b = parseInt( p.lerp( b1, b2, amt ) );
var a = parseFloat( p.lerp( a1, a2, amt ) );
return aColor = "rgba("+ r +","+ g +","+ b +","+ a +")";
}
// Forced default color mode for #aaaaaa style
p.DefaultColor = function( aValue1, aValue2, aValue3 ){
var tmpColorMode = curColorMode;
curColorMode = p.RGB;
var c = p.color(aValue1 / 255 * redRange, aValue2 / 255 * greenRange, aValue3 / 255 * blueRange );
curColorMode = tmpColorMode;
return c;
}
p.colorMode = function colorMode( mode, range1, range2, range3, range4 ){
curColorMode = mode;
if( arguments.length >= 4 ){ redRange = range1; greenRange = range2; blueRange = range3; }
if( arguments.length == 5 ){ opacityRange = range4; }
if( arguments.length == 2 ){ p.colorMode( mode, range1, range1, range1, range1 ); }
};
////////////////////////////////////////////////////////////////////////////
// Canvas-Matrix manipulation
////////////////////////////////////////////////////////////////////////////
p.translate = function translate( x, y ){ curContext.translate( x, y ); };
p.scale = function scale( x, y ) { curContext.scale( x, y || x ); };
p.rotate = function rotate( aAngle ) { curContext.rotate( aAngle ); };
p.pushMatrix = function pushMatrix() { curContext.save(); };
p.popMatrix = function popMatrix() { curContext.restore(); };
p.ortho = function ortho(){};
////////////////////////////////////////////////////////////////////////////
//Time based functions
////////////////////////////////////////////////////////////////////////////
p.year = function year() { return ( new Date ).getYear() + 1900; };
p.month = function month() { return ( new Date ).getMonth(); };
p.day = function day() { return ( new Date ).getDay(); };
p.hour = function hour() { return ( new Date ).getHours(); };
p.minute = function minute(){ return ( new Date ).getMinutes(); };
p.second = function second(){ return ( new Date ).getSeconds(); };
p.millis = function millis(){ return ( new Date ) .getTime() - start; };
p.noLoop = function noLoop(){ doLoop = false; };
p.redraw = function redraw(){
if( hasBackground ){ p.background(); }
p.frameCount++;
inDraw = true;
p.pushMatrix();
p.draw();
p.popMatrix();
inDraw = false;
};
p.loop = function loop(){
if( loopStarted ){ return; }
looping = setInterval( function(){
try {
p.redraw();
}
catch( e ){
clearInterval( looping );
throw e;
}
}, curMsPerFrame );
loopStarted = true;
};
p.frameRate = function frameRate( aRate ){
curFrameRate = aRate;
curMsPerFrame = 1000 / curFrameRate;
};
p.exit = function exit(){
clearInterval( looping );
};
////////////////////////////////////////////////////////////////////////////
// MISC functions
////////////////////////////////////////////////////////////////////////////
p.cursor = function(mode){ document.body.style.cursor=mode; }
p.link = function( href, target ) { window.location = href; };
p.beginDraw = function beginDraw(){};
p.endDraw = function endDraw(){};
p.ajax = ajax;
// Imports an external Processing.js library
p.Import = function Import( lib ){
eval( p.ajax( lib ) );
}
////////////////////////////////////////////////////////////////////////////
// String functions
////////////////////////////////////////////////////////////////////////////
p.nfs = function( num, left, right){
var str;
// array handling
if (typeof num == "object"){
str = new Array();
len = num.length;
for(var i=0; i < len; i++){
str[i] = p.nfs(num[i], left, right);
}
}
else if (arguments.length == 3){
var negative = false;
if (num < 0)
negative = true;
str = "" + Math.abs(num);
var digits = ("" + Math.floor(Math.abs(num))).length;
var count = left - digits;
while (count > 0){
str = "0" + str;
count--;
}
// get the number of decimal places, if none will be -1
var decimals = ("" + Math.abs(num)).length - digits - 1;
if (decimals == -1 && right > 0)
str = str + ".";
if (decimals != -1)
count = right - decimals;
else if (decimals == -1 && right > 0){
count = right;
}
else
count = 0;
while (count > 0){
str = str + "0";
count--;
}
str = (negative ? "-" : " ") + str;
}
else if (arguments.length == 2){
str = p.nfs(num, left, 0);
}
return str;
}
p.unhex = function( str ){
var value = 0,
multiplier = 1,
num = 0;
var len = str.length - 1;
for (var i = len ; i >= 0; i--){
try{
switch(str[i]){
case "0": num = 0; break;
case "1": num = 1; break;
case "2": num = 2; break;
case "3": num = 3; break;
case "4": num = 4; break;
case "5": num = 5; break;
case "6": num = 6; break;
case "7": num = 7; break;
case "8": num = 8; break;
case "9": num = 9; break;
case "A":
case "a": num = 10; break;
case "B":
case "b": num = 11; break;
case "C":
case "c": num = 12; break;
case "D":
case "d": num = 13; break;
case "E":
case "e": num = 14; break;
case "F":
case "f": num = 15; break;
default:return 0; break;
}
value += num * multiplier;
multiplier *= 16;
}catch(e){;}
// correct for int overflow java expectation
if (value > 2147483647)
{
value -= 4294967296;
}
}
return value;
}
// Load a file or URL into strings
p.loadStrings = function loadStrings( url ){
return p.ajax( url ).split( "\n" );
};
p.nf = function( num, pad ){
var str = "" + num;
while ( pad - str.length ){
str = "0" + str;
}
return str;
};
String.prototype.replaceAll = function( re, replace ){
return this.replace( new RegExp( re, "g" ), replace );
};
// Returns a line to lnPrinted() for user handling
p.lnPrinted = function lnPrinted(){};
p.printed = function printed() {};
// Event to send output to user control function print()/println()
p.println = function println(){
// Not working on Safari :( find work around!
if( arguments.callee.caller ){
var Caller = arguments.callee.caller.name.toString();
if( arguments.length > 1 ){
Caller != "print" ?
p.ln = arguments :
p.ln = arguments[ 0 ] ;
}else{
p.ln = arguments[ 0 ] ;
}
//Returns a line to lnPrinted() for user error handling/debugging
Caller == "print" ?
p.printed( arguments ) :
p.lnPrinted() ;
}
};
// Converts a number to a string
p.str = function str( aNumber ){ return aNumber+''; }
p.print = function print(){ p.println(arguments[ 0 ] ) };
p.char = function char( key ){ return key; };
////////////////////////////////////////////////////////////////////////////
// Math functions
////////////////////////////////////////////////////////////////////////////
p.sq = function sq ( aNumber ){ return aNumber * aNumber; };
p.sqrt = function sqrt ( aNumber ){ return Math.sqrt( aNumber ); };
p.int = function int ( aNumber ){ return Math.floor( aNumber ); };
p.min = function min ( aNumber, aNumber2 ){ return Math.min( aNumber, aNumber2 ); };
p.max = function max ( aNumber, aNumber2 ){ return Math.max( aNumber, aNumber2 ); };
p.floor = function floor ( aNumber ){ return Math.floor( aNumber ); };
p.float = function float ( aNumber ){ return parseFloat( aNumber ); };
p.ceil = function ceil ( aNumber ){ return Math.ceil( aNumber ); };
p.round = function round ( aNumber ){ return Math.round( aNumber ); };
p.lerp = function lerp ( value1, value2, amt ){ return ( ( value2 - value1 ) * amt ) + value1; };
p.abs = function abs ( aNumber ){ return Math.abs( aNumber ); };
p.cos = function cos ( aNumber ){ return Math.cos( aNumber ); };
p.sin = function sin ( aNumber ){ return Math.sin( aNumber ); };
p.pow = function pow ( aNumber, aExponent ){ return Math.pow( aNumber, aExponent ); };
p.sqrt = function sqrt ( aNumber ){ return Math.sqrt( aNumber ); };
p.atan2 = function atan2 ( aNumber, aNumber2 ){ return Math.atan2( aNumber, aNumber2 ); };
p.radians = function radians( aAngle ){ return ( aAngle / 180 ) * p.PI; };
p.dist = function dist( x1, y1, x2, y2 ){
return Math.sqrt( Math.pow( x2 - x1, 2 ) + Math.pow( y2 - y1, 2 ) );
};
p.map = function map( value, istart, istop, ostart, ostop ){
return ostart + ( ostop - ostart ) * ( ( value - istart ) / ( istop - istart ) );
};
p.Random = function(){
var haveNextNextGaussian = false,
nextNextGaussian;
this.nextGaussian = function(){
if( haveNextNextGaussian ){
haveNextNextGaussian = false;
return nextNextGaussian;
}else{
var v1, v2, s;
do{
v1 = 2 * p.random( 1 ) - 1; // between -1.0 and 1.0
v2 = 2 * p.random( 1 ) - 1; // between -1.0 and 1.0
s = v1 * v1 + v2 * v2;
}
while( s >= 1 || s == 0 );
var multiplier = Math.sqrt( - 2 * Math.log( s ) / s );
nextNextGaussian = v2 * multiplier;
haveNextNextGaussian = true;
return v1 * multiplier;
}
};
};
//! This can't be right... right?
p.byte = function byte( aNumber ){ return aNumber || 0; };
p.norm = function norm( aNumber, low, high ){
var range = high-low;
return ( ( 1 / range ) * aNumber ) - ( ( 1 / range ) * low );
};
p.random = function random( aMin, aMax ) {
return arguments.length == 2 ?
aMin + ( Math.random() * ( aMax - aMin ) ) :
Math.random() * aMin ;
};
// From: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm
p.noise = function( x, y, z ){
return arguments.length >= 2 ?
PerlinNoise_2D( x, y, z ) :
PerlinNoise_3D( x, x, z ) ;
};
function Noise( x, y ){
var n = x + y * 57;
n = ( n << 13 ) ^ n;
return Math.abs( 1.0 - ( ( ( n * ( ( n * n * 15731 ) + 789221 ) + 1376312589 ) & 0x7fffffff ) / 1073741824.0 ) );
};
function SmoothedNoise( x, y ){
var corners = ( Noise( x - 1, y - 1 ) + Noise( x + 1, y - 1 ) + Noise( x - 1, y + 1 ) + Noise( x + 1, y + 1 ) ) / 16,
sides = ( Noise( x - 1, y ) + Noise( x + 1, y ) + Noise( x, y - 1 ) + Noise( x, y + 1 ) ) / 8,
center = Noise( x, y ) / 4;
return corners + sides + center;
};
function InterpolatedNoise( x, y ){
var integer_X = Math.floor( x );
var fractional_X = x - integer_X;
var integer_Y = Math.floor( y );
var fractional_Y = y - integer_Y;
var v1 = SmoothedNoise( integer_X, integer_Y ),
v2 = SmoothedNoise( integer_X + 1, integer_Y ),
v3 = SmoothedNoise( integer_X, integer_Y + 1 ),
v4 = SmoothedNoise( integer_X + 1, integer_Y + 1 );
var i1 = Interpolate( v1, v2, fractional_X ),
i2 = Interpolate( v3, v4, fractional_X );
return Interpolate( i1, i2, fractional_Y );
}
function PerlinNoise_2D( x, y ){
var total = 0,
p = 0.25,
n = 3;
for( var i = 0; i <= n; i++ ){
var frequency = Math.pow( 2, i );
var amplitude = Math.pow( p, i );
total += InterpolatedNoise( x * frequency, y * frequency ) * amplitude;
}
return total;
}
function Interpolate( a, b, x ){
var ft = x * p.PI;
var f = (1 - Math.cos( ft ) ) * .5;
return a * ( 1 - f ) + b * f;
}
p.constrain = function constrain( aNumber, aMin, aMax ){
return Math.min( Math.max( aNumber, aMin ), aMax );
};
p.degrees = function degrees( aAngle ){
aAngle = ( aAngle * 180 ) / p.PI;
if (aAngle < 0) {aAngle = 360 + aAngle}
return aAngle;
};
p.size = function size( aWidth, aHeight ){
var fillStyle = curContext.fillStyle,
strokeStyle = curContext.strokeStyle;
curElement.width = p.width = aWidth;
curElement.height = p.height = aHeight;
curContext.fillStyle = fillStyle;
curContext.strokeStyle = strokeStyle;
};
////////////////////////////////////////////////////////////////////////////
// Style functions
////////////////////////////////////////////////////////////////////////////
p.noStroke = function noStroke() { doStroke = false; };
p.noFill = function noFill() { doFill = false; };
p.smooth = function smooth() {};
p.noSmooth = function noSmooth() {};
p.fill = function fill(){
doFill = true;
curContext.fillStyle = p.color.apply( this, arguments );
};
p.stroke = function stroke(){
doStroke = true;
curContext.strokeStyle = p.color.apply( this, arguments );
};
p.strokeWeight = function strokeWeight( w ){
curContext.lineWidth = w;
};
////////////////////////////////////////////////////////////////////////////
// Vector drawing functions
////////////////////////////////////////////////////////////////////////////
p.Point = function Point( x, y ){
this.x = x;
this.y = y;
this.copy = function(){
return new Point( x, y );
}
};
p.point = function point( x, y ){
var oldFill = curContext.fillStyle;
curContext.fillStyle = curContext.strokeStyle;
curContext.fillRect( Math.round( x ), Math.round( y ), 1, 1 );
curContext.fillStyle = oldFill;
};
p.beginShape = function beginShape( type ){
curShape = type;
curShapeCount = 0;
curvePoints = [];
};
p.endShape = function endShape( close ){
if( curShapeCount != 0 ){
if( close || doFill ){ curContext.lineTo( firstX, firstY ); }
if( doFill ){ curContext.fill(); }
if( doStroke ){ curContext.stroke(); }
curContext.closePath();
curShapeCount = 0;
pathOpen = false;
}
if( pathOpen ){
if ( doFill ){ curContext.fill(); }
if ( doStroke ){ curContext.stroke(); }
curContext.closePath();
curShapeCount = 0;
pathOpen = false;
}
};
p.vertex = function vertex( x, y, x2, y2, x3, y3 ){
if( curShapeCount == 0 && curShape != p.POINTS ){
pathOpen = true;
curContext.beginPath();
curContext.moveTo( x, y );
firstX = x;
firstY = y;
}else{
if( curShape == p.POINTS ){
p.point( x, y );
}else if( arguments.length == 2 ){
if( curShape != p.QUAD_STRIP || curShapeCount != 2 ){
curContext.lineTo( x, y );
}
if( curShape == p.TRIANGLE_STRIP ){
if( curShapeCount == 2 ){
// finish shape
p.endShape( p.CLOSE );
pathOpen = true;
curContext.beginPath();
// redraw last line to start next shape
curContext.moveTo( prevX, prevY );
curContext.lineTo( x, y );
curShapeCount = 1;
}
firstX = prevX;
firstY = prevY;
}
if( curShape == p.TRIANGLE_FAN && curShapeCount == 2 ){
// finish shape
p.endShape( p.CLOSE) ;
pathOpen = true;
curContext.beginPath();
// redraw last line to start next shape
curContext.moveTo( firstX, firstY );
curContext.lineTo( x, y );
curShapeCount = 1;
}
if( curShape == p.QUAD_STRIP && curShapeCount == 3 ){
// finish shape
curContext.lineTo( prevX, prevY );
p.endShape(p.CLOSE);
pathOpen = true;
curContext.beginPath();
// redraw lines to start next shape
curContext.moveTo( prevX, prevY );
curContext.lineTo( x, y );
curShapeCount = 1;
}
if( curShape == p.QUAD_STRIP ){
firstX = secondX;
firstY = secondY;
secondX = prevX;
secondY = prevY;
}
}else if( arguments.length == 4 ){
if( curShapeCount > 1 ){
curContext.moveTo( prevX, prevY );
curContext.quadraticCurveTo( firstX, firstY, x, y );
curShapeCount = 1;
}
}else if( arguments.length == 6 ){
curContext.bezierCurveTo( x, y, x2, y2, x3, y3 );
}
}
prevX = x;
prevY = y;
curShapeCount ++;
if( curShape == p.LINES && curShapeCount == 2 ||
( curShape == p.TRIANGLES ) && curShapeCount == 3 ||
( curShape == p.QUADS ) && curShapeCount == 4
){
p.endShape( p.CLOSE );
}
};
p.curveVertex = function( x, y, x2, y2 ){
if( curvePoints.length < 3 ){
curvePoints.push( [ x, y ] );
}else{
var b = [], s = 1 - curTightness;
/*
* Matrix to convert from Catmull-Rom to cubic Bezier
* where t = curTightness
* |0 1 0 0 |
* |(t-1)/6 1 (1-t)/6 0 |
* |0 (1-t)/6 1 (t-1)/6 |
* |0 0 0 0 |
*/
curvePoints.push( [ x, y ] );
b[ 0 ] = [ curvePoints[ 1 ][ 0 ], curvePoints[ 1 ][ 1 ] ];
b[ 1 ] = [ curvePoints[ 1 ][ 0 ] + ( s * curvePoints[ 2 ][ 0 ] - s * curvePoints[ 0 ][ 0 ] ) / 6, curvePoints[ 1 ][ 1 ] + ( s * curvePoints[ 2 ][ 1 ] - s * curvePoints[ 0 ][ 1 ] ) / 6 ];
b[ 2 ] = [ curvePoints[ 2 ][ 0 ] + ( s * curvePoints[ 1 ][ 0 ] - s * curvePoints[ 3 ][ 0 ] ) / 6, curvePoints[ 2 ][ 1 ] + ( s * curvePoints[ 1 ][ 1 ] - s * curvePoints[ 3 ][ 1 ] ) / 6 ];
b[ 3 ] = [ curvePoints[ 2 ][ 0 ], curvePoints[ 2 ][ 1 ] ];
if( !pathOpen ){
p.vertex( b[ 0 ][ 0 ], b[ 0 ][ 1 ] );
}else{
curShapeCount = 1;
}
p.vertex(
b[ 1 ][ 0 ],
b[ 1 ][ 1 ],
b[ 2 ][ 0 ],
b[ 2 ][ 1 ],
b[ 3 ][ 0 ],
b[ 3 ][ 1 ]
);
curvePoints.shift();
}
};
p.curveTightness = function( tightness ){ curTightness = tightness; };
p.bezierVertex = p.vertex;
p.rectMode = function rectMode( aRectMode ){ curRectMode = aRectMode; };
p.imageMode = function (){};
p.ellipseMode = function ellipseMode( aEllipseMode ) { curEllipseMode = aEllipseMode; };
p.arc = function arc( x, y, width, height, start, stop ){
if( width <= 0 ){ return; }
if( curEllipseMode == p.CORNER ){
x += width / 2;
y += height / 2;
}
curContext.moveTo( x, y );
curContext.beginPath();
curContext.arc( x, y, curEllipseMode == p.CENTER_RADIUS ? width : width/2, start, stop, false );
if( doStroke ){ curContext.stroke(); }
curContext.lineTo( x, y );
if( doFill ){ curContext.fill(); }
curContext.closePath();
};
p.line = function line( x1, y1, x2, y2 ){
curContext.lineCap = "round";
curContext.beginPath();
curContext.moveTo( x1 || 0, y1 || 0 );
curContext.lineTo( x2 || 0, y2 || 0 );
curContext.stroke();
curContext.closePath();
};
p.bezier = function bezier( x1, y1, x2, y2, x3, y3, x4, y4 ){
curContext.lineCap = "butt";
curContext.beginPath();
curContext.moveTo( x1, y1 );
curContext.bezierCurveTo( x2, y2, x3, y3, x4, y4 );
curContext.stroke();
curContext.closePath();
};
p.triangle = function triangle( x1, y1, x2, y2, x3, y3 ){
p.beginShape();
p.vertex( x1, y1 );
p.vertex( x2, y2 );
p.vertex( x3, y3 );
p.endShape();
};
p.quad = function quad( x1, y1, x2, y2, x3, y3, x4, y4 ){
curContext.lineCap = "square";
p.beginShape();
p.vertex( x1, y1 );
p.vertex( x2, y2 );
p.vertex( x3, y3 );
p.vertex( x4, y4 );
p.endShape();
};
p.rect = function rect( x, y, width, height ){
if( !( width + height ) ){ return; }
curContext.beginPath();
var offsetStart = 0;
var offsetEnd = 0;
if( curRectMode == p.CORNERS ){
width -= x;
height -= y;
}
if( curRectMode == p.RADIUS ){
width *= 2;
height *= 2;
}
if( curRectMode == p.CENTER || curRectMode == p.RADIUS ){
x -= width / 2;
y -= height / 2;
}
curContext.rect(
Math.round( x ) - offsetStart,
Math.round( y ) - offsetStart,
Math.round( width ) + offsetEnd,
Math.round( height ) + offsetEnd
);
if( doFill ){ curContext.fill(); }
if( doStroke ){ curContext.stroke() };
curContext.closePath();
};
p.ellipse = function ellipse( x, y, width, height ){
x = x || 0;
y = y || 0;
if( width <= 0 && height <= 0 ){ return; }
curContext.beginPath();
if( curEllipseMode == p.RADIUS ){
width *= 2;
height *= 2;
}
var offsetStart = 0;
// Shortcut for drawing a circle
if( width == height ){
curContext.arc( x - offsetStart, y - offsetStart, width / 2, 0, p.TWO_PI, false );
}else{
var w = width/2,
h = height/2,
C = 0.5522847498307933;
var c_x = C * w,
c_y = C * h;
//! Do we still need this? I hope the Canvas arc() more capable by now?
curContext.moveTo( x + w, y );
curContext.bezierCurveTo( x+w , y-c_y , x+c_x , y-h , x , y-h );
curContext.bezierCurveTo( x-c_x , y-h , x-w , y-c_y , x-w , y );
curContext.bezierCurveTo( x-w , y+c_y , x-c_x , y+h, x, y+h );
curContext.bezierCurveTo( x+c_x , y+h , x+w , y+c_y , x+w , y );
}
if( doFill ){ curContext.fill(); }
if( doStroke ){ curContext.stroke(); }
curContext.closePath();
};
////////////////////////////////////////////////////////////////////////////
// Raster drawing functions
////////////////////////////////////////////////////////////////////////////
p.save = function save( file ){};
// Loads an image for display. Type is unused. Callback is fired on load.
p.loadImage = function loadImage( file, type, callback ){
var img = document.createElement( 'img' );
img.src = file;
img.onload = function(){
var h = this.height,
w = this.width;
var canvas = document.createElement( "canvas" );
canvas.width = w;
canvas.height = h;
var context = canvas.getContext( "2d" );
context.drawImage( this, 0, 0 );
this.data = buildImageObject( context.getImageData( 0, 0, w, h ) );
this.data.img = img;
callback?callback():0;
}
return img;
};
// Gets a single pixel or block of pixels from the current Canvas Context
p.get = function get( x, y ){
if( !arguments.length ){
var c = p.createGraphics( p.width, p.height );
c.image( curContext, 0, 0 );
return c;
}
if( !getLoaded ){
getLoaded = buildImageObject( curContext.getImageData( 0, 0, p.width, p.height ) );
}
return getLoaded.get( x, y );
};
// Creates a new Processing instance and passes it back for... processing
p.createGraphics = function createGraphics( w, h ){
var canvas = document.createElement( "canvas" );
var ret = buildProcessing( canvas );
ret.size( w, h );
ret.canvas = canvas;
return ret;
};
// Paints a pixel array into the canvas
p.set = function set( x, y, obj ){
if( obj && obj.img ){
p.image( obj, x, y );
}else{
var oldFill = curContext.fillStyle,
color = obj;
curContext.fillStyle = color;
curContext.fillRect( Math.round( x ), Math.round( y ), 1, 1 );
curContext.fillStyle = oldFill;
}
};
// Gets a 1-Dimensional pixel array from Canvas
p.loadPixels = function(){
p.pixels = buildImageObject( curContext.getImageData(0, 0, p.width, p.height) ).pixels;
};
// Draws a 1-Dimensional pixel array to Canvas
p.updatePixels = function() {
var colors = /(\d+),(\d+),(\d+),(\d+)/,
pixels = {};
pixels.width = p.width;
pixels.height = p.height;
pixels.data = [];
if( curContext.createImageData ){
pixels = curContext.createImageData( p.width, p.height );
}
var data = pixels.data,
pos = 0;
for( var i = 0, l = p.pixels.length; i < l; i++ ){
var c = ( p.pixels[i] || "rgba(0,0,0,1)" ).match( colors );
data[ pos + 0 ] = parseInt( c[ 1 ] );
data[ pos + 1 ] = parseInt( c[ 2 ] );
data[ pos + 2 ] = parseInt( c[ 3 ] );
data[ pos + 3 ] = parseFloat( c[ 4 ] ) * 255;
pos += 4;
}
curContext.putImageData( pixels, 0, 0 );
};
// Draw an image or a color to the background
p.background = function background( img ) {
if( arguments.length ){
if( img.data && img.data.img ){
curBackground = img.data;
}else{
curBackground = p.color.apply( this, arguments );
}
}
if( curBackground.img ){
p.image( img, 0, 0 );
}else{
var oldFill = curContext.fillStyle;
curContext.fillStyle = curBackground + "";
curContext.fillRect( 0, 0, p.width, p.height );
curContext.fillStyle = oldFill;
}
};
p.AniSprite = function( prefix, frames ){
this.images = [];
this.pos = 0;
for( var i = 0; i < frames; i++ ){
this.images.push( prefix + p.nf( i, ( "" + frames ).length ) + ".gif" );
}
this.display = function( x, y ){
p.image_old( this.images[ this.pos ], x, y );
if( ++this.pos >= frames ){
this.pos = 0;
}
};
this.getWidth = function(){ return getImage_old( this.images[ 0 ] ).width; };
this.getHeight = function(){ return getImage_old( this.images[ 0 ] ).height; };
};
function buildImageObject( obj ){
var pixels = obj.data;
var data = p.createImage( obj.width, obj.height );
if( data.__defineGetter__ && data.__lookupGetter__ && !data.__lookupGetter__( "pixels" ) ){
var pixelsDone;
data.__defineGetter__( "pixels", function(){
if( pixelsDone ){
return pixelsDone;
}
pixelsDone = [];
for( var i = 0; i < pixels.length; i += 4 ){
pixelsDone.push(
p.color(
pixels[ i ],
pixels[ i + 1 ],
pixels[ i + 2 ],
pixels[ i + 3 ])
);
}
return pixelsDone;
});
}else{
data.pixels = [];
for ( var i = 0; i < pixels.length; i += 4 ){
data.pixels.push( p.color(
pixels[ i ],
pixels[ i + 1 ],
pixels[ i + 2 ],
pixels[ i + 3 ]
));
}
}
return data;
}
p.createImage = function createImage( w, h, mode ){
var data = {};
data.width = w;
data.height = h;
data.data = [];
if( curContext.createImageData ) {
data = curContext.createImageData( w, h );
}
data.pixels = new Array( w * h );
data.get = function( x, y ){
return this.pixels[ w * y + x ];
};
data._mask = null;
data.mask = function( img ){
this._mask = img;
};
data.loadPixels = function(){};
data.updatePixels = function(){};
return data;
};
function getImage( img ){
if( typeof img == "string" ){
return document.getElementById( img );
}
if( img.img ){
return img.img;
}else if( img.getContext || img.canvas ){
img.pixels = img.getContext( '2d' ).createImageData( img.width, img.height );
}
for( var i = 0, l = img.pixels.length; i < l; i++ ){
var pos = i * 4;
var c = ( img.pixels[ i ] || "rgba(0,0,0,1)" ).slice( 5, - 1 ).split( "," );
img.data[ pos + 0 ] = parseInt( c[ 0 ] );
img.data[ pos + 1 ] = parseInt( c[ 1 ] );
img.data[ pos + 2 ] = parseInt( c[ 2 ] );
img.data[ pos + 3 ] = parseFloat( c[ 3 ] ) * 100;
}
var canvas = document.createElement( "canvas" );
canvas.width = img.width;
canvas.height = img.height;
var context = canvas.getContext( "2d" );
context.putImageData( img.pixels, 0, 0 );
img.canvas = canvas;
return img;
}
// Depreciating "getImage_old" from PJS - currently here to support AniSprite
function getImage_old( img ){
if( typeof img == "string" ){
return document.getElementById( img );
}
if( img.img || img.canvas ){
return img.img || img.canvas;
}
for( var i = 0, l = img.pixels.length; i < l; i++ ){
var pos = i * 4;
var c = ( img.pixels[ i ] || "rgba(0,0,0,1)" ).slice( 5, - 1 ).split( "," );
img.data[ pos + 0 ] = parseInt( c[ 0 ] );
img.data[ pos + 1 ] = parseInt( c[ 1 ] );
img.data[ pos + 2 ] = parseInt( c[ 2 ] );
img.data[ pos + 3 ] = parseFloat( c[ 3 ] ) * 100;
}
var canvas = document.createElement( "canvas" );
canvas.width = img.width;
canvas.height = img.height;
var context = canvas.getContext( "2d" );
context.putImageData( img, 0, 0 );
img.canvas = canvas;
return canvas;
}
// Depreciating "getImage_old" from PJS - currently here to support AniSprite
p.image_old=function image_old(img,x,y,w,h){
x = x || 0;
y = y || 0;
var obj = getImage( img );
if( curTint >= 0 ){
var oldAlpha = curContext.globalAlpha;
curContext.globalAlpha = curTint / opacityRange;
}
if( arguments.length == 3 ){
curContext.drawImage( obj, x, y );
}else{
curContext.drawImage( obj, x, y, w, h );
}
if( curTint >= 0 ){
curContext.globalAlpha = oldAlpha;
}
if( img._mask ){
var oldComposite = curContext.globalCompositeOperation;
curContext.globalCompositeOperation = "darker";
p.image( img._mask, x, y );
curContext.globalCompositeOperation = oldComposite;
}
};
// Draws an image to the Canvas
p.image = function image( img, x, y, w, h ){
if( img.data || img.canvas ){
x = x || 0;
y = y || 0;
var obj = getImage( img.data || img.canvas );
if( curTint >= 0 ){
var oldAlpha = curContext.globalAlpha;
curContext.globalAlpha = curTint / opacityRange;
}
if( arguments.length == 3 ){
curContext.drawImage( obj, x, y );
}else{
curContext.drawImage( obj, x, y, w, h );
}
if( curTint >= 0 ){
curContext.globalAlpha = oldAlpha;
}
if( img._mask ){
var oldComposite = curContext.globalCompositeOperation;
curContext.globalCompositeOperation = "darker";
p.image( img._mask, x, y );
curContext.globalCompositeOperation = oldComposite;
}
}
if( typeof img == 'string' ){
}
};
// Clears hole in the Canvas or the whole Canvas
p.clear = function clear ( x, y, width, height ) {
if( arguments.length == 0 ){
curContext.clearRect( x, y, width, height );
}else{
curContext.clearRect( 0, 0, p.width, p.height );
}
}
p.tint = function tint( rgb, a ){
curTint = a;
};
////////////////////////////////////////////////////////////////////////////
// Font handling
////////////////////////////////////////////////////////////////////////////
// Loads a font from an SVG or Canvas API
p.loadFont = function loadFont( name ){
if( name.indexOf( ".svg" ) == - 1 ){
return {
name: name,
width: function( str ){
if( curContext.mozMeasureText ){
return curContext.mozMeasureText(
typeof str == "number" ?
String.fromCharCode( str ) :
str
) / curTextSize;
}else{
return 0;
}
}
};
}else{
// If the font is a glyph, calculate by SVG table
var font = p.loadGlyphs( name );
return {
name : name,
glyph : true,
units_per_em : font.units_per_em,
horiz_adv_x : 1 / font.units_per_em * font.horiz_adv_x,
ascent : font.ascent,
descent : font.descent,
width :
function( str ){
var width = 0;
var len = str.length;
for( var i = 0; i < len; i++ ){
try{ width += parseFloat( p.glyphLook( p.glyphTable[ name ], str[ i ] ).horiz_adv_x ); }
catch( e ){ ; }
}
return width / p.glyphTable[ name ].units_per_em;
}
}
}
};
// Sets a 'current font' for use
p.textFont = function textFont( name, size ){
curTextFont = name;
p.textSize( size );
};
// Sets the font size
p.textSize = function textSize( size ){
//! Was this meant to return textSize value if no arguments were passed?
if( size ){
curTextSize = size;
}
};
p.textAlign = function textAlign(){};
// A lookup table for characters that can not be referenced by Object
p.glyphLook = function glyphLook( font, chr ){
try{
switch( chr ){
case "1" : return font[ "one" ]; break;
case "2" : return font[ "two" ]; break;
case "3" : return font[ "three" ]; break;
case "4" : return font[ "four" ]; break;
case "5" : return font[ "five" ]; break;
case "6" : return font[ "six" ]; break;
case "7" : return font[ "seven" ]; break;
case "8" : return font[ "eight" ]; break;
case "9" : return font[ "nine" ]; break;
case "0" : return font[ "zero" ]; break;
case " " : return font[ "space" ]; break;
case "$" : return font[ "dollar" ]; break;
case "!" : return font[ "exclam" ]; break;
case '"' : return font[ "quotedbl" ]; break;
case "#" : return font[ "numbersign" ]; break;
case "%" : return font[ "percent" ]; break;
case "&" : return font[ "ampersand" ]; break;
case "'" : return font[ "quotesingle" ]; break;
case "(" : return font[ "parenleft" ]; break;
case ")" : return font[ "parenright" ]; break;
case "*" : return font[ "asterisk" ]; break;
case "+" : return font[ "plus" ]; break;
case "," : return font[ "comma" ]; break;
case "-" : return font[ "hyphen" ]; break;
case "." : return font[ "period" ]; break;
case "/" : return font[ "slash" ]; break;
case "_" : return font[ "underscore" ]; break;
case ":" : return font[ "colon" ]; break;
case ";" : return font[ "semicolon" ]; break;
case "<" : return font[ "less" ]; break;
case "=" : return font[ "equal" ]; break;
case ">" : return font[ "greater" ]; break;
case "?" : return font[ "question" ]; break;
case "@" : return font[ "at" ]; break;
case "[" : return font[ "bracketleft" ]; break;
case "\\" : return font[ "backslash" ]; break;
case "]" : return font[ "bracketright" ]; break;
case "^" : return font[ "asciicircum" ]; break;
case "`" : return font[ "grave" ]; break;
case "{" : return font[ "braceleft" ]; break;
case "|" : return font[ "bar" ]; break;
case "}" : return font[ "braceright" ]; break;
case "~" : return font[ "asciitilde" ]; break;
// If the character is not 'special', access it by object reference
default : return font[ chr ]; break;
}
}catch( e ){ ; }
}
// Print some text to the Canvas
p.text = function text( str, x, y ){
// If the font is a standard Canvas font...
if( !curTextFont.glyph ){
if( str && curContext.mozDrawText ){
curContext.save();
curContext.mozTextStyle = curTextSize + "px " + curTextFont.name;
curContext.translate( x, y );
curContext.mozDrawText(
typeof str == "number" ?
String.fromCharCode( str ) :
str ) ;
curContext.restore();
}
}else{
// If the font is a Batik SVG font...
var font = p.glyphTable[ curTextFont.name ];
curContext.save();
curContext.translate( x, y + curTextSize );
var upem = font[ "units_per_em" ],
newScale = 1 / upem * curTextSize;
curContext.scale( newScale, newScale );
var len = str.length;
for(var i = 0; i < len; i++ ){
// Test character against glyph table
try{ p.glyphLook( font, str[ i ] ).draw(); }
catch( e ){ ; }
}
curContext.restore();
}
};
// Load Batik SVG Fonts and parse to pre-def objects for quick rendering
p.loadGlyphs = function loadGlyph( url ){
// Load and parse Batik SVG font as XML into a Processing Glyph object
var loadXML = function loadXML(){
try{
var xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" );
}
catch( e ){
try{
xmlDoc=document.implementation.createDocument( "", "", null );
}
catch( e ){
p.println( e.message );
return;
}
};
try{
xmlDoc.async = false;
xmlDoc.load( url );
parse( xmlDoc.getElementsByTagName( "svg" )[ 0 ] );
}
catch( e ){
// Google Chrome, Safari etc.
try{
p.println( e.message );
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open( "GET", url, false );
xmlhttp.send( null );
parse( xmlhttp.responseXML.documentElement );
}
catch( e ){ ; }
}
};
// Return arrays of SVG commands and coords
var regex = function regex( needle, hay ){
var regexp = new RegExp( needle, "g" ),
results = [],
i = 0;
while( results[ i ] = regexp.exec( hay ) ){ i++; }
return results;
}
// Parse SVG font-file into block of Canvas commands
var parse = function parse( svg ){
// Store font attributes
var font = svg.getElementsByTagName( "font" );
p.glyphTable[ url ][ "horiz_adv_x" ] = font[ 0 ].getAttribute( "horiz-adv-x" );
var font_face = svg.getElementsByTagName( "font-face" )[ 0 ];
p.glyphTable[ url ][ "units_per_em" ] = parseFloat( font_face.getAttribute( "units-per-em") );
p.glyphTable[ url ][ "ascent" ] = parseFloat( font_face.getAttribute( "ascent" ) );
p.glyphTable[ url ][ "descent" ] = parseFloat( font_face.getAttribute( "descent" ) );
var getXY = "[0-9\-]+",
glyph = svg.getElementsByTagName( "glyph" ),
len = glyph.length;
// Loop through each glyph in the SVG
for( var i = 0; i < len; i++ ){
// Store attributes for this glyph
var unicode = glyph[ i ].getAttribute( "unicode" );
var name = glyph[ i ].getAttribute( "glyph-name" );
var horiz_adv_x = glyph[ i ].getAttribute( "horiz-adv-x" );
if( horiz_adv_x == null ){ var horiz_adv_x = p.glyphTable[ url ][ 'horiz_adv_x' ]; }
var buildPath = function buildPath( d ){
var c = regex( "[A-Za-z][0-9\- ]+|Z", d );
// Begin storing path object
var path = "var path={draw:function(){curContext.beginPath();curContext.save();";
var x = 0,
y = 0,
cx = 0,
cy = 0,
nx = 0,
ny = 0,
d = 0,
a = 0,
lastCom = "",
lenC = c.length - 1;
// Loop through SVG commands translating to canvas eqivs functions in path object
for( var j = 0; j < lenC; j++ ){
var com = c[ j ][ 0 ],
xy = regex( getXY, com );
switch( com[ 0 ] ){
case "M": //curContext.moveTo(x,-y);
x = parseFloat( xy[ 0 ][ 0 ] );
y = parseFloat( xy[ 1 ][ 0 ] );
//! Brackets needed on (-y)?
path += "curContext.moveTo("+ x +","+ (-y) +");";
break;
case "L": //curContext.lineTo(x,-y);
x = parseFloat( xy[ 0 ][ 0 ] );
y = parseFloat( xy[ 1 ][ 0 ] );
path += "curContext.lineTo("+ x +","+ (-y) +");";
break;
case "H"://curContext.lineTo(x,-y)
x = parseFloat( xy[ 0 ][ 0 ] );
path += "curContext.lineTo("+ x +","+ (-y) +");";
break;
case "V"://curContext.lineTo(x,-y);
y = parseFloat( xy[ 0 ][ 0 ] );
path += "curContext.lineTo("+ x +","+ (-y) +");";
break;
case "T"://curContext.quadraticCurveTo(cx,-cy,nx,-ny);
nx = parseFloat( xy[ 0 ][ 0 ] );
ny = parseFloat( xy[ 1 ][ 0 ] );
if( lastCom == "Q" || lastCom == "T" ){
d = Math.sqrt( Math.pow( x - cx, 2 ) + Math.pow( cy - y, 2 ) );
a = Math.PI+Math.atan2( cx - x, cy - y );
cx = x + ( Math.sin( a ) * ( d ) );
cy = y + ( Math.cos( a ) * ( d ) );
}else{
cx = x;
cy = y;
}
path += "curContext.quadraticCurveTo("+ cx +","+ (-cy) +","+ nx +","+ (-ny) +");";
x = nx;
y = ny;
break;
case "Q"://curContext.quadraticCurveTo(cx,-cy,nx,-ny);
cx = parseFloat( xy[ 0 ][ 0 ] );
cy = parseFloat( xy[ 1 ][ 0 ] );
nx = parseFloat( xy[ 2 ][ 0 ] );
ny = parseFloat( xy[ 3 ][ 0 ] );
path += "curContext.quadraticCurveTo("+ cx +","+ (-cy) +","+ nx +","+ (-ny) +");";
x = nx;
y = ny;
break;
case "Z"://curContext.closePath();
path += "curContext.closePath();";
break;
}
lastCom = com[ 0 ];
}
path += "doStroke?curContext.stroke():0;";
path += "doFill?curContext.fill():0;";
path += "curContext.restore();";
path += "curContext.translate("+ horiz_adv_x +",0);";
path += "}}";
return path;
}
var d = glyph[ i ].getAttribute( "d" );
// Split path commands in glpyh
if( d !== undefined ){
var path = buildPath( d );
eval( path );
// Store glyph data to table object
p.glyphTable[ url ][ name ] = {
name : name,
unicode : unicode,
horiz_adv_x : horiz_adv_x,
draw : path.draw
}
}
} // finished adding glyphs to table
}
// Create a new object in glyphTable to store this font
p.glyphTable[ url ] = {};
// Begin loading the Batik SVG font...
loadXML( url );
// Return the loaded font for attribute grabbing
return p.glyphTable[ url ];
}
////////////////////////////////////////////////////////////////////////////
// Class methods
////////////////////////////////////////////////////////////////////////////
p.extendClass = function extendClass( obj, args, fn ){
if( arguments.length == 3 ){
fn.apply( obj, args );
}else{
args.call( obj );
}
};
p.addMethod = function addMethod( object, name, fn ){
if( object[ name ] ){
var args = fn.length,
oldfn = object[ name ];
object[ name ] = function(){
if( arguments.length == args ){
return fn.apply( this, arguments );
}else{
return oldfn.apply( this, arguments );
}
};
}else{
object[ name ] = fn;
}
};
////////////////////////////////////////////////////////////////////////////
// Set up environment
////////////////////////////////////////////////////////////////////////////
p.init = function init(code){
p.stroke( 0 );
p.fill( 255 );
// Canvas has trouble rendering single pixel stuff on whole-pixel
// counts, so we slightly offset it (this is super lame).
curContext.translate( 0.5, 0.5 );
// The fun bit!
if( code ){
(function( Processing ){
with ( p ){
eval(parse(code, p));
}
})( p );
}
if( p.setup ){
inSetup = true;
p.setup();
}
inSetup = false;
if( p.draw ){
if( !doLoop ){
p.redraw();
} else {
p.loop();
}
}
//////////////////////////////////////////////////////////////////////////
// Event handling
//////////////////////////////////////////////////////////////////////////
attach( curElement, "mousemove" , function(e){
var scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
var scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
p.pmouseX = p.mouseX;
p.pmouseY = p.mouseY;
p.mouseX = e.clientX - curElement.offsetLeft + scrollX;
p.mouseY = e.clientY - curElement.offsetTop + scrollY;
if( p.mouseMoved ){ p.mouseMoved(); }
if( mousePressed && p.mouseDragged ){ p.mouseDragged(); }
});
attach( curElement, "mouseout" , function( e ){ p.cursor("auto"); });
attach( curElement, "mousedown", function( e ){
mousePressed = true;
switch(e.which){
case 1: p.mouseButton = p.LEFT; break;
case 2: p.mouseButton = p.CENTER; break;
case 3: p.mouseButton = p.RIGHT; break;
}
p.mouseDown = true;
if( typeof p.mousePressed == "function" ){ p.mousePressed(); }
else{ p.mousePressed = true; }
});
attach( curElement, "contextmenu", function( e ){
e.preventDefault();
e.stopPropagation();
});
attach( curElement, "mouseup", function( e ){
mousePressed = false;
if( p.mouseClicked ){ p.mouseClicked(); }
if( typeof p.mousePressed != "function" ){ p.mousePressed = false; }
if( p.mouseReleased ){ p.mouseReleased(); }
});
attach( document, "keydown", function( e ){
keyPressed = true;
p.key = e.keyCode + 32;
var i, len = p.codedKeys.length;
for( i=0; i < len; i++ ){
if( p.key == p.codedKeys[ i ] ){
switch(p.key){
case 70: p.keyCode = p.UP ; break;
case 71: p.keyCode = p.RIGHT ; break;
case 72: p.keyCode = p.DOWN ; break;
case 69: p.keyCode = p.LEFT ; break;
}
p.key=p.CODED;
}
}
if( e.shiftKey ){ p.key = String.fromCharCode(p.key).toUpperCase().charCodeAt( 0 ); }
if( typeof p.keyPressed == "function" ){ p.keyPressed(); }
else{ p.keyPressed = true; }
});
attach( document, "keyup", function( e ){
keyPressed = false;
if( typeof p.keyPressed != "function" ){ p.keyPressed = false; }
if( p.keyReleased ){ p.keyReleased(); }
});
function attach(elem, type, fn) {
if( elem.addEventListener ){ elem.addEventListener( type, fn, false ); }
else{ elem.attachEvent( "on" + type, fn ); }
}
};
return p;
}
})();
sagenb-1.0.1/sagenb/data/jquery/ 0000775 0000000 0000000 00000000000 13114362624 0016441 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/jquery/plugins/ 0000775 0000000 0000000 00000000000 13114362624 0020122 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/jquery/plugins/achtung/ 0000775 0000000 0000000 00000000000 13114362624 0021553 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/jquery/plugins/achtung/AUTHORS.txt 0000664 0000000 0000000 00000002054 13114362624 0023442 0 ustar 00root root 0000000 0000000 achtung 0.3.0
Josh Varner
http://achtung-ui.googlecode.com/
===============================================================================
For portions from jQuery UI:
===============================================================================
jQuery UI Authors (http://ui.jquery.com/about)
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
and logs, available at http://jquery-ui.googlecode.com/svn/
Brandon Aaron
Paul Bakaus (paulbakaus.com)
David Bolter
Rich Caloggero
Chi Cheng (cloudream@gmail.com)
Colin Clark (http://colin.atrc.utoronto.ca/)
Michelle D'Souza
Aaron Eisenberger (aaronchi@gmail.com)
Ariel Flesler
Bohdan Ganicky
Scott González
Marc Grabanski (m@marcgrabanski.com)
Klaus Hartl (stilbuero.de)
Scott Jehl
Cody Lindley
Eduardo Lundgren (eduardolundgren@gmail.com)
Todd Parker
John Resig
Patty Toland
Ca-Phun Ung (yelotofu.com)
Keith Wood (kbwood@virginbroadband.com.au)
Maggie Costello Wachs
Richard D. Worth (rdworth.org)
Jörn Zaefferer (bassistance.de)
sagenb-1.0.1/sagenb/data/jquery/plugins/achtung/LICENSE.txt 0000664 0000000 0000000 00000002120 13114362624 0023371 0 ustar 00root root 0000000 0000000 achtung 0.3.0
Copyright (c) 2009 Josh Varner, http://achtung-ui.googlecode.com/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
sagenb-1.0.1/sagenb/data/jquery/plugins/achtung/ui.achtung-min.css 0000664 0000000 0000000 00000025442 13114362624 0025122 0 ustar 00root root 0000000 0000000 * html #achtung-overlay{position:absolute;}* html .achtung{width:280px;}#achtung-overlay{overflow:hidden;position:fixed;top:15px;right:15px;width:280px;z-index:50;}.achtung{display:none;margin-bottom:8px;padding:15px 15px;background-color:#000;color:white;width:250px;font-weight:bold;position:relative;overflow:hidden;-moz-box-shadow:#aaa 1px 1px 2px;-webkit-box-shadow:#aaa 1px 1px 2px;box-shadow:#aaa 1px 1px 2px;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;opacity:.85;filter:Alpha(Opacity=85);}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat;}.ui-icon{width:16px;height:16px;background-image:url(images/ui-icons_222222_256x240.png);}.ui-icon-carat-1-n{background-position:0 0;}.ui-icon-carat-1-ne{background-position:-16px 0;}.ui-icon-carat-1-e{background-position:-32px 0;}.ui-icon-carat-1-se{background-position:-48px 0;}.ui-icon-carat-1-s{background-position:-64px 0;}.ui-icon-carat-1-sw{background-position:-80px 0;}.ui-icon-carat-1-w{background-position:-96px 0;}.ui-icon-carat-1-nw{background-position:-112px 0;}.ui-icon-carat-2-n-s{background-position:-128px 0;}.ui-icon-carat-2-e-w{background-position:-144px 0;}.ui-icon-triangle-1-n{background-position:0 -16px;}.ui-icon-triangle-1-ne{background-position:-16px -16px;}.ui-icon-triangle-1-e{background-position:-32px -16px;}.ui-icon-triangle-1-se{background-position:-48px -16px;}.ui-icon-triangle-1-s{background-position:-64px -16px;}.ui-icon-triangle-1-sw{background-position:-80px -16px;}.ui-icon-triangle-1-w{background-position:-96px -16px;}.ui-icon-triangle-1-nw{background-position:-112px -16px;}.ui-icon-triangle-2-n-s{background-position:-128px -16px;}.ui-icon-triangle-2-e-w{background-position:-144px -16px;}.ui-icon-arrow-1-n{background-position:0 -32px;}.ui-icon-arrow-1-ne{background-position:-16px -32px;}.ui-icon-arrow-1-e{background-position:-32px -32px;}.ui-icon-arrow-1-se{background-position:-48px -32px;}.ui-icon-arrow-1-s{background-position:-64px -32px;}.ui-icon-arrow-1-sw{background-position:-80px -32px;}.ui-icon-arrow-1-w{background-position:-96px -32px;}.ui-icon-arrow-1-nw{background-position:-112px -32px;}.ui-icon-arrow-2-n-s{background-position:-128px -32px;}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px;}.ui-icon-arrow-2-e-w{background-position:-160px -32px;}.ui-icon-arrow-2-se-nw{background-position:-176px -32px;}.ui-icon-arrowstop-1-n{background-position:-192px -32px;}.ui-icon-arrowstop-1-e{background-position:-208px -32px;}.ui-icon-arrowstop-1-s{background-position:-224px -32px;}.ui-icon-arrowstop-1-w{background-position:-240px -32px;}.ui-icon-arrowthick-1-n{background-position:0 -48px;}.ui-icon-arrowthick-1-ne{background-position:-16px -48px;}.ui-icon-arrowthick-1-e{background-position:-32px -48px;}.ui-icon-arrowthick-1-se{background-position:-48px -48px;}.ui-icon-arrowthick-1-s{background-position:-64px -48px;}.ui-icon-arrowthick-1-sw{background-position:-80px -48px;}.ui-icon-arrowthick-1-w{background-position:-96px -48px;}.ui-icon-arrowthick-1-nw{background-position:-112px -48px;}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px;}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px;}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px;}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px;}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px;}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px;}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px;}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px;}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px;}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px;}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px;}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px;}.ui-icon-arrowreturn-1-w{background-position:-64px -64px;}.ui-icon-arrowreturn-1-n{background-position:-80px -64px;}.ui-icon-arrowreturn-1-e{background-position:-96px -64px;}.ui-icon-arrowreturn-1-s{background-position:-112px -64px;}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px;}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px;}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px;}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px;}.ui-icon-arrow-4{background-position:0 -80px;}.ui-icon-arrow-4-diag{background-position:-16px -80px;}.ui-icon-extlink{background-position:-32px -80px;}.ui-icon-newwin{background-position:-48px -80px;}.ui-icon-refresh{background-position:-64px -80px;}.ui-icon-shuffle{background-position:-80px -80px;}.ui-icon-transfer-e-w{background-position:-96px -80px;}.ui-icon-transferthick-e-w{background-position:-112px -80px;}.ui-icon-folder-collapsed{background-position:0 -96px;}.ui-icon-folder-open{background-position:-16px -96px;}.ui-icon-document{background-position:-32px -96px;}.ui-icon-document-b{background-position:-48px -96px;}.ui-icon-note{background-position:-64px -96px;}.ui-icon-mail-closed{background-position:-80px -96px;}.ui-icon-mail-open{background-position:-96px -96px;}.ui-icon-suitcase{background-position:-112px -96px;}.ui-icon-comment{background-position:-128px -96px;}.ui-icon-person{background-position:-144px -96px;}.ui-icon-print{background-position:-160px -96px;}.ui-icon-trash{background-position:-176px -96px;}.ui-icon-locked{background-position:-192px -96px;}.ui-icon-unlocked{background-position:-208px -96px;}.ui-icon-bookmark{background-position:-224px -96px;}.ui-icon-tag{background-position:-240px -96px;}.ui-icon-home{background-position:0 -112px;}.ui-icon-flag{background-position:-16px -112px;}.ui-icon-calendar{background-position:-32px -112px;}.ui-icon-cart{background-position:-48px -112px;}.ui-icon-pencil{background-position:-64px -112px;}.ui-icon-clock{background-position:-80px -112px;}.ui-icon-disk{background-position:-96px -112px;}.ui-icon-calculator{background-position:-112px -112px;}.ui-icon-zoomin{background-position:-128px -112px;}.ui-icon-zoomout{background-position:-144px -112px;}.ui-icon-search{background-position:-160px -112px;}.ui-icon-wrench{background-position:-176px -112px;}.ui-icon-gear{background-position:-192px -112px;}.ui-icon-heart{background-position:-208px -112px;}.ui-icon-star{background-position:-224px -112px;}.ui-icon-link{background-position:-240px -112px;}.ui-icon-cancel{background-position:0 -128px;}.ui-icon-plus{background-position:-16px -128px;}.ui-icon-plusthick{background-position:-32px -128px;}.ui-icon-minus{background-position:-48px -128px;}.ui-icon-minusthick{background-position:-64px -128px;}.ui-icon-close{background-position:-80px -128px;}.ui-icon-closethick{background-position:-96px -128px;}.ui-icon-key{background-position:-112px -128px;}.ui-icon-lightbulb{background-position:-128px -128px;}.ui-icon-scissors{background-position:-144px -128px;}.ui-icon-clipboard{background-position:-160px -128px;}.ui-icon-copy{background-position:-176px -128px;}.ui-icon-contact{background-position:-192px -128px;}.ui-icon-image{background-position:-208px -128px;}.ui-icon-video{background-position:-224px -128px;}.ui-icon-script{background-position:-240px -128px;}.ui-icon-alert{background-position:0 -144px;}.ui-icon-info{background-position:-16px -144px;}.ui-icon-notice{background-position:-32px -144px;}.ui-icon-help{background-position:-48px -144px;}.ui-icon-check{background-position:-64px -144px;}.ui-icon-bullet{background-position:-80px -144px;}.ui-icon-radio-off{background-position:-96px -144px;}.ui-icon-radio-on{background-position:-112px -144px;}.ui-icon-pin-w{background-position:-128px -144px;}.ui-icon-pin-s{background-position:-144px -144px;}.ui-icon-play{background-position:0 -160px;}.ui-icon-pause{background-position:-16px -160px;}.ui-icon-seek-next{background-position:-32px -160px;}.ui-icon-seek-prev{background-position:-48px -160px;}.ui-icon-seek-end{background-position:-64px -160px;}.ui-icon-seek-first{background-position:-80px -160px;}.ui-icon-stop{background-position:-96px -160px;}.ui-icon-eject{background-position:-112px -160px;}.ui-icon-volume-off{background-position:-128px -160px;}.ui-icon-volume-on{background-position:-144px -160px;}.ui-icon-power{background-position:0 -176px;}.ui-icon-signal-diag{background-position:-16px -176px;}.ui-icon-signal{background-position:-32px -176px;}.ui-icon-battery-0{background-position:-48px -176px;}.ui-icon-battery-1{background-position:-64px -176px;}.ui-icon-battery-2{background-position:-80px -176px;}.ui-icon-battery-3{background-position:-96px -176px;}.ui-icon-circle-plus{background-position:0 -192px;}.ui-icon-circle-minus{background-position:-16px -192px;}.ui-icon-circle-close{background-position:-32px -192px;}.ui-icon-circle-triangle-e{background-position:-48px -192px;}.ui-icon-circle-triangle-s{background-position:-64px -192px;}.ui-icon-circle-triangle-w{background-position:-80px -192px;}.ui-icon-circle-triangle-n{background-position:-96px -192px;}.ui-icon-circle-arrow-e{background-position:-112px -192px;}.ui-icon-circle-arrow-s{background-position:-128px -192px;}.ui-icon-circle-arrow-w{background-position:-144px -192px;}.ui-icon-circle-arrow-n{background-position:-160px -192px;}.ui-icon-circle-zoomin{background-position:-176px -192px;}.ui-icon-circle-zoomout{background-position:-192px -192px;}.ui-icon-circle-check{background-position:-208px -192px;}.ui-icon-circlesmall-plus{background-position:0 -208px;}.ui-icon-circlesmall-minus{background-position:-16px -208px;}.ui-icon-circlesmall-close{background-position:-32px -208px;}.ui-icon-squaresmall-plus{background-position:-48px -208px;}.ui-icon-squaresmall-minus{background-position:-64px -208px;}.ui-icon-squaresmall-close{background-position:-80px -208px;}.ui-icon-grip-dotted-vertical{background-position:0 -224px;}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px;}.ui-icon-grip-solid-vertical{background-position:-32px -224px;}.ui-icon-grip-solid-horizontal{background-position:-48px -224px;}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px;}.ui-icon-grip-diagonal-se{background-position:-80px -224px;}.achtung .achtung-message-icon{margin-top:0;margin-left:-.5em;margin-right:.5em;float:left;zoom:1;}.achtung .ui-icon.achtung-close-button{overflow:hidden;float:right;position:relative;top:-8px;right:-8px;cursor:pointer;background-image:url(images/ui-icons_cccccc_256x240.png);}.achtung .ui-icon.achtung-close-button-hover{background-image:url(images/ui-icons_ffffff_256x240.png);}.achtungSuccess,.achtungFail,.achtungWait{opacity:.93;filter:Alpha(Opacity=93);}.achtungSuccess{background-color:#4DB559;}.achtungFail{background-color:#D64450;}.achtungWait{background-color:#658093;}.achtungSuccess .ui-icon.achtung-close-button,.achtungFail .ui-icon.achtung-close-button{background-image:url(images/ui-icons_444444_256x240.png);}.achtungSuccess .ui-icon.achtung-close-button-hover,.achtungFail .ui-icon.achtung-close-button-hover{background-image:url(images/ui-icons_000000_256x240.png);}.achtung .wait-icon{background-image:url('images/wait.gif');}.achtung .achtung-message{display:inline;} sagenb-1.0.1/sagenb/data/jquery/plugins/achtung/ui.achtung-mod.js 0000664 0000000 0000000 00000021252 13114362624 0024735 0 ustar 00root root 0000000 0000000 // This modified version adds optional callbacks at the end of a
// timeout (in lieu of close) and when a user clicks on the close
// button (just before close).
/**
* achtung 0.3.0
*
* Growl-like notifications for jQuery
*
* Copyright (c) 2009 Josh Varner
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @license http://www.opensource.org/licenses/mit-license.php
* @author Josh Varner
*/
/*globals jQuery,clearTimeout,document,navigator,setTimeout
*/
(function($) {
/**
* This is based on the jQuery UI $.widget code. I would have just made this
* a $.widget but I didn't want the jQuery UI dependency.
*/
$.fn.achtung = function(options)
{
var isMethodCall = (typeof options === 'string'),
args = Array.prototype.slice.call(arguments, 0),
name = 'achtung';
// handle initialization and non-getter methods
return this.each(function() {
var instance = $.data(this, name);
// prevent calls to internal methods
if (isMethodCall && options.substring(0, 1) === '_') {
return this;
}
// constructor
(!instance && !isMethodCall &&
$.data(this, name, new $.achtung(this))._init(args));
// method call
(instance && isMethodCall && $.isFunction(instance[options]) &&
instance[options].apply(instance, args.slice(1)));
});
};
$.achtung = function(element)
{
var args = Array.prototype.slice.call(arguments, 0), $el;
if (!element || !element.nodeType) {
$el = $('');
return $el.achtung.apply($el, args);
}
this.$container = $(element);
};
/**
* Static members
**/
$.extend($.achtung, {
version: '0.3.0',
$overlay: false,
defaults: {
timeout: 10,
// Called at end of a timeout *instead* of close. Inside the
// callback, close explicitly with this.close().
onTimeout: null,
// Called on clicking the close button but before close.
onCloseButton: null,
disableClose: false,
icon: false,
className: '',
animateClassSwitch: false,
showEffects: {'opacity':'toggle','height':'toggle'},
hideEffects: {'opacity':'toggle','height':'toggle'},
showEffectDuration: 500,
hideEffectDuration: 700
}
});
/**
* Non-static members
**/
$.extend($.achtung.prototype, {
$container: false,
closeTimer: false,
options: {},
_init: function(args)
{
var o, self = this;
args = $.isArray(args) ? args : [];
args.unshift($.achtung.defaults);
args.unshift({});
o = this.options = $.extend.apply($, args);
if (!$.achtung.$overlay) {
$.achtung.$overlay = $('').appendTo(document.body);
}
if (!o.disableClose) {
$('')
.click(function () {
if ($.isFunction(o.onCloseButton)) {
o.onCloseButton.call(self);
}
self.close();
})
.hover(function () { $(this).addClass('achtung-close-button-hover'); },
function () { $(this).removeClass('achtung-close-button-hover'); })
.prependTo(this.$container);
}
this.changeIcon(o.icon, true);
if (o.message) {
this.$container.append($('' + o.message + ''));
}
(o.className && this.$container.addClass(o.className));
(o.css && this.$container.css(o.css));
this.$container
.addClass('achtung')
.appendTo($.achtung.$overlay);
if (o.showEffects) {
this.$container.animate(o.showEffects, o.showEffectDuration);
} else {
this.$container.show();
}
if (o.timeout > 0) {
this.timeout(o.timeout);
}
},
timeout: function(timeout)
{
var self = this;
if (this.closeTimer) {
clearTimeout(this.closeTimer);
}
this.closeTimer = setTimeout(function() {
if ($.isFunction(self.options.onTimeout)) {
self.options.onTimeout.call(self);
} else {
self.close();
}
}, timeout * 1000);
this.options.timeout = timeout;
},
/**
* Change the CSS class associated with this message, using
* a transition if available (not availble in Safari/Webkit).
* If no transition is available, the switch is immediate.
*
* #LATER Check if this has been corrected in Webkit or jQuery UI
* #TODO Make transition time configurable
* @param newClass string Name of new class to associate
*/
changeClass: function(newClass)
{
var self = this;
if (this.options.className === newClass) {
return;
}
this.$container.queue(function() {
if (!self.options.animateClassSwitch ||
/webkit/.test(navigator.userAgent.toLowerCase()) ||
!$.isFunction($.fn.switchClass)) {
self.$container.removeClass(self.options.className);
self.$container.addClass(newClass);
} else {
self.$container.switchClass(self.options.className, newClass, 500);
}
self.options.className = newClass;
self.$container.dequeue();
});
},
changeIcon: function(newIcon, force)
{
var self = this;
if ((force !== true || newIcon === false) && this.options.icon === newIcon) {
return;
}
if (force || this.options.icon === false) {
this.$container.prepend($(''));
this.options.icon = newIcon;
return;
} else if (newIcon === false) {
this.$container.find('.achtung-message-icon').remove();
this.options.icon = false;
return;
}
this.$container.queue(function() {
var $span = $('.achtung-message-icon', self.$container);
if (!self.options.animateClassSwitch ||
/webkit/.test(navigator.userAgent.toLowerCase()) ||
!$.isFunction($.fn.switchClass)) {
$span.removeClass(self.options.icon);
$span.addClass(newIcon);
} else {
$span.switchClass(self.options.icon, newIcon, 500);
}
self.options.icon = newIcon;
self.$container.dequeue();
});
},
changeMessage: function(newMessage)
{
this.$container.queue(function() {
$('.achtung-message', $(this)).html(newMessage);
$(this).dequeue();
});
},
update: function(options)
{
(options.className && this.changeClass(options.className));
(options.css && this.$container.css(options.css));
(typeof(options.icon) !== 'undefined' && this.changeIcon(options.icon));
(options.message && this.changeMessage(options.message));
(options.timeout && this.timeout(options.timeout));
},
close: function()
{
var o = this.options, $container = this.$container;
if (this.closeTimer) {
clearTimeout(this.closeTimer);
}
if (o.hideEffects) {
this.$container.animate(o.hideEffects, o.hideEffectDuration);
} else {
this.$container.hide();
}
$container.queue(function() {
$container.removeData('achtung');
$container.remove();
if ($.achtung.$overlay && $.achtung.$overlay.is(':empty')) {
$.achtung.$overlay.remove();
$.achtung.$overlay = false;
}
$container.dequeue();
});
}
});
})(jQuery);
sagenb-1.0.1/sagenb/data/jquery/plugins/achtung/ui.achtung.css 0000664 0000000 0000000 00000033434 13114362624 0024341 0 ustar 00root root 0000000 0000000 /**
* achtung 0.3.0
*
* Growl-like notifications for jQuery
*
* Copyright (c) 2009 Josh Varner
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Portions of this file are from the jQuery UI CSS framework.
*
* @license http://www.opensource.org/licenses/mit-license.php
* @author Josh Varner
*/
/* IE 6 doesn't support position: fixed */
* html #achtung-overlay {
position:absolute;
}
/* IE6 includes padding in width */
* html .achtung {
width: 280px;
}
#achtung-overlay {
overflow: hidden;
position: fixed;
top: 15px;
right: 15px;
width: 280px;
z-index:50;
}
.achtung {
display:none;
margin-bottom: 8px;
padding: 15px 15px;
background-color: #000;
color: white;
width: 250px;
font-weight: bold;
position:relative;
overflow: hidden;
-moz-box-shadow: #aaa 1px 1px 2px;
-webkit-box-shadow: #aaa 1px 1px 2px;
box-shadow: #aaa 1px 1px 2px;
-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;
/* Note that if using show/hide animations, IE will lose
this setting */
opacity: .85;
filter:Alpha(Opacity=85);
}
/**
* This section from jQuery UI CSS framework
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
* Can (and should) be removed if you are already loading the jQuery UI CSS
* to reduce payload size.
*/
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
.ui-icon-carat-1-n { background-position: 0 0; }
.ui-icon-carat-1-ne { background-position: -16px 0; }
.ui-icon-carat-1-e { background-position: -32px 0; }
.ui-icon-carat-1-se { background-position: -48px 0; }
.ui-icon-carat-1-s { background-position: -64px 0; }
.ui-icon-carat-1-sw { background-position: -80px 0; }
.ui-icon-carat-1-w { background-position: -96px 0; }
.ui-icon-carat-1-nw { background-position: -112px 0; }
.ui-icon-carat-2-n-s { background-position: -128px 0; }
.ui-icon-carat-2-e-w { background-position: -144px 0; }
.ui-icon-triangle-1-n { background-position: 0 -16px; }
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
.ui-icon-triangle-1-e { background-position: -32px -16px; }
.ui-icon-triangle-1-se { background-position: -48px -16px; }
.ui-icon-triangle-1-s { background-position: -64px -16px; }
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
.ui-icon-triangle-1-w { background-position: -96px -16px; }
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
.ui-icon-arrow-1-n { background-position: 0 -32px; }
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
.ui-icon-arrow-1-e { background-position: -32px -32px; }
.ui-icon-arrow-1-se { background-position: -48px -32px; }
.ui-icon-arrow-1-s { background-position: -64px -32px; }
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
.ui-icon-arrow-1-w { background-position: -96px -32px; }
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
.ui-icon-arrow-4 { background-position: 0 -80px; }
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
.ui-icon-extlink { background-position: -32px -80px; }
.ui-icon-newwin { background-position: -48px -80px; }
.ui-icon-refresh { background-position: -64px -80px; }
.ui-icon-shuffle { background-position: -80px -80px; }
.ui-icon-transfer-e-w { background-position: -96px -80px; }
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
.ui-icon-folder-collapsed { background-position: 0 -96px; }
.ui-icon-folder-open { background-position: -16px -96px; }
.ui-icon-document { background-position: -32px -96px; }
.ui-icon-document-b { background-position: -48px -96px; }
.ui-icon-note { background-position: -64px -96px; }
.ui-icon-mail-closed { background-position: -80px -96px; }
.ui-icon-mail-open { background-position: -96px -96px; }
.ui-icon-suitcase { background-position: -112px -96px; }
.ui-icon-comment { background-position: -128px -96px; }
.ui-icon-person { background-position: -144px -96px; }
.ui-icon-print { background-position: -160px -96px; }
.ui-icon-trash { background-position: -176px -96px; }
.ui-icon-locked { background-position: -192px -96px; }
.ui-icon-unlocked { background-position: -208px -96px; }
.ui-icon-bookmark { background-position: -224px -96px; }
.ui-icon-tag { background-position: -240px -96px; }
.ui-icon-home { background-position: 0 -112px; }
.ui-icon-flag { background-position: -16px -112px; }
.ui-icon-calendar { background-position: -32px -112px; }
.ui-icon-cart { background-position: -48px -112px; }
.ui-icon-pencil { background-position: -64px -112px; }
.ui-icon-clock { background-position: -80px -112px; }
.ui-icon-disk { background-position: -96px -112px; }
.ui-icon-calculator { background-position: -112px -112px; }
.ui-icon-zoomin { background-position: -128px -112px; }
.ui-icon-zoomout { background-position: -144px -112px; }
.ui-icon-search { background-position: -160px -112px; }
.ui-icon-wrench { background-position: -176px -112px; }
.ui-icon-gear { background-position: -192px -112px; }
.ui-icon-heart { background-position: -208px -112px; }
.ui-icon-star { background-position: -224px -112px; }
.ui-icon-link { background-position: -240px -112px; }
.ui-icon-cancel { background-position: 0 -128px; }
.ui-icon-plus { background-position: -16px -128px; }
.ui-icon-plusthick { background-position: -32px -128px; }
.ui-icon-minus { background-position: -48px -128px; }
.ui-icon-minusthick { background-position: -64px -128px; }
.ui-icon-close { background-position: -80px -128px; }
.ui-icon-closethick { background-position: -96px -128px; }
.ui-icon-key { background-position: -112px -128px; }
.ui-icon-lightbulb { background-position: -128px -128px; }
.ui-icon-scissors { background-position: -144px -128px; }
.ui-icon-clipboard { background-position: -160px -128px; }
.ui-icon-copy { background-position: -176px -128px; }
.ui-icon-contact { background-position: -192px -128px; }
.ui-icon-image { background-position: -208px -128px; }
.ui-icon-video { background-position: -224px -128px; }
.ui-icon-script { background-position: -240px -128px; }
.ui-icon-alert { background-position: 0 -144px; }
.ui-icon-info { background-position: -16px -144px; }
.ui-icon-notice { background-position: -32px -144px; }
.ui-icon-help { background-position: -48px -144px; }
.ui-icon-check { background-position: -64px -144px; }
.ui-icon-bullet { background-position: -80px -144px; }
.ui-icon-radio-off { background-position: -96px -144px; }
.ui-icon-radio-on { background-position: -112px -144px; }
.ui-icon-pin-w { background-position: -128px -144px; }
.ui-icon-pin-s { background-position: -144px -144px; }
.ui-icon-play { background-position: 0 -160px; }
.ui-icon-pause { background-position: -16px -160px; }
.ui-icon-seek-next { background-position: -32px -160px; }
.ui-icon-seek-prev { background-position: -48px -160px; }
.ui-icon-seek-end { background-position: -64px -160px; }
.ui-icon-seek-first { background-position: -80px -160px; }
.ui-icon-stop { background-position: -96px -160px; }
.ui-icon-eject { background-position: -112px -160px; }
.ui-icon-volume-off { background-position: -128px -160px; }
.ui-icon-volume-on { background-position: -144px -160px; }
.ui-icon-power { background-position: 0 -176px; }
.ui-icon-signal-diag { background-position: -16px -176px; }
.ui-icon-signal { background-position: -32px -176px; }
.ui-icon-battery-0 { background-position: -48px -176px; }
.ui-icon-battery-1 { background-position: -64px -176px; }
.ui-icon-battery-2 { background-position: -80px -176px; }
.ui-icon-battery-3 { background-position: -96px -176px; }
.ui-icon-circle-plus { background-position: 0 -192px; }
.ui-icon-circle-minus { background-position: -16px -192px; }
.ui-icon-circle-close { background-position: -32px -192px; }
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
.ui-icon-circle-zoomin { background-position: -176px -192px; }
.ui-icon-circle-zoomout { background-position: -192px -192px; }
.ui-icon-circle-check { background-position: -208px -192px; }
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
.ui-icon-circlesmall-close { background-position: -32px -208px; }
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
.ui-icon-squaresmall-close { background-position: -80px -208px; }
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
.achtung .achtung-message-icon {
margin-top: 0px;
margin-left: -.5em;
margin-right: .5em;
float: left;
zoom: 1;
}
.achtung .ui-icon.achtung-close-button {
overflow: hidden;
float: right;
position: relative;
top: -8px;
right: -8px;
cursor: pointer;
background-image: url(images/ui-icons_cccccc_256x240.png);
}
.achtung .ui-icon.achtung-close-button-hover {
background-image: url(images/ui-icons_ffffff_256x240.png);
}
/* Slightly darker for these colors (readability) */
.achtungSuccess, .achtungFail, .achtungWait {
/* Note that if using show/hide animations, IE will lose
this setting */
opacity: .93; filter:Alpha(Opacity=93);
}
.achtungSuccess {
background-color: #4DB559;
}
.achtungFail {
background-color: #D64450;
}
.achtungWait {
background-color: #658093;
}
.achtungSuccess .ui-icon.achtung-close-button,
.achtungFail .ui-icon.achtung-close-button {
background-image: url(images/ui-icons_444444_256x240.png);
}
.achtungSuccess .ui-icon.achtung-close-button-hover,
.achtungFail .ui-icon.achtung-close-button-hover {
background-image: url(images/ui-icons_000000_256x240.png);
}
.achtung .wait-icon {
background-image: url('images/wait.gif');
}
.achtung .achtung-message {
display: inline;
}
sagenb-1.0.1/sagenb/data/jquery/plugins/achtung/ui.achtung.js 0000664 0000000 0000000 00000020011 13114362624 0024150 0 ustar 00root root 0000000 0000000 /**
* achtung 0.3.0
*
* Growl-like notifications for jQuery
*
* Copyright (c) 2009 Josh Varner
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @license http://www.opensource.org/licenses/mit-license.php
* @author Josh Varner
*/
/*globals jQuery,clearTimeout,document,navigator,setTimeout
*/
(function($) {
/**
* This is based on the jQuery UI $.widget code. I would have just made this
* a $.widget but I didn't want the jQuery UI dependency.
*/
$.fn.achtung = function(options)
{
var isMethodCall = (typeof options === 'string'),
args = Array.prototype.slice.call(arguments, 0),
name = 'achtung';
// handle initialization and non-getter methods
return this.each(function() {
var instance = $.data(this, name);
// prevent calls to internal methods
if (isMethodCall && options.substring(0, 1) === '_') {
return this;
}
// constructor
(!instance && !isMethodCall &&
$.data(this, name, new $.achtung(this))._init(args));
// method call
(instance && isMethodCall && $.isFunction(instance[options]) &&
instance[options].apply(instance, args.slice(1)));
});
};
$.achtung = function(element)
{
var args = Array.prototype.slice.call(arguments, 0), $el;
if (!element || !element.nodeType) {
$el = $('');
return $el.achtung.apply($el, args);
}
this.$container = $(element);
};
/**
* Static members
**/
$.extend($.achtung, {
version: '0.3.0',
$overlay: false,
defaults: {
timeout: 10,
disableClose: false,
icon: false,
className: '',
animateClassSwitch: false,
showEffects: {'opacity':'toggle','height':'toggle'},
hideEffects: {'opacity':'toggle','height':'toggle'},
showEffectDuration: 500,
hideEffectDuration: 700
}
});
/**
* Non-static members
**/
$.extend($.achtung.prototype, {
$container: false,
closeTimer: false,
options: {},
_init: function(args)
{
var o, self = this;
args = $.isArray(args) ? args : [];
args.unshift($.achtung.defaults);
args.unshift({});
o = this.options = $.extend.apply($, args);
if (!$.achtung.$overlay) {
$.achtung.$overlay = $('').appendTo(document.body);
}
if (!o.disableClose) {
$('')
.click(function () { self.close(); })
.hover(function () { $(this).addClass('achtung-close-button-hover'); },
function () { $(this).removeClass('achtung-close-button-hover'); })
.prependTo(this.$container);
}
this.changeIcon(o.icon, true);
if (o.message) {
this.$container.append($('' + o.message + ''));
}
(o.className && this.$container.addClass(o.className));
(o.css && this.$container.css(o.css));
this.$container
.addClass('achtung')
.appendTo($.achtung.$overlay);
if (o.showEffects) {
this.$container.animate(o.showEffects, o.showEffectDuration);
} else {
this.$container.show();
}
if (o.timeout > 0) {
this.timeout(o.timeout);
}
},
timeout: function(timeout)
{
var self = this;
if (this.closeTimer) {
clearTimeout(this.closeTimer);
}
this.closeTimer = setTimeout(function() { self.close(); }, timeout * 1000);
this.options.timeout = timeout;
},
/**
* Change the CSS class associated with this message, using
* a transition if available (not availble in Safari/Webkit).
* If no transition is available, the switch is immediate.
*
* #LATER Check if this has been corrected in Webkit or jQuery UI
* #TODO Make transition time configurable
* @param newClass string Name of new class to associate
*/
changeClass: function(newClass)
{
var self = this;
if (this.options.className === newClass) {
return;
}
this.$container.queue(function() {
if (!self.options.animateClassSwitch ||
/webkit/.test(navigator.userAgent.toLowerCase()) ||
!$.isFunction($.fn.switchClass)) {
self.$container.removeClass(self.options.className);
self.$container.addClass(newClass);
} else {
self.$container.switchClass(self.options.className, newClass, 500);
}
self.options.className = newClass;
self.$container.dequeue();
});
},
changeIcon: function(newIcon, force)
{
var self = this;
if ((force !== true || newIcon === false) && this.options.icon === newIcon) {
return;
}
if (force || this.options.icon === false) {
this.$container.prepend($(''));
this.options.icon = newIcon;
return;
} else if (newIcon === false) {
this.$container.find('.achtung-message-icon').remove();
this.options.icon = false;
return;
}
this.$container.queue(function() {
var $span = $('.achtung-message-icon', self.$container);
if (!self.options.animateClassSwitch ||
/webkit/.test(navigator.userAgent.toLowerCase()) ||
!$.isFunction($.fn.switchClass)) {
$span.removeClass(self.options.icon);
$span.addClass(newIcon);
} else {
$span.switchClass(self.options.icon, newIcon, 500);
}
self.options.icon = newIcon;
self.$container.dequeue();
});
},
changeMessage: function(newMessage)
{
this.$container.queue(function() {
$('.achtung-message', $(this)).html(newMessage);
$(this).dequeue();
});
},
update: function(options)
{
(options.className && this.changeClass(options.className));
(options.css && this.$container.css(options.css));
(typeof(options.icon) !== 'undefined' && this.changeIcon(options.icon));
(options.message && this.changeMessage(options.message));
(options.timeout && this.timeout(options.timeout));
},
close: function()
{
var o = this.options, $container = this.$container;
if (o.hideEffects) {
this.$container.animate(o.hideEffects, o.hideEffectDuration);
} else {
this.$container.hide();
}
$container.queue(function() {
$container.removeData('achtung');
$container.remove();
if ($.achtung.$overlay && $.achtung.$overlay.is(':empty')) {
$.achtung.$overlay.remove();
$.achtung.$overlay = false;
}
$container.dequeue();
});
}
});
})(jQuery); sagenb-1.0.1/sagenb/data/jquery/plugins/achtung/version.txt 0000664 0000000 0000000 00000000005 13114362624 0023774 0 ustar 00root root 0000000 0000000 0.3.0 sagenb-1.0.1/sagenb/data/jquery/plugins/extendedclick/ 0000775 0000000 0000000 00000000000 13114362624 0022730 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/jquery/plugins/extendedclick/jquery.event.extendedclick.js 0000664 0000000 0000000 00000005402 13114362624 0030533 0 ustar 00root root 0000000 0000000 ;(function($){
/*
* Copyright (c) 2008, Minus Creative (http://minuscreative.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Created: 2008-10-01
*
* Updated from version 1.0 by Jason Grout
* Available at https://github.com/jasongrout/jquery-extended-click
*
*/
// According to http://docs.jquery.com/Plugins/Authoring#Plugin_Methods,
// having 8 different namespaces for this plugin is discouraged, so we comment this out.
//$.fn.plainclick = function(fn) { return this[fn ? "bind" : "trigger"]("plainclick", fn); };
//$.fn.ctrlclick = function(fn) { return this[fn ? "bind" : "trigger"]("ctrlclick", fn); };
//$.fn.shiftclick = function(fn) { return this[fn ? "bind" : "trigger"]("shiftclick", fn); };
//$.fn.altclick = function(fn) { return this[fn ? "bind" : "trigger"]("altclick", fn); };
//$.fn.ctrlaltclick = function(fn) { return this[fn ? "bind" : "trigger"]("ctrlaltclick", fn); };
//$.fn.ctrlshiftclick = function(fn) { return this[fn ? "bind" : "trigger"]("ctrlshiftclick", fn); };
//$.fn.altshiftclick = function(fn) { return this[fn ? "bind" : "trigger"]("altshiftclick", fn); };
//$.fn.ctrlaltshiftclick = function(fn) { return this[fn ? "bind" : "trigger"]("ctrlaltshiftclick", fn); };
// all event clicks share the same config
$.event.special.plainclick =
$.event.special.ctrlclick =
$.event.special.altclick =
$.event.special.shiftclick =
$.event.special.ctrlaltclick =
$.event.special.ctrlshiftclick =
$.event.special.altshiftclick =
$.event.special.ctrlaltshiftclick = {
setup: function() {
$.event.add(this, "click", extendedClickHandler, {});
},
teardown: function() {
$.event.remove(this, "click", extendedClickHandler);
}
};
// Big shared event handler
function extendedClickHandler(event){
if(event.type==="click") {
if (event.ctrlKey)
{
if (event.shiftKey)
{
if (event.altKey || event.originalEvent.altKey)
{
event.type = "ctrlaltshiftclick"; // set to trigger
}
else
event.type = "ctrlshiftclick"; // set to trigger
}
else if (event.altKey || event.originalEvent.altKey)
{
event.type = "ctrlaltclick"; // set to trigger
}
else
event.type = "ctrlclick"; // set to trigger
}
else if (event.altKey || event.originalEvent.altKey)
{
if (event.shiftKey)
{
event.type = "altshiftclick"; // set to trigger
}
else
event.type = "altclick"; // set to trigger
}
else if (event.shiftKey)
{
event.type = "shiftclick"; // set to trigger
}
else
{
event.type = "plainclick"; // set to trigger
}
return $.event.handle.call(this, event);
}
}
})(jQuery);
sagenb-1.0.1/sagenb/data/jquery/plugins/jeditable/ 0000775 0000000 0000000 00000000000 13114362624 0022045 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/jquery/plugins/jeditable/jquery.jeditable.js 0000664 0000000 0000000 00000057437 13114362624 0025664 0 ustar 00root root 0000000 0000000 /*
* Jeditable - jQuery in place edit plugin
*
* Copyright (c) 2006-2009 Mika Tuupola, Dylan Verheul
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* http://www.appelsiini.net/projects/jeditable
*
* Based on editable by Dylan Verheul :
* http://www.dyve.net/jquery/?editable
*
*/
/**
* Version 1.7.1
*
* ** means there is basic unit tests for this parameter.
*
* @name Jeditable
* @type jQuery
* @param String target (POST) URL or function to send edited content to **
* @param Hash options additional options
* @param String options[method] method to use to send edited content (POST or PUT) **
* @param Function options[callback] Function to run after submitting edited content **
* @param String options[name] POST parameter name of edited content
* @param String options[id] POST parameter name of edited div id
* @param Hash options[submitdata] Extra parameters to send when submitting edited content.
* @param String options[type] text, textarea or select (or any 3rd party input type) **
* @param Integer options[rows] number of rows if using textarea **
* @param Integer options[cols] number of columns if using textarea **
* @param Mixed options[height] 'auto', 'none' or height in pixels **
* @param Mixed options[width] 'auto', 'none' or width in pixels **
* @param String options[loadurl] URL to fetch input content before editing **
* @param String options[loadtype] Request type for load url. Should be GET or POST.
* @param String options[loadtext] Text to display while loading external content.
* @param Mixed options[loaddata] Extra parameters to pass when fetching content before editing.
* @param Mixed options[data] Or content given as paramameter. String or function.**
* @param String options[indicator] indicator html to show when saving
* @param String options[tooltip] optional tooltip text via title attribute **
* @param String options[event] jQuery event such as 'click' of 'dblclick' **
* @param String options[submit] submit button value, empty means no button **
* @param String options[cancel] cancel button value, empty means no button **
* @param String options[cssclass] CSS class to apply to input form. 'inherit' to copy from parent. **
* @param String options[style] Style to apply to input form 'inherit' to copy from parent. **
* @param String options[select] true or false, when true text is highlighted ??
* @param String options[placeholder] Placeholder text or html to insert when element is empty. **
* @param String options[onblur] 'cancel', 'submit', 'ignore' or function ??
*
* @param Function options[onsubmit] function(settings, original) { ... } called before submit
* @param Function options[onreset] function(settings, original) { ... } called before reset
* @param Function options[onerror] function(settings, original, xhr) { ... } called on error
*
* @param Hash options[ajaxoptions] jQuery Ajax options. See docs.jquery.com.
*
*/
(function($) {
$.fn.editable = function(target, options) {
if ('disable' == target) {
$(this).data('disabled.editable', true);
return;
}
if ('enable' == target) {
$(this).data('disabled.editable', false);
return;
}
if ('destroy' == target) {
$(this)
.unbind($(this).data('event.editable'))
.removeData('disabled.editable')
.removeData('event.editable');
return;
}
var settings = $.extend({}, $.fn.editable.defaults, {target:target}, options);
/* setup some functions */
var plugin = $.editable.types[settings.type].plugin || function() { };
var submit = $.editable.types[settings.type].submit || function() { };
var buttons = $.editable.types[settings.type].buttons
|| $.editable.types['defaults'].buttons;
var content = $.editable.types[settings.type].content
|| $.editable.types['defaults'].content;
var element = $.editable.types[settings.type].element
|| $.editable.types['defaults'].element;
var reset = $.editable.types[settings.type].reset
|| $.editable.types['defaults'].reset;
var callback = settings.callback || function() { };
var onedit = settings.onedit || function() { };
var onsubmit = settings.onsubmit || function() { };
var onreset = settings.onreset || function() { };
var onerror = settings.onerror || reset;
/* show tooltip */
if (settings.tooltip) {
$(this).attr('title', settings.tooltip);
}
settings.autowidth = 'auto' == settings.width;
settings.autoheight = 'auto' == settings.height;
return this.each(function() {
/* save this to self because this changes when scope changes */
var self = this;
/* inlined block elements lose their width and height after first edit */
/* save them for later use as workaround */
var savedwidth = $(self).width();
var savedheight = $(self).height();
/* save so it can be later used by $.editable('destroy') */
$(this).data('event.editable', settings.event);
/* if element is empty add something clickable (if requested) */
if (!$.trim($(this).html())) {
$(this).html(settings.placeholder);
}
$(this).bind(settings.event, function(e) {
/* abort if disabled for this element */
if (true === $(this).data('disabled.editable')) {
return;
}
/* prevent throwing an exeption if edit field is clicked again */
if (self.editing) {
return;
}
/* abort if onedit hook returns false */
if (false === onedit.apply(this, [settings, self])) {
return;
}
/* prevent default action and bubbling */
e.preventDefault();
e.stopPropagation();
/* remove tooltip */
if (settings.tooltip) {
$(self).removeAttr('title');
}
/* figure out how wide and tall we are, saved width and height */
/* are workaround for http://dev.jquery.com/ticket/2190 */
if (0 == $(self).width()) {
//$(self).css('visibility', 'hidden');
settings.width = savedwidth;
settings.height = savedheight;
} else {
if (settings.width != 'none') {
settings.width =
settings.autowidth ? $(self).width() : settings.width;
}
if (settings.height != 'none') {
settings.height =
settings.autoheight ? $(self).height() : settings.height;
}
}
//$(this).css('visibility', '');
/* remove placeholder text, replace is here because of IE */
if ($(this).html().toLowerCase().replace(/(;|")/g, '') ==
settings.placeholder.toLowerCase().replace(/(;|")/g, '')) {
$(this).html('');
}
self.editing = true;
self.revert = $(self).html();
$(self).html('');
/* create the form object */
var form = $('');
/* apply css or style or both */
if (settings.cssclass) {
if ('inherit' == settings.cssclass) {
form.attr('class', $(self).attr('class'));
} else {
form.attr('class', settings.cssclass);
}
}
if (settings.style) {
if ('inherit' == settings.style) {
form.attr('style', $(self).attr('style'));
/* IE needs the second line or display wont be inherited */
form.css('display', $(self).css('display'));
} else {
form.attr('style', settings.style);
}
}
/* add main input element to form and store it in input */
var input = element.apply(form, [settings, self]);
/* set input content via POST, GET, given data or existing value */
var input_content;
if (settings.loadurl) {
var t = setTimeout(function() {
input.disabled = true;
content.apply(form, [settings.loadtext, settings, self]);
}, 100);
var loaddata = {};
loaddata[settings.id] = self.id;
if ($.isFunction(settings.loaddata)) {
$.extend(loaddata, settings.loaddata.apply(self, [self.revert, settings]));
} else {
$.extend(loaddata, settings.loaddata);
}
$.ajax({
type : settings.loadtype,
url : settings.loadurl,
data : loaddata,
async : false,
success: function(result) {
window.clearTimeout(t);
input_content = result;
input.disabled = false;
}
});
} else if (settings.data) {
input_content = settings.data;
if ($.isFunction(settings.data)) {
input_content = settings.data.apply(self, [self.revert, settings]);
}
} else {
input_content = self.revert;
}
content.apply(form, [input_content, settings, self]);
input.attr('name', settings.name);
/* add buttons to the form */
buttons.apply(form, [settings, self]);
/* add created form to self */
$(self).append(form);
/* attach 3rd party plugin if requested */
plugin.apply(form, [settings, self]);
/* focus to first visible form element */
$(':input:visible:enabled:first', form).focus();
/* highlight input contents when requested */
if (settings.select) {
input.select();
}
/* discard changes if pressing esc */
input.keydown(function(e) {
if (e.keyCode == 27) {
e.preventDefault();
//self.reset();
reset.apply(form, [settings, self]);
}
});
/* discard, submit or nothing with changes when clicking outside */
/* do nothing is usable when navigating with tab */
var t;
if ('cancel' == settings.onblur) {
input.blur(function(e) {
/* prevent canceling if submit was clicked */
t = setTimeout(function() {
reset.apply(form, [settings, self]);
}, 500);
});
} else if ('submit' == settings.onblur) {
input.blur(function(e) {
/* prevent double submit if submit was clicked */
t = setTimeout(function() {
form.submit();
}, 200);
});
} else if ($.isFunction(settings.onblur)) {
input.blur(function(e) {
settings.onblur.apply(self, [input.val(), settings]);
});
} else {
input.blur(function(e) {
/* TODO: maybe something here */
});
}
form.submit(function(e) {
if (t) {
clearTimeout(t);
}
/* do no submit */
e.preventDefault();
/* call before submit hook. */
/* if it returns false abort submitting */
if (false !== onsubmit.apply(form, [settings, self])) {
/* custom inputs call before submit hook. */
/* if it returns false abort submitting */
if (false !== submit.apply(form, [settings, self])) {
/* check if given target is function */
if ($.isFunction(settings.target)) {
var str = settings.target.apply(self, [input.val(), settings]);
$(self).html(str);
self.editing = false;
callback.apply(self, [self.innerHTML, settings]);
/* TODO: this is not dry */
if (!$.trim($(self).html())) {
$(self).html(settings.placeholder);
}
} else {
/* add edited content and id of edited element to POST */
var submitdata = {};
submitdata[settings.name] = input.val();
submitdata[settings.id] = self.id;
/* add extra data to be POST:ed */
if ($.isFunction(settings.submitdata)) {
$.extend(submitdata, settings.submitdata.apply(self, [self.revert, settings]));
} else {
$.extend(submitdata, settings.submitdata);
}
/* quick and dirty PUT support */
if ('PUT' == settings.method) {
submitdata['_method'] = 'put';
}
/* show the saving indicator */
$(self).html(settings.indicator);
/* defaults for ajaxoptions */
var ajaxoptions = {
type : 'POST',
data : submitdata,
dataType: 'html',
url : settings.target,
success : function(result, status) {
if (ajaxoptions.dataType == 'html') {
$(self).html(result);
}
self.editing = false;
callback.apply(self, [result, settings]);
if (!$.trim($(self).html())) {
$(self).html(settings.placeholder);
}
},
error : function(xhr, status, error) {
onerror.apply(form, [settings, self, xhr]);
}
};
/* override with what is given in settings.ajaxoptions */
$.extend(ajaxoptions, settings.ajaxoptions);
$.ajax(ajaxoptions);
}
}
}
/* show tooltip again */
$(self).attr('title', settings.tooltip);
return false;
});
});
/* privileged methods */
this.reset = function(form) {
/* prevent calling reset twice when blurring */
if (this.editing) {
/* before reset hook, if it returns false abort reseting */
if (false !== onreset.apply(form, [settings, self])) {
$(self).html(self.revert);
self.editing = false;
if (!$.trim($(self).html())) {
$(self).html(settings.placeholder);
}
/* show tooltip again */
if (settings.tooltip) {
$(self).attr('title', settings.tooltip);
}
}
}
};
});
};
$.editable = {
types: {
defaults: {
element : function(settings, original) {
var input = $('');
$(this).append(input);
return(input);
},
content : function(string, settings, original) {
$(':input:first', this).val(string);
},
reset : function(settings, original) {
original.reset(this);
},
buttons : function(settings, original) {
var form = this;
if (settings.submit) {
/* if given html string use that */
if (settings.submit.match(/>$/)) {
var submit = $(settings.submit).click(function() {
if (submit.attr("type") != "submit") {
form.submit();
}
});
/* otherwise use button with given string as text */
} else {
var submit = $('');
submit.html(settings.submit);
}
$(this).append(submit);
}
if (settings.cancel) {
/* if given html string use that */
if (settings.cancel.match(/>$/)) {
var cancel = $(settings.cancel);
/* otherwise use button with given string as text */
} else {
var cancel = $('');
cancel.html(settings.cancel);
}
$(this).append(cancel);
$(cancel).click(function(event) {
//original.reset();
if ($.isFunction($.editable.types[settings.type].reset)) {
var reset = $.editable.types[settings.type].reset;
} else {
var reset = $.editable.types['defaults'].reset;
}
reset.apply(form, [settings, original]);
return false;
});
}
}
},
text: {
element : function(settings, original) {
var input = $('');
if (settings.width != 'none') { input.width(settings.width); }
if (settings.height != 'none') { input.height(settings.height); }
/* https://bugzilla.mozilla.org/show_bug.cgi?id=236791 */
//input[0].setAttribute('autocomplete','off');
input.attr('autocomplete','off');
$(this).append(input);
return(input);
}
},
textarea: {
element : function(settings, original) {
var textarea = $('');
if (settings.rows) {
textarea.attr('rows', settings.rows);
} else if (settings.height != "none") {
textarea.height(settings.height);
}
if (settings.cols) {
textarea.attr('cols', settings.cols);
} else if (settings.width != "none") {
textarea.width(settings.width);
}
$(this).append(textarea);
return(textarea);
}
},
select: {
element : function(settings, original) {
var select = $('');
$(this).append(select);
return(select);
},
content : function(data, settings, original) {
/* If it is string assume it is json. */
if (String == data.constructor) {
eval ('var json = ' + data);
} else {
/* Otherwise assume it is a hash already. */
var json = data;
}
for (var key in json) {
if (!json.hasOwnProperty(key)) {
continue;
}
if ('selected' == key) {
continue;
}
var option = $('').val(key).append(json[key]);
$('select', this).append(option);
}
/* Loop option again to set selected. IE needed this... */
$('select', this).children().each(function() {
if ($(this).val() == json['selected'] ||
$(this).text() == $.trim(original.revert)) {
$(this).attr('selected', 'selected');
}
});
}
}
},
/* Add new input type */
addInputType: function(name, input) {
$.editable.types[name] = input;
}
};
// publicly accessible defaults
$.fn.editable.defaults = {
name : 'value',
id : 'id',
type : 'text',
width : 'auto',
height : 'auto',
event : 'click.editable',
onblur : 'cancel',
loadtype : 'GET',
loadtext : 'Loading...',
placeholder: 'Click to edit',
loaddata : {},
submitdata : {},
ajaxoptions: {}
};
})(jQuery);
sagenb-1.0.1/sagenb/data/nodoctest.py 0000664 0000000 0000000 00000000000 13114362624 0017464 0 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/openid-realselector/ 0000775 0000000 0000000 00000000000 13114362624 0021062 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/openid-realselector/css/ 0000775 0000000 0000000 00000000000 13114362624 0021652 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/openid-realselector/css/style.css 0000664 0000000 0000000 00000003137 13114362624 0023530 0 ustar 00root root 0000000 0000000 body {
font: 14px 'Arial';
}
#openid {
background: url(../img/indicator.gif) center center no-repeat;
margin: 0 auto;
width: 440px;
height: 162px;
}
#openid_inputarea {
clear: both;
display: none;
/*background: url(../img/balloon.png) no-repeat;*/
width: 330px;
height: 40px;
color: black;
/*text-align: center;*/
margin-top: 35px;
padding-top: 15px !important;
}
#openid_inputarea #openid_username {
margin: 0 4px 0 8px;
width: 120px;
}
#openid_btns, #openid_btns br {
clear: both;
}
#openid_highlight {
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
padding: 2px !important;
background-color: #FFFCC9;
float: left;
}
.openid_large_btn, .openid_small_btn {
background: url(../img/openid-icons.png) no-repeat;
margin: 3px;
float: left;
}
.openid_large_btn {
width: 91px;
height: 51px;
}
.openid_small_btn {
width: 16px;
height: 16px;
}
.Google { background-position: 0 0; }
.Yahoo { background-position: 0 -51px; }
.AOL { background-position: 0 -102px; }
.OpenID { background-position: 0 -153px; }
.MyOpenID { background-position: 0 -204px; }
.Flickr { background-position: 0 -220px; }
.Technorati { background-position: -17px -220px; }
.Wordpress { background-position: -17px -204px; }
.Blogger { background-position: -34px -204px; }
.Verisign { background-position: -51px -220px; }
.Vidoop { background-position: -34px -220px; }
.ClaimID { background-position: -68px -204px; }
.LiveJournal { background-position: -51px -204px; }
.MySpace { background-position: -68px -220px; }
a.openid_large_btn:focus {
outline: none;
-moz-outline-style: none;
}
sagenb-1.0.1/sagenb/data/openid-realselector/img/ 0000775 0000000 0000000 00000000000 13114362624 0021636 5 ustar 00root root 0000000 0000000 sagenb-1.0.1/sagenb/data/openid-realselector/img/balloon.png 0000664 0000000 0000000 00000001020 13114362624 0023763 0 ustar 00root root 0000000 0000000 ‰PNG
IHDR š 0 (Lm sBITÛáOà 3PLTE^^^™™™………BBBÖÖÖ***zzz‹‹‹²²²”””fff333ÿÿÿïA}c tRNSÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ %™b pHYs ÒÝ~ü tEXtSoftware Adobe Fireworks CS4²Ó tEXtCreation Time 1/14/09tÆ/½ IDATxœíÜÍnƒ0 áM )Îöû?m!!-MÜkwó}Zi’—hÇ[ïTÿ+:gS¶É×IsŒ°
À{šµÌÒæ#aí½¥y”±M¾×4Ï2¶I÷’æ§Œm²mi®ó"çë>ÍÉ.$ãé;ÍmÈF¿<>]býÂÍtOS²ÇPGYÓ|fO¡Žº¤ñ¡a*-æìÔ5·¨Ù3¨«¶¸dÏ ®¡eO ¿˜Ë4X¦Á2
–i°Lƒe,Ó`™Ë4X¦Á2
–i°Lƒe,Ó`™Ë4X¦Á2
–7j¨.ÞC£ªÞÞ¤š½óLUZ4ßhDÕýªâVÔ´íržÝådÎn@3í6 å`†ñP¶ÿ|O#¹¾òAš IEND®B`‚ sagenb-1.0.1/sagenb/data/openid-realselector/img/indicator.gif 0000664 0000000 0000000 00000004761 13114362624 0024311 0 ustar 00root root 0000000 0000000 GIF89a ô ÿÿÿ 3fÎ×áúúûàæì°¿ÏèìðŽ¤ºÈÒÝœ¯ÃØß稹ÊÀÌØòôöv‘¬†ž¶¸ÆÔh†¤ !þCreated with ajaxload.info !ù !ÿNETSCAPE2.0 , ® Ž$ AeZ
ù<ä ’„ÃŒQ46„<‹A”
߈áH a ¡¡:’êID0ÄF„Ãa\xGƒ3€×!Ä ßO:-‡‚Rj—TJ‚ƒ* ƒ
t
†ˆŠŒŽ„—~—"ds]š
š)t–¥-"– i;H>³n§Qg]_*‹
®R±3ÁGI?
ÎË´¨v$ý›j3! !ù , ° Ž$À0eZy¤0¨£q £ãŒP¤Ð£W )"; qXˆ^ÏD50‡† Õˆ