kopia lustrzana https://github.com/backface/turtlestitch
Creation
commit
0b510366d2
|
@ -0,0 +1,25 @@
|
|||
|
||||
Snap! Build Your Own Blocks
|
||||
|
||||
http://snap.berkeley.edu
|
||||
|
||||
a visual, blocks based programming language
|
||||
inspired by Scratch
|
||||
|
||||
written by Jens Mönig and Brian Harvey
|
||||
jens@moenig.org, bh@cs.berkeley.edu
|
||||
|
||||
Copyright (C) 2013 by Jens Mönig and Brian Harvey
|
||||
|
||||
Snap! is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
@ -0,0 +1,661 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik binarny nie jest wyświetlany.
|
@ -0,0 +1,472 @@
|
|||
/*
|
||||
|
||||
cloud.js
|
||||
|
||||
a backend API for SNAP!
|
||||
|
||||
written by Jens Mšnig
|
||||
|
||||
Copyright (C) 2013 by Jens Mšnig
|
||||
|
||||
This file is part of Snap!.
|
||||
|
||||
Snap! is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
// Global settings /////////////////////////////////////////////////////
|
||||
|
||||
/*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop*/
|
||||
|
||||
modules.cloud = '2013-February-27';
|
||||
|
||||
// Global stuff
|
||||
|
||||
var Cloud;
|
||||
|
||||
var SnapCloud = new Cloud(
|
||||
'https://snapcloud.miosoft.com/miocon/app/login?_app=SnapCloud'
|
||||
);
|
||||
|
||||
// Cloud /////////////////////////////////////////////////////////////
|
||||
|
||||
function Cloud(url) {
|
||||
this.username = null;
|
||||
this.password = null; // hex_sha512 hashed
|
||||
this.url = url;
|
||||
this.session = null;
|
||||
this.api = {};
|
||||
}
|
||||
|
||||
Cloud.prototype.clear = function () {
|
||||
this.username = null;
|
||||
this.password = null;
|
||||
this.session = null;
|
||||
this.api = {};
|
||||
};
|
||||
|
||||
Cloud.prototype.hasProtocol = function () {
|
||||
return this.url.toLowerCase().indexOf('http') === 0;
|
||||
};
|
||||
|
||||
// Cloud: Snap! API
|
||||
|
||||
Cloud.prototype.signup = function (
|
||||
username,
|
||||
email,
|
||||
callBack,
|
||||
errorCall
|
||||
) {
|
||||
// both callBack and errorCall are two-argument functions
|
||||
var request = new XMLHttpRequest(),
|
||||
myself = this;
|
||||
try {
|
||||
request.open(
|
||||
"GET",
|
||||
(this.hasProtocol() ? '' : 'http://')
|
||||
+ this.url + 'SignUp'
|
||||
+ '&Username='
|
||||
+ encodeURIComponent(username)
|
||||
+ '&Email='
|
||||
+ email,
|
||||
true
|
||||
);
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4) {
|
||||
if (request.responseText) {
|
||||
if (request.responseText.indexOf('ERROR') === 0) {
|
||||
errorCall.call(
|
||||
this,
|
||||
request.responseText,
|
||||
'Signup'
|
||||
);
|
||||
} else {
|
||||
callBack.call(
|
||||
null,
|
||||
request.responseText,
|
||||
'Signup'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
errorCall.call(
|
||||
null,
|
||||
myself.url + 'SignUp',
|
||||
'could not connect to:'
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
request.send(null);
|
||||
} catch (err) {
|
||||
errorCall.call(this, err.toString(), 'Snap!Cloud');
|
||||
}
|
||||
};
|
||||
|
||||
Cloud.prototype.connect = function (
|
||||
callBack,
|
||||
errorCall
|
||||
) {
|
||||
// both callBack and errorCall are two-argument functions
|
||||
var request = new XMLHttpRequest(),
|
||||
myself = this;
|
||||
try {
|
||||
request.open(
|
||||
"GET",
|
||||
(this.hasProtocol() ? '' : 'http://') + this.url,
|
||||
true
|
||||
);
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4) {
|
||||
if (request.responseText) {
|
||||
myself.api = myself.parseAPI(request.responseText);
|
||||
myself.session = request.getResponseHeader('MioCracker')
|
||||
.split(';')[0];
|
||||
if (myself.api.login) {
|
||||
callBack.call(null, myself.api, 'Snap!Cloud');
|
||||
} else {
|
||||
errorCall.call(
|
||||
null,
|
||||
'connection failed'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
errorCall.call(
|
||||
null,
|
||||
myself.url,
|
||||
'could not connect to:'
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
request.send(null);
|
||||
} catch (err) {
|
||||
errorCall.call(this, err.toString(), 'Snap!Cloud');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Cloud.prototype.login = function (
|
||||
username,
|
||||
password,
|
||||
callBack,
|
||||
errorCall
|
||||
) {
|
||||
var myself = this;
|
||||
this.connect(
|
||||
function () {
|
||||
myself.rawLogin(username, password, callBack, errorCall);
|
||||
myself.disconnect();
|
||||
},
|
||||
errorCall
|
||||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.rawLogin = function (
|
||||
username,
|
||||
password,
|
||||
callBack,
|
||||
errorCall
|
||||
) {
|
||||
// both callBack and errorCall are two-argument functions
|
||||
var myself = this,
|
||||
pwHash = hex_sha512("miosoft%20miocon,"
|
||||
+ this.session.split('=')[1] + ","
|
||||
+ encodeURIComponent(username.toLowerCase()) + ","
|
||||
+ password // alreadey hex_sha512 hashed
|
||||
);
|
||||
this.callService(
|
||||
'login',
|
||||
function (response, url) {
|
||||
if (myself.api.logout) {
|
||||
myself.username = username;
|
||||
myself.password = password;
|
||||
callBack.call(null, response, url);
|
||||
} else {
|
||||
errorCall.call(
|
||||
null,
|
||||
'Service catalog is not available,\nplease retry',
|
||||
'Connection Error:'
|
||||
);
|
||||
}
|
||||
},
|
||||
errorCall,
|
||||
[username, pwHash]
|
||||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.reconnect = function (
|
||||
callBack,
|
||||
errorCall
|
||||
) {
|
||||
if (!(this.username && this.password)) {
|
||||
this.message('You are not logged in');
|
||||
return;
|
||||
}
|
||||
this.login(
|
||||
this.username,
|
||||
this.password,
|
||||
callBack,
|
||||
errorCall
|
||||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.saveProject = function (ide, callBack, errorCall) {
|
||||
var myself = this,
|
||||
pdata,
|
||||
media;
|
||||
|
||||
ide.serializer.isCollectingMedia = true;
|
||||
pdata = ide.serializer.serialize(ide.stage);
|
||||
media = ide.hasChangedMedia ?
|
||||
ide.serializer.mediaXML(ide.projectName) : null;
|
||||
ide.serializer.isCollectingMedia = false;
|
||||
ide.serializer.flushMedia();
|
||||
|
||||
myself.reconnect(
|
||||
function () {
|
||||
myself.callService(
|
||||
'saveProject',
|
||||
function (response, url) {
|
||||
callBack.call(null, response, url);
|
||||
myself.disconnect();
|
||||
ide.hasChangedMedia = false;
|
||||
},
|
||||
errorCall,
|
||||
[ide.projectName, pdata, media]
|
||||
);
|
||||
},
|
||||
errorCall
|
||||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.getProjectList = function (callBack, errorCall) {
|
||||
var myself = this;
|
||||
this.reconnect(
|
||||
function () {
|
||||
myself.callService(
|
||||
'getProjectList',
|
||||
function (response, url) {
|
||||
callBack.call(null, response, url);
|
||||
myself.disconnect();
|
||||
},
|
||||
errorCall
|
||||
);
|
||||
},
|
||||
errorCall
|
||||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.changePassword = function (
|
||||
oldPW,
|
||||
newPW,
|
||||
callBack,
|
||||
errorCall
|
||||
) {
|
||||
var myself = this;
|
||||
this.reconnect(
|
||||
function () {
|
||||
myself.callService(
|
||||
'changePassword',
|
||||
function (response, url) {
|
||||
callBack.call(null, response, url);
|
||||
myself.disconnect();
|
||||
},
|
||||
errorCall,
|
||||
[oldPW, newPW]
|
||||
);
|
||||
},
|
||||
errorCall
|
||||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.logout = function (callBack, errorCall) {
|
||||
this.clear();
|
||||
this.callService(
|
||||
'logout',
|
||||
callBack,
|
||||
errorCall
|
||||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.disconnect = function () {
|
||||
this.callService(
|
||||
'logout',
|
||||
nop,
|
||||
nop
|
||||
);
|
||||
};
|
||||
|
||||
// Cloud: backend communication
|
||||
|
||||
Cloud.prototype.callURL = function (url, callBack, errorCall) {
|
||||
// both callBack and errorCall are optional two-argument functions
|
||||
var request = new XMLHttpRequest(),
|
||||
myself = this;
|
||||
try {
|
||||
request.open('GET', url, true);
|
||||
request.withCredentials = true;
|
||||
request.setRequestHeader('Content-Type', 'text/plain');
|
||||
request.setRequestHeader('MioCracker', this.session);
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4) {
|
||||
if (request.responseText) {
|
||||
var responseList = myself.parseResponse(
|
||||
request.responseText
|
||||
);
|
||||
callBack.call(null, responseList, url);
|
||||
} else {
|
||||
errorCall.call(
|
||||
null,
|
||||
url,
|
||||
'no response from:'
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
request.send(null);
|
||||
} catch (err) {
|
||||
errorCall.call(this, err.toString(), url);
|
||||
}
|
||||
};
|
||||
|
||||
Cloud.prototype.callService = function (
|
||||
serviceName,
|
||||
callBack,
|
||||
errorCall,
|
||||
args
|
||||
) {
|
||||
// both callBack and errorCall are optional two-argument functions
|
||||
var request = new XMLHttpRequest(),
|
||||
service = this.api[serviceName],
|
||||
myself = this,
|
||||
postDict;
|
||||
|
||||
if (!this.session) {
|
||||
errorCall.call('You are not connected', 'Cloud');
|
||||
return;
|
||||
}
|
||||
if (!service) {
|
||||
errorCall.call('service ' + serviceName + ' is not available', 'API');
|
||||
return;
|
||||
}
|
||||
if (args && args.length > 0) {
|
||||
postDict = {};
|
||||
service.parameters.forEach(function (parm, idx) {
|
||||
postDict[parm] = args[idx];
|
||||
});
|
||||
}
|
||||
try {
|
||||
request.open(service.method, service.url, true);
|
||||
request.withCredentials = true;
|
||||
request.setRequestHeader('Content-Type', 'text/plain');
|
||||
request.setRequestHeader('MioCracker', this.session);
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4) {
|
||||
var responseList = [];
|
||||
if (request.responseText &&
|
||||
request.responseText.indexOf('ERROR') === 0) {
|
||||
errorCall.call(
|
||||
this,
|
||||
request.responseText,
|
||||
'Service: ' + serviceName
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (serviceName === 'login') {
|
||||
myself.api = myself.parseAPI(request.responseText);
|
||||
}
|
||||
responseList = myself.parseResponse(
|
||||
request.responseText
|
||||
);
|
||||
callBack.call(null, responseList, service.url);
|
||||
}
|
||||
};
|
||||
request.send(this.encodeDict(postDict));
|
||||
} catch (err) {
|
||||
errorCall.call(this, err.toString(), service.url);
|
||||
}
|
||||
};
|
||||
|
||||
// Cloud: payload transformation
|
||||
|
||||
Cloud.prototype.parseAPI = function (src) {
|
||||
var api = {},
|
||||
services;
|
||||
services = src.split(" ");
|
||||
services.forEach(function (service) {
|
||||
var entries = service.split("&"),
|
||||
serviceDescription = {},
|
||||
parms;
|
||||
entries.forEach(function (entry) {
|
||||
var pair = entry.split("="),
|
||||
key = decodeURIComponent(pair[0]).toLowerCase(),
|
||||
val = decodeURIComponent(pair[1]);
|
||||
if (key === "service") {
|
||||
api[val] = serviceDescription;
|
||||
} else if (key === "parameters") {
|
||||
parms = val.split(",");
|
||||
if (!(parms.length === 1 && !parms[0])) {
|
||||
serviceDescription.parameters = parms;
|
||||
}
|
||||
} else {
|
||||
serviceDescription[key] = val;
|
||||
}
|
||||
});
|
||||
});
|
||||
return api;
|
||||
};
|
||||
|
||||
Cloud.prototype.parseResponse = function (src) {
|
||||
var ans = [],
|
||||
lines;
|
||||
if (!src) {return ans; }
|
||||
lines = src.split(" ");
|
||||
lines.forEach(function (service) {
|
||||
var entries = service.split("&"),
|
||||
dict = {};
|
||||
entries.forEach(function (entry) {
|
||||
var pair = entry.split("="),
|
||||
key = decodeURIComponent(pair[0]),
|
||||
val = decodeURIComponent(pair[1]);
|
||||
dict[key] = val;
|
||||
});
|
||||
ans.push(dict);
|
||||
});
|
||||
return ans;
|
||||
};
|
||||
|
||||
Cloud.prototype.encodeDict = function (dict) {
|
||||
var str = '',
|
||||
pair,
|
||||
key;
|
||||
if (!dict) {return null; }
|
||||
for (key in dict) {
|
||||
if (dict.hasOwnProperty(key)) {
|
||||
pair = encodeURIComponent(key)
|
||||
+ '='
|
||||
+ encodeURIComponent(dict[key]);
|
||||
if (pair.length > 0) {
|
||||
str += '&';
|
||||
}
|
||||
str += pair;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
// Cloud: user messages (to be overridden)
|
||||
|
||||
Cloud.prototype.message = function (string) {
|
||||
alert(string);
|
||||
};
|
|
@ -0,0 +1,173 @@
|
|||
*****************************
|
||||
Contributing to BYOB4 / Snap!
|
||||
by Jens Mönig
|
||||
last changed: 12/09/14
|
||||
*****************************
|
||||
|
||||
Attached is the current development code base for BYOB4 a.k.a. Snap. It consists of
|
||||
several JavaScript, HTML and text files, and while some of it may be functional
|
||||
most parts will be in flux and subject to frequent, even fundamental modifications.
|
||||
This document lays out a few simple guidelines ensuring that collaborative code
|
||||
contribution works out.
|
||||
|
||||
|
||||
Working with changesets
|
||||
-----------------------
|
||||
You'll often want to change or add code in existing JS files. Please don't. Instead
|
||||
use a changeset. The way I always do it myself is to copy the empty
|
||||
|
||||
changeset.js
|
||||
|
||||
file and rename it to something like
|
||||
|
||||
JensChangesToMorphic.js
|
||||
|
||||
Into this file I write all the functions I want to add to Morphic. If I want to
|
||||
change a function in Morphic.js I copy it to the changeset and edit it there. Then
|
||||
I always validate the changeset with
|
||||
|
||||
JSLint.com
|
||||
|
||||
Please check your code frequently with JSLint!
|
||||
|
||||
For our Snap code set JSLint's settings to:
|
||||
|
||||
assume a browser
|
||||
tolerate missing 'use strict' pragma
|
||||
|
||||
[4] indentation
|
||||
[78] maximum line length
|
||||
|
||||
If you're working on the core Morphic library you can also
|
||||
|
||||
tolerate eval
|
||||
tolerate unfiltered for in
|
||||
|
||||
although you'll probably not ever going to need either EVAL or FORIN in your
|
||||
changesets anyway.
|
||||
|
||||
There are, of course, other tools - like JSHint and Firebug - that help you debug
|
||||
your code. Feel free to use whichever suits you best, but let's all agree on
|
||||
JSLint's (nitpicky!) formatting rules so we get code that's well readable and
|
||||
easily shareable among ourselves.
|
||||
|
||||
|
||||
Coding style
|
||||
------------
|
||||
Snap's codebase is both big and fast moving. We'll continue to churn out several
|
||||
builds per day for a long time, hunting bugs and adding features throughout the
|
||||
whole application. We'll also need to be able to get our heads around the whole
|
||||
codebase. Being able to read and to quickly understand the code is most important,
|
||||
much more so than mathematical elegance.
|
||||
|
||||
Let me really stress this point: In creating Snap we're neither playing "Code Golf"
|
||||
(solving a problem using the least number of keystrokes) nor are we trying to
|
||||
outsmart Knuth. Instead we're maintaining a large number of small interchangeable
|
||||
code chunks, therefore:
|
||||
|
||||
|
||||
Avoid
|
||||
-----
|
||||
* accessing the DOM
|
||||
|
||||
* frameworks (e.g. JQuery)
|
||||
|
||||
* modules and namespaces (e.g. IIFE)
|
||||
|
||||
- all of Snap is a single "World" with unique names for everything
|
||||
|
||||
- remember: Changesets contain "small interchangeable code chunks"...
|
||||
|
||||
* passing "thisArg" to functions like map(), filter() or forEach()
|
||||
|
||||
- except in call()
|
||||
- always use "myself" to reference "this" in an outer scope instead
|
||||
|
||||
* meta-class systems
|
||||
|
||||
- use Morphic's way of creating class-like constructors instead
|
||||
|
||||
- initialize all attributes either in the constructor or in an init()
|
||||
method, so you now the object's structure by casting a single look
|
||||
upon it. Avoid adding adding attributes elsewhere, or if you do,
|
||||
initialize them explicitly to "null" in the constructor or init()
|
||||
code
|
||||
|
||||
* nested ternary operators
|
||||
|
||||
* RegEx
|
||||
|
||||
* overwriting existing definitions
|
||||
|
||||
- except in changesets, duh :-)
|
||||
- create new constructors instead
|
||||
|
||||
* non-descriptive names for variables, functions, objects
|
||||
|
||||
* giant functions
|
||||
|
||||
- which often are "modules in disguise",
|
||||
especially if they define local helper functions
|
||||
|
||||
- create a new constructor instead
|
||||
|
||||
|
||||
Testing your code
|
||||
------------------
|
||||
(don't worry, I'm not talking about formal UnitTest Suites or other BDSM software
|
||||
fetishes, just about playing with what you're creating while you're doing it)
|
||||
|
||||
To test your changesets just add another line in the html stub file with your
|
||||
changeset. Make sure to put your changeset /after/ Morphic.js and Blocks.js and
|
||||
whichever libraries are already included, so it'll actually get used.
|
||||
|
||||
In your changeset override the world's
|
||||
|
||||
customMorphs
|
||||
|
||||
function so it returns a list of instances of your Morphs. For "Blocks.js" that
|
||||
code is:
|
||||
|
||||
var BlockMorph;
|
||||
var ScriptsMorph;
|
||||
|
||||
WorldMorph.prototype.customMorphs = function () {
|
||||
var sm = new ScriptsMorph();
|
||||
sm.setExtent(new Point(800, 600));
|
||||
return [
|
||||
new BlockMorph(),
|
||||
sm
|
||||
];
|
||||
};
|
||||
|
||||
Just modify this code so it returns your list of sample Morphs instead of
|
||||
BlockMorph and ScriptsMorph instances.
|
||||
|
||||
Once you've added this code to your changeset you can open your sample html file
|
||||
in your browser, and you'll find your sample Morphs in the World's DEMO menu.
|
||||
|
||||
|
||||
Inspectors
|
||||
----------
|
||||
To actually test play with your Morphs you can right-click on them and open an
|
||||
inspector on them. You can open more than one inspector on each object. The
|
||||
inspector pretty much works the same as in Smalltalk. It even has an evaluation
|
||||
pane at the bottom, in which you can type in any JS code, mark it with your mouse
|
||||
(or select all with ctrl-a), righ-click on the selection and either "do it", "show
|
||||
it" or "inspect it" (again, like in Squeak).
|
||||
|
||||
Needless to say, in the evaluation pane "this" always refers to the inspected
|
||||
object.
|
||||
|
||||
|
||||
Source Code Mgmt
|
||||
-----------------
|
||||
The good thing about changesets is that you can continue working on them regardless
|
||||
of new dev releases that happen in the meantime. When you feel you've got something
|
||||
that's finished just send me your changeset, and I'll work all the changesets into
|
||||
the Snap codebase and release another dev version. That way there will always (and
|
||||
frequently) be a harmonized common code base.
|
||||
|
||||
Thanks!
|
||||
|
||||
--Jens
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,928 @@
|
|||
/*
|
||||
|
||||
lang-pt.js
|
||||
|
||||
Portuguese (literary) translation for SNAP!
|
||||
|
||||
translated by Manuel Menezes de Sequeira
|
||||
|
||||
Copyright (C) 2012 by Manuel Menezes de Sequeira
|
||||
*/
|
||||
|
||||
/*global SnapTranslator*/
|
||||
|
||||
SnapTranslator.dict.pt = {
|
||||
|
||||
/*
|
||||
Special characters: (see <http://0xcc.net/jsescape/>)
|
||||
|
||||
Ä, ä \u00c4, \u00e4
|
||||
Ö, ö \u00d6, \u00f6
|
||||
Ü, ü \u00dc, \u00fc
|
||||
ß \u00df
|
||||
*/
|
||||
|
||||
// translations meta information
|
||||
'language_name':
|
||||
'Português (literário)',
|
||||
'language_translator':
|
||||
'Manuel Menezes de Sequeira',
|
||||
'translator_e-mail':
|
||||
'mmsequeira@gmail.com',
|
||||
'last_changed':
|
||||
'2012-10-23',
|
||||
|
||||
// GUI
|
||||
// control bar:
|
||||
'untitled':
|
||||
'Sem título',
|
||||
'development mode':
|
||||
'modo de desenvolvimento',
|
||||
|
||||
// categories:
|
||||
'Motion':
|
||||
'Movimento',
|
||||
'Looks':
|
||||
'Aparência',
|
||||
'Sound':
|
||||
'Som',
|
||||
'Pen':
|
||||
'Caneta',
|
||||
'Control':
|
||||
'Controlo',
|
||||
'Sensing':
|
||||
'Sensores',
|
||||
'Operators':
|
||||
'Operadores',
|
||||
'Variables':
|
||||
'Variáveis',
|
||||
'Lists':
|
||||
'Listas',
|
||||
'Other':
|
||||
'Outros',
|
||||
|
||||
// editor:
|
||||
'draggable':
|
||||
'arrastável',
|
||||
|
||||
// tabs:
|
||||
'Scripts':
|
||||
'Guiões',
|
||||
'Costumes':
|
||||
'Trajes',
|
||||
'Sounds':
|
||||
'Sons',
|
||||
|
||||
// names:
|
||||
'Sprite':
|
||||
'o actor',
|
||||
'Stage':
|
||||
'o palco',
|
||||
|
||||
// rotation styles:
|
||||
'don\'t rotate':
|
||||
'não pode rodar',
|
||||
'can rotate':
|
||||
'pode rodar',
|
||||
'only face left/right':
|
||||
'pode apenas olhar para a esquerda ou para a direita',
|
||||
|
||||
// new sprite button:
|
||||
'add a new Sprite':
|
||||
'adicionar um novo actor',
|
||||
|
||||
// tab help
|
||||
'costumes tab help':
|
||||
'Importa uma imagem de uma página Web ou de um\n'
|
||||
+ 'arquivo no teu computador arrastando-a para aqui',
|
||||
'import a sound from your computer\nby dragging it into here':
|
||||
'Importa um som do teu computador\narrastando-o para aqui',
|
||||
|
||||
// primitive blocks:
|
||||
|
||||
/*
|
||||
Attention Translators:
|
||||
----------------------
|
||||
At this time your translation of block specs will only work
|
||||
correctly, if the order of formal parameters and their types
|
||||
are unchanged. Placeholders for inputs (formal parameters) are
|
||||
indicated by a preceding % prefix and followed by a type
|
||||
abbreviation.
|
||||
|
||||
For example:
|
||||
|
||||
'say %s for %n secs'
|
||||
|
||||
can currently not be changed into
|
||||
|
||||
'say %n secs long %s'
|
||||
|
||||
and still work as intended.
|
||||
|
||||
Similarly
|
||||
|
||||
'point towards %dst'
|
||||
|
||||
cannot be changed into
|
||||
|
||||
'point towards %cst'
|
||||
|
||||
without breaking its functionality.
|
||||
*/
|
||||
|
||||
// motion:
|
||||
'Stage selected:\nno motion primitives':
|
||||
'Palco seleccionado\nnenhuma primitiva de movimento',
|
||||
|
||||
'move %n steps':
|
||||
'anda %n passos',
|
||||
'turn %clockwise %n degrees':
|
||||
'gira %clockwise %n graus',
|
||||
'turn %counterclockwise %n degrees':
|
||||
'gira %counterclockwise %n graus',
|
||||
'point in direction %dir':
|
||||
'altera a tua direcção para %dir',
|
||||
'point towards %dst':
|
||||
'aponta em direcção a %dst',
|
||||
'go to x: %n y: %n':
|
||||
'vai para as coordenadas x: %n y: %n',
|
||||
'go to %dst':
|
||||
'vai para a posição de %dst',
|
||||
'glide %n secs to x: %n y: %n':
|
||||
'desliza em %n s para as coordenadas x: %n y: %n',
|
||||
'change x by %n':
|
||||
'adiciona %n à tua coordenada x',
|
||||
'set x to %n':
|
||||
'altera a tua coordenada x para %n',
|
||||
'change y by %n':
|
||||
'adiciona %n à tua coordenada y',
|
||||
'set y to %n':
|
||||
'altera a tua coordenada y para %n',
|
||||
'if on edge, bounce':
|
||||
'se estiveres a bater na borda, ressalta',
|
||||
'x position':
|
||||
'a coordenada x da posição',
|
||||
'y position':
|
||||
'a coordenada y da posição',
|
||||
'direction':
|
||||
'a direcção',
|
||||
|
||||
// looks:
|
||||
'switch to costume %cst':
|
||||
'muda para o traje %cst',
|
||||
'next costume':
|
||||
'passa para o próximo traje',
|
||||
'costume #':
|
||||
'o número do traje',
|
||||
'say %s for %n secs':
|
||||
'diz %s durante %n s',
|
||||
'say %s':
|
||||
'diz %s',
|
||||
'think %s for %n secs':
|
||||
'pensa %s durante %n s',
|
||||
'think %s':
|
||||
'pensa %s',
|
||||
'Hello!':
|
||||
'Olá!',
|
||||
'Hmm...':
|
||||
'Hmm...',
|
||||
'change %eff effect by %n':
|
||||
'adiciona ao efeito %eff o valor %n',
|
||||
'set %eff effect to %n':
|
||||
'altera o teu efeito %eff para %n',
|
||||
'clear graphic effects':
|
||||
'limpa os efeitos gráficos',
|
||||
'change size by %n':
|
||||
'adiciona %n ao teu tamanho',
|
||||
'set size to %n %':
|
||||
'altera o teu tamanho para %n %',
|
||||
'size':
|
||||
'o tamanho',
|
||||
'show':
|
||||
'mostra-te',
|
||||
'hide':
|
||||
'esconde-te',
|
||||
'go to front':
|
||||
'vem para a frente',
|
||||
'go back %n layers':
|
||||
'recua %n camadas',
|
||||
|
||||
'development mode \ndebugging primitives:':
|
||||
'primitivas de depuração \ndo modo de desenvolvimento',
|
||||
'console log %mult%s':
|
||||
'regista %mult%s na consola',
|
||||
'alert %mult%s':
|
||||
'mostra janela de alerta com %mult%s',
|
||||
|
||||
// sound:
|
||||
'play sound %snd':
|
||||
'toca o som %snd',
|
||||
'play sound %snd until done':
|
||||
'toca o som %snd até terminar',
|
||||
'stop all sounds':
|
||||
'pára todos os sons',
|
||||
|
||||
// pen:
|
||||
'clear':
|
||||
'apaga tudo',
|
||||
'pen down':
|
||||
'baixa a tua caneta',
|
||||
'pen up':
|
||||
'levanta a tua caneta',
|
||||
'set pen color to %clr':
|
||||
'altera a cor da tua caneta para %clr',
|
||||
'change pen color by %n':
|
||||
'adiciona %n à cor da tua caneta',
|
||||
'set pen color to %n':
|
||||
'altera a cor da tua caneta para %n',
|
||||
'change pen shade by %n':
|
||||
'adiciona %n ao tom da tua caneta',
|
||||
'set pen shade to %n':
|
||||
'altera o tom da tua caneta para %n',
|
||||
'change pen size by %n':
|
||||
'adiciona %n ao tamanho da tua caneta',
|
||||
'set pen size to %n':
|
||||
'altera o tamanho da tua caneta para %n',
|
||||
'stamp':
|
||||
'carimba-te',
|
||||
|
||||
// control:
|
||||
'when %greenflag clicked':
|
||||
'quando alguém clicar em %greenflag',
|
||||
'when %key key pressed':
|
||||
'quando alguém pressionar a tecla %key',
|
||||
'when I am clicked':
|
||||
'quando alguém clicar em ti',
|
||||
'when I receive %msg':
|
||||
'quando receberes a mensagem %msg',
|
||||
'broadcast %msg':
|
||||
'difunde a mensagem %msg',
|
||||
'broadcast %msg and wait':
|
||||
'difunde a mensagem %msg e espera',
|
||||
'Message name':
|
||||
'Qual o nome da mensagem?',
|
||||
'wait %n secs':
|
||||
'espera %n s',
|
||||
'wait until %b':
|
||||
'espera até que %b',
|
||||
'forever %c':
|
||||
'para sempre, %c',
|
||||
'repeat %n %c':
|
||||
'repete %n vezes %c',
|
||||
'repeat until %b %c':
|
||||
'até que %b . repete %c',
|
||||
'if %b %c':
|
||||
'se %b , então %c',
|
||||
'if %b %c else %c':
|
||||
'se %b , então %c senão, %c',
|
||||
'report %s':
|
||||
'reporta %s',
|
||||
'stop block':
|
||||
'pára o bloco',
|
||||
'stop script':
|
||||
'pára o guião',
|
||||
'stop all %stop':
|
||||
'pára tudo %stop',
|
||||
'run %cmdRing %inputs':
|
||||
'executa %cmdRing %inputs',
|
||||
'launch %cmdRing %inputs':
|
||||
'lança execução de %cmdRing %inputs',
|
||||
'call %repRing %inputs':
|
||||
'o resultado da invocação de %repRing %inputs',
|
||||
'run %cmdRing w/continuation':
|
||||
'executa %cmdRing com continuação',
|
||||
'call %cmdRing w/continuation':
|
||||
'o resultado da invocação de %cmdRing com continuação',
|
||||
'warp %c':
|
||||
'executa atomicamente %c',
|
||||
|
||||
// sensing:
|
||||
'touching %col ?':
|
||||
'estás a tocar em %col',
|
||||
'touching %clr ?':
|
||||
'estás a tocar na cor %clr',
|
||||
'color %clr is touching %clr ?':
|
||||
'a cor %clr está a tocar na cor %clr',
|
||||
'ask %s and wait':
|
||||
'pergunta %s e espera pela resposta',
|
||||
'what\'s your name?':
|
||||
'Como te chamas?',
|
||||
'answer':
|
||||
'a resposta dada',
|
||||
'mouse x':
|
||||
'a coordenada x do rato',
|
||||
'mouse y':
|
||||
'a coordenada y do rato',
|
||||
'mouse down?':
|
||||
'o botão do rato está pressionado',
|
||||
'key %key pressed?':
|
||||
'a tecla %key está a ser pressionada',
|
||||
'distance to %dst':
|
||||
'a distância até %dst',
|
||||
'reset timer':
|
||||
'reinicia o cronómetro',
|
||||
'timer':
|
||||
'o cronómetro',
|
||||
'http:// %s':
|
||||
'http:// %s',
|
||||
|
||||
'filtered for %clr':
|
||||
'filtrado para %clr',
|
||||
'stack size':
|
||||
'tamanho da pilha',
|
||||
'frames':
|
||||
'frames',
|
||||
|
||||
// operators:
|
||||
'%n mod %n':
|
||||
'o resto de %n a dividir por %n',
|
||||
'round %n':
|
||||
'o arredondamento de %n',
|
||||
'%fun of %n':
|
||||
'%fun de %n',
|
||||
'pick random %n to %n':
|
||||
'um valor ao acaso entre %n e %n',
|
||||
'%b and %b':
|
||||
'%b e %b',
|
||||
'%b or %b':
|
||||
'%b ou %b',
|
||||
'not %b':
|
||||
'é falso que %b',
|
||||
'true':
|
||||
'verdadeiro',
|
||||
'false':
|
||||
'falso',
|
||||
'join %words':
|
||||
'a junção de %words',
|
||||
'hello':
|
||||
'olá',
|
||||
'world':
|
||||
'mundo',
|
||||
'letter %n of %s':
|
||||
'o caractere %n de %s',
|
||||
'length of %s':
|
||||
'o comprimento de %s',
|
||||
'unicode of %s':
|
||||
'o código Unicode do caractere %s',
|
||||
'unicode %n as letter':
|
||||
'o caractere cujo código Unicode é %n',
|
||||
'is %s a %typ ?':
|
||||
'%s é um(a) %typ',
|
||||
|
||||
'type of %s':
|
||||
'o tipo de %s',
|
||||
|
||||
// variables:
|
||||
'Make a variable':
|
||||
'Criar uma variável',
|
||||
'Variable name':
|
||||
'Qual o nome da variável?',
|
||||
'Delete a variable':
|
||||
'Remover uma variável',
|
||||
|
||||
'set %var to %s':
|
||||
'altera %var para %s',
|
||||
'change %var by %n':
|
||||
'adiciona a %var o valor %n',
|
||||
'show variable %var':
|
||||
'mostra a variável %var',
|
||||
'hide variable %var':
|
||||
'esconde a variável %var',
|
||||
'script variables %scriptVars':
|
||||
'cria as variáveis de guião %scriptVars',
|
||||
|
||||
// lists:
|
||||
'list %exp':
|
||||
'a lista %exp',
|
||||
'%s in front of %l':
|
||||
'a prefixação de %s a %l',
|
||||
'item %idx of %l':
|
||||
'%idx de %l',
|
||||
'all but first of %l':
|
||||
'todos menos o primeiro item de %l',
|
||||
'length of %l':
|
||||
'o comprimento de %l',
|
||||
'%l contains %s':
|
||||
'%l contém %s',
|
||||
'thing':
|
||||
'coisa',
|
||||
'add %s to %l':
|
||||
'acrescenta %s a %l',
|
||||
'delete %ida of %l':
|
||||
'remove %ida de %l',
|
||||
'insert %s at %idx of %l':
|
||||
'insere %s antes de %idx de %l',
|
||||
'replace item %idx of %l with %s':
|
||||
'substitui %idx de %l por %s',
|
||||
|
||||
// other
|
||||
'Make a block':
|
||||
'Criar um bloco',
|
||||
|
||||
// menus
|
||||
// snap menu
|
||||
'About...':
|
||||
'Sobre o Snap!...',
|
||||
'Snap! website':
|
||||
'Sítio Web do Snap!',
|
||||
'Download source':
|
||||
'Descarregar código fonte',
|
||||
'Switch back to user mode':
|
||||
'Regressar ao modo de utilizador',
|
||||
'disable deep-Morphic\ncontext menus\nand show user-friendly ones':
|
||||
'Desactivar menus de contexto\nprofundos do Morphic e\nmostrar menus amigáveis.',
|
||||
'Switch to dev mode':
|
||||
'Passar ao modo de desenvolvimento',
|
||||
'enable Morphic\ncontext menus\nand inspectors,\nnot user-friendly!':
|
||||
'Activar menus de contexto e inspectores não amigáveis do Morphic!',
|
||||
|
||||
// project menu
|
||||
'Project Notes...':
|
||||
'Notas do projecto...',
|
||||
'New':
|
||||
'Novo',
|
||||
'Open...':
|
||||
'Abrir...',
|
||||
'Save':
|
||||
'Guardar',
|
||||
'Save As...':
|
||||
'Guardar como...',
|
||||
'Import...':
|
||||
'Importar...',
|
||||
'file menu import hint':
|
||||
'Carregar um projecto exportado,\n'
|
||||
+ 'uma biblioteca de blocos,\n'
|
||||
+ 'um traje ou um som.',
|
||||
'Export project as plain text ...':
|
||||
'Exportar projecto como texto simples...',
|
||||
'Export project...':
|
||||
'Exportar projecto...',
|
||||
'show project data as XML\nin a new browser window':
|
||||
'Mostrar os dados do projecto no\nformato XML numa nova janela do navegador.',
|
||||
'Export blocks ...':
|
||||
'Exportar blocos',
|
||||
'show global custom block definitions as XML\nin a new browser window':
|
||||
'Mostrar as definições de blocos personalizados globais\n no formato XML numa nova janela do navegador.',
|
||||
|
||||
// settings menu
|
||||
'Language...':
|
||||
'Língua...',
|
||||
'Blurred shadows':
|
||||
'Sombras desfocadas',
|
||||
'uncheck to use solid drop\nshadows and highlights':
|
||||
'Desassinalar para usar sombras\ne realces nítidos.',
|
||||
'check to use blurred drop\nshadows and highlights':
|
||||
'Assinalar para usar sombras\ne realces desfocados.',
|
||||
'Zebra coloring':
|
||||
'Coloração em zebra',
|
||||
'check to enable alternating\ncolors for nested blocks':
|
||||
'Assinalar para alternar\nas cores de blocos aninhados.',
|
||||
'uncheck to disable alternating\ncolors for nested block':
|
||||
'Desassinalar para deixar de alternar\nas cores de blocos aninhados.',
|
||||
'Prefer empty slot drops':
|
||||
'Preferir largadas em ranhuras vazias',
|
||||
'settings menu prefer empty slots hint':
|
||||
'Assinalar para focar em ranhuras vazias\nquando arrastando e largando repórteres.',
|
||||
'uncheck to allow dropped\nreporters to kick out others':
|
||||
'Desassinalar para permitir que\nrepórteres largados desalojem outros.',
|
||||
'Long form input dialog':
|
||||
'Forma longa da caixa de diálogo das entradas',
|
||||
'check to always show slot\ntypes in the input dialog':
|
||||
'Assinalar para mostrar sempre\no tipo das ranhuras na caixa\nde diálogo das entradas.',
|
||||
'uncheck to use the input\ndialog in short form':
|
||||
'Desassinalar para usar a forma curta\nda caixa de diálogo das entradas.',
|
||||
'Virtual keyboard':
|
||||
'Teclado virtual',
|
||||
'uncheck to disable\nvirtual keyboard support\nfor mobile devices':
|
||||
'Desassinalar para desactivar o\nsuporte do teclado virtual\npara dispositivos móveis.',
|
||||
'check to enable\nvirtual keyboard support\nfor mobile devices':
|
||||
'Assinalar para activar o\nsuporte do teclado virtual\npara dispositivos móveis.',
|
||||
'Input sliders':
|
||||
'Deslizadores de entrada',
|
||||
'uncheck to disable\ninput sliders for\nentry fields':
|
||||
'Desassinalar para desactivar\ndeslizadores nos campos de entrada.',
|
||||
'check to enable\ninput sliders for\nentry fields':
|
||||
'Assinalar para activar deslizadores\nnos campos de entrada.',
|
||||
'Clicking sound':
|
||||
'Som de cliques',
|
||||
'uncheck to turn\nblock clicking\nsound off':
|
||||
'Desassinar para desactivar o som produzido ao clicar nos blocos.',
|
||||
'check to turn\nblock clicking\nsound on':
|
||||
'Assinar para activar o som produzido ao clicar nos blocos.',
|
||||
'Thread safe scripts':
|
||||
'Guiões thread-safe',
|
||||
'uncheck to allow\nscript reentrancy':
|
||||
'Desassinar para permitir\nreentrância nos guiões.',
|
||||
'check to disallow\nscript reentrancy':
|
||||
'Assinar para não permitir\nreentrância nos guiões.',
|
||||
|
||||
// inputs
|
||||
'with inputs':
|
||||
'com entradas',
|
||||
'input names:':
|
||||
'nomes das entradas:',
|
||||
'Input Names:':
|
||||
'Nomes das entradas:',
|
||||
|
||||
// context menus:
|
||||
'help':
|
||||
'ajuda',
|
||||
|
||||
// blocks:
|
||||
'help...':
|
||||
'ajuda...',
|
||||
'duplicate':
|
||||
'duplicar',
|
||||
'make a copy\nand pick it up':
|
||||
'fazer uma cópia\ne recolhê-la',
|
||||
'delete':
|
||||
'remover',
|
||||
'script pic...':
|
||||
'imagem do guião...',
|
||||
'open a new window\nwith a picture of this script':
|
||||
'Abrir uma nova janela com uma imagem deste guião.',
|
||||
'ringify':
|
||||
'adicionar anel',
|
||||
'unringify':
|
||||
'remover anel',
|
||||
|
||||
// custom blocks:
|
||||
'delete block definition...':
|
||||
'remover definição do bloco...',
|
||||
'edit...':
|
||||
'editar...',
|
||||
|
||||
// sprites:
|
||||
'edit':
|
||||
'editar',
|
||||
'export...':
|
||||
'exportar...',
|
||||
|
||||
// scripting area
|
||||
'clean up':
|
||||
'organizar',
|
||||
'arrange scripts\nvertically':
|
||||
'Organiza os guiões\nverticalmente.',
|
||||
'add comment':
|
||||
'adicionar comentário',
|
||||
'make a block...':
|
||||
'criar um bloco...',
|
||||
|
||||
// costumes
|
||||
'rename':
|
||||
'alterar o nome',
|
||||
'export':
|
||||
'exportar',
|
||||
'rename costume':
|
||||
'Qual o novo nome do traje?',
|
||||
|
||||
// sounds
|
||||
'Play sound':
|
||||
'Tocar som.',
|
||||
'Stop sound':
|
||||
'Parar som.',
|
||||
'Stop':
|
||||
'Parar',
|
||||
'Play':
|
||||
'Tocar',
|
||||
'rename sound':
|
||||
'Qual o novo nome do som?',
|
||||
|
||||
// dialogs
|
||||
// buttons
|
||||
'OK':
|
||||
'OK',
|
||||
'Ok':
|
||||
'OK',
|
||||
'Cancel':
|
||||
'Cancelar',
|
||||
'Yes':
|
||||
'Sim',
|
||||
'No':
|
||||
'Não',
|
||||
|
||||
// help
|
||||
'Help':
|
||||
'Ajuda',
|
||||
|
||||
// Project Manager
|
||||
'Untitled':
|
||||
'Sem título',
|
||||
'Open Project':
|
||||
'Abrir Projecto',
|
||||
'(empty)':
|
||||
'(vazio)',
|
||||
'Saved!':
|
||||
'Guardado!',
|
||||
'Delete Project':
|
||||
'Remover Projecto',
|
||||
'Are you sure you want to delete':
|
||||
'Quer mesmo remover?',
|
||||
'rename...':
|
||||
'alterar o nome...',
|
||||
|
||||
// costume editor
|
||||
'Costume Editor':
|
||||
'Editor de Trajes',
|
||||
'click or drag crosshairs to move the rotation center':
|
||||
'Clique ou arraste a mira para alterar o centro de rotação.',
|
||||
|
||||
// project notes
|
||||
'Project Notes':
|
||||
'Notas do Projecto',
|
||||
|
||||
// new project
|
||||
'New Project':
|
||||
'Novo Projecto',
|
||||
'Replace the current project with a new one?':
|
||||
'Substituir o projecto actual por um novo projecto?',
|
||||
|
||||
// save project
|
||||
'Save Project As...':
|
||||
'Guardar Projeto ...',
|
||||
|
||||
// export blocks
|
||||
'Export blocks':
|
||||
'Exportar blocos',
|
||||
'this project doesn\'t have any\ncustom global blocks yet':
|
||||
'este projecto ainda não tem nenhum bloco personalizado global',
|
||||
'select':
|
||||
'seleccionar',
|
||||
'all':
|
||||
'todos',
|
||||
'none':
|
||||
'nenhum',
|
||||
|
||||
// variable dialog
|
||||
'for all sprites':
|
||||
'para todos os actores',
|
||||
'for this sprite only':
|
||||
'apenas para este actor',
|
||||
|
||||
// block dialog
|
||||
'Change block':
|
||||
'Alterar bloco',
|
||||
'Command':
|
||||
'Comando',
|
||||
'Reporter':
|
||||
'Repórter',
|
||||
'Predicate':
|
||||
'Predicado',
|
||||
|
||||
// block editor
|
||||
'Block Editor':
|
||||
'Editor de Blocos',
|
||||
'Apply':
|
||||
'Aplicar',
|
||||
|
||||
// block deletion dialog
|
||||
'Delete Custom Block':
|
||||
'Remover Bloco Personalizado',
|
||||
'block deletion dialog text':
|
||||
'Quer mesmo remover este bloco e todas as suas utilizações?',
|
||||
|
||||
// input dialog
|
||||
'Create input name':
|
||||
'Criar nome de entrada',
|
||||
'Edit input name':
|
||||
'Editar nome da entrada',
|
||||
'Title text':
|
||||
'Texto de título',
|
||||
'Input name':
|
||||
'Nome de entrada',
|
||||
'Delete':
|
||||
'Remover',
|
||||
'Object':
|
||||
'Objecto',
|
||||
'Number':
|
||||
'Número',
|
||||
'Text':
|
||||
'Texto',
|
||||
'List':
|
||||
'Lista',
|
||||
'Any type':
|
||||
'Qualquer tipo',
|
||||
'Boolean (T/F)':
|
||||
'Booleano (V/F)',
|
||||
'Command\n(inline)':
|
||||
'Comando\n(em linha)',
|
||||
'Command\n(C-shape)':
|
||||
'Comando\n(em forquilha)',
|
||||
'Any\n(unevaluated)':
|
||||
'Qualquer\n(por calcular)',
|
||||
'Boolean\n(unevaluated)':
|
||||
'Booleano\n(por calcular)',
|
||||
'Single input.':
|
||||
'Entrada única.',
|
||||
'Default Value:':
|
||||
'Valor por omissão:',
|
||||
'Multiple inputs (value is list of inputs)':
|
||||
'Múltiplas entradas (valor é uma lista das entradas)',
|
||||
'Upvar - make internal variable visible to caller':
|
||||
'Tornar a variável interna visível pelo invocador',
|
||||
|
||||
// About Snap
|
||||
'About Snap':
|
||||
'Sobre o Snap!',
|
||||
'Back...':
|
||||
'Para trás...',
|
||||
'License...':
|
||||
'Licensa...',
|
||||
'Modules...':
|
||||
'Módulos...',
|
||||
'Credits...':
|
||||
'Créditos...',
|
||||
'Translators...':
|
||||
'Tradutores',
|
||||
'License':
|
||||
'Licença',
|
||||
'current module versions:':
|
||||
'versões actuais dos módulos',
|
||||
'Contributors':
|
||||
'Contribuidores',
|
||||
'Translations':
|
||||
'Traduções',
|
||||
|
||||
// variable watchers
|
||||
'normal':
|
||||
'normal',
|
||||
'large':
|
||||
'grande',
|
||||
'slider':
|
||||
'deslizador',
|
||||
'slider min...':
|
||||
'mínimmo do deslizador...',
|
||||
'slider max...':
|
||||
'máximo do deslizador...',
|
||||
'Slider minimum value':
|
||||
'Valor mínimo do deslizador',
|
||||
'Slider maximum value':
|
||||
'Valor máximo do deslizador',
|
||||
|
||||
// list watchers
|
||||
'length: ':
|
||||
'comprimento: ',
|
||||
|
||||
// coments
|
||||
'add comment here...':
|
||||
'adicionar um comentário aqui...',
|
||||
|
||||
// drow downs
|
||||
// directions
|
||||
'(90) right':
|
||||
'(90) direita',
|
||||
'(-90) left':
|
||||
'(-90) esquerda',
|
||||
'(0) up':
|
||||
'(0) cima',
|
||||
'(180) down':
|
||||
'(180) baixo',
|
||||
|
||||
// collision detection
|
||||
'mouse-pointer':
|
||||
'ponteiro do rato',
|
||||
'edge':
|
||||
'borda',
|
||||
'pen trails':
|
||||
'traços da caneta',
|
||||
|
||||
// costumes
|
||||
'Turtle':
|
||||
'Tartaruga',
|
||||
|
||||
// graphical effects
|
||||
'ghost':
|
||||
'fantasma',
|
||||
|
||||
// keys
|
||||
'space':
|
||||
'espaço',
|
||||
'up arrow':
|
||||
'seta para cima',
|
||||
'down arrow':
|
||||
'seta para baixo',
|
||||
'right arrow':
|
||||
'seta para a direita',
|
||||
'left arrow':
|
||||
'seta para a esquerda',
|
||||
'a':
|
||||
'a',
|
||||
'b':
|
||||
'b',
|
||||
'c':
|
||||
'c',
|
||||
'd':
|
||||
'd',
|
||||
'e':
|
||||
'e',
|
||||
'f':
|
||||
'f',
|
||||
'g':
|
||||
'g',
|
||||
'h':
|
||||
'h',
|
||||
'i':
|
||||
'i',
|
||||
'j':
|
||||
'j',
|
||||
'k':
|
||||
'k',
|
||||
'l':
|
||||
'l',
|
||||
'm':
|
||||
'm',
|
||||
'n':
|
||||
'n',
|
||||
'o':
|
||||
'o',
|
||||
'p':
|
||||
'p',
|
||||
'q':
|
||||
'q',
|
||||
'r':
|
||||
'r',
|
||||
's':
|
||||
's',
|
||||
't':
|
||||
't',
|
||||
'u':
|
||||
'u',
|
||||
'v':
|
||||
'v',
|
||||
'w':
|
||||
'w',
|
||||
'x':
|
||||
'x',
|
||||
'y':
|
||||
'y',
|
||||
'z':
|
||||
'z',
|
||||
'0':
|
||||
'0',
|
||||
'1':
|
||||
'1',
|
||||
'2':
|
||||
'2',
|
||||
'3':
|
||||
'3',
|
||||
'4':
|
||||
'4',
|
||||
'5':
|
||||
'5',
|
||||
'6':
|
||||
'6',
|
||||
'7':
|
||||
'7',
|
||||
'8':
|
||||
'8',
|
||||
'9':
|
||||
'9',
|
||||
|
||||
// messages
|
||||
'new...':
|
||||
'nova...',
|
||||
|
||||
// math functions
|
||||
'abs':
|
||||
'valor absoluto',
|
||||
'sqrt':
|
||||
'raiz quadrada',
|
||||
'sin':
|
||||
'seno',
|
||||
'cos':
|
||||
'cosseno',
|
||||
'tan':
|
||||
'tangente',
|
||||
'asin':
|
||||
'arco-seno',
|
||||
'acos':
|
||||
'arco-cosseno',
|
||||
'atan':
|
||||
'arco-tangente',
|
||||
'ln':
|
||||
'logaritmo natural',
|
||||
'e^':
|
||||
'exponencial',
|
||||
|
||||
// data types
|
||||
'number':
|
||||
'número',
|
||||
'text':
|
||||
'texto',
|
||||
'Boolean':
|
||||
'booleano',
|
||||
'list':
|
||||
'lista',
|
||||
'command':
|
||||
'comando',
|
||||
'reporter':
|
||||
'repórter',
|
||||
'predicate':
|
||||
'predicado',
|
||||
|
||||
// list indices
|
||||
'last':
|
||||
'o fim',
|
||||
'any':
|
||||
'qualquer dos itens'
|
||||
};
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,662 @@
|
|||
/*
|
||||
|
||||
lists.js
|
||||
|
||||
list data structure and GUI for SNAP!
|
||||
|
||||
written by Jens Mšnig and Brian Harvey
|
||||
jens@moenig.org, bh@cs.berkeley.edu
|
||||
|
||||
Copyright (C) 2013 by Jens Mšnig and Brian Harvey
|
||||
|
||||
This file is part of Snap!.
|
||||
|
||||
Snap! is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
prerequisites:
|
||||
--------------
|
||||
needs morphic.js, widgets.js and gui.js
|
||||
|
||||
|
||||
I. hierarchy
|
||||
-------------
|
||||
the following tree lists all constructors hierarchically,
|
||||
indentation indicating inheritance. Refer to this list to get a
|
||||
contextual overview:
|
||||
|
||||
List
|
||||
|
||||
BoxMorph*
|
||||
ListWatcherMorph
|
||||
|
||||
* from Morphic.js
|
||||
|
||||
|
||||
II. toc
|
||||
-------
|
||||
the following list shows the order in which all constructors are
|
||||
defined. Use this list to locate code in this document:
|
||||
|
||||
List
|
||||
ListWatcherMorph
|
||||
|
||||
*/
|
||||
|
||||
// Global settings /////////////////////////////////////////////////////
|
||||
|
||||
/*global modules, contains, BoxMorph, WorldMorph, HandleMorph,
|
||||
PushButtonMorph, SyntaxElementMorph, Color, Point, WatcherMorph,
|
||||
StringMorph, SpriteMorph, ScrollFrameMorph, CellMorph, ArrowMorph,
|
||||
MenuMorph, snapEquals, Morph, isNil, localize*/
|
||||
|
||||
modules.lists = '2013-March-12';
|
||||
|
||||
var List;
|
||||
var ListWatcherMorph;
|
||||
|
||||
// List ////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
I am a dynamic array data structure for SNAP!
|
||||
My index starts with 1
|
||||
|
||||
I am a "smart" hybrid list, because I can be used as both a linked
|
||||
list and as a dynamic array
|
||||
|
||||
public interface:
|
||||
|
||||
setters (linked):
|
||||
-----------------
|
||||
cons - answer a new list with the given item in front
|
||||
cdr - answer all but the first element
|
||||
|
||||
setters (arrayed):
|
||||
------------------
|
||||
add(element, index) - insert the element before the given slot,
|
||||
put(element, index) - overwrite the element at the given slot
|
||||
remove(index) - remove the given slot, shortening the list
|
||||
clear() - remove all elements
|
||||
|
||||
getters (all hybrid):
|
||||
---------------------
|
||||
length() - number of slots
|
||||
at(index) - element present in specified slot
|
||||
contains(element) - <bool>
|
||||
|
||||
conversion:
|
||||
-----------
|
||||
asArray() - answer me as JavaScript array
|
||||
asText() - answer my elements (recursively) concatenated
|
||||
*/
|
||||
|
||||
// List instance creation:
|
||||
|
||||
function List(array) {
|
||||
this.contents = array || [];
|
||||
this.first = null;
|
||||
this.rest = null;
|
||||
this.isLinked = false;
|
||||
this.lastChanged = Date.now();
|
||||
}
|
||||
|
||||
List.prototype.toString = function () {
|
||||
return 'a List [' + this.asArray + ']';
|
||||
};
|
||||
|
||||
// List updating:
|
||||
|
||||
List.prototype.changed = function () {
|
||||
this.lastChanged = Date.now();
|
||||
};
|
||||
|
||||
// Linked List ops:
|
||||
|
||||
List.prototype.cons = function (car, cdr) {
|
||||
var answer = new List();
|
||||
answer.first = isNil(car) ? null : car;
|
||||
answer.rest = cdr || null;
|
||||
answer.isLinked = true;
|
||||
return answer;
|
||||
};
|
||||
|
||||
List.prototype.cdr = function () {
|
||||
function helper(i) {
|
||||
if (i > this.contents.length) {
|
||||
return new List();
|
||||
}
|
||||
return this.cons(this.at(i), helper.call(this, i + 1));
|
||||
}
|
||||
if (this.isLinked) {
|
||||
return this.rest || new List();
|
||||
}
|
||||
if (this.contents.length < 2) {
|
||||
return new List();
|
||||
}
|
||||
return helper.call(this, 2);
|
||||
};
|
||||
|
||||
// List array setters:
|
||||
|
||||
List.prototype.add = function (element, index) {
|
||||
/*
|
||||
insert the element before the given slot index,
|
||||
if no index is specifed, append the element
|
||||
*/
|
||||
var idx = index || this.length() + 1,
|
||||
obj = element === 0 ? 0
|
||||
: element === false ? false
|
||||
: element || null;
|
||||
this.becomeArray();
|
||||
this.contents.splice(idx - 1, 0, obj);
|
||||
this.changed();
|
||||
};
|
||||
|
||||
List.prototype.put = function (element, index) {
|
||||
// exchange the element at the given slot for another
|
||||
var data = element === 0 ? 0
|
||||
: element === false ? false
|
||||
: element || null;
|
||||
|
||||
this.becomeArray();
|
||||
this.contents[index - 1] = data;
|
||||
this.changed();
|
||||
};
|
||||
|
||||
List.prototype.remove = function (index) {
|
||||
// remove the given slot, shortening the list
|
||||
this.becomeArray();
|
||||
this.contents.splice(index - 1, 1);
|
||||
this.changed();
|
||||
};
|
||||
|
||||
List.prototype.clear = function () {
|
||||
this.contents = [];
|
||||
this.first = null;
|
||||
this.rest = null;
|
||||
this.isLinked = false;
|
||||
this.changed();
|
||||
};
|
||||
|
||||
// List getters (all hybrid):
|
||||
|
||||
List.prototype.length = function () {
|
||||
if (this.isLinked) {
|
||||
return (this.first === undefined ? 0 : 1)
|
||||
+ (this.rest ? this.rest.length() : 0);
|
||||
}
|
||||
return this.contents.length;
|
||||
};
|
||||
|
||||
List.prototype.at = function (index) {
|
||||
var value;
|
||||
if (this.isLinked) {
|
||||
return index === 1 ? this.first : this.rest.at(index - 1);
|
||||
}
|
||||
value = this.contents[index - 1];
|
||||
return isNil(value) ? '' : value;
|
||||
};
|
||||
|
||||
List.prototype.contains = function (element) {
|
||||
var num = parseFloat(element);
|
||||
if (this.isLinked) {
|
||||
if (this.first === element) {
|
||||
return true;
|
||||
}
|
||||
if (!isNaN(num)) {
|
||||
if (this.first === num) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (this.rest instanceof List) {
|
||||
return this.rest.contains(element);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// in case I'm arrayed
|
||||
if (contains(this.contents, element)) {
|
||||
return true;
|
||||
}
|
||||
if (!isNaN(num)) {
|
||||
return (contains(this.contents, num));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// List conversion:
|
||||
|
||||
List.prototype.asArray = function () {
|
||||
// for use in the evaluator
|
||||
this.becomeArray();
|
||||
return this.contents;
|
||||
};
|
||||
|
||||
List.prototype.asText = function () {
|
||||
var result = '',
|
||||
length = this.length(),
|
||||
element,
|
||||
i;
|
||||
for (i = 1; i <= length; i += 1) {
|
||||
element = this.at(i);
|
||||
if (element instanceof List) {
|
||||
result = result.concat(element.asText());
|
||||
} else {
|
||||
element = isNil(element) ? '' : element.toString();
|
||||
result = result.concat(element);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
List.prototype.becomeArray = function () {
|
||||
if (this.isLinked) {
|
||||
var next = this;
|
||||
this.contents = [];
|
||||
while (next instanceof List && (next.length() > 0)) {
|
||||
this.contents.push(next.at(1));
|
||||
next = next.cdr();
|
||||
}
|
||||
this.isLinked = false;
|
||||
}
|
||||
};
|
||||
|
||||
List.prototype.becomeLinked = function () {
|
||||
var i, stop, tail = this;
|
||||
if (!this.isLinked) {
|
||||
stop = this.length();
|
||||
for (i = 0; i < stop; i += 1) {
|
||||
tail.first = this.contents[i];
|
||||
tail.rest = new List();
|
||||
tail.isLinked = true;
|
||||
tail = tail.rest;
|
||||
}
|
||||
this.contents = [];
|
||||
this.isLinked = true;
|
||||
}
|
||||
};
|
||||
|
||||
// List testing
|
||||
|
||||
List.prototype.equalTo = function (other) {
|
||||
var i;
|
||||
if (!(other instanceof List)) {
|
||||
return false;
|
||||
}
|
||||
if ((!this.isLinked) && (!other.isLinked)) {
|
||||
if (this.length() === 0 && (other.length() === 0)) {
|
||||
return true;
|
||||
}
|
||||
if (this.length() !== other.length()) {
|
||||
return false;
|
||||
}
|
||||
for (i = 0; i < this.length(); i += 1) {
|
||||
if (!snapEquals(this.contents[i], other.contents[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ((this.isLinked) && (other.isLinked)) {
|
||||
if (snapEquals(this.at(1), other.at(1))) {
|
||||
return this.cdr().equalTo(other.cdr());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (this.length() !== other.length()) {
|
||||
return false;
|
||||
}
|
||||
for (i = 0; i < this.length(); i += 1) {
|
||||
if (!snapEquals(this.at(i), other.at(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// ListWatcherMorph ////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
I am a little window which observes a list and continuously
|
||||
updates itself accordingly
|
||||
*/
|
||||
|
||||
// ListWatcherMorph inherits from BoxMorph:
|
||||
|
||||
ListWatcherMorph.prototype = new BoxMorph();
|
||||
ListWatcherMorph.prototype.constructor = ListWatcherMorph;
|
||||
ListWatcherMorph.uber = BoxMorph.prototype;
|
||||
|
||||
// ListWatcherMorph default settings
|
||||
|
||||
ListWatcherMorph.prototype.cellColor =
|
||||
SpriteMorph.prototype.blockColor.lists;
|
||||
|
||||
// ListWatcherMorph instance creation:
|
||||
|
||||
function ListWatcherMorph(list) {
|
||||
this.init(list);
|
||||
}
|
||||
|
||||
ListWatcherMorph.prototype.init = function (list) {
|
||||
var myself = this;
|
||||
|
||||
this.list = list || new List();
|
||||
this.start = 1;
|
||||
this.range = 100;
|
||||
this.lastUpdated = Date.now();
|
||||
this.lastCell = null;
|
||||
|
||||
// elements declarations
|
||||
this.label = new StringMorph(
|
||||
localize('length: ') + this.list.length(),
|
||||
SyntaxElementMorph.prototype.fontSize,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
new Point(1, 1),
|
||||
new Color(255, 255, 255)
|
||||
);
|
||||
this.label.mouseClickLeft = function () {myself.startIndexMenu(); };
|
||||
|
||||
|
||||
this.frame = new ScrollFrameMorph(null, 10);
|
||||
this.frame.alpha = 0;
|
||||
this.frame.acceptsDrops = false;
|
||||
this.frame.contents.acceptsDrops = false;
|
||||
|
||||
this.handle = new HandleMorph(
|
||||
this,
|
||||
80,
|
||||
70,
|
||||
3,
|
||||
3
|
||||
);
|
||||
this.handle.setExtent(new Point(13, 13));
|
||||
|
||||
this.arrow = new ArrowMorph(
|
||||
'down',
|
||||
SyntaxElementMorph.prototype.fontSize
|
||||
);
|
||||
this.arrow.mouseClickLeft = function () {myself.startIndexMenu(); };
|
||||
this.arrow.setRight(this.handle.right());
|
||||
this.arrow.setBottom(this.handle.top());
|
||||
this.handle.add(this.arrow);
|
||||
|
||||
this.plusButton = new PushButtonMorph(
|
||||
this.list,
|
||||
'add',
|
||||
'+'
|
||||
);
|
||||
this.plusButton.padding = 0;
|
||||
this.plusButton.edge = 0;
|
||||
this.plusButton.outlineColor = this.color;
|
||||
this.plusButton.drawNew();
|
||||
this.plusButton.fixLayout();
|
||||
|
||||
ListWatcherMorph.uber.init.call(
|
||||
this,
|
||||
SyntaxElementMorph.prototype.rounding,
|
||||
1.000001, // shadow bug in Chrome,
|
||||
new Color(120, 120, 120)
|
||||
);
|
||||
|
||||
this.color = new Color(220, 220, 220);
|
||||
this.isDraggable = true;
|
||||
this.setExtent(new Point(80, 70));
|
||||
this.add(this.label);
|
||||
this.add(this.frame);
|
||||
this.add(this.plusButton);
|
||||
this.add(this.handle);
|
||||
this.handle.drawNew();
|
||||
this.update();
|
||||
this.fixLayout();
|
||||
};
|
||||
|
||||
// ListWatcherMorph updating:
|
||||
|
||||
ListWatcherMorph.prototype.update = function (anyway) {
|
||||
var i, idx, ceil, morphs, cell, cnts, label, button, max,
|
||||
starttime, maxtime = 1000;
|
||||
|
||||
this.frame.contents.children.forEach(function (m) {
|
||||
if (m instanceof CellMorph
|
||||
&& m.contentsMorph instanceof ListWatcherMorph) {
|
||||
m.contentsMorph.update();
|
||||
}
|
||||
});
|
||||
|
||||
if (this.lastUpdated === this.list.lastChanged && !anyway) {
|
||||
return null;
|
||||
}
|
||||
|
||||
this.updateLength(true);
|
||||
|
||||
// adjust start index to current list length
|
||||
this.start = Math.max(
|
||||
Math.min(
|
||||
this.start,
|
||||
Math.floor((this.list.length() - 1) / this.range)
|
||||
* this.range + 1
|
||||
),
|
||||
1
|
||||
);
|
||||
|
||||
// refresh existing cells
|
||||
// highest index shown:
|
||||
max = Math.min(
|
||||
this.start + this.range - 1,
|
||||
this.list.length()
|
||||
);
|
||||
|
||||
// number of morphs available for refreshing
|
||||
ceil = Math.min(
|
||||
(max - this.start + 1) * 3,
|
||||
this.frame.contents.children.length
|
||||
);
|
||||
|
||||
for (i = 0; i < ceil; i += 3) {
|
||||
idx = this.start + (i / 3);
|
||||
|
||||
cell = this.frame.contents.children[i];
|
||||
label = this.frame.contents.children[i + 1];
|
||||
button = this.frame.contents.children[i + 2];
|
||||
cnts = this.list.at(idx);
|
||||
|
||||
if (cell.contents !== cnts) {
|
||||
cell.contents = cnts;
|
||||
cell.drawNew();
|
||||
if (this.lastCell) {
|
||||
cell.setLeft(this.lastCell.left());
|
||||
}
|
||||
}
|
||||
this.lastCell = cell;
|
||||
|
||||
if (label.text !== idx.toString()) {
|
||||
label.text = idx.toString();
|
||||
label.drawNew();
|
||||
}
|
||||
|
||||
button.action = idx;
|
||||
}
|
||||
|
||||
// remove excess cells
|
||||
// number of morphs to be shown
|
||||
morphs = (max - this.start + 1) * 3;
|
||||
|
||||
while (this.frame.contents.children.length > morphs) {
|
||||
this.frame.contents.children[morphs].destroy();
|
||||
}
|
||||
|
||||
// add additional cells
|
||||
ceil = morphs; //max * 3;
|
||||
i = this.frame.contents.children.length;
|
||||
|
||||
starttime = Date.now();
|
||||
if (ceil > i + 1) {
|
||||
for (i; i < ceil; i += 3) {
|
||||
if (Date.now() - starttime > maxtime) {
|
||||
this.fixLayout();
|
||||
this.frame.contents.adjustBounds();
|
||||
this.frame.contents.setLeft(this.frame.left());
|
||||
return null;
|
||||
}
|
||||
idx = this.start + (i / 3);
|
||||
label = new StringMorph(
|
||||
idx.toString(),
|
||||
SyntaxElementMorph.prototype.fontSize,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
new Point(1, 1),
|
||||
new Color(255, 255, 255)
|
||||
);
|
||||
cell = new CellMorph(
|
||||
this.list.at(idx),
|
||||
this.cellColor,
|
||||
idx
|
||||
);
|
||||
button = new PushButtonMorph(
|
||||
this.list.remove,
|
||||
idx,
|
||||
'-',
|
||||
this.list
|
||||
);
|
||||
button.padding = 1;
|
||||
button.edge = 0;
|
||||
button.corner = 1;
|
||||
button.outlineColor = this.color.darker();
|
||||
button.drawNew();
|
||||
button.fixLayout();
|
||||
|
||||
this.frame.contents.add(cell);
|
||||
if (this.lastCell) {
|
||||
cell.setPosition(this.lastCell.bottomLeft());
|
||||
} else {
|
||||
cell.setTop(this.frame.contents.top());
|
||||
}
|
||||
this.lastCell = cell;
|
||||
label.setCenter(cell.center());
|
||||
label.setRight(cell.left() - 2);
|
||||
this.frame.contents.add(label);
|
||||
this.frame.contents.add(button);
|
||||
}
|
||||
}
|
||||
this.lastCell = null;
|
||||
|
||||
this.fixLayout();
|
||||
this.frame.contents.adjustBounds();
|
||||
this.frame.contents.setLeft(this.frame.left());
|
||||
this.updateLength();
|
||||
this.lastUpdated = this.list.lastChanged;
|
||||
};
|
||||
|
||||
ListWatcherMorph.prototype.updateLength = function (notDone) {
|
||||
this.label.text = localize('length: ') + this.list.length();
|
||||
if (notDone) {
|
||||
this.label.color = new Color(0, 0, 100);
|
||||
} else {
|
||||
this.label.color = new Color(0, 0, 0);
|
||||
}
|
||||
this.label.drawNew();
|
||||
this.label.setCenter(this.center());
|
||||
this.label.setBottom(this.bottom() - 3);
|
||||
};
|
||||
|
||||
ListWatcherMorph.prototype.startIndexMenu = function () {
|
||||
var i,
|
||||
range,
|
||||
myself = this,
|
||||
items = Math.ceil(this.list.length() / this.range),
|
||||
menu = new MenuMorph(
|
||||
function (idx) {myself.setStartIndex(idx); },
|
||||
null,
|
||||
myself
|
||||
);
|
||||
menu.addItem('1...', 1);
|
||||
for (i = 1; i < items; i += 1) {
|
||||
range = i * 100 + 1;
|
||||
menu.addItem(range + '...', range);
|
||||
}
|
||||
menu.popUpAtHand(this.world());
|
||||
};
|
||||
|
||||
ListWatcherMorph.prototype.setStartIndex = function (index) {
|
||||
this.start = index;
|
||||
this.list.changed();
|
||||
};
|
||||
|
||||
ListWatcherMorph.prototype.fixLayout = function () {
|
||||
Morph.prototype.trackChanges = false;
|
||||
if (this.frame) {
|
||||
this.arrangeCells();
|
||||
this.frame.silentSetPosition(this.position().add(3));
|
||||
this.frame.bounds.corner = this.bounds.corner.subtract(new Point(
|
||||
3,
|
||||
17
|
||||
));
|
||||
this.frame.drawNew();
|
||||
this.frame.contents.adjustBounds();
|
||||
}
|
||||
|
||||
this.label.setCenter(this.center());
|
||||
this.label.setBottom(this.bottom() - 3);
|
||||
this.plusButton.setLeft(this.left() + 3);
|
||||
this.plusButton.setBottom(this.bottom() - 3);
|
||||
|
||||
Morph.prototype.trackChanges = true;
|
||||
this.changed();
|
||||
|
||||
if (this.parent && this.parent.fixLayout) {
|
||||
this.parent.fixLayout();
|
||||
}
|
||||
};
|
||||
|
||||
ListWatcherMorph.prototype.arrangeCells = function () {
|
||||
var i, cell, label, button, lastCell,
|
||||
end = this.frame.contents.children.length;
|
||||
for (i = 0; i < end; i += 3) {
|
||||
cell = this.frame.contents.children[i];
|
||||
label = this.frame.contents.children[i + 1];
|
||||
button = this.frame.contents.children[i + 2];
|
||||
if (lastCell) {
|
||||
cell.setTop(lastCell.bottom());
|
||||
}
|
||||
if (label) {
|
||||
label.setTop(cell.center().y - label.height() / 2);
|
||||
label.setRight(cell.left() - 2);
|
||||
}
|
||||
if (button) {
|
||||
button.setCenter(cell.center());
|
||||
button.setLeft(cell.right() + 2);
|
||||
}
|
||||
lastCell = cell;
|
||||
}
|
||||
this.frame.contents.adjustBounds();
|
||||
};
|
||||
|
||||
// ListWatcherMorph hiding/showing:
|
||||
|
||||
ListWatcherMorph.prototype.show = function () {
|
||||
ListWatcherMorph.uber.show.call(this);
|
||||
this.frame.contents.adjustBounds();
|
||||
};
|
||||
|
||||
// ListWatcherMorph drawing:
|
||||
|
||||
ListWatcherMorph.prototype.drawNew = function () {
|
||||
WatcherMorph.prototype.drawNew.call(this);
|
||||
this.fixLayout();
|
||||
};
|
Plik binarny nie jest wyświetlany.
|
@ -0,0 +1,14 @@
|
|||
CACHE MANIFEST
|
||||
snap.html
|
||||
blocks.js
|
||||
byob.js
|
||||
gui.js
|
||||
lists.js
|
||||
morphic.js
|
||||
objects.js
|
||||
threads.js
|
||||
widgets.js
|
||||
store.js
|
||||
xml.js
|
||||
scriptsPaneTexture.gif
|
||||
snap_logo_sm.gif
|
Plik diff jest za duży
Load Diff
Plik binarny nie jest wyświetlany.
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,20 @@
|
|||
readme - Snap! 4.0
|
||||
------------------
|
||||
|
||||
this document is just a stub as of now. For the first official release of Snap! 4.0 it will contain release notes covering the following issues:
|
||||
|
||||
saving, loading, exporting, importing
|
||||
|
||||
artefacts: projects, blocks, sprites
|
||||
|
||||
URL options: #run: #open:
|
||||
|
||||
supported browsers, problems with the Android virtual keyboard
|
||||
|
||||
supported browser / OS settings
|
||||
|
||||
SVG support limitations
|
||||
|
||||
OS/X: turn LCD font smoothing off
|
||||
|
||||
Beware of third-party Chrome toolbars and iFrames
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 155 B |
|
@ -0,0 +1,347 @@
|
|||
/*
|
||||
|
||||
sha512.js
|
||||
|
||||
encryption for SNAP!
|
||||
This file is derived from crypto-js.
|
||||
|
||||
© 2009–2012 by Jeff Mott. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation or other materials provided with the distribution.
|
||||
Neither the name CryptoJS nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS," AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
var hex_sha512 = (function (hex_sha512) {
|
||||
|
||||
var hexcase = 0;
|
||||
|
||||
function hex_sha512(s)
|
||||
{
|
||||
return CryptoJS.SHA512(str2rstr_utf8(s)).toString(CryptoJS.enc.Hex);
|
||||
}
|
||||
|
||||
function rstr_sha512(s)
|
||||
{
|
||||
return binb2rstr(binb_sha512(rstr2binb(s), s.length * 8));
|
||||
}
|
||||
|
||||
var CryptoJS=CryptoJS||function(a,g){var m={},e=m.lib={},q=e.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var d=new a;b&&d.mixIn(b);d.$super=this;return d},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var k in a)a.hasOwnProperty(k)&&(this[k]=a[k]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),r=e.WordArray=q.extend({init:function(a,b){a=
|
||||
this.words=a||[];this.sigBytes=b!=g?b:4*a.length},toString:function(a){return(a||n).stringify(this)},concat:function(a){var b=this.words,d=a.words,c=this.sigBytes,a=a.sigBytes;this.clamp();if(c%4)for(var i=0;i<a;i++)b[c+i>>>2]|=(d[i>>>2]>>>24-8*(i%4)&255)<<24-8*((c+i)%4);else if(65535<d.length)for(i=0;i<a;i+=4)b[c+i>>>2]=d[i>>>2];else b.push.apply(b,d);this.sigBytes+=a;return this},clamp:function(){var k=this.words,b=this.sigBytes;k[b>>>2]&=4294967295<<32-8*(b%4);k.length=a.ceil(b/4)},clone:function(){var a=
|
||||
q.clone.call(this);a.words=this.words.slice(0);return a},random:function(k){for(var b=[],d=0;d<k;d+=4)b.push(4294967296*a.random()|0);return r.create(b,k)}}),y=m.enc={},n=y.Hex={stringify:function(a){for(var b=a.words,a=a.sigBytes,d=[],c=0;c<a;c++){var i=b[c>>>2]>>>24-8*(c%4)&255;d.push((i>>>4).toString(16));d.push((i&15).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,d=[],c=0;c<b;c+=2)d[c>>>3]|=parseInt(a.substr(c,2),16)<<24-4*(c%8);return r.create(d,b/2)}},l=y.Latin1={stringify:function(a){for(var b=
|
||||
a.words,a=a.sigBytes,d=[],c=0;c<a;c++)d.push(String.fromCharCode(b[c>>>2]>>>24-8*(c%4)&255));return d.join("")},parse:function(a){for(var b=a.length,d=[],c=0;c<b;c++)d[c>>>2]|=(a.charCodeAt(c)&255)<<24-8*(c%4);return r.create(d,b)}},da=y.Utf8={stringify:function(a){try{return decodeURIComponent(escape(l.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return l.parse(unescape(encodeURIComponent(a)))}},h=e.BufferedBlockAlgorithm=q.extend({reset:function(){this._data=
|
||||
r.create();this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=da.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(k){var b=this._data,d=b.words,c=b.sigBytes,i=this.blockSize,l=c/(4*i),l=k?a.ceil(l):a.max((l|0)-this._minBufferSize,0),k=l*i,c=a.min(4*k,c);if(k){for(var h=0;h<k;h+=i)this._doProcessBlock(d,h);h=d.splice(0,k);b.sigBytes-=c}return r.create(h,c)},clone:function(){var a=q.clone.call(this);a._data=this._data.clone();return a},_minBufferSize:0});e.Hasher=
|
||||
h.extend({init:function(){this.reset()},reset:function(){h.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);this._doFinalize();return this._hash},clone:function(){var a=h.clone.call(this);a._hash=this._hash.clone();return a},blockSize:16,_createHelper:function(a){return function(b,d){return a.create(d).finalize(b)}},_createHmacHelper:function(a){return function(b,d){return ea.HMAC.create(a,d).finalize(b)}}});
|
||||
var ea=m.algo={};return m}(Math);
|
||||
(function(a){var g=CryptoJS,m=g.lib,e=m.Base,q=m.WordArray,g=g.x64={};g.Word=e.extend({init:function(a,e){this.high=a;this.low=e}});g.WordArray=e.extend({init:function(e,y){e=this.words=e||[];this.sigBytes=y!=a?y:8*e.length},toX32:function(){for(var a=this.words,e=a.length,n=[],l=0;l<e;l++){var g=a[l];n.push(g.high);n.push(g.low)}return q.create(n,this.sigBytes)},clone:function(){for(var a=e.clone.call(this),g=a.words=this.words.slice(0),n=g.length,l=0;l<n;l++)g[l]=g[l].clone();return a}})})();
|
||||
(function(){function a(){return q.create.apply(q,arguments)}var g=CryptoJS,m=g.lib.Hasher,e=g.x64,q=e.Word,r=e.WordArray,e=g.algo,y=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),
|
||||
a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,
|
||||
2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),
|
||||
a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,
|
||||
3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],n=[];(function(){for(var l=0;80>l;l++)n[l]=a()})();e=e.SHA512=m.extend({_doReset:function(){this._hash=r.create([a(1779033703,4089235720),a(3144134277,2227873595),a(1013904242,4271175723),a(2773480762,1595750129),a(1359893119,2917565137),a(2600822924,725511199),a(528734635,4215389547),a(1541459225,327033209)])},_doProcessBlock:function(a,e){for(var h=this._hash.words,g=h[0],k=h[1],b=h[2],d=h[3],c=h[4],i=h[5],m=
|
||||
h[6],h=h[7],q=g.high,r=g.low,W=k.high,K=k.low,X=b.high,L=b.low,Y=d.high,M=d.low,Z=c.high,N=c.low,$=i.high,O=i.low,aa=m.high,P=m.low,ba=h.high,Q=h.low,t=q,o=r,E=W,C=K,F=X,D=L,T=Y,G=M,u=Z,p=N,R=$,H=O,S=aa,I=P,U=ba,J=Q,v=0;80>v;v++){var z=n[v];if(16>v)var s=z.high=a[e+2*v]|0,f=z.low=a[e+2*v+1]|0;else{var s=n[v-15],f=s.high,w=s.low,s=(w<<31|f>>>1)^(w<<24|f>>>8)^f>>>7,w=(f<<31|w>>>1)^(f<<24|w>>>8)^(f<<25|w>>>7),B=n[v-2],f=B.high,j=B.low,B=(j<<13|f>>>19)^(f<<3|j>>>29)^f>>>6,j=(f<<13|j>>>19)^(j<<3|f>>>29)^
|
||||
(f<<26|j>>>6),f=n[v-7],V=f.high,A=n[v-16],x=A.high,A=A.low,f=w+f.low,s=s+V+(f>>>0<w>>>0?1:0),f=f+j,s=s+B+(f>>>0<j>>>0?1:0),f=f+A,s=s+x+(f>>>0<A>>>0?1:0);z.high=s;z.low=f}var V=u&R^~u&S,A=p&H^~p&I,z=t&E^t&F^E&F,fa=o&C^o&D^C&D,w=(o<<4|t>>>28)^(t<<30|o>>>2)^(t<<25|o>>>7),B=(t<<4|o>>>28)^(o<<30|t>>>2)^(o<<25|t>>>7),j=y[v],ga=j.high,ca=j.low,j=J+((u<<18|p>>>14)^(u<<14|p>>>18)^(p<<23|u>>>9)),x=U+((p<<18|u>>>14)^(p<<14|u>>>18)^(u<<23|p>>>9))+(j>>>0<J>>>0?1:0),j=j+A,x=x+V+(j>>>0<A>>>0?1:0),j=j+ca,x=x+ga+
|
||||
(j>>>0<ca>>>0?1:0),j=j+f,x=x+s+(j>>>0<f>>>0?1:0),f=B+fa,z=w+z+(f>>>0<B>>>0?1:0),U=S,J=I,S=R,I=H,R=u,H=p,p=G+j|0,u=T+x+(p>>>0<G>>>0?1:0)|0,T=F,G=D,F=E,D=C,E=t,C=o,o=j+f|0,t=x+z+(o>>>0<j>>>0?1:0)|0}r=g.low=r+o|0;g.high=q+t+(r>>>0<o>>>0?1:0)|0;K=k.low=K+C|0;k.high=W+E+(K>>>0<C>>>0?1:0)|0;L=b.low=L+D|0;b.high=X+F+(L>>>0<D>>>0?1:0)|0;M=d.low=M+G|0;d.high=Y+T+(M>>>0<G>>>0?1:0)|0;N=c.low=N+p|0;c.high=Z+u+(N>>>0<p>>>0?1:0)|0;O=i.low=O+H|0;i.high=$+R+(O>>>0<H>>>0?1:0)|0;P=m.low=P+I|0;m.high=aa+S+(P>>>0<I>>>
|
||||
0?1:0)|0;Q=h.low=Q+J|0;h.high=ba+U+(Q>>>0<J>>>0?1:0)|0},_doFinalize:function(){var a=this._data,e=a.words,h=8*this._nDataBytes,g=8*a.sigBytes;e[g>>>5]|=128<<24-g%32;e[(g+128>>>10<<5)+31]=h;a.sigBytes=4*e.length;this._process();this._hash=this._hash.toX32()},blockSize:32});g.SHA512=m._createHelper(e);g.HmacSHA512=m._createHmacHelper(e)})();
|
||||
|
||||
function rstr2hex(input)
|
||||
{
|
||||
try { hexcase } catch(e) { hexcase=0; }
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var output = "";
|
||||
var x;
|
||||
for(var i = 0; i < input.length; i++)
|
||||
{
|
||||
x = input.charCodeAt(i);
|
||||
output += hex_tab.charAt((x >>> 4) & 0x0F)
|
||||
+ hex_tab.charAt( x & 0x0F);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function str2rstr_utf8(input)
|
||||
{
|
||||
var output = "";
|
||||
var i = -1;
|
||||
var x, y;
|
||||
|
||||
while(++i < input.length)
|
||||
{
|
||||
x = input.charCodeAt(i);
|
||||
y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
|
||||
if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
|
||||
{
|
||||
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
|
||||
i++;
|
||||
}
|
||||
|
||||
if(x <= 0x7F)
|
||||
output += String.fromCharCode(x);
|
||||
else if(x <= 0x7FF)
|
||||
output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
|
||||
0x80 | ( x & 0x3F));
|
||||
else if(x <= 0xFFFF)
|
||||
output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
|
||||
0x80 | ((x >>> 6 ) & 0x3F),
|
||||
0x80 | ( x & 0x3F));
|
||||
else if(x <= 0x1FFFFF)
|
||||
output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
|
||||
0x80 | ((x >>> 12) & 0x3F),
|
||||
0x80 | ((x >>> 6 ) & 0x3F),
|
||||
0x80 | ( x & 0x3F));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function rstr2binb(input)
|
||||
{
|
||||
var output = Array(input.length >> 2);
|
||||
for(var i = 0; i < output.length; i++)
|
||||
output[i] = 0;
|
||||
for(var i = 0; i < input.length * 8; i += 8)
|
||||
output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
|
||||
return output;
|
||||
}
|
||||
|
||||
function binb2rstr(input)
|
||||
{
|
||||
var output = "";
|
||||
for(var i = 0; i < input.length * 32; i += 8)
|
||||
output += String.fromCharCode((input[i>>5] >>> (24 - i % 32)) & 0xFF);
|
||||
return output;
|
||||
}
|
||||
|
||||
var sha512_k;
|
||||
function binb_sha512(x, len)
|
||||
{
|
||||
if(sha512_k == undefined)
|
||||
{
|
||||
sha512_k = new Array(
|
||||
new int64(0x428a2f98, -685199838), new int64(0x71374491, 0x23ef65cd),
|
||||
new int64(-1245643825, -330482897), new int64(-373957723, -2121671748),
|
||||
new int64(0x3956c25b, -213338824), new int64(0x59f111f1, -1241133031),
|
||||
new int64(-1841331548, -1357295717), new int64(-1424204075, -630357736),
|
||||
new int64(-670586216, -1560083902), new int64(0x12835b01, 0x45706fbe),
|
||||
new int64(0x243185be, 0x4ee4b28c), new int64(0x550c7dc3, -704662302),
|
||||
new int64(0x72be5d74, -226784913), new int64(-2132889090, 0x3b1696b1),
|
||||
new int64(-1680079193, 0x25c71235), new int64(-1046744716, -815192428),
|
||||
new int64(-459576895, -1628353838), new int64(-272742522, 0x384f25e3),
|
||||
new int64(0xfc19dc6, -1953704523), new int64(0x240ca1cc, 0x77ac9c65),
|
||||
new int64(0x2de92c6f, 0x592b0275), new int64(0x4a7484aa, 0x6ea6e483),
|
||||
new int64(0x5cb0a9dc, -1119749164), new int64(0x76f988da, -2096016459),
|
||||
new int64(-1740746414, -295247957), new int64(-1473132947, 0x2db43210),
|
||||
new int64(-1341970488, -1728372417), new int64(-1084653625, -1091629340),
|
||||
new int64(-958395405, 0x3da88fc2), new int64(-710438585, -1828018395),
|
||||
new int64(0x6ca6351, -536640913), new int64(0x14292967, 0xa0e6e70),
|
||||
new int64(0x27b70a85, 0x46d22ffc), new int64(0x2e1b2138, 0x5c26c926),
|
||||
new int64(0x4d2c6dfc, 0x5ac42aed), new int64(0x53380d13, -1651133473),
|
||||
new int64(0x650a7354, -1951439906), new int64(0x766a0abb, 0x3c77b2a8),
|
||||
new int64(-2117940946, 0x47edaee6), new int64(-1838011259, 0x1482353b),
|
||||
new int64(-1564481375, 0x4cf10364), new int64(-1474664885, -1136513023),
|
||||
new int64(-1035236496, -789014639), new int64(-949202525, 0x654be30),
|
||||
new int64(-778901479, -688958952), new int64(-694614492, 0x5565a910),
|
||||
new int64(-200395387, 0x5771202a), new int64(0x106aa070, 0x32bbd1b8),
|
||||
new int64(0x19a4c116, -1194143544), new int64(0x1e376c08, 0x5141ab53),
|
||||
new int64(0x2748774c, -544281703), new int64(0x34b0bcb5, -509917016),
|
||||
new int64(0x391c0cb3, -976659869), new int64(0x4ed8aa4a, -482243893),
|
||||
new int64(0x5b9cca4f, 0x7763e373), new int64(0x682e6ff3, -692930397),
|
||||
new int64(0x748f82ee, 0x5defb2fc), new int64(0x78a5636f, 0x43172f60),
|
||||
new int64(-2067236844, -1578062990), new int64(-1933114872, 0x1a6439ec),
|
||||
new int64(-1866530822, 0x23631e28), new int64(-1538233109, -561857047),
|
||||
new int64(-1090935817, -1295615723), new int64(-965641998, -479046869),
|
||||
new int64(-903397682, -366583396), new int64(-779700025, 0x21c0c207),
|
||||
new int64(-354779690, -840897762), new int64(-176337025, -294727304),
|
||||
new int64(0x6f067aa, 0x72176fba), new int64(0xa637dc5, -1563912026),
|
||||
new int64(0x113f9804, -1090974290), new int64(0x1b710b35, 0x131c471b),
|
||||
new int64(0x28db77f5, 0x23047d84), new int64(0x32caab7b, 0x40c72493),
|
||||
new int64(0x3c9ebe0a, 0x15c9bebc), new int64(0x431d67c4, -1676669620),
|
||||
new int64(0x4cc5d4be, -885112138), new int64(0x597f299c, -60457430),
|
||||
new int64(0x5fcb6fab, 0x3ad6faec), new int64(0x6c44198c, 0x4a475817));
|
||||
}
|
||||
|
||||
var H = new Array(
|
||||
new int64(0x6a09e667, -205731576),
|
||||
new int64(-1150833019, -2067093701),
|
||||
new int64(0x3c6ef372, -23791573),
|
||||
new int64(-1521486534, 0x5f1d36f1),
|
||||
new int64(0x510e527f, -1377402159),
|
||||
new int64(-1694144372, 0x2b3e6c1f),
|
||||
new int64(0x1f83d9ab, -79577749),
|
||||
new int64(0x5be0cd19, 0x137e2179));
|
||||
|
||||
var T1 = new int64(0, 0),
|
||||
T2 = new int64(0, 0),
|
||||
a = new int64(0,0),
|
||||
b = new int64(0,0),
|
||||
c = new int64(0,0),
|
||||
d = new int64(0,0),
|
||||
e = new int64(0,0),
|
||||
f = new int64(0,0),
|
||||
g = new int64(0,0),
|
||||
h = new int64(0,0),
|
||||
|
||||
s0 = new int64(0, 0),
|
||||
s1 = new int64(0, 0),
|
||||
Ch = new int64(0, 0),
|
||||
Maj = new int64(0, 0),
|
||||
r1 = new int64(0, 0),
|
||||
r2 = new int64(0, 0),
|
||||
r3 = new int64(0, 0);
|
||||
var j, i;
|
||||
var W = new Array(80);
|
||||
for(i=0; i<80; i++)
|
||||
W[i] = new int64(0, 0);
|
||||
|
||||
x[len >> 5] |= 0x80 << (24 - (len & 0x1f));
|
||||
x[((len + 128 >> 10)<< 5) + 31] = len;
|
||||
|
||||
for(i = 0; i<x.length; i+=32)
|
||||
{
|
||||
int64copy(a, H[0]);
|
||||
int64copy(b, H[1]);
|
||||
int64copy(c, H[2]);
|
||||
int64copy(d, H[3]);
|
||||
int64copy(e, H[4]);
|
||||
int64copy(f, H[5]);
|
||||
int64copy(g, H[6]);
|
||||
int64copy(h, H[7]);
|
||||
|
||||
for(j=0; j<16; j++)
|
||||
{
|
||||
W[j].h = x[i + 2*j];
|
||||
W[j].l = x[i + 2*j + 1];
|
||||
}
|
||||
|
||||
for(j=16; j<80; j++)
|
||||
{
|
||||
int64rrot(r1, W[j-2], 19);
|
||||
int64revrrot(r2, W[j-2], 29);
|
||||
int64shr(r3, W[j-2], 6);
|
||||
s1.l = r1.l ^ r2.l ^ r3.l;
|
||||
s1.h = r1.h ^ r2.h ^ r3.h;
|
||||
int64rrot(r1, W[j-15], 1);
|
||||
int64rrot(r2, W[j-15], 8);
|
||||
int64shr(r3, W[j-15], 7);
|
||||
s0.l = r1.l ^ r2.l ^ r3.l;
|
||||
s0.h = r1.h ^ r2.h ^ r3.h;
|
||||
|
||||
int64add4(W[j], s1, W[j-7], s0, W[j-16]);
|
||||
}
|
||||
|
||||
for(j = 0; j < 80; j++)
|
||||
{
|
||||
Ch.l = (e.l & f.l) ^ (~e.l & g.l);
|
||||
Ch.h = (e.h & f.h) ^ (~e.h & g.h);
|
||||
|
||||
int64rrot(r1, e, 14);
|
||||
int64rrot(r2, e, 18);
|
||||
int64revrrot(r3, e, 9);
|
||||
s1.l = r1.l ^ r2.l ^ r3.l;
|
||||
s1.h = r1.h ^ r2.h ^ r3.h;
|
||||
int64rrot(r1, a, 28);
|
||||
int64revrrot(r2, a, 2);
|
||||
int64revrrot(r3, a, 7);
|
||||
s0.l = r1.l ^ r2.l ^ r3.l;
|
||||
s0.h = r1.h ^ r2.h ^ r3.h;
|
||||
|
||||
Maj.l = (a.l & b.l) ^ (a.l & c.l) ^ (b.l & c.l);
|
||||
Maj.h = (a.h & b.h) ^ (a.h & c.h) ^ (b.h & c.h);
|
||||
|
||||
int64add5(T1, h, s1, Ch, sha512_k[j], W[j]);
|
||||
int64add(T2, s0, Maj);
|
||||
|
||||
int64copy(h, g);
|
||||
int64copy(g, f);
|
||||
int64copy(f, e);
|
||||
int64add(e, d, T1);
|
||||
int64copy(d, c);
|
||||
int64copy(c, b);
|
||||
int64copy(b, a);
|
||||
int64add(a, T1, T2);
|
||||
}
|
||||
int64add(H[0], H[0], a);
|
||||
int64add(H[1], H[1], b);
|
||||
int64add(H[2], H[2], c);
|
||||
int64add(H[3], H[3], d);
|
||||
int64add(H[4], H[4], e);
|
||||
int64add(H[5], H[5], f);
|
||||
int64add(H[6], H[6], g);
|
||||
int64add(H[7], H[7], h);
|
||||
}
|
||||
|
||||
var hash = new Array(16);
|
||||
for(i=0; i<8; i++)
|
||||
{
|
||||
hash[2*i] = H[i].h;
|
||||
hash[2*i + 1] = H[i].l;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
function int64(h, l)
|
||||
{
|
||||
this.h = h;
|
||||
this.l = l;
|
||||
}
|
||||
|
||||
function int64copy(dst, src)
|
||||
{
|
||||
dst.h = src.h;
|
||||
dst.l = src.l;
|
||||
}
|
||||
|
||||
function int64rrot(dst, x, shift)
|
||||
{
|
||||
dst.l = (x.l >>> shift) | (x.h << (32-shift));
|
||||
dst.h = (x.h >>> shift) | (x.l << (32-shift));
|
||||
}
|
||||
|
||||
function int64revrrot(dst, x, shift)
|
||||
{
|
||||
dst.l = (x.h >>> shift) | (x.l << (32-shift));
|
||||
dst.h = (x.l >>> shift) | (x.h << (32-shift));
|
||||
}
|
||||
|
||||
function int64shr(dst, x, shift)
|
||||
{
|
||||
dst.l = (x.l >>> shift) | (x.h << (32-shift));
|
||||
dst.h = (x.h >>> shift);
|
||||
}
|
||||
|
||||
function int64add(dst, x, y)
|
||||
{
|
||||
var w0 = (x.l & 0xffff) + (y.l & 0xffff);
|
||||
var w1 = (x.l >>> 16) + (y.l >>> 16) + (w0 >>> 16);
|
||||
var w2 = (x.h & 0xffff) + (y.h & 0xffff) + (w1 >>> 16);
|
||||
var w3 = (x.h >>> 16) + (y.h >>> 16) + (w2 >>> 16);
|
||||
dst.l = (w0 & 0xffff) | (w1 << 16);
|
||||
dst.h = (w2 & 0xffff) | (w3 << 16);
|
||||
}
|
||||
|
||||
function int64add4(dst, a, b, c, d)
|
||||
{
|
||||
var w0 = (a.l & 0xffff) + (b.l & 0xffff) + (c.l & 0xffff) + (d.l & 0xffff);
|
||||
var w1 = (a.l >>> 16) + (b.l >>> 16) + (c.l >>> 16) + (d.l >>> 16) + (w0 >>> 16);
|
||||
var w2 = (a.h & 0xffff) + (b.h & 0xffff) + (c.h & 0xffff) + (d.h & 0xffff) + (w1 >>> 16);
|
||||
var w3 = (a.h >>> 16) + (b.h >>> 16) + (c.h >>> 16) + (d.h >>> 16) + (w2 >>> 16);
|
||||
dst.l = (w0 & 0xffff) | (w1 << 16);
|
||||
dst.h = (w2 & 0xffff) | (w3 << 16);
|
||||
}
|
||||
|
||||
function int64add5(dst, a, b, c, d, e)
|
||||
{
|
||||
var w0 = (a.l & 0xffff) + (b.l & 0xffff) + (c.l & 0xffff) + (d.l & 0xffff) + (e.l & 0xffff);
|
||||
var w1 = (a.l >>> 16) + (b.l >>> 16) + (c.l >>> 16) + (d.l >>> 16) + (e.l >>> 16) + (w0 >>> 16);
|
||||
var w2 = (a.h & 0xffff) + (b.h & 0xffff) + (c.h & 0xffff) + (d.h & 0xffff) + (e.h & 0xffff) + (w1 >>> 16);
|
||||
var w3 = (a.h >>> 16) + (b.h >>> 16) + (c.h >>> 16) + (d.h >>> 16) + (e.h >>> 16) + (w2 >>> 16);
|
||||
dst.l = (w0 & 0xffff) | (w1 << 16);
|
||||
dst.h = (w2 & 0xffff) | (w3 << 16);
|
||||
}
|
||||
|
||||
return hex_sha512;
|
||||
|
||||
})({});
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Snap! Build Your Own Blocks. Beta</title>
|
||||
<link rel="shortcut icon" href="http://snap.berkeley.edu/fav3.gif" type="image/gif">
|
||||
<script type="text/javascript" src="morphic.js"></script>
|
||||
<script type="text/javascript" src="widgets.js"></script>
|
||||
<script type="text/javascript" src="blocks.js"></script>
|
||||
<script type="text/javascript" src="threads.js"></script>
|
||||
<script type="text/javascript" src="objects.js"></script>
|
||||
<script type="text/javascript" src="gui.js"></script>
|
||||
<script type="text/javascript" src="lists.js"></script>
|
||||
<script type="text/javascript" src="byob.js"></script>
|
||||
<script type="text/javascript" src="xml.js"></script>
|
||||
<script type="text/javascript" src="store.js"></script>
|
||||
<script type="text/javascript" src="locale.js"></script>
|
||||
<script type="text/javascript" src="cloud.js"></script>
|
||||
<script type="text/javascript" src="sha512.js"></script>
|
||||
<script type="text/javascript">
|
||||
var world;
|
||||
window.onload = function () {
|
||||
world = new WorldMorph(document.getElementById('world'));
|
||||
new IDE_Morph().openIn(world);
|
||||
setInterval(loop, 1);
|
||||
};
|
||||
function loop() {
|
||||
world.doOneCycle();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body style="background-color: #282828; margin: 0;">
|
||||
<canvas id="world" tabindex="1" width="800" height="600" style="position: absolute;">
|
||||
<p>Your browser doesn't support canvas.</p>
|
||||
</canvas>
|
||||
</body>
|
||||
</html>
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 1.3 KiB |
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,143 @@
|
|||
*****************************
|
||||
Translating BYOB4 / Snap!
|
||||
by Jens Moenig
|
||||
last changed: 12/10/16
|
||||
*****************************
|
||||
|
||||
At this stage of development, Snap! can be translated to any LTR language
|
||||
maintaining the current order of inputs (formal parameters in blocks).
|
||||
|
||||
Translating Snap! is easy:
|
||||
|
||||
|
||||
1. Download
|
||||
|
||||
Download the sources and extract them into a local folder on your
|
||||
computer:
|
||||
|
||||
<http://snap.berkeley.edu/snapsource/snap.zip>
|
||||
|
||||
Use the German translation file (named 'lang-de.js') as template for your
|
||||
own translations. Start with editing the original file, because that way
|
||||
you will be able to immediately check the results in your browsers while
|
||||
you're working on your translation (keep the local copy of snap.html open
|
||||
in your web browser, and refresh it as you progress with your
|
||||
translation).
|
||||
|
||||
|
||||
2. Edit
|
||||
|
||||
Edit the translation file with a regular text editor, or with your
|
||||
favorite JavaScript editor.
|
||||
|
||||
In the first non-commented line (the one right below this
|
||||
note) replace "de" with the two-letter ISO 639-1 code for your language,
|
||||
e.g.
|
||||
|
||||
fr - French => SnapTranslator.dict.fr = {
|
||||
it - Italian => SnapTranslator.dict.it = {
|
||||
pl - Polish => SnapTranslator.dict.pl = {
|
||||
pt - Portuguese => SnapTranslator.dict.pt = {
|
||||
es - Spanish => SnapTranslator.dict.es = {
|
||||
el - Greek => => SnapTranslator.dict.el = {
|
||||
|
||||
etc. (see <http://en.wikipedia.org/wiki/ISO_639-1>)
|
||||
|
||||
|
||||
3. Translate
|
||||
|
||||
Then work through the dictionary, replacing the German strings against
|
||||
your translations. The dictionary is a straight-forward JavaScript ad-hoc
|
||||
object, for review purposes it should be formatted as follows:
|
||||
|
||||
{
|
||||
'English string':
|
||||
'Translation string',
|
||||
'last key':
|
||||
} 'last value'
|
||||
|
||||
and you only edit the indented value strings. Note that each key-value
|
||||
pair needs to be delimited by a comma, but that there shouldn't be a comma
|
||||
after the last pair (again, just overwrite the template file and you'll be
|
||||
fine).
|
||||
|
||||
If something doesn't work, or if you're unsure about the formalities you
|
||||
should check your file with
|
||||
|
||||
<http://JSLint.com>
|
||||
|
||||
This will inform you about any missed commas etc.
|
||||
|
||||
|
||||
4. Accented characters
|
||||
|
||||
Depending on which text editor and which file encoding you use you can
|
||||
directly enter special characters (e.g. Umlaut, accented characters) on
|
||||
your keyboard. However, I've noticed that some browsers may not display
|
||||
special characters correctly, even if other browsers do. So it's best to
|
||||
check your results in several browsers. If you want to be on the safe
|
||||
side, it's even better to escape these characters using Unicode.
|
||||
|
||||
see: <http://0xcc.net/jsescape/>
|
||||
|
||||
|
||||
5. Block specs:
|
||||
|
||||
At this time your translation of block specs will only work
|
||||
correctly, if the order of formal parameters and their types
|
||||
are unchanged. Placeholders for inputs (formal parameters) are
|
||||
indicated by a preceding % prefix and followed by a type
|
||||
abbreviation.
|
||||
|
||||
For example:
|
||||
|
||||
'say %s for %n secs'
|
||||
|
||||
can currently not be changed into
|
||||
|
||||
'say %n secs long %s'
|
||||
|
||||
and still work as intended.
|
||||
|
||||
Similarly
|
||||
|
||||
'point towards %dst'
|
||||
|
||||
cannot be changed into
|
||||
|
||||
'point towards %cst'
|
||||
|
||||
without breaking its functionality.
|
||||
|
||||
|
||||
6. Submit
|
||||
|
||||
When you're done, rename the edited file by replacing the "de" part of the
|
||||
filename with the two-letter ISO 639-1 code for your language, e.g.
|
||||
|
||||
fr - French => lang-fr.js
|
||||
it - Italian => lang-it.js
|
||||
pl - Polish => lang-pl.js
|
||||
pt - Portuguese => lang-pt.js
|
||||
es - Spanish => lang-es.js
|
||||
el - Greek => => lang-el.js
|
||||
|
||||
and send it to me for inclusion in the official Snap! distribution.
|
||||
Once your translation has been included, Your name will the shown in the
|
||||
"Translators" tab in the "About Snap!" dialog box, and you will be able to
|
||||
directly launch a translated version of Snap! in your browser by appending
|
||||
|
||||
lang:xx
|
||||
|
||||
to the URL, xx representing your translations two-letter code.
|
||||
|
||||
|
||||
7. Known issues
|
||||
|
||||
In some browsers accents or ornaments located in typographic ascenders
|
||||
above the cap height are currently (partially) cut-off.
|
||||
|
||||
|
||||
|
||||
Enjoy!
|
||||
-Jens
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,428 @@
|
|||
/*
|
||||
|
||||
xml.js
|
||||
|
||||
a simple XML DOM, encoder and parser for morphic.js
|
||||
|
||||
written by Jens Mšnig
|
||||
jens@moenig.org
|
||||
|
||||
Copyright (C) 2013 by Jens Mšnig
|
||||
|
||||
This file is part of Snap!.
|
||||
|
||||
Snap! is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
prerequisites:
|
||||
--------------
|
||||
needs morphic.js
|
||||
|
||||
|
||||
hierarchy
|
||||
---------
|
||||
the following tree lists all constructors hierarchically,
|
||||
indentation indicating inheritance. Refer to this list to get a
|
||||
contextual overview:
|
||||
|
||||
Node*
|
||||
XML_Element
|
||||
ReadStream
|
||||
|
||||
* defined in morphic.js
|
||||
|
||||
|
||||
toc
|
||||
---
|
||||
the following list shows the order in which all constructors are
|
||||
defined. Use this list to locate code in this document:
|
||||
|
||||
ReadStream
|
||||
XML_Element
|
||||
|
||||
|
||||
credits
|
||||
-------
|
||||
Nathan Dinsmore contributed to the design and implemented a first
|
||||
working version of a complete XMLSerializer. I have taken much of the
|
||||
overall design and many of the functions and methods in this file from
|
||||
Nathan's fine original prototype.
|
||||
|
||||
*/
|
||||
|
||||
/*global modules, isString, detect, Node, isNil*/
|
||||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.xml = '2013-February-18';
|
||||
|
||||
// Declarations
|
||||
|
||||
var ReadStream;
|
||||
var XML_Element;
|
||||
|
||||
// ReadStream ////////////////////////////////////////////////////////////
|
||||
|
||||
// I am a sequential reading interface to an Array or String
|
||||
|
||||
// ReadStream instance creation:
|
||||
|
||||
function ReadStream(arrayOrString) {
|
||||
this.contents = arrayOrString || '';
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
// ReadStream constants:
|
||||
|
||||
ReadStream.prototype.space = /[\s]/;
|
||||
|
||||
// ReadStream accessing:
|
||||
|
||||
ReadStream.prototype.next = function (count) {
|
||||
var element;
|
||||
if (count === undefined) {
|
||||
element = this.contents[this.index];
|
||||
this.index += 1;
|
||||
return element;
|
||||
}
|
||||
return this.contents.slice(this.index, this.index += count);
|
||||
};
|
||||
|
||||
ReadStream.prototype.peek = function () {
|
||||
return this.contents[this.index];
|
||||
};
|
||||
|
||||
ReadStream.prototype.skip = function (count) {
|
||||
this.index += count || 1;
|
||||
};
|
||||
|
||||
ReadStream.prototype.atEnd = function () {
|
||||
return this.index > (this.contents.length - 1);
|
||||
};
|
||||
|
||||
// ReadStream accessing String contents:
|
||||
|
||||
ReadStream.prototype.upTo = function (regex) {
|
||||
if (!isString(this.contents)) {return ''; }
|
||||
var i = this.contents.substr(this.index).search(regex);
|
||||
if (i === -1) {
|
||||
return '';
|
||||
}
|
||||
return this.contents.substring(this.index, this.index += i);
|
||||
};
|
||||
|
||||
ReadStream.prototype.peekUpTo = function (regex) {
|
||||
if (!isString(this.contents)) {return ''; }
|
||||
var i = this.contents.substr(this.index).search(regex);
|
||||
if (i === -1) {
|
||||
return '';
|
||||
}
|
||||
return this.contents.substring(this.index, this.index + i);
|
||||
};
|
||||
|
||||
ReadStream.prototype.skipSpace = function () {
|
||||
if (!isString(this.contents)) {return ''; }
|
||||
var ch;
|
||||
while (this.space.test(ch = this.peek()) && ch !== '') {
|
||||
this.skip();
|
||||
}
|
||||
};
|
||||
|
||||
ReadStream.prototype.word = function () {
|
||||
if (!isString(this.contents)) {return ''; }
|
||||
var i = this.contents.substr(this.index).search(/[\s\>\/\=]|$/);
|
||||
if (i === -1) {
|
||||
return '';
|
||||
}
|
||||
return this.contents.substring(this.index, this.index += i);
|
||||
};
|
||||
|
||||
// XML_Element ///////////////////////////////////////////////////////////
|
||||
/*
|
||||
I am a DOM-Node which can encode itself to as well as parse itself
|
||||
from a well-formed XML string. Note that there is no separate parser
|
||||
object, all the parsing can be done in a single object.
|
||||
*/
|
||||
|
||||
// XML_Element inherits from Node:
|
||||
|
||||
XML_Element.prototype = new Node();
|
||||
XML_Element.prototype.constructor = XML_Element;
|
||||
XML_Element.uber = Node.prototype;
|
||||
|
||||
// XML_Element preferences settings:
|
||||
|
||||
XML_Element.prototype.indentation = ' ';
|
||||
|
||||
// XML_Element instance creation:
|
||||
|
||||
function XML_Element(tag, contents, parent) {
|
||||
this.init(tag, contents, parent);
|
||||
}
|
||||
|
||||
XML_Element.prototype.init = function (tag, contents, parent) {
|
||||
// additional properties:
|
||||
this.tag = tag || 'unnamed';
|
||||
this.attributes = {};
|
||||
this.contents = contents || '';
|
||||
|
||||
// initialize inherited properties:
|
||||
XML_Element.uber.init.call(this);
|
||||
|
||||
// override inherited properties
|
||||
if (parent instanceof XML_Element) {
|
||||
parent.addChild(this);
|
||||
}
|
||||
};
|
||||
|
||||
// XML_Element DOM navigation: (aside from what's inherited from Node)
|
||||
|
||||
XML_Element.prototype.require = function (tagName) {
|
||||
// answer the first direct child with the specified tagName, or throw
|
||||
// an error if it doesn't exist
|
||||
var child = this.childNamed(tagName);
|
||||
if (!child) {
|
||||
throw new Error('Missing required element <' + tagName + '>!');
|
||||
}
|
||||
return child;
|
||||
};
|
||||
|
||||
XML_Element.prototype.childNamed = function (tagName) {
|
||||
// answer the first direct child with the specified tagName, or null
|
||||
return detect(
|
||||
this.children,
|
||||
function (child) {return child.tag === tagName; }
|
||||
);
|
||||
};
|
||||
|
||||
XML_Element.prototype.childrenNamed = function (tagName) {
|
||||
// answer all direct children with the specified tagName
|
||||
return this.children.filter(
|
||||
function (child) {return child.tag === tagName; }
|
||||
);
|
||||
};
|
||||
|
||||
XML_Element.prototype.parentNamed = function (tagName) {
|
||||
// including myself
|
||||
if (this.tag === tagName) {
|
||||
return this;
|
||||
}
|
||||
if (!this.parent) {
|
||||
return null;
|
||||
}
|
||||
return this.parent.parentNamed(tagName);
|
||||
};
|
||||
|
||||
// XML_Element output:
|
||||
|
||||
XML_Element.prototype.toString = function (isFormatted, indentationLevel) {
|
||||
var result = '',
|
||||
indent = '',
|
||||
level = indentationLevel || 0,
|
||||
key,
|
||||
i;
|
||||
|
||||
// spaces for indentation, if any
|
||||
if (isFormatted) {
|
||||
for (i = 0; i < level; i += 1) {
|
||||
indent += this.indentation;
|
||||
}
|
||||
result += indent;
|
||||
}
|
||||
|
||||
// opening tag
|
||||
result += ('<' + this.tag);
|
||||
|
||||
// attributes, if any
|
||||
for (key in this.attributes) {
|
||||
if (this.attributes.hasOwnProperty(key) && this.attributes[key]) {
|
||||
result += ' ' + key + '="' + this.attributes[key] + '"';
|
||||
}
|
||||
}
|
||||
|
||||
// contents, subnodes, and closing tag
|
||||
if (!this.contents.length && !this.children.length) {
|
||||
result += '/>';
|
||||
} else {
|
||||
result += '>';
|
||||
result += this.contents;
|
||||
this.children.forEach(function (element) {
|
||||
if (isFormatted) {
|
||||
result += '\n';
|
||||
}
|
||||
result += element.toString(isFormatted, level + 1);
|
||||
});
|
||||
if (isFormatted && this.children.length) {
|
||||
result += ('\n' + indent);
|
||||
}
|
||||
result += '</' + this.tag + '>';
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
XML_Element.prototype.escape = function (string, ignoreQuotes) {
|
||||
var src = isNil(string) ? '' : string.toString(),
|
||||
result = '',
|
||||
i,
|
||||
ch;
|
||||
for (i = 0; i < src.length; i += 1) {
|
||||
ch = src[i];
|
||||
switch (ch) {
|
||||
case '\'':
|
||||
result += ''';
|
||||
break;
|
||||
case '\"':
|
||||
result += ignoreQuotes ? ch : '"';
|
||||
break;
|
||||
case '<':
|
||||
result += '<';
|
||||
break;
|
||||
case '>':
|
||||
result += '>';
|
||||
break;
|
||||
case '&':
|
||||
result += '&';
|
||||
break;
|
||||
case '\n': // escape CR b/c of export to URL feature
|
||||
result += '
';
|
||||
break;
|
||||
case '~': // escape tilde b/c it's overloaded in serializer.store()
|
||||
result += '~';
|
||||
break;
|
||||
default:
|
||||
result += ch;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
XML_Element.prototype.unescape = function (string) {
|
||||
var stream = new ReadStream(string),
|
||||
result = '',
|
||||
ch,
|
||||
esc;
|
||||
|
||||
function nextPut(str) {
|
||||
result += str;
|
||||
stream.upTo(';');
|
||||
stream.skip();
|
||||
}
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
ch = stream.next();
|
||||
if (ch === '&') {
|
||||
esc = stream.peekUpTo(';');
|
||||
switch (esc) {
|
||||
case 'apos':
|
||||
nextPut('\'');
|
||||
break;
|
||||
case 'quot':
|
||||
nextPut('\"');
|
||||
break;
|
||||
case 'lt':
|
||||
nextPut('<');
|
||||
break;
|
||||
case 'gt':
|
||||
nextPut('>');
|
||||
break;
|
||||
case 'amp':
|
||||
nextPut('&');
|
||||
break;
|
||||
case '#xD':
|
||||
nextPut('\n');
|
||||
break;
|
||||
case '#126':
|
||||
nextPut('~');
|
||||
break;
|
||||
default:
|
||||
result += ch;
|
||||
}
|
||||
} else {
|
||||
result += ch;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// XML_Element parsing:
|
||||
|
||||
XML_Element.prototype.parseString = function (string) {
|
||||
var stream = new ReadStream(string);
|
||||
stream.upTo('<');
|
||||
stream.skip();
|
||||
this.parseStream(stream);
|
||||
};
|
||||
|
||||
XML_Element.prototype.parseStream = function (stream) {
|
||||
var key,
|
||||
value,
|
||||
ch,
|
||||
child;
|
||||
|
||||
// tag:
|
||||
this.tag = stream.word();
|
||||
stream.skipSpace();
|
||||
|
||||
// attributes:
|
||||
while ((ch = stream.peek()) !== '>' && ch !== '/') {
|
||||
key = stream.word();
|
||||
stream.skipSpace();
|
||||
if (stream.next() !== '=') {
|
||||
throw new Error('Expected "=" after attribute name');
|
||||
}
|
||||
stream.skipSpace();
|
||||
if ((ch = stream.next()) !== '"' && ch !== "'") {
|
||||
throw new Error(
|
||||
'Expected single- or double-quoted attribute value'
|
||||
);
|
||||
}
|
||||
value = stream.upTo(ch);
|
||||
stream.skip(1);
|
||||
stream.skipSpace();
|
||||
this.attributes[key] = this.unescape(value);
|
||||
}
|
||||
|
||||
// empty tag:
|
||||
if (stream.peek() === '/') {
|
||||
stream.skip();
|
||||
if (stream.next() !== '>') {
|
||||
throw new Error('Expected ">" after "/" in empty tag');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (stream.next() !== '>') {
|
||||
throw new Error('Expected ">" after tag name and attributes');
|
||||
}
|
||||
|
||||
// contents and children
|
||||
while (!stream.atEnd()) {
|
||||
ch = stream.next();
|
||||
if (ch === '<') {
|
||||
if (stream.peek() === '/') { // closing tag
|
||||
stream.skip();
|
||||
if (stream.word() !== this.tag) {
|
||||
throw new Error('Expected to close ' + this.tag);
|
||||
}
|
||||
stream.upTo('>');
|
||||
stream.skip();
|
||||
this.contents = this.unescape(this.contents);
|
||||
return;
|
||||
}
|
||||
child = new XML_Element(null, null, this);
|
||||
child.parseStream(stream);
|
||||
} else {
|
||||
this.contents += ch;
|
||||
}
|
||||
}
|
||||
};
|
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue