initial, based on v1.2.5
3
.hgignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
syntax: glob
|
||||
src/db/todolist.db
|
||||
src/tmp/sessions/sess*
|
||||
48
src/COPYRIGHT
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
myTinyTodo is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
myTinyTodo is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
See file LICENSE or <http://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
|
||||
myTinyTodo
|
||||
--------------
|
||||
Url: http://www.pozdeev.com/mytinytodo/
|
||||
Copyright: 2009 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
License: GPL version 3 (see LICENSE file)
|
||||
|
||||
|
||||
myTinyTodo uses other works:
|
||||
|
||||
jQuery
|
||||
--------------
|
||||
Url: http://jquery.com/
|
||||
Copyright: 2009 John Resig <jeresig@gmail.com>
|
||||
License: Dual licensed under the MIT and GPL version 2 licenses (see http://docs.jquery.com/License)
|
||||
|
||||
jQuery UI
|
||||
--------------
|
||||
Url: http://jqueryui.com/
|
||||
Copyright: 2009 jQuery UI Authors (see http://jqueryui.com/about)
|
||||
License: Dual licensed under the MIT and GPL version 2 licenses (see http://jqueryui.com/about)
|
||||
|
||||
Autocomplete - jQuery plugin
|
||||
------------------------------
|
||||
Url: http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
|
||||
Copyright: 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
|
||||
License: Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
|
||||
Images based on Silk Icons set (see also images/COPYRIGHT file)
|
||||
-----------------------------------
|
||||
Url: http://www.famfamfam.com/lab/icons/silk/
|
||||
Copyright: Mark James
|
||||
License: Creative Commons Attribution 2.5 License (http://creativecommons.org/licenses/by/2.5/)
|
||||
674
src/LICENSE
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 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 General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<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 General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
839
src/ajax.js
Normal file
|
|
@ -0,0 +1,839 @@
|
|||
theme = {
|
||||
newTaskFlashColor: '#ffffaa',
|
||||
editTaskFlashColor: '#bbffaa',
|
||||
errorFlashColor: '#ffffff'
|
||||
};
|
||||
|
||||
//Global vars
|
||||
var taskList, taskOrder;
|
||||
var filter = { compl:0, search:'', tag:'', due:'' };
|
||||
var sortOrder; //save task order before dragging
|
||||
var searchTimer;
|
||||
var objPrio = {};
|
||||
var selTask = 0;
|
||||
var sortBy = 0;
|
||||
var flag = { needAuth:false, isLogged:false, canAllRead:true, tagsChanged:true, windowTaskEditMoved:false };
|
||||
var tz = 0;
|
||||
var img = {
|
||||
'note': ['images/page_white_text_add_bw.png','images/page_white_text_add.png'],
|
||||
'edit': ['images/page_white_edit_bw.png','images/page_white_edit.png'],
|
||||
'del': ['images/page_cross_bw.png','images/page_cross.png']
|
||||
};
|
||||
var taskCnt = { total:0, past: 0, today:0, soon:0 };
|
||||
var tmp = {};
|
||||
|
||||
function loadTasks()
|
||||
{
|
||||
tz = -1 * (new Date()).getTimezoneOffset();
|
||||
setAjaxErrorTrigger();
|
||||
if(filter.search) search = '&s='+encodeURIComponent(filter.search); else search = '';
|
||||
if(filter.tag) tag = '&t='+encodeURIComponent(filter.tag); else tag = '';
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.getJSON('ajax.php?loadTasks&compl='+filter.compl+'&sort='+sortBy+search+tag+'&tz='+tz+nocache, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
$('#total').html(json.total);
|
||||
taskList = new Array();
|
||||
taskOrder = new Array();
|
||||
taskCnt.past = taskCnt.today = taskCnt.soon = 0;
|
||||
taskCnt.total = json.total;
|
||||
var tasks = '';
|
||||
$.each(json.list, function(i,item){
|
||||
tasks += prepareTaskStr(item);
|
||||
taskList[item.id] = item;
|
||||
taskOrder.push(parseInt(item.id));
|
||||
if(!item.compl) changeTaskCnt(item.dueClass);
|
||||
});
|
||||
refreshTaskCnt();
|
||||
$('#tasklist').html(tasks);
|
||||
if(filter.compl) showhide($('#compl_hide'),$('#compl_show'));
|
||||
else showhide($('#compl_show'),$('#compl_hide'));
|
||||
if(json.denied) errorDenied();
|
||||
});
|
||||
}
|
||||
|
||||
function prepareTaskStr(item)
|
||||
{
|
||||
id = parseInt(item.id);
|
||||
prio = parseInt(item.prio);
|
||||
readOnly = (flag.needAuth && flag.canAllRead && !flag.isLogged) ? true : false;
|
||||
return '<li id="taskrow_'+id+'" class="'+(item.compl?'task-completed ':'')+item.dueClass+'" onDblClick="editTask('+id+')"><div class="task-actions">'+
|
||||
'<a href="#" onClick="return toggleTaskNote('+id+')"><img src="'+img.note[0]+'" onMouseOver="this.src=img.note[1]" onMouseOut="this.src=img.note[0]" title="'+lang.actionNote+'"></a>'+
|
||||
'<a href="#" onClick="return editTask('+id+')"><img src="'+img.edit[0]+'" onMouseOver="this.src=img.edit[1]" onMouseOut="this.src=img.edit[0]" title="'+lang.actionEdit+'"></a>'+
|
||||
'<a href="#" onClick="return deleteTask('+id+')"><img src="'+img.del[0]+'" onMouseOver="this.src=img.del[1]" onMouseOut="this.src=img.del[0]" title="'+lang.actionDelete+'"></a></div>'+
|
||||
'<div class="task-left"><input type="checkbox" '+(readOnly?'disabled':'')+' onClick="completeTask('+id+',this)" '+(item.compl?'checked':'')+'></div>'+
|
||||
'<div class="task-middle">'+prepareDuedate(item.duedate, item.dueClass, item.dueStr)+
|
||||
'<span class="nobr"><span class="task-through">'+preparePrio(prio,id)+'<span class="task-title">'+prepareHtml(item.title)+'</span>'+
|
||||
prepareTagsStr(item.tags)+'<span class="task-date">'+lang.taskDate(item.date)+'</span></span></span>'+
|
||||
'<div class="task-note-block'+(item.note==''?' hidden':'')+'">'+
|
||||
'<div id="tasknote'+id+'" class="task-note"><span>'+prepareHtml(item.note)+'</span></div>'+
|
||||
'<div id="tasknotearea'+id+'" class="task-note-area"><textarea id="notetext'+id+'"></textarea>'+
|
||||
'<span class="task-note-actions"><a href="#" onClick="return saveTaskNote('+id+')">'+lang.actionNoteSave+
|
||||
'</a> | <a href="#" onClick="return cancelTaskNote('+id+')">'+lang.actionNoteCancel+'</a></span></div>'+
|
||||
'</div>'+
|
||||
"</div></li>\n";
|
||||
}
|
||||
|
||||
function prepareHtml(s)
|
||||
{
|
||||
// make URLs clickable
|
||||
s = s.replace(/(^|\s|>)(www\.([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/gi, '$1<a href="http://$2" target="_blank">$2</a>$4');
|
||||
return s.replace(/(^|\s|>)((?:http|https|ftp):\/\/([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/ig, '$1<a href="$2" target="_blank">$2</a>$4');
|
||||
}
|
||||
|
||||
function preparePrio(prio,id)
|
||||
{
|
||||
cl = v = '';
|
||||
if(prio < 0) { cl = 'prio-neg'; v = '−'+Math.abs(prio); }
|
||||
else if(prio > 0) { cl = 'prio-pos'; v = '+'+prio; }
|
||||
else { cl = 'prio-o'; v = '±0'; }
|
||||
return '<span class="task-prio '+cl+'" onMouseOver="prioPopup(1,this,'+id+')" onMouseOut="prioPopup(0,this)">'+v+'</span>';
|
||||
}
|
||||
|
||||
function prepareTagsStr(tags)
|
||||
{
|
||||
if(!tags || tags == '') return '';
|
||||
a = tags.split(',');
|
||||
if(!a.length) return '';
|
||||
for(i in a) {
|
||||
a[i] = '<a href="#" class="tag" onClick=\'addFilterTag("'+a[i]+'");return false\'>'+a[i]+'</a>';
|
||||
}
|
||||
return '<span class="task-tags">'+a.join(', ')+'</span>';
|
||||
}
|
||||
|
||||
function prepareDuedate(duedate, c, s)
|
||||
{
|
||||
if(!duedate) return '';
|
||||
return '<span class="duedate" title="'+duedate+'">'+s+'</span>';
|
||||
}
|
||||
|
||||
function submitNewTask(form)
|
||||
{
|
||||
if(form.task.value == '') return false;
|
||||
var tz = -1 * (new Date()).getTimezoneOffset();
|
||||
setAjaxErrorTrigger()
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.post('ajax.php?newTask'+nocache, { title: form.task.value, tz:tz, tag:filter.tag }, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
if(!parseInt(json.total)) return;
|
||||
$('#total').text( parseInt($('#total').text()) + parseInt(json.total) );
|
||||
form.task.value = '';
|
||||
var item = json.list[0];
|
||||
taskList[item.id] = item;
|
||||
taskOrder.push(parseInt(item.id));
|
||||
$('#tasklist').append(prepareTaskStr(item));
|
||||
changeTaskOrder(item.id);
|
||||
$('#taskrow_'+item.id).effect("highlight", {color:theme.newTaskFlashColor}, 2000);
|
||||
}, 'json');
|
||||
flag.tagsChanged = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function setAjaxErrorTrigger()
|
||||
{
|
||||
resetAjaxErrorTrigger();
|
||||
$("#msg").ajaxError(function(event, request, settings){
|
||||
var errtxt;
|
||||
if(request.status == 0) errtxt = 'Bad connection';
|
||||
else if(request.status != 200) errtxt = 'HTTP (ajax.php): '+request.status+'/'+request.statusText;
|
||||
else errtxt = request.responseText;
|
||||
flashError(lang.error, errtxt);
|
||||
});
|
||||
}
|
||||
|
||||
function flashError(str, details)
|
||||
{
|
||||
$("#msg").text(str).css('display','block');
|
||||
$("#msgdetails").text(details);
|
||||
$("#loading").hide();
|
||||
$("#msg").effect("highlight", {color:theme.errorFlashColor}, 700);
|
||||
}
|
||||
|
||||
function toggleMsgDetails()
|
||||
{
|
||||
el = $("#msgdetails");
|
||||
if(!el) return;
|
||||
if(el.css('display') == 'none') el.show();
|
||||
else el.hide()
|
||||
}
|
||||
|
||||
function resetAjaxErrorTrigger()
|
||||
{
|
||||
$("#msg").hide().unbind('ajaxError');
|
||||
$("#msgdetails").text('').hide();
|
||||
}
|
||||
|
||||
function deleteTask(id)
|
||||
{
|
||||
if(!confirm(lang.confirmDelete)) {
|
||||
return false;
|
||||
}
|
||||
setAjaxErrorTrigger()
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.getJSON('ajax.php?deleteTask='+id+nocache, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
if(!parseInt(json.total)) return;
|
||||
$('#total').text( parseInt($('#total').text()) - 1 );
|
||||
var item = json.list[0];
|
||||
taskOrder.splice($.inArray(id,taskOrder), 1);
|
||||
$('#taskrow_'+item.id).fadeOut('normal', function(){ $(this).remove() });
|
||||
if(!taskList[id].compl && changeTaskCnt(taskList[id].dueClass, -1)) refreshTaskCnt();
|
||||
delete taskList[id];
|
||||
});
|
||||
flag.tagsChanged = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function completeTask(id,ch)
|
||||
{
|
||||
compl = 0;
|
||||
if(ch.checked) compl = 1;
|
||||
setAjaxErrorTrigger();
|
||||
$.getJSON('ajax.php?completeTask='+id+'&compl='+compl+nocache, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
if(!parseInt(json.total)) return;
|
||||
var item = json.list[0];
|
||||
if(item.compl) $('#taskrow_'+id).addClass('task-completed');
|
||||
else $('#taskrow_'+id).removeClass('task-completed');
|
||||
if(changeTaskCnt(taskList[id].dueClass, item.compl?-1:1)) refreshTaskCnt();
|
||||
if(item.compl && !filter.compl) {
|
||||
delete taskList[id];
|
||||
taskOrder.splice($.inArray(id,taskOrder), 1);
|
||||
$('#taskrow_'+item.id).fadeOut('normal', function(){ $(this).remove() });
|
||||
$('#total').html( parseInt($('#total').text())-1 );
|
||||
}
|
||||
else if(filter.compl) {
|
||||
taskList[id].ow = item.ow;
|
||||
taskList[id].compl = item.compl;
|
||||
changeTaskOrder(id);
|
||||
$('#taskrow_'+id).effect("highlight", {color:theme.editTaskFlashColor}, 'normal');
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function toggleTaskNote(id)
|
||||
{
|
||||
aArea = '#tasknotearea'+id;
|
||||
if($(aArea).css('display') == 'none')
|
||||
{
|
||||
$('#notetext'+id).val(taskList[id].noteText);
|
||||
$('#taskrow_'+id+'>div>div.task-note-block').removeClass('hidden');
|
||||
$(aArea).css('display', 'block');
|
||||
$('#tasknote'+id).css('display', 'none');
|
||||
$('#notetext'+id).focus();
|
||||
} else {
|
||||
cancelTaskNote(id)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function cancelTaskNote(id)
|
||||
{
|
||||
$('#tasknotearea'+id).css('display', 'none');
|
||||
$('#tasknote'+id).css('display', 'block');
|
||||
if($('#tasknote'+id).text() == '') {
|
||||
$('#taskrow_'+id+'>div>div.task-note-block').addClass('hidden');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function saveTaskNote(id)
|
||||
{
|
||||
setAjaxErrorTrigger()
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.post('ajax.php?editNote='+id+nocache, {note: $('#notetext'+id).val()}, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
if(!parseInt(json.total)) return;
|
||||
var item = json.list[0];
|
||||
taskList[id].note = item.note;
|
||||
taskList[id].noteText = item.noteText;
|
||||
$('#tasknote'+item.id+'>span').html(prepareHtml(item.note));
|
||||
cancelTaskNote(item.id);
|
||||
}, 'json');
|
||||
return false;
|
||||
}
|
||||
|
||||
function editTask(id)
|
||||
{
|
||||
var item = taskList[id];
|
||||
if(!item) return false;
|
||||
document.edittask.task.value = dehtml(item.title);
|
||||
document.edittask.note.value = item.noteText;
|
||||
document.edittask.id.value = item.id;
|
||||
document.edittask.tags.value = item.tags.split(',').join(', ');
|
||||
document.edittask.duedate.value = item.duedate;
|
||||
sel = document.edittask.prio;
|
||||
for(i=0; i<sel.length; i++) {
|
||||
if(sel.options[i].value == item.prio) sel.options[i].selected = true;
|
||||
}
|
||||
$('<div id="overlay"></div>').appendTo('body').css('opacity', 0.5).show();
|
||||
w = $('#page_taskedit');
|
||||
if(!flag.windowTaskEditMoved)
|
||||
{
|
||||
var x,y;
|
||||
if(document.getElementById('viewport')) {
|
||||
x = Math.floor(Math.min($(window).width(),screen.width)/2 - w.outerWidth()/2);
|
||||
y = Math.floor(Math.min($(window).height(),screen.height)/2 - w.outerHeight()/2);
|
||||
}
|
||||
else {
|
||||
x = Math.floor($(window).width()/2 - w.outerWidth()/2);
|
||||
y = Math.floor($(window).height()/2 - w.outerHeight()/2);
|
||||
}
|
||||
if(x < 0) x = 0;
|
||||
if(y < 0) y = 0;
|
||||
w.css('left',x).css('top',y);
|
||||
tmp.editformpos = [x, y];
|
||||
}
|
||||
w.fadeIn('fast'); //.show();
|
||||
$(document).bind('keydown', cancelEdit);
|
||||
return false;
|
||||
}
|
||||
|
||||
function cancelEdit(e)
|
||||
{
|
||||
if(e && e.keyCode != 27) return;
|
||||
$(document).unbind('keydown', cancelEdit);
|
||||
$('#page_taskedit').hide();
|
||||
$('#overlay').remove();
|
||||
document.edittask.task.value = '';
|
||||
document.edittask.note.value = '';
|
||||
document.edittask.tags.value = '';
|
||||
document.edittask.duedate.value = '';
|
||||
return false;
|
||||
}
|
||||
|
||||
function saveTask(form)
|
||||
{
|
||||
if(flag.needAuth && !flag.isLogged && flag.canAllRead) return false;
|
||||
setAjaxErrorTrigger();
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.post('ajax.php?editTask='+form.id.value+nocache, { title: form.task.value, note:form.note.value, prio:form.prio.value, tags:form.tags.value, duedate:form.duedate.value }, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
if(!parseInt(json.total)) return;
|
||||
var item = json.list[0];
|
||||
if(!taskList[item.id].compl) changeTaskCnt(taskList[item.id].dueClass, -1);
|
||||
taskList[item.id] = item;
|
||||
$('#taskrow_'+item.id).replaceWith(prepareTaskStr(item));
|
||||
if(item.note == '') $('#taskrow_'+item.id+'>div.task-note-block').addClass('hidden');
|
||||
else $('#taskrow_'+item.id+'>div.task-note-block').removeClass('hidden');
|
||||
if(sortBy != 0) changeTaskOrder(item.id);
|
||||
cancelEdit();
|
||||
if(!taskList[item.id].compl) {
|
||||
changeTaskCnt(item.dueClass, 1);
|
||||
refreshTaskCnt();
|
||||
}
|
||||
$('#taskrow_'+item.id).effect("highlight", {color:theme.editTaskFlashColor}, 'normal');
|
||||
}, 'json');
|
||||
$("#edittags").flushCache();
|
||||
flag.tagsChanged = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function showhide(a,b)
|
||||
{
|
||||
a.show();
|
||||
b.hide();
|
||||
}
|
||||
|
||||
function sortStart(event,ui)
|
||||
{
|
||||
// remember initial order before sorting
|
||||
sortOrder = $(this).sortable('toArray');
|
||||
}
|
||||
|
||||
function orderChanged(event,ui)
|
||||
{
|
||||
if(!ui.item[0]) return;
|
||||
var itemId = ui.item[0].id;
|
||||
n = $(this).sortable('toArray');
|
||||
// remove possible empty id's
|
||||
for(i=0; i<sortOrder.length; i++) {
|
||||
if(sortOrder[i] == '') { sortOrder.splice(i,1); i--; }
|
||||
}
|
||||
if(n.toString() == sortOrder.toString()) return;
|
||||
// make assoc from array for easy index
|
||||
var h0 = new Array();
|
||||
for(j=0; j<sortOrder.length; j++) {
|
||||
h0[sortOrder[j]] = j;
|
||||
}
|
||||
var h1 = new Array();
|
||||
for(j=0; j<n.length; j++) {
|
||||
h1[n[j]] = j;
|
||||
taskOrder[j] = n[j].split('_')[1];
|
||||
}
|
||||
// prepare param string
|
||||
var s = '';
|
||||
var diff;
|
||||
var replaceOW = taskList[sortOrder[h1[itemId]].split('_')[1]].ow;
|
||||
for(j in h0)
|
||||
{
|
||||
diff = h1[j] - h0[j];
|
||||
if(diff != 0) {
|
||||
a = j.split('_');
|
||||
if(j == itemId) diff = replaceOW - taskList[a[1]].ow;
|
||||
s += a[1] +'='+ diff+ '&';
|
||||
taskList[a[1]].ow += diff;
|
||||
}
|
||||
}
|
||||
setAjaxErrorTrigger();
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.post('ajax.php?changeOrder'+nocache, { order: s }, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
function timerSearch()
|
||||
{
|
||||
clearTimeout(searchTimer);
|
||||
searchTimer = setTimeout("searchTasks()", 500);
|
||||
}
|
||||
|
||||
function searchTasks()
|
||||
{
|
||||
filter.search = $('#search').val();
|
||||
$('#searchbarkeyword').text(filter.search);
|
||||
if(filter.search != '') $('#searchbar').fadeIn('fast');
|
||||
else $('#searchbar').fadeOut('fast');
|
||||
loadTasks();
|
||||
return false;
|
||||
}
|
||||
|
||||
function tabSelected(event, ui)
|
||||
{
|
||||
// reload tasks when we return to task tab (from search tab)
|
||||
if(ui.index == 0 && filter.search != '') {
|
||||
filter.search = '';
|
||||
$('#searchbarkeyword').text('');
|
||||
$('#searchbar').hide();
|
||||
loadTasks();
|
||||
}
|
||||
}
|
||||
|
||||
function dehtml(str)
|
||||
{
|
||||
return str.replace(/"/g,'"').replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&');
|
||||
}
|
||||
|
||||
function errorDenied()
|
||||
{
|
||||
flashError(lang.denied);
|
||||
}
|
||||
|
||||
function updateAccessStatus(onInit)
|
||||
{
|
||||
if(flag.needAuth && !flag.isLogged) $("#tasklist").sortable('disable').addClass('readonly');
|
||||
else if(sortBy == 0) $("#tasklist").sortable('enable').removeClass('readonly');
|
||||
|
||||
if(!flag.canAllRead && !flag.isLogged) {
|
||||
$('#page_tasks > h3,#taskcontainer').hide();
|
||||
$('#tabs').hide();
|
||||
}
|
||||
else {
|
||||
$('#page_tasks > h3,#taskcontainer').show();
|
||||
$('#tabs').show();
|
||||
}
|
||||
if(flag.needAuth) {
|
||||
$('#bar_auth').show();
|
||||
showhide($("#bar_login"),$("#bar_logout"));
|
||||
}
|
||||
if(!flag.needAuth) {
|
||||
$("#authstr").text('').hide();
|
||||
$('#bar_auth').hide();
|
||||
}
|
||||
else if(flag.canAllRead && !flag.isLogged) $("#authstr").text(lang.readonly).addClass('attention').show();
|
||||
else if(flag.isLogged) showhide($("#bar_logout"),$("#bar_login"));
|
||||
else if(!flag.canAllRead) $("#authstr").text('').hide();
|
||||
|
||||
if(onInit == null || !onInit)
|
||||
{
|
||||
if(flag.isLogged) $("#tabs").tabs('enable',0).tabs('enable',1).tabs('select',0);
|
||||
else if(flag.canAllRead) $("#tabs").tabs('enable',1).tabs('select', 1).tabs('disable',0);
|
||||
else $("#tabs").tabs('disable',0).tabs('disable',1);
|
||||
}
|
||||
}
|
||||
|
||||
function doAuth(form)
|
||||
{
|
||||
setAjaxErrorTrigger();
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.post('ajax.php?login'+nocache, { password: form.password.value }, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
form.password.value = '';
|
||||
if(json.logged)
|
||||
{
|
||||
flag.isLogged = true;
|
||||
if(filter.search != '') {
|
||||
filter.search = '';
|
||||
$('#searchbarkeyword').text('');
|
||||
$('#searchbar').hide();
|
||||
}
|
||||
updateAccessStatus();
|
||||
loadTasks();
|
||||
}
|
||||
else {
|
||||
flashError(lang.invalidpass);
|
||||
$('#password').focus();
|
||||
}
|
||||
}, 'json');
|
||||
$('#authform').hide();
|
||||
}
|
||||
|
||||
function logout()
|
||||
{
|
||||
setAjaxErrorTrigger();
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.getJSON('ajax.php?logout'+nocache, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
});
|
||||
flag.isLogged = false;
|
||||
updateAccessStatus();
|
||||
if(flag.canAllRead) {
|
||||
loadTasks();
|
||||
}
|
||||
else {
|
||||
$('#total').html('0');
|
||||
$('#tasklist').html('');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function tasklistClick(e)
|
||||
{
|
||||
node = e.target.nodeName;
|
||||
if(node=='SPAN' || node=='LI' || node=='DIV') {
|
||||
li = getRecursParent(e.target, 'LI', 10);
|
||||
if(li) {
|
||||
if(selTask && li.id != selTask) $('#'+selTask).removeClass('clicked doubleclicked');
|
||||
selTask = li.id;
|
||||
if($(li).is('.clicked')) $(li).toggleClass('doubleclicked');
|
||||
else $(li).addClass('clicked');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getRecursParent(el, needle, level)
|
||||
{
|
||||
if(el.nodeName == needle) return el;
|
||||
if(!el.parentNode) return null;
|
||||
level--;
|
||||
if(level <= 0) return false;
|
||||
return getRecursParent(el.parentNode, needle, level);
|
||||
}
|
||||
|
||||
function cancelTagFilter()
|
||||
{
|
||||
$('#tagcloudbtn>.btnstr').text($('#tagcloudbtn').attr('title'));
|
||||
filter.tag = '';
|
||||
loadTasks();
|
||||
}
|
||||
|
||||
function addFilterTag(tag)
|
||||
{
|
||||
filter.tag = tag;
|
||||
loadTasks();
|
||||
$('#tagcloudbtn>.btnstr').html(lang.tagfilter + ' <span class="tag">'+tag+'</span>');
|
||||
}
|
||||
|
||||
function showAuth(el)
|
||||
{
|
||||
w = $('#authform');
|
||||
if(w.css('display') == 'none')
|
||||
{
|
||||
offset = $(el).offset();
|
||||
w.css({
|
||||
position: 'absolute',
|
||||
top: offset.top + el.offsetHeight + 3,
|
||||
left: offset.left + el.offsetWidth - w.outerWidth()
|
||||
}).show();
|
||||
$('#password').focus();
|
||||
}
|
||||
else {
|
||||
w.hide();
|
||||
el.blur();
|
||||
}
|
||||
}
|
||||
|
||||
function prioPopup(act, el, id)
|
||||
{
|
||||
if(act == 0) {
|
||||
clearTimeout(objPrio.timer);
|
||||
return;
|
||||
}
|
||||
offset = $(el).offset();
|
||||
$('#priopopup').css({ position: 'absolute', top: offset.top + 1, left: offset.left + 1 });
|
||||
objPrio.taskId = id;
|
||||
objPrio.el = el;
|
||||
objPrio.timer = setTimeout("$('#priopopup').show()", 300);
|
||||
}
|
||||
|
||||
function prioClick(prio, el)
|
||||
{
|
||||
el.blur();
|
||||
prio = parseInt(prio);
|
||||
setAjaxErrorTrigger();
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.getJSON('ajax.php?setPrio='+objPrio.taskId+'&prio='+prio+nocache, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
});
|
||||
taskList[objPrio.taskId].prio = prio;
|
||||
$(objPrio.el).replaceWith(preparePrio(prio, objPrio.taskId));
|
||||
$('#priopopup').fadeOut('fast'); //.hide();
|
||||
if(sortBy != 0) changeTaskOrder(objPrio.taskId);
|
||||
$('#taskrow_'+objPrio.taskId).effect("highlight", {color:theme.editTaskFlashColor}, 'normal');
|
||||
}
|
||||
|
||||
function showSort(el)
|
||||
{
|
||||
w = $('#sortform');
|
||||
if(w.css('display') == 'none')
|
||||
{
|
||||
offset = $(el).offset();
|
||||
w.css({ position: 'absolute', top: offset.top+el.offsetHeight-1, left: offset.left , 'min-width': $(el).width() }).show();
|
||||
$(document).bind("click", sortClose);
|
||||
}
|
||||
else {
|
||||
el.blur();
|
||||
sortClose();
|
||||
}
|
||||
}
|
||||
|
||||
function setSort(v, init)
|
||||
{
|
||||
if(v == 0) $('#sort>.btnstr').text($('#sortByHand').text());
|
||||
else if(v == 1) $('#sort>.btnstr').text($('#sortByPrio').text());
|
||||
else if(v == 2) $('#sort>.btnstr').text($('#sortByDueDate').text());
|
||||
else return;
|
||||
if(sortBy != v) {
|
||||
sortBy = v;
|
||||
if(v==0) $("#tasklist").sortable('enable');
|
||||
else $("#tasklist").sortable('disable');
|
||||
if(!init) {
|
||||
changeTaskOrder();
|
||||
exp = new Date();
|
||||
exp.setTime(exp.getTime() + 3650*86400*1000); //+10 years
|
||||
document.cookie = "sort="+sortBy+'; expires='+exp.toUTCString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sortClose(e)
|
||||
{
|
||||
if(e) {
|
||||
if(isParentId(e.target, ['sortform','sort'])) return;
|
||||
}
|
||||
$(document).unbind("click", sortClose);
|
||||
$('#sortform').hide();
|
||||
}
|
||||
|
||||
function isParentId(el, id)
|
||||
{
|
||||
if(el.id && $.inArray(el.id, id) != -1) return true;
|
||||
if(!el.parentNode) return null;
|
||||
return isParentId(el.parentNode, id);
|
||||
}
|
||||
|
||||
function changeTaskOrder(id)
|
||||
{
|
||||
id = parseInt(id);
|
||||
if(taskOrder.length < 2) return;
|
||||
oldOrder = taskOrder.slice();
|
||||
if(sortBy == 0) taskOrder.sort( function(a,b){
|
||||
if(taskList[a].compl != taskList[b].compl) return taskList[a].compl-taskList[b].compl;
|
||||
return taskList[a].ow-taskList[b].ow
|
||||
});
|
||||
else if(sortBy == 1) taskOrder.sort( function(a,b){
|
||||
if(taskList[a].compl != taskList[b].compl) return taskList[a].compl-taskList[b].compl;
|
||||
if(taskList[a].prio != taskList[b].prio) return taskList[b].prio-taskList[a].prio;
|
||||
if(taskList[a].dueInt != taskList[b].dueInt) return taskList[a].dueInt-taskList[b].dueInt;
|
||||
return taskList[a].ow-taskList[b].ow;
|
||||
});
|
||||
else if(sortBy == 2) taskOrder.sort( function(a,b){
|
||||
if(taskList[a].compl != taskList[b].compl) return taskList[a].compl-taskList[b].compl;
|
||||
if(taskList[a].dueInt != taskList[b].dueInt) return taskList[a].dueInt-taskList[b].dueInt;
|
||||
if(taskList[a].prio != taskList[b].prio) return taskList[b].prio-taskList[a].prio;
|
||||
return taskList[a].ow-taskList[b].ow;
|
||||
});
|
||||
else return;
|
||||
if(oldOrder.toString() == taskOrder.toString()) return;
|
||||
if(id && taskList[id])
|
||||
{
|
||||
// optimization: determine where to insert task: top or after some task
|
||||
indx = $.inArray(id,taskOrder);
|
||||
if(indx ==0) {
|
||||
$('#tasklist').prepend($('#taskrow_'+id))
|
||||
} else {
|
||||
after = taskOrder[indx-1];
|
||||
$('#taskrow_'+after).after($('#taskrow_'+id));
|
||||
}
|
||||
}
|
||||
else {
|
||||
o = $('#tasklist');
|
||||
for(i in taskOrder) {
|
||||
o.append($('#taskrow_'+taskOrder[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showTagCloud(el)
|
||||
{
|
||||
w = $('#tagcloud');
|
||||
if(w.css('display') == 'none')
|
||||
{
|
||||
if(flag.tagsChanged)
|
||||
{
|
||||
$('#tagcloudcontent').html('');
|
||||
$('#tagcloudload').show();
|
||||
offset = $(el).offset();
|
||||
l = Math.ceil(offset.left - w.outerWidth()/2 + $(el).outerWidth()/2);
|
||||
if(l<0) l=0;
|
||||
w.css({ position: 'absolute', top: offset.top+el.offsetHeight-1, left: l }).show();
|
||||
|
||||
setAjaxErrorTrigger();
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.getJSON('ajax.php?tagCloud'+nocache, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
$('#tagcloudload').hide();
|
||||
if(!parseInt(json.total)) return;
|
||||
var cloud = '';
|
||||
$.each(json.cloud, function(i,item){
|
||||
cloud += '<a href="#" onClick=\'addFilterTag("'+item.tag+'");tagCloudClose();return false;\' class="tag w'+item.w+'" >'+item.tag+'</a>';
|
||||
});
|
||||
$('#tagcloudcontent').html(cloud)
|
||||
flag.tagsChanged = false;
|
||||
});
|
||||
}
|
||||
else {
|
||||
offset = $(el).offset();
|
||||
l = Math.ceil(offset.left - w.outerWidth()/2 + $(el).outerWidth()/2);
|
||||
if(l<0) l=0;
|
||||
w.css({ position: 'absolute', top: offset.top+el.offsetHeight-1, left: l }).show();
|
||||
}
|
||||
$(document).bind("click", tagCloudClose);
|
||||
}
|
||||
else {
|
||||
el.blur();
|
||||
tagCloudClose();
|
||||
}
|
||||
}
|
||||
|
||||
function tagCloudClose(e)
|
||||
{
|
||||
if(e) {
|
||||
if(isParentId(e.target, ['tagcloudbtn','tagcloud'])) return;
|
||||
}
|
||||
$(document).unbind("click", tagCloudClose);
|
||||
$('#tagcloud').hide();
|
||||
}
|
||||
|
||||
function preloadImg()
|
||||
{
|
||||
for(i in img) {
|
||||
o = new Image();
|
||||
o.src = img[i][0];
|
||||
if(img[i][1] != img[i][0]) {
|
||||
o = new Image();
|
||||
o.src = img[i][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeTaskCnt(cl, dir)
|
||||
{
|
||||
if(!dir) dir = 1;
|
||||
else if(dir > 0) dir = 1;
|
||||
else if(dir < 0) die = -1;
|
||||
if(cl == 'soon') { taskCnt.soon += dir; return true; }
|
||||
else if(cl == 'today') { taskCnt.today += dir; return true; }
|
||||
else if(cl == 'past') { taskCnt.past+= dir; return true; }
|
||||
}
|
||||
|
||||
function refreshTaskCnt()
|
||||
{
|
||||
$('#cnt_past').text(taskCnt.past);
|
||||
$('#cnt_today').text(taskCnt.today);
|
||||
$('#cnt_soon').text(taskCnt.soon);
|
||||
}
|
||||
|
||||
function showTaskview(el)
|
||||
{
|
||||
w = $('#taskview');
|
||||
if(w.css('display') == 'none')
|
||||
{
|
||||
offset = $(el).offset();
|
||||
w.css({ position: 'absolute', top: offset.top+el.offsetHeight-1, left: offset.left , 'min-width': $(el).width() }).show();
|
||||
$(document).bind("click", taskviewClose);
|
||||
}
|
||||
else {
|
||||
el.blur();
|
||||
taskviewClose();
|
||||
}
|
||||
}
|
||||
|
||||
function taskviewClose(e)
|
||||
{
|
||||
if(e) {
|
||||
if(isParentId(e.target, ['taskviewcontainer','taskview'])) return;
|
||||
}
|
||||
$(document).unbind("click", taskviewClose);
|
||||
$('#taskview').hide();
|
||||
}
|
||||
|
||||
function setTaskview(v)
|
||||
{
|
||||
if(v == 0)
|
||||
{
|
||||
if(filter.due == '' && filter.compl == 0) return;
|
||||
$('#taskviewcontainer .btnstr').text($('#view_tasks').text());
|
||||
if(filter.due != '') {
|
||||
$('#tasklist').removeClass('filter-'+filter.due);
|
||||
filter.due = '';
|
||||
if(filter.compl == 0) $('#total').text(taskCnt.total);
|
||||
}
|
||||
if(filter.compl != 0) {
|
||||
filter.compl = 0;
|
||||
$('#total').text('...');
|
||||
loadTasks();
|
||||
}
|
||||
}
|
||||
else if(v == 1)
|
||||
{
|
||||
if(filter.due == '' && filter.compl == 1) return;
|
||||
$('#taskviewcontainer .btnstr').text($('#view_compl').text());
|
||||
if(filter.due != '') {
|
||||
$('#tasklist').removeClass('filter-'+filter.due);
|
||||
filter.due = '';
|
||||
if(filter.compl == 1) $('#total').text(taskCnt.total);
|
||||
}
|
||||
if(filter.compl != 1) {
|
||||
filter.compl = 1;
|
||||
$('#total').text('...');
|
||||
loadTasks();
|
||||
}
|
||||
}
|
||||
else if(v=='past' || v=='today' || v=='soon')
|
||||
{
|
||||
if(filter.due == v) return;
|
||||
else if(filter.due != '') {
|
||||
$('#tasklist').removeClass('filter-'+filter.due);
|
||||
}
|
||||
$('#tasklist').addClass('filter-'+v);
|
||||
$('#taskviewcontainer .btnstr').text($('#view_'+v).text());
|
||||
$('#total').text(taskCnt[v]);
|
||||
filter.due = v;
|
||||
}
|
||||
}
|
||||
|
||||
function editFormResize(startstop, event)
|
||||
{
|
||||
f = $('#page_taskedit');
|
||||
if(startstop == 1) {
|
||||
tmp.editformdiff = f.height() - $('#page_taskedit textarea').height();
|
||||
}
|
||||
else if(startstop == 2) {
|
||||
//to avoid bug http://dev.jqueryui.com/ticket/3628
|
||||
if(f.is('.ui-draggable')) {
|
||||
f.css('left',tmp.editformpos[0]).css('top',tmp.editformpos[1]).css('position', 'fixed');
|
||||
}
|
||||
}
|
||||
else $('#page_taskedit textarea').height(f.height() - tmp.editformdiff);
|
||||
}
|
||||
12
src/ajax.lang.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once('./db/config.php');
|
||||
require_once('./lang/class.default.php');
|
||||
require_once('./lang/'. $config['lang']. '.php');
|
||||
|
||||
$l = new Lang();
|
||||
|
||||
header('Content-type: text/javascript');
|
||||
echo $l->makeJS();
|
||||
|
||||
?>
|
||||
528
src/ajax.php
Normal file
|
|
@ -0,0 +1,528 @@
|
|||
<?php
|
||||
|
||||
set_error_handler('myErrorHandler');
|
||||
set_exception_handler('myExceptionHandler');
|
||||
|
||||
require_once('./init.php');
|
||||
require_once('./lang/class.default.php');
|
||||
require_once('./lang/'.$config['lang'].'.php');
|
||||
$lang = new Lang();
|
||||
|
||||
if(isset($_GET['loadTasks']))
|
||||
{
|
||||
check_read_access();
|
||||
stop_gpc($_GET);
|
||||
if(_get('compl')) $sqlWhere = '';
|
||||
else $sqlWhere = ' AND compl=0';
|
||||
$inner = '';
|
||||
$tag = trim(_get('t'));
|
||||
if($tag != '') {
|
||||
$tag_id = get_tag_id($tag);
|
||||
$inner = "INNER JOIN tag2task ON id=tag2task.task_id";
|
||||
$sqlWhere .= " AND tag_id=$tag_id ";
|
||||
}
|
||||
$s = trim(_get('s'));
|
||||
if($s != '') $sqlWhere .= " AND (title LIKE ". $db->quoteForLike("%%%s%%",$s). " OR note LIKE ". $db->quoteForLike("%%%s%%",$s). ")";
|
||||
$sort = (int)_get('sort');
|
||||
$sqlSort = "ORDER BY compl ASC, ";
|
||||
if($sort == 1) $sqlSort .= "prio DESC, ddn ASC, duedate ASC, ow ASC";
|
||||
elseif($sort == 2) $sqlSort .= "ddn ASC, duedate ASC, prio DESC, ow ASC";
|
||||
else $sqlSort .= "ow ASC";
|
||||
$tz = (int)_get('tz');
|
||||
if((isset($config['autotz']) && $config['autotz']==0) || $tz<-720 || $tz>720 || $tz%30!=0) $tz = null;
|
||||
$t = array();
|
||||
$t['total'] = 0;
|
||||
$t['list'] = array();
|
||||
$q = $db->dq("SELECT *, duedate IS NULL AS ddn FROM todolist $inner WHERE 1=1 $sqlWhere $sqlSort");
|
||||
while($r = $q->fetch_assoc($q))
|
||||
{
|
||||
$t['total']++;
|
||||
$t['list'][] = prepareTaskRow($r, $tz);
|
||||
}
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['newTask']))
|
||||
{
|
||||
check_write_access();
|
||||
stop_gpc($_POST);
|
||||
$t = array();
|
||||
$t['total'] = 0;
|
||||
$title = trim(_post('title'));
|
||||
$prio = 0;
|
||||
$tags = '';
|
||||
if(!isset($config['smartsyntax']) || $config['smartsyntax'] != 0)
|
||||
{
|
||||
$a = parse_smartsyntax($title);
|
||||
if($a === false) {
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
$title = $a['title'];
|
||||
$prio = $a['prio'];
|
||||
$tags = $a['tags'];
|
||||
}
|
||||
if($title == '') {
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
if(isset($config['autotag']) && $config['autotag']) $tags .= ','._post('tag');
|
||||
$tz = (int)_post('tz');
|
||||
if( (isset($config['autotz']) && $config['autotz']==0) || $tz<-720 || $tz>720 || $tz%30!=0 ) $d = strftime("%Y-%m-%d %H:%M:%S");
|
||||
else $d = gmdate("Y-m-d H:i:s", time()+$tz*60);
|
||||
$ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM todolist WHERE compl=0");
|
||||
$db->ex("BEGIN");
|
||||
$db->dq("INSERT INTO todolist (title,d,ow,prio) VALUES (?,?,$ow,$prio)", array($title, $d));
|
||||
$id = $db->last_insert_id();
|
||||
if($tags)
|
||||
{
|
||||
$tag_ids = prepare_tags($tags);
|
||||
if($tag_ids) {
|
||||
update_task_tags($id, $tag_ids);
|
||||
$db->ex("UPDATE todolist SET tags=? WHERE id=$id", $tags);
|
||||
}
|
||||
}
|
||||
$db->ex("COMMIT");
|
||||
$r = $db->sqa("SELECT * FROM todolist WHERE id=$id");
|
||||
$t['list'][] = prepareTaskRow($r);
|
||||
$t['total'] = 1;
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['deleteTask']))
|
||||
{
|
||||
check_write_access();
|
||||
$id = (int)$_GET['deleteTask'];
|
||||
$tags = get_task_tags($id);
|
||||
$db->ex("BEGIN");
|
||||
if($tags) {
|
||||
$s = implode(',', $tags);
|
||||
$db->ex("DELETE FROM tag2task WHERE task_id=$id");
|
||||
$db->ex("UPDATE tags SET tags_count=tags_count-1 WHERE id IN ($s)");
|
||||
$db->ex("DELETE FROM tags WHERE tags_count < 1"); # slow on large amount of tags
|
||||
}
|
||||
$db->dq("DELETE FROM todolist WHERE id=$id");
|
||||
$affected = $db->affected();
|
||||
$db->ex("COMMIT");
|
||||
$t = array();
|
||||
$t['total'] = $affected;
|
||||
$t['list'][] = array('id'=>$id);
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['completeTask']))
|
||||
{
|
||||
check_write_access();
|
||||
$id = (int)$_GET['completeTask'];
|
||||
$compl = _get('compl') ? 1 : 0;
|
||||
if($compl) $ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM todolist WHERE compl=1");
|
||||
else $ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM todolist WHERE compl=0");
|
||||
$db->dq("UPDATE todolist SET compl=$compl,ow=$ow WHERE id=$id");
|
||||
$t = array();
|
||||
$t['total'] = 1;
|
||||
$t['list'][] = array('id'=>$id, 'compl'=>$compl, 'ow'=>$ow);
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['editNote']))
|
||||
{
|
||||
check_write_access();
|
||||
$id = (int)$_GET['editNote'];
|
||||
stop_gpc($_POST);
|
||||
$note = str_replace("\r\n", "\n", trim(_post('note')));
|
||||
$db->dq("UPDATE todolist SET note=? WHERE id=$id", $note);
|
||||
$t = array();
|
||||
$t['total'] = 1;
|
||||
$t['list'][] = array('id'=>$id, 'note'=>nl2br(htmlarray($note)), 'noteText'=>(string)$note);
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['getTask']))
|
||||
{
|
||||
check_read_access();
|
||||
$id = (int)$_GET['getTask'];
|
||||
$t = array();
|
||||
$t['total'] = 0;
|
||||
$r = $db->sqa("SELECT * FROM todolist WHERE id=$id");
|
||||
if($r) {
|
||||
$t['list'][] = prepareTaskRow($r);
|
||||
$t['total'] = 1;
|
||||
}
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['editTask']))
|
||||
{
|
||||
check_write_access();
|
||||
$id = (int)$_GET['editTask'];
|
||||
stop_gpc($_POST);
|
||||
$title = trim(_post('title'));
|
||||
$note = str_replace("\r\n", "\n", trim(_post('note')));
|
||||
$prio = (int)_post('prio');
|
||||
if($prio < -1) $prio = -1;
|
||||
elseif($prio > 2) $prio = 2;
|
||||
$duedate = parse_duedate(trim(_post('duedate')));
|
||||
$t = array();
|
||||
$t['total'] = 0;
|
||||
if($title == '') {
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
$tags = trim(_post('tags'));
|
||||
$db->ex("BEGIN");
|
||||
$tag_ids = prepare_tags($tags);
|
||||
$cur_ids = get_task_tags($id);
|
||||
if($cur_ids) {
|
||||
$ids = implode(',', $cur_ids);
|
||||
$db->ex("DELETE FROM tag2task WHERE task_id=$id");
|
||||
$db->dq("UPDATE tags SET tags_count=tags_count-1 WHERE id IN ($ids)");
|
||||
}
|
||||
if($tag_ids) {
|
||||
update_task_tags($id, $tag_ids);
|
||||
}
|
||||
if(is_null($duedate)) $duedate = 'NULL'; else $duedate = $db->quote($duedate);
|
||||
$db->dq("UPDATE todolist SET title=?,note=?,prio=?,tags=?,duedate=$duedate WHERE id=$id", array($title,$note,$prio,$tags));
|
||||
$db->ex("COMMIT");
|
||||
$r = $db->sqa("SELECT * FROM todolist WHERE id=$id");
|
||||
if($r) {
|
||||
$t['list'][] = prepareTaskRow($r);
|
||||
$t['total'] = 1;
|
||||
}
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['changeOrder']))
|
||||
{
|
||||
check_write_access();
|
||||
stop_gpc($_POST);
|
||||
$s = _post('order');
|
||||
parse_str($s, $order);
|
||||
$t = array();
|
||||
$t['total'] = 0;
|
||||
if($order)
|
||||
{
|
||||
$ad = array();
|
||||
foreach($order as $id=>$diff) {
|
||||
$ad[(int)$diff][] = (int)$id;
|
||||
}
|
||||
$db->ex("BEGIN");
|
||||
foreach($ad as $diff=>$ids) {
|
||||
if($diff >=0) $set = "ow=ow+".$diff;
|
||||
else $set = "ow=ow-".abs($diff);
|
||||
$db->dq("UPDATE todolist SET $set WHERE id IN (".implode(',',$ids).")");
|
||||
}
|
||||
$db->ex("COMMIT");
|
||||
$t['total'] = 1;
|
||||
}
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['login']))
|
||||
{
|
||||
$t = array('logged' => 0);
|
||||
if(!$needAuth) {
|
||||
$t['disabled'] = 1;
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
stop_gpc($_POST);
|
||||
$password = _post('password');
|
||||
if($password == $config['password']) {
|
||||
$t['logged'] = 1;
|
||||
session_regenerate_id(1);
|
||||
$_SESSION['logged'] = 1;
|
||||
}
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['logout']))
|
||||
{
|
||||
$_SESSION = array();
|
||||
$t = array('logged' => 0);
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['suggestTags']))
|
||||
{
|
||||
check_read_access();
|
||||
$begin = trim(_get('q'));
|
||||
$limit = (int)_get('limit');
|
||||
if($limit<1) $limit = 8;
|
||||
$q = $db->dq("SELECT name,id FROM tags WHERE name LIKE ". $db->quoteForLike('%s%%',$begin). " AND tags_count>0 ORDER BY name LIMIT $limit");
|
||||
$s = '';
|
||||
while($r = $q->fetch_row()) {
|
||||
$s .= "$r[0]|$r[1]\n";
|
||||
}
|
||||
echo htmlarray($s);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['setPrio']))
|
||||
{
|
||||
check_write_access();
|
||||
$id = (int)$_GET['setPrio'];
|
||||
$prio = (int)_get('prio');
|
||||
if($prio < -1) $prio = -1;
|
||||
elseif($prio > 2) $prio = 2;
|
||||
$db->ex("UPDATE todolist SET prio=$prio WHERE id=$id");
|
||||
$t = array();
|
||||
$t['total'] = 1;
|
||||
$t['list'][] = array('id'=>$id, 'prio'=>$prio);
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_GET['tagCloud']))
|
||||
{
|
||||
$a = array();
|
||||
$q = $db->dq("SELECT name,tags_count FROM tags WHERE tags_count>0 ORDER BY tags_count ASC");
|
||||
while($r = $q->fetch_row()) {
|
||||
$a[$r[0]] = $r[1];
|
||||
}
|
||||
$t = array();
|
||||
$t['total'] = 0;
|
||||
$count = sizeof($a);
|
||||
if(!$count) {
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
$qmax = max(array_values($a));
|
||||
$qmin = min(array_values($a));
|
||||
if($count >= 10) $grades = 10;
|
||||
else $grades = $count;
|
||||
$step = ($qmax - $qmin)/$grades;
|
||||
foreach($a as $tag=>$q) {
|
||||
$t['cloud'][] = array('tag'=>htmlarray($tag), 'w'=> tag_size($qmin,$q,$step) );
|
||||
}
|
||||
$t['total'] = $count;
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function prepareTaskRow($r, $tz=null)
|
||||
{
|
||||
$dueA = prepare_duedate($r['duedate'], $tz);
|
||||
return array(
|
||||
'id' => $r['id'],
|
||||
'title' => htmlarray($r['title']),
|
||||
'date' => htmlarray($r['d']),
|
||||
'compl' => (int)$r['compl'],
|
||||
'prio' => $r['prio'],
|
||||
'note' => nl2br(htmlarray($r['note'])),
|
||||
'noteText' => (string)$r['note'],
|
||||
'ow' => (int)$r['ow'],
|
||||
'tags' => htmlarray($r['tags']),
|
||||
'duedate' => $dueA['formatted'],
|
||||
'dueClass' => $dueA['class'],
|
||||
'dueStr' => htmlarray($dueA['str']),
|
||||
'dueInt' => date2int($r['duedate']),
|
||||
);
|
||||
}
|
||||
|
||||
function check_read_access()
|
||||
{
|
||||
if(canAllRead() || is_logged()) return;
|
||||
echo json_encode( array('total'=>0, 'list'=>array(), 'denied'=>1) );
|
||||
exit;
|
||||
}
|
||||
|
||||
function check_write_access()
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config['password']) || $config['password'] == '') return;
|
||||
if(is_logged()) return;
|
||||
echo json_encode( array('total'=>0, 'list'=>array(), 'denied'=>1) );
|
||||
exit;
|
||||
}
|
||||
|
||||
function prepare_tags(&$tags_str)
|
||||
{
|
||||
$tag_ids = array();
|
||||
$tag_names = array();
|
||||
$tags = explode(',', $tags_str);
|
||||
foreach($tags as $v)
|
||||
{
|
||||
# remove duplicate tags?
|
||||
$tag = str_replace(array('"',"'",'<','>','&'),array('','','','',''),trim($v));
|
||||
if($tag == '') continue;
|
||||
list($tag_id,$tag_name) = get_or_create_tag($tag);
|
||||
if($tag_id && !in_array($tag_id, $tag_ids)) {
|
||||
$tag_ids[] = $tag_id;
|
||||
$tag_names[] = $tag_name;
|
||||
}
|
||||
}
|
||||
$tags_str = implode(',', $tag_names);
|
||||
return $tag_ids;
|
||||
}
|
||||
|
||||
function get_or_create_tag($name)
|
||||
{
|
||||
global $db;
|
||||
$tag = $db->sq("SELECT id,name FROM tags WHERE name=?", $name);
|
||||
if($tag) return $tag;
|
||||
|
||||
# need to create tag
|
||||
$db->ex("INSERT INTO tags (name) VALUES (?)", $name);
|
||||
return array($db->last_insert_id(), $name);
|
||||
}
|
||||
|
||||
function get_tag_id($tag)
|
||||
{
|
||||
global $db;
|
||||
$id = $db->sq("SELECT id FROM tags WHERE name=?", $tag);
|
||||
return $id ? $id : 0;
|
||||
}
|
||||
|
||||
function get_task_tags($id)
|
||||
{
|
||||
global $db;
|
||||
$q = $db->dq("SELECT tag_id FROM tag2task WHERE task_id=?", $id);
|
||||
$a = array();
|
||||
while($r = $q->fetch_row()) {
|
||||
$a[] = $r[0];
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
|
||||
function update_task_tags($id, $tag_ids)
|
||||
{
|
||||
global $db;
|
||||
foreach($tag_ids as $v) {
|
||||
$db->ex("INSERT INTO tag2task (task_id,tag_id) VALUES ($id,$v)");
|
||||
}
|
||||
$db->ex("UPDATE tags SET tags_count=tags_count+1 WHERE id IN (". implode(',', $tag_ids). ")");
|
||||
}
|
||||
|
||||
function parse_smartsyntax($title)
|
||||
{
|
||||
$a = array();
|
||||
if(!preg_match("|^(/([+-]{0,1}\d+)?/)?(.*?)(\s+/([^/]*)/$)?$|", $title, $m)) return false;
|
||||
$a['prio'] = isset($m[2]) ? (int)$m[2] : 0;
|
||||
$a['title'] = isset($m[3]) ? trim($m[3]) : '';
|
||||
$a['tags'] = isset($m[5]) ? trim($m[5]) : '';
|
||||
if($a['prio'] < -1) $a['prio'] = -1;
|
||||
elseif($a['prio'] > 2) $a['prio'] = 2;
|
||||
return $a;
|
||||
}
|
||||
|
||||
function tag_size($qmin, $q, $step)
|
||||
{
|
||||
if($step == 0) return 1;
|
||||
$v = ceil(($q - $qmin)/$step);
|
||||
if($v == 0) return 0;
|
||||
else return $v-1;
|
||||
|
||||
}
|
||||
|
||||
function parse_duedate($s)
|
||||
{
|
||||
$y = $m = $d = 0;
|
||||
if(preg_match("|^(\d+)-(\d+)-(\d+)\b|", $s, $ma)) {
|
||||
$y = (int)$ma[1]; $m = (int)$ma[2]; $d = (int)$ma[3];
|
||||
}
|
||||
elseif(preg_match("|^(\d+)\/(\d+)\/(\d+)\b|", $s, $ma)) {
|
||||
$m = (int)$ma[1]; $d = (int)$ma[2]; $y = (int)$ma[3];
|
||||
}
|
||||
elseif(preg_match("|^(\d+)\.(\d+)\.(\d+)\b|", $s, $ma)) {
|
||||
$d = (int)$ma[1]; $m = (int)$ma[2]; $y = (int)$ma[3];
|
||||
}
|
||||
elseif(preg_match("|^(\d+)\.(\d+)\b|", $s, $ma)) {
|
||||
$d = (int)$ma[1]; $m = (int)$ma[2];
|
||||
$a = explode(',', date('Y,m,d'));
|
||||
if( $m<(int)$a[1] || ($m==(int)$a[1] && $d<(int)$a[2]) ) $y = (int)$a[0]+1;
|
||||
else $y = (int)$a[0];
|
||||
}
|
||||
elseif(preg_match("|^(\d+)\/(\d+)\b|", $s, $ma)) {
|
||||
$m = (int)$ma[1]; $d = (int)$ma[2];
|
||||
$a = explode(',', date('Y,m,d'));
|
||||
if( $m<(int)$a[1] || ($m==(int)$a[1] && $d<(int)$a[2]) ) $y = (int)$a[0]+1;
|
||||
else $y = (int)$a[0];
|
||||
}
|
||||
else return null;
|
||||
if($y < 100) $y = 2000 + $y;
|
||||
elseif($y < 1000 || $y > 2099) $y = 2000 + (int)substr((string)$y, -2);
|
||||
if($m > 12) $m = 12;
|
||||
$maxdays = daysInMonth($m,$y);
|
||||
if($m < 10) $m = '0'.$m;
|
||||
if($d > $maxdays) $d = $maxdays;
|
||||
elseif($d < 10) $d = '0'.$d;
|
||||
return "$y-$m-$d";
|
||||
}
|
||||
|
||||
function prepare_duedate($duedate, $tz=null)
|
||||
{
|
||||
global $lang, $config;
|
||||
|
||||
$a = array( 'class'=>'', 'str'=>'', 'formatted'=>'' );
|
||||
if($duedate == '') {
|
||||
return $a;
|
||||
}
|
||||
if(is_null($tz)) {
|
||||
$ad = explode('-', $duedate);
|
||||
$at = explode('-', date('Y-m-d'));
|
||||
}
|
||||
else {
|
||||
$ad = explode('-', $duedate);
|
||||
$at = explode('-', gmdate('Y-m-d',time() + $tz*60));
|
||||
}
|
||||
$diff = mktime(0,0,0,$ad[1],$ad[2],$ad[0]) - mktime(0,0,0,$at[1],$at[2],$at[0]);
|
||||
|
||||
if($diff < -604800 && $ad[0] == $at[0]) { $a['class'] = 'past'; $a['str'] = $lang->formatMD((int)$ad[1], (int)$ad[2]); }
|
||||
elseif($diff < -604800) { $a['class'] = 'past'; $a['str'] = $lang->formatYMD((int)$ad[0], (int)$ad[1], (int)$ad[2]); }
|
||||
elseif($diff < -86400) { $a['class'] = 'past'; $a['str'] = sprintf($lang->get('daysago'),ceil(abs($diff)/86400)); }
|
||||
elseif($diff < 0) { $a['class'] = 'past'; $a['str'] = $lang->get('yesterday'); }
|
||||
elseif($diff < 86400) { $a['class'] = 'today'; $a['str'] = $lang->get('today'); }
|
||||
elseif($diff < 172800) { $a['class'] = 'today'; $a['str'] = $lang->get('tomorrow'); }
|
||||
elseif($diff < 691200) { $a['class'] = 'soon'; $a['str'] = sprintf($lang->get('indays'),ceil($diff/86400)); }
|
||||
elseif($ad[0] == $at[0]) { $a['class'] = 'future'; $a['str'] = $lang->formatMD((int)$ad[1], (int)$ad[2]); }
|
||||
else { $a['class'] = 'future'; $a['str'] = $lang->formatYMD((int)$ad[0], (int)$ad[1], (int)$ad[2]); }
|
||||
|
||||
if($config['duedateformat'] == 2) $a['formatted'] = (int)$ad[1].'/'.(int)$ad[2].'/'.$ad[0];
|
||||
elseif($config['duedateformat'] == 3) $a['formatted'] = $ad[2].'.'.$ad[1].'.'.$ad[0];
|
||||
else $a['formatted'] = $duedate;
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
function date2int($d)
|
||||
{
|
||||
if(!$d) return 33330000;
|
||||
$ad = explode('-', $d);
|
||||
$s = $ad[0];
|
||||
if(strlen($ad[1]) < 2) $s .= "0$ad[1]"; else $s .= $ad[1];
|
||||
if(strlen($ad[2]) < 2) $s .= "0$ad[2]"; else $s .= $ad[2];
|
||||
return (int)$s;
|
||||
}
|
||||
|
||||
function daysInMonth($m, $y=0)
|
||||
{
|
||||
if($y == 0) $y = (int)date('Y');
|
||||
$a = array(1=>31,(($y-2000)%4?28:29),31,30,31,30,31,31,30,31,30,31);
|
||||
if(isset($a[$m])) return $a[$m]; else return 0;
|
||||
}
|
||||
|
||||
function myErrorHandler($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
if($errno==E_ERROR || $errno==E_CORE_ERROR || $errno==E_COMPILE_ERROR || $errno==E_USER_ERROR || $errno==E_PARSE) $error = 'Error';
|
||||
elseif($errno==E_WARNING || $errno==E_CORE_WARNING || $errno==E_COMPILE_WARNING || $errno==E_USER_WARNING || $errno==E_STRICT) {
|
||||
if(error_reporting() & $errno) $error = 'Warning'; else return;
|
||||
}
|
||||
elseif($errno==E_NOTICE || $errno==E_USER_NOTICE) {
|
||||
if(error_reporting() & $errno) $error = 'Notice'; else return;
|
||||
}
|
||||
elseif(defined('E_DEPRECATED') && ($errno==E_DEPRECATED || $errno==E_USER_DEPRECATED)) { # since 5.3.0
|
||||
if(error_reporting() & $errno) $error = 'Notice'; else return;
|
||||
}
|
||||
else $error = "Error ($errno)"; # here may be E_RECOVERABLE_ERROR
|
||||
throw new Exception("$error: '$errstr' in $errfile:$errline", -1);
|
||||
}
|
||||
|
||||
function myExceptionHandler($e)
|
||||
{
|
||||
if(-1 == $e->getCode()) {
|
||||
echo $e->getMessage(); exit;
|
||||
}
|
||||
echo 'Exception: \''. $e->getMessage() .'\' in '. $e->getFile() .':'. $e->getLine();
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
167
src/class.db.mysql.php
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
# Copyright 2009 Max Pozdeev
|
||||
|
||||
class DatabaseResult_Mysql
|
||||
{
|
||||
|
||||
var $parent;
|
||||
var $q;
|
||||
var $query;
|
||||
var $rows = NULL;
|
||||
var $affected = NULL;
|
||||
|
||||
function __construct($query, &$h, $resultless = 0)
|
||||
{
|
||||
$this->parent = $h;
|
||||
$this->query = $query;
|
||||
|
||||
$this->q = mysql_query($query, $this->parent->dbh);
|
||||
|
||||
if(!$this->q)
|
||||
{
|
||||
throw new Exception($this->parent->error());
|
||||
}
|
||||
}
|
||||
|
||||
function affected()
|
||||
{
|
||||
if(is_null($this->affected))
|
||||
{
|
||||
$this->affected = mysql_affected_rows($this->parent->dbh);
|
||||
}
|
||||
return $this->affected;
|
||||
}
|
||||
|
||||
function fetch_row()
|
||||
{
|
||||
return mysql_fetch_row($this->q);
|
||||
}
|
||||
|
||||
function fetch_assoc()
|
||||
{
|
||||
return mysql_fetch_assoc($this->q);
|
||||
}
|
||||
|
||||
function rows()
|
||||
{
|
||||
if (!is_null($this -> rows)) return $this->rows;
|
||||
$this->rows = mysql_num_rows($this->q);
|
||||
return $this->rows;
|
||||
}
|
||||
}
|
||||
|
||||
class Database_Mysql
|
||||
{
|
||||
var $dbh;
|
||||
var $error_str;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
function connect($host, $user, $pass, $db)
|
||||
{
|
||||
if(!$this->dbh = @mysql_connect($host,$user,$pass))
|
||||
{
|
||||
throw new Exception(mysql_error());
|
||||
}
|
||||
if( @!mysql_select_db($db, $this->dbh) )
|
||||
{
|
||||
throw new Exception($this->error());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function last_insert_id()
|
||||
{
|
||||
return mysql_insert_id($this->dbh);
|
||||
}
|
||||
|
||||
function error()
|
||||
{
|
||||
return mysql_error($this->dbh);
|
||||
}
|
||||
|
||||
function sq($query, $p = NULL)
|
||||
{
|
||||
$q = $this->_dq($query, $p);
|
||||
|
||||
if($q->rows()) $res = $q->fetch_row();
|
||||
else return NULL;
|
||||
|
||||
if(sizeof($res) > 1) return $res;
|
||||
else return $res[0];
|
||||
}
|
||||
|
||||
function sqa($query, $p = NULL)
|
||||
{
|
||||
$q = $this->_dq($query, $p);
|
||||
|
||||
if($q->rows()) $res = $q->fetch_assoc();
|
||||
else return NULL;
|
||||
|
||||
if(sizeof($res) > 1) return $res;
|
||||
else return $res[0];
|
||||
}
|
||||
|
||||
function dq($query, $p = NULL)
|
||||
{
|
||||
return $this->_dq($query, $p);
|
||||
}
|
||||
|
||||
function ex($query, $p = NULL)
|
||||
{
|
||||
return $this->_dq($query, $p, 1);
|
||||
}
|
||||
|
||||
private function _dq($query, $p = NULL, $resultless = 0)
|
||||
{
|
||||
if(!isset($p)) $p = array();
|
||||
elseif(!is_array($p)) $p = array($p);
|
||||
|
||||
$m = explode('?', $query);
|
||||
|
||||
if(sizeof($p)>0)
|
||||
{
|
||||
if(sizeof($m)< sizeof($p)+1) {
|
||||
throw new Exception("params to set MORE than query params");
|
||||
}
|
||||
if(sizeof($m)> sizeof($p)+1) {
|
||||
throw new Exception("params to set LESS than query params");
|
||||
}
|
||||
$query = "";
|
||||
for($i=0; $i<sizeof($m)-1; $i++) {
|
||||
$query .= $m[$i]. $this->quote($p[$i]);
|
||||
}
|
||||
$query .= $m[$i];
|
||||
}
|
||||
return new DatabaseResult_Mysql($query, $this, $resultless);
|
||||
}
|
||||
|
||||
function affected()
|
||||
{
|
||||
return mysql_affected_rows($this->dbh);
|
||||
}
|
||||
|
||||
function quote($s)
|
||||
{
|
||||
return '\''. addslashes($s). '\'';
|
||||
}
|
||||
|
||||
function quoteForLike($format, $s)
|
||||
{
|
||||
$s = str_replace(array('%','_'), array('\%','\_'), addslashes($s));
|
||||
return '\''. sprintf($format, $s). '\'';
|
||||
}
|
||||
|
||||
function table_exists($table)
|
||||
{
|
||||
$table = addslashes($table);
|
||||
$q = mysql_query("SELECT 1 FROM `$table` WHERE 1=0", $this->dbh);
|
||||
if($q === false) return false;
|
||||
else return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
158
src/class.db.sqlite.php
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
|
||||
class DatabaseResult_Sqlite
|
||||
{
|
||||
private $parent;
|
||||
private $q;
|
||||
var $query;
|
||||
private $rows = NULL;
|
||||
private $affected = NULL;
|
||||
|
||||
function __construct($query, &$h, $resultless = 0)
|
||||
{
|
||||
$this->parent = $h;
|
||||
$this->query = $query;
|
||||
|
||||
if($resultless) $this->q = @$this->parent->dbh->queryExec($query, $error);
|
||||
else $this->q = @$this->parent->dbh->query($query, 0, $error);
|
||||
|
||||
if(!$this->q)
|
||||
{
|
||||
if($error) throw new Exception($error);
|
||||
else throw new Exception(sqlite_error_string($this->parent->dbh->lastError()));
|
||||
}
|
||||
}
|
||||
|
||||
function rows()
|
||||
{
|
||||
if (!is_null($this->rows)) return $this->rows;
|
||||
$this->rows = $this->q->numRows();
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
function fetch_row()
|
||||
{
|
||||
return $this->q->fetch(SQLITE_NUM);
|
||||
}
|
||||
|
||||
function fetch_assoc()
|
||||
{
|
||||
return $this->q->fetch(SQLITE_ASSOC);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Database_Sqlite
|
||||
{
|
||||
var $dbh;
|
||||
private $affected = null;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
function connect($filename, $mode=0666)
|
||||
{
|
||||
try {
|
||||
$this->dbh = new SQLiteDatabase($filename, 0666, $error);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
throw new Exception($error);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function sq($query, $p = NULL)
|
||||
{
|
||||
$q = $this->_dq($query, $p);
|
||||
|
||||
if($q->rows()) $res = $q->fetch_row();
|
||||
else return NULL;
|
||||
|
||||
if(sizeof($res) > 1) return $res;
|
||||
else return $res[0];
|
||||
}
|
||||
|
||||
function sqa($query, $p = NULL)
|
||||
{
|
||||
$q = $this->_dq($query, $p);
|
||||
|
||||
if($q->rows()) $res = $q->fetch_assoc();
|
||||
else return NULL;
|
||||
|
||||
if(sizeof($res) > 1) return $res;
|
||||
else return $res[0];
|
||||
}
|
||||
|
||||
function dq($query, $p = NULL)
|
||||
{
|
||||
return $this->_dq($query, $p);
|
||||
}
|
||||
|
||||
/*
|
||||
for resultless queries like INSERT,UPDATE
|
||||
*/
|
||||
function ex($query, $p = NULL)
|
||||
{
|
||||
return $this->_dq($query, $p, 1);
|
||||
}
|
||||
|
||||
private function _dq($query, $p = NULL, $resultless = 0)
|
||||
{
|
||||
if(!isset($p)) $p = array();
|
||||
elseif(!is_array($p)) $p = array($p);
|
||||
|
||||
$m = explode('?', $query);
|
||||
|
||||
if(sizeof($p)>0)
|
||||
{
|
||||
if(sizeof($m)< sizeof($p)+1) {
|
||||
throw new Exception("params to set MORE than query params");
|
||||
}
|
||||
if(sizeof($m)> sizeof($p)+1) {
|
||||
throw new Exception("params to set LESS than query params");
|
||||
}
|
||||
$query = "";
|
||||
for($i=0; $i<sizeof($m)-1; $i++) {
|
||||
$query .= $m[$i]. $this->quote($p[$i]);
|
||||
}
|
||||
$query .= $m[$i];
|
||||
}
|
||||
return new DatabaseResult_Sqlite($query, $this, $resultless);
|
||||
}
|
||||
|
||||
function affected()
|
||||
{
|
||||
if(is_null($this->affected))
|
||||
{
|
||||
$this->affected = $this->dbh->changes();
|
||||
}
|
||||
return $this->affected;
|
||||
}
|
||||
|
||||
function quote($s)
|
||||
{
|
||||
return '\''. sqlite_escape_string($s). '\'';
|
||||
}
|
||||
|
||||
function quoteForLike($format, $s)
|
||||
{
|
||||
$s = str_replace(array('\\','%','_'), array('\\\\','\%','\_'), $s);
|
||||
return $this->quote(sprintf($format, $s));
|
||||
}
|
||||
|
||||
function last_insert_id()
|
||||
{
|
||||
return $this->dbh->lastInsertRowid();
|
||||
}
|
||||
|
||||
function table_exists($table)
|
||||
{
|
||||
$table = $this->quote($table);
|
||||
$q = @$this->dbh->query("SELECT 1 FROM $table WHERE 1=0");
|
||||
if($q === false) return false;
|
||||
else return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
156
src/class.db.sqlite3.php
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
class DatabaseResult_Sqlite3
|
||||
{
|
||||
private $parent;
|
||||
private $q;
|
||||
var $query;
|
||||
|
||||
function __construct($query, &$h, $resultless = 0)
|
||||
{
|
||||
$this->parent = $h;
|
||||
$this->parent->lastQuery = $this->query = $query;
|
||||
|
||||
if($resultless)
|
||||
{
|
||||
$r = $this->parent->dbh->exec($query);
|
||||
if($r === false) {
|
||||
$ei = $this->parent->dbh->errorInfo();
|
||||
throw new Exception($ei[2]);
|
||||
}
|
||||
$this->parent->affected = $r;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->q = $this->parent->dbh->query($query);
|
||||
if(!$this->q) {
|
||||
$ei = $this->parent->dbh->errorInfo();
|
||||
throw new Exception($ei[2]);
|
||||
}
|
||||
$this->parent->affected = $this->q->rowCount();
|
||||
}
|
||||
}
|
||||
|
||||
function fetch_row()
|
||||
{
|
||||
return $this->q->fetch(PDO::FETCH_NUM);
|
||||
}
|
||||
|
||||
function fetch_assoc()
|
||||
{
|
||||
return $this->q->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Database_Sqlite3
|
||||
{
|
||||
var $dbh;
|
||||
var $affected = null;
|
||||
var $lastQuery;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
function connect($filename)
|
||||
{
|
||||
try {
|
||||
$this->dbh = new PDO("sqlite:$filename");
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function sq($query, $p = NULL)
|
||||
{
|
||||
$q = $this->_dq($query, $p);
|
||||
|
||||
$res = $q->fetch_row();
|
||||
if($res === false) return NULL;
|
||||
|
||||
if(sizeof($res) > 1) return $res;
|
||||
else return $res[0];
|
||||
}
|
||||
|
||||
function sqa($query, $p = NULL)
|
||||
{
|
||||
$q = $this->_dq($query, $p);
|
||||
|
||||
$res = $q->fetch_assoc();
|
||||
if($res === false) return NULL;
|
||||
|
||||
if(sizeof($res) > 1) return $res;
|
||||
else return $res[0];
|
||||
}
|
||||
|
||||
function dq($query, $p = NULL)
|
||||
{
|
||||
return $this->_dq($query, $p);
|
||||
}
|
||||
|
||||
/*
|
||||
for resultless queries like INSERT,UPDATE
|
||||
*/
|
||||
function ex($query, $p = NULL)
|
||||
{
|
||||
return $this->_dq($query, $p, 1);
|
||||
}
|
||||
|
||||
private function _dq($query, $p = NULL, $resultless = 0)
|
||||
{
|
||||
if(!isset($p)) $p = array();
|
||||
elseif(!is_array($p)) $p = array($p);
|
||||
|
||||
$m = explode('?', $query);
|
||||
|
||||
if(sizeof($p)>0)
|
||||
{
|
||||
if(sizeof($m)< sizeof($p)+1) {
|
||||
throw new Exception("params to set MORE than query params");
|
||||
}
|
||||
if(sizeof($m)> sizeof($p)+1) {
|
||||
throw new Exception("params to set LESS than query params");
|
||||
}
|
||||
$query = "";
|
||||
for($i=0; $i<sizeof($m)-1; $i++) {
|
||||
$query .= $m[$i]. $this->quote($p[$i]);
|
||||
}
|
||||
$query .= $m[$i];
|
||||
}
|
||||
return new DatabaseResult_Sqlite3($query, $this, $resultless);
|
||||
}
|
||||
|
||||
function affected()
|
||||
{
|
||||
return $this->affected;
|
||||
}
|
||||
|
||||
function quote($s)
|
||||
{
|
||||
return $this->dbh->quote($s);
|
||||
}
|
||||
|
||||
function quoteForLike($format, $s)
|
||||
{
|
||||
$s = str_replace(array('\\','%','_'), array('\\\\','\%','\_'), $s);
|
||||
return $this->dbh->quote(sprintf($format, $s)). " ESCAPE '\'";
|
||||
}
|
||||
|
||||
function last_insert_id()
|
||||
{
|
||||
return $this->dbh->lastInsertId();
|
||||
}
|
||||
|
||||
function table_exists($table)
|
||||
{
|
||||
$table = $this->dbh->quote($table);
|
||||
$q = $this->dbh->query("SELECT 1 FROM $table WHERE 1=0");
|
||||
if($q === false) return false;
|
||||
else return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
62
src/common.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
function htmlarray($a, $exclude=null)
|
||||
{
|
||||
htmlarray_ref($a, $exclude);
|
||||
return $a;
|
||||
}
|
||||
|
||||
function htmlarray_ref(&$a, $exclude=null)
|
||||
{
|
||||
if(!$a) return;
|
||||
if(!is_array($a)) {
|
||||
$a = htmlspecialchars($a);
|
||||
return;
|
||||
}
|
||||
reset($a);
|
||||
if($exclude && !is_array($exclude)) $exclude = array($exclude);
|
||||
foreach($a as $k=>$v)
|
||||
{
|
||||
if(is_array($v)) $a[$k] = htmlarray($v, $exclude);
|
||||
elseif(!$exclude) $a[$k] = htmlspecialchars($v);
|
||||
elseif(!in_array($k, $exclude)) $a[$k] = htmlspecialchars($v);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function stop_gpc(&$arr)
|
||||
{
|
||||
if (!is_array($arr)) return 1;
|
||||
|
||||
if (!get_magic_quotes_gpc()) return 1;
|
||||
reset($arr);
|
||||
foreach($arr as $k=>$v)
|
||||
{
|
||||
if(is_array($arr[$k])) stop_gpc($arr[$k]);
|
||||
elseif(is_string($arr[$k])) $arr[$k] = stripslashes($v);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
function _post($param,$defvalue = '')
|
||||
{
|
||||
if(!isset($_POST[$param])) {
|
||||
return $defvalue;
|
||||
}
|
||||
else {
|
||||
return $_POST[$param];
|
||||
}
|
||||
}
|
||||
|
||||
function _get($param,$defvalue = '')
|
||||
{
|
||||
if(!isset($_GET[$param])) {
|
||||
return $defvalue;
|
||||
}
|
||||
else {
|
||||
return $_GET[$param];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
1
src/db/.htaccess
Normal file
|
|
@ -0,0 +1 @@
|
|||
deny from all
|
||||
0
src/db/todolist.db.empty
Normal file
5
src/images/COPYRIGHT
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Image files (page_cross.png, page_cross_bw.png, page_white_edit.png, page_white_edit_bw.png,
|
||||
page_white_text_add.png, page_white_text_add_bw.png) are based on icons from Silk Icons set,
|
||||
and icons page_white_text.png and calendar.png are part of Silk Icons set by Mark James
|
||||
<http://www.famfamfam.com/lab/icons/silk/>, licensed under Creative Commons Attribution 2.5 License
|
||||
<http://creativecommons.org/licenses/by/2.5/>.
|
||||
BIN
src/images/arrdown.gif
Normal file
|
After Width: | Height: | Size: 110 B |
BIN
src/images/calendar.png
Normal file
|
After Width: | Height: | Size: 675 B |
1
src/images/index.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
Place for Images
|
||||
BIN
src/images/loading1.gif
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
src/images/loading1_24.gif
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/images/page_cross.png
Normal file
|
After Width: | Height: | Size: 729 B |
BIN
src/images/page_cross_bw.png
Normal file
|
After Width: | Height: | Size: 660 B |
BIN
src/images/page_white_edit.png
Normal file
|
After Width: | Height: | Size: 618 B |
BIN
src/images/page_white_edit_bw.png
Normal file
|
After Width: | Height: | Size: 550 B |
BIN
src/images/page_white_text.png
Normal file
|
After Width: | Height: | Size: 342 B |
BIN
src/images/page_white_text_add.png
Normal file
|
After Width: | Height: | Size: 629 B |
BIN
src/images/page_white_text_add_bw.png
Normal file
|
After Width: | Height: | Size: 592 B |
BIN
src/images/resizegrip.gif
Normal file
|
After Width: | Height: | Size: 56 B |
190
src/index.php
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
<?php
|
||||
/*
|
||||
This file is part of myTinyTodo.
|
||||
(C) Copyright 2009 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
|
||||
require_once('init.php');
|
||||
require_once('./lang/class.default.php');
|
||||
require_once('./lang/'.$config['lang'].'.php');
|
||||
|
||||
$lang = new Lang();
|
||||
if(!$needAuth) $tabDisabled = '';
|
||||
elseif(!is_logged() && canAllRead()) $tabDisabled = ', selected:1, disabled: [0]';
|
||||
elseif(!is_logged()) $tabDisabled = ', disabled: [0,1]';
|
||||
else $tabDisabled = '';
|
||||
|
||||
$sort = 0;
|
||||
if(isset($_COOKIE['sort']) && $_COOKIE['sort'] != '') $sort = (int)$_COOKIE['sort'];
|
||||
|
||||
if($config['duedateformat'] == 2) $duedateformat = 'm/d/yy';
|
||||
elseif($config['duedateformat'] == 3) $duedateformat = 'dd.mm.yy';
|
||||
else $duedateformat = 'yy-mm-dd';
|
||||
|
||||
function __($s)
|
||||
{
|
||||
global $lang;
|
||||
echo $lang->get($s);
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<HEAD>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title><?php __('My Tiny Todolist');?></title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css" media="all">
|
||||
<?php if(isset($_GET['pda'])): ?>
|
||||
<meta name="viewport" id="viewport" content="width=device-width">
|
||||
<link rel="stylesheet" type="text/css" href="pda.css" media="all">
|
||||
<?php else: ?>
|
||||
<link rel="stylesheet" type="text/css" href="print.css" media="print">
|
||||
<?php endif; ?>
|
||||
</HEAD>
|
||||
|
||||
<body>
|
||||
|
||||
<script type="text/javascript" src="jquery/jquery-1.3.2.min.js"></script>
|
||||
<script type="text/javascript" src="jquery/jquery-ui-1.7.2.custom.min.js"></script>
|
||||
<script type="text/javascript" src="ajax.lang.php"></script>
|
||||
<script type="text/javascript" src="ajax.js"></script>
|
||||
<script type="text/javascript" src="jquery/jquery.autocomplete.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$().ready(function(){
|
||||
$("#tabs").tabs({ select: tabSelected <?php echo $tabDisabled; ?>});
|
||||
$("#tasklist").sortable({cancel:'span,input,a,textarea', delay: 150, update:orderChanged, start:sortStart, items:'> :not(.task-completed)'});
|
||||
$("#tasklist").bind("click", tasklistClick);
|
||||
$("#edittags").autocomplete('ajax.php?suggestTags', {scroll: false, multiple: true, selectFirst:false, max:8});
|
||||
$("#priopopup").mouseleave(function(){$(this).hide()});
|
||||
setSort(<?php echo $sort; ?>,1);
|
||||
<?php
|
||||
if($needAuth)
|
||||
{
|
||||
echo "\tflag.needAuth = true;\n";
|
||||
if(!canAllRead()) echo "\tflag.canAllRead = false;\n";
|
||||
if(is_logged()) echo "\tflag.isLogged = true;\n";
|
||||
if(is_logged() || canAllRead()) echo "\tloadTasks();\n";
|
||||
echo "\tupdateAccessStatus(1);\n";
|
||||
} else {
|
||||
echo "\tloadTasks();\n";
|
||||
}
|
||||
?>
|
||||
preloadImg();
|
||||
$("#duedate").datepicker({dateFormat: '<?php echo $duedateformat; ?>', firstDay: 1, showOn: 'button', buttonImage: 'images/calendar.png', buttonImageOnly: true,
|
||||
changeMonth:true, changeYear:true, constrainInput: false, duration:'', nextText:'>', prevText:'<', dayNamesMin:lang.daysMin,
|
||||
monthNamesShort:lang.monthsShort });
|
||||
<?php if(!isset($_GET['pda'])): ?>
|
||||
$("#page_taskedit").draggable({ stop: function(e,ui){ flag.windowTaskEditMoved=true; tmp.editformpos=[$(this).css('left'),$(this).css('top')]; } });
|
||||
$("#page_taskedit").resizable({ minWidth:$("#page_taskedit").width(), minHeight:$("#page_taskedit").height(), start:function(ui,e){editFormResize(1)}, resize:function(ui,e){editFormResize(0,e)}, stop:function(ui,e){editFormResize(2,e)} });
|
||||
<?php endif; ?>
|
||||
|
||||
});
|
||||
$().ajaxSend( function(r,s) {$("#loading").show();} );
|
||||
$().ajaxStop( function(r,s) {$("#loading").fadeOut();} );
|
||||
</script>
|
||||
|
||||
<div id="wrapper">
|
||||
<div id="container">
|
||||
<div id="body">
|
||||
|
||||
<h2><?php __('My Tiny Todolist');?></h2>
|
||||
|
||||
<div id="loading"><img src="images/loading1.gif"></div>
|
||||
|
||||
<div id="bar">
|
||||
<div style="float:left"><span id="msg" onClick="toggleMsgDetails()"></span><div id="msgdetails"></div></div>
|
||||
<div id="bar_auth" align="right">
|
||||
<span id="bar_login"><span id="authstr"> </span> <a href="#" class="nodecor" onClick="showAuth(this);return false;"><u><?php __('a_login');?></u> <img src="images/arrdown.gif" border=0></a></span>
|
||||
<a href="#" id="bar_logout" onClick="logout();return false"><?php __('a_logout');?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br clear="all">
|
||||
|
||||
<div id="page_tasks">
|
||||
|
||||
<div id="tabs">
|
||||
<ul class="">
|
||||
<li><a href="#newtask"><?php __('tab_newtask');?></a></li>
|
||||
<li><a href="#searchtask"><?php __('tab_search');?></a></li>
|
||||
</ul><br clear="all">
|
||||
<div class="tab-content" id="newtask">
|
||||
<form onSubmit="return submitNewTask(this)"><input type="text" name="task" value="" maxlength="250" id="task"> <input type="submit" value="<?php __('btn_add');?>"></form>
|
||||
</div>
|
||||
<div class="tab-content" id="searchtask">
|
||||
<form onSubmit="return searchTasks()"><input type="text" name="search" value="" maxlength="250" id="search" onKeyUp="timerSearch()" autocomplete="off"> <input type="submit" value="<?php __('btn_search');?>"></form>
|
||||
<div id="searchbar"><?php __('searching');?> <span id="searchbarkeyword"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3><span id="taskviewcontainer" onClick="showTaskview(this);"><span class="btnstr"><?php __('tasks');?></span> (<span id="total">0</span>) <img src="images/arrdown.gif"></span>
|
||||
<span id="sort" onClick="showSort(this);"><span class="btnstr"></span> <img src="images/arrdown.gif"></span>
|
||||
<span id="tagcloudbtn" onClick="showTagCloud(this);" title="<?php __('tags');?>"><span class="btnstr"><?php __('tags');?></span> <img src="images/arrdown.gif"></span>
|
||||
</h3>
|
||||
|
||||
<div id="taskcontainer">
|
||||
<ol id="tasklist" class="sortable"></ol>
|
||||
</div>
|
||||
|
||||
</div> <!-- end of page_tasks -->
|
||||
|
||||
|
||||
<div id="page_taskedit" style="display:none">
|
||||
|
||||
<h3><?php __('edit_task');?></h3>
|
||||
|
||||
<form onSubmit="return saveTask(this)" name="edittask">
|
||||
<input type="hidden" name="id" value="">
|
||||
<div class="form-row"><span class="h"><?php __('priority');?></span> <SELECT name="prio"><option value="2">+2</option><option value="1">+1</option><option value="0" selected>±0</option><option value="-1">−1</option></SELECT>
|
||||
<span class="h"><?php __('due');?> </span> <input name="duedate" id="duedate" value="" class="in100" title="Y-M-D, M/D/Y, D.M.Y, M/D, D.M" autocomplete="off"></div>
|
||||
<div class="form-row"><span class="h"><?php __('task');?></span><br> <input type="text" name="task" value="" class="in500" maxlength="250"></div>
|
||||
<div class="form-row"><span class="h"><?php __('note');?></span><br> <textarea name="note" class="in500"></textarea></div>
|
||||
<div class="form-row"><span class="h"><?php __('tags');?></span><br> <input type="text" name="tags" id="edittags" value="" class="in500" maxlength="250"></div>
|
||||
<div class="form-row"><input type="submit" value="<?php __('save');?>" onClick="this.blur()"> <input type="button" value="<?php __('cancel');?>" onClick="cancelEdit();this.blur();return false"></div>
|
||||
</form>
|
||||
|
||||
</div> <!-- end of page_taskedit -->
|
||||
|
||||
|
||||
<div id="authform" style="display:none">
|
||||
<form onSubmit="doAuth(this);return false;">
|
||||
<div class="h"><?php __('password');?></div><div><input type="password" name="password" id="password"></div><div><input type="submit" value="<?php __('btn_login');?>"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="priopopup" style="display:none">
|
||||
<span class="prio-neg" onClick="prioClick(-1,this)">−1</span> <span class="prio-o" onClick="prioClick(0,this)">±0</span>
|
||||
<span class="prio-pos" onClick="prioClick(1,this)">+1</span> <span class="prio-pos" onClick="prioClick(2,this)">+2</span>
|
||||
</div>
|
||||
|
||||
<div id="taskview" style="display:none">
|
||||
<div class="li" onClick="setTaskview(0);taskviewClose();"><span id="view_tasks"><?php __('tasks');?></span></div>
|
||||
<div class="li" onClick="setTaskview(1);taskviewClose();"><span id="view_compl"><?php __('tasks_and_compl');?></span></div>
|
||||
<div class="li" onClick="setTaskview('past');taskviewClose();"><span id="view_past"><?php __('f_past');?></span> (<span id="cnt_past">0</span>)</div>
|
||||
<div class="li" onClick="setTaskview('today');taskviewClose();"><span id="view_today"><?php __('f_today');?></span> (<span id="cnt_today">0</span>)</div>
|
||||
<div class="li" onClick="setTaskview('soon');taskviewClose();"><span id="view_soon"><?php __('f_soon');?></span> (<span id="cnt_soon">0</span>)</div>
|
||||
</div>
|
||||
|
||||
<div id="sortform" style="display:none">
|
||||
<div id="sortByHand" class="li" onClick="setSort(0);sortClose();"><?php __('sortByHand');?></div>
|
||||
<div id="sortByPrio" class="li" onClick="setSort(1);sortClose();"><?php __('sortByPriority');?></div>
|
||||
<div id="sortByDueDate" class="li" onClick="setSort(2);sortClose();"><?php __('sortByDueDate');?></div>
|
||||
</div>
|
||||
|
||||
<div id="tagcloud" style="display:none">
|
||||
<div id="tagcloudcancel" onClick="cancelTagFilter();tagCloudClose();"><?php __('tagfilter_cancel');?></div>
|
||||
<div id="tagcloudload""><img src="images/loading1_24.gif"></div>
|
||||
<div id="tagcloudcontent"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="space"></div>
|
||||
</div>
|
||||
|
||||
<div id="footer"><div id="footer_content">Powered by <strong><a href="http://www.pozdeev.com/mytinytodo/">myTinyTodo</a></strong> v1.2.5 </div></div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
68
src/init.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
require_once('common.php');
|
||||
require_once('./db/config.php');
|
||||
|
||||
ini_set('display_errors', 'On');
|
||||
|
||||
# MySQL Database Connection
|
||||
if(isset($config['mysql']))
|
||||
{
|
||||
require_once('class.db.mysql.php');
|
||||
$db = new Database_Mysql;
|
||||
$db->connect($config['mysql'][0], $config['mysql'][1], $config['mysql'][2], $config['mysql'][3]);
|
||||
$db->dq("SET NAMES utf8");
|
||||
}
|
||||
|
||||
# SQLite2 Database
|
||||
elseif(isset($config['sqlite']) && 2 == $config['sqlite'])
|
||||
|
||||
{
|
||||
require_once('class.db.sqlite.php');
|
||||
$db = new Database_Sqlite;
|
||||
$db->connect('./db/todolist.db');
|
||||
}
|
||||
|
||||
# SQLite3 (pdo_sqlite)
|
||||
else
|
||||
{
|
||||
require_once('class.db.sqlite3.php');
|
||||
$db = new Database_Sqlite3;
|
||||
$db->connect('./db/todolist.db');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$needAuth = (isset($config['password']) && $config['password'] != '') ? 1 : 0;
|
||||
if($needAuth)
|
||||
{
|
||||
if(isset($config['session']) && $config['session'] == 'files')
|
||||
{
|
||||
session_save_path(realpath('./tmp/sessions/'));
|
||||
ini_set('session.gc_maxlifetime', '1209600'); # 14 days session file minimum lifetime
|
||||
ini_set('session.gc_probability', 1);
|
||||
ini_set('session.gc_divisor', 10);
|
||||
}
|
||||
|
||||
ini_set('session.use_cookies', true);
|
||||
ini_set('session.use_only_cookies', true);
|
||||
session_set_cookie_params(1209600, substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1)); #14 days session cookie lifetime
|
||||
session_start();
|
||||
}
|
||||
|
||||
|
||||
function canAllRead()
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config['password']) || $config['password'] == '') return true;
|
||||
if(isset($config['allow']) && $config['allow'] == "read") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_logged()
|
||||
{
|
||||
if(!isset($_SESSION['logged']) || !$_SESSION['logged']) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
1
src/jquery/index.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
Place for jQuery UI
|
||||
19
src/jquery/jquery-1.3.2.min.js
vendored
Normal file
91
src/jquery/jquery-ui-1.7.2.custom.min.js
vendored
Normal file
15
src/jquery/jquery.autocomplete.min.js
vendored
Normal file
1
src/lang/.htaccess
Normal file
|
|
@ -0,0 +1 @@
|
|||
deny from all
|
||||
110
src/lang/class.default.php
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
myTinyTodo default language class
|
||||
*/
|
||||
|
||||
class DefaultLang
|
||||
{
|
||||
private $default_js = array
|
||||
(
|
||||
'actionNote' => "note",
|
||||
'actionEdit' => "modify",
|
||||
'actionDelete' => "delete",
|
||||
'taskDate' => array("function(date) { return 'added at '+date; }"),
|
||||
'confirmDelete' => "Are you sure?",
|
||||
'actionNoteSave' => "save",
|
||||
'actionNoteCancel' => "cancel",
|
||||
'error' => "Some error occurred (click for details)",
|
||||
'denied' => "Access denied",
|
||||
'invalidpass' => "Wrong password",
|
||||
'readonly' => "read-only",
|
||||
'tagfilter' => "Tag:",
|
||||
);
|
||||
|
||||
private $default_inc = array
|
||||
(
|
||||
'My Tiny Todolist' => "My Tiny Todolist",
|
||||
'tab_newtask' => "new task",
|
||||
'tab_search' => "search",
|
||||
'btn_add' => "Add",
|
||||
'btn_search' => "Search",
|
||||
'searching' => "Searching for",
|
||||
'tasks' => "Tasks",
|
||||
'edit_task' => "Edit Task",
|
||||
'priority' => "Priority",
|
||||
'task' => "Task",
|
||||
'note' => "Note",
|
||||
'save' => "Save",
|
||||
'cancel' => "Cancel",
|
||||
'password' => "Password",
|
||||
'btn_login' => "Login",
|
||||
'a_login' => "Login",
|
||||
'a_logout' => "Logout",
|
||||
'tags' => "Tags",
|
||||
'tagfilter_cancel' => "cancel filter",
|
||||
'sortByHand' => "Sort by hand",
|
||||
'sortByPriority' => "Sort by priority",
|
||||
'sortByDueDate' => "Sort by due date",
|
||||
'due' => "Due",
|
||||
'daysago' => "%d days ago",
|
||||
'indays' => "in %d days",
|
||||
'months_short' => array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),
|
||||
'days_min' => array("Su","Mo","Tu","We","Th","Fr","Sa"),
|
||||
'date_md' => "%1\$s %2\$d",
|
||||
'date_ymd' => "%2\$s %3\$d, %1\$d",
|
||||
'today' => "today",
|
||||
'yesterday' => "yesterday",
|
||||
'tomorrow' => "tomorrow",
|
||||
'f_past' => "Overdue",
|
||||
'f_today' => "Today and tomorrow",
|
||||
'f_soon' => "Soon",
|
||||
'tasks_and_compl' => "Tasks + completed",
|
||||
);
|
||||
|
||||
var $js = array();
|
||||
var $inc = array();
|
||||
|
||||
function makeJS()
|
||||
{
|
||||
$a = array();
|
||||
foreach($this->default_js as $k=>$v)
|
||||
{
|
||||
if(isset($this->js[$k])) $v = $this->js[$k];
|
||||
|
||||
if(is_array($v)) {
|
||||
$a[] = "$k: ". $v[0];
|
||||
} else {
|
||||
$a[] = "$k: \"". str_replace('"','\\"',$v). "\"";
|
||||
}
|
||||
}
|
||||
$t = array();
|
||||
foreach($this->get('days_min') as $v) { $t[] = '"'.str_replace('"','\\"',$v).'"'; }
|
||||
$a[] = "daysMin: [". implode(',', $t). "]";
|
||||
$t = array();
|
||||
foreach($this->get('months_short') as $v) { $t[] = '"'.str_replace('"','\\"',$v).'"'; }
|
||||
$a[] = "monthsShort: [". implode(',', $t). "]";
|
||||
return "lang = {\n". implode(",\n", $a). "\n};";
|
||||
}
|
||||
|
||||
function get($key)
|
||||
{
|
||||
if(isset($this->inc[$key])) return $this->inc[$key];
|
||||
if(isset($this->default_inc[$key])) return $this->default_inc[$key];
|
||||
return $key;
|
||||
}
|
||||
|
||||
function formatMD($m, $d)
|
||||
{
|
||||
$months = $this->get('months_short');
|
||||
return sprintf($this->get('date_md'), $months[$m-1], $d);
|
||||
}
|
||||
|
||||
function formatYMD($y, $m, $d)
|
||||
{
|
||||
$months = $this->get('months_short');
|
||||
return sprintf($this->get('date_ymd'), $y, $months[$m-1], $d);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
62
src/lang/en.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
class Lang extends DefaultLang
|
||||
{
|
||||
var $js = array
|
||||
(
|
||||
'actionNote' => "note",
|
||||
'actionEdit' => "modify",
|
||||
'actionDelete' => "delete",
|
||||
'taskDate' => array("function(date) { return 'added at '+date; }"),
|
||||
'confirmDelete' => "Are you sure?",
|
||||
'actionNoteSave' => "save",
|
||||
'actionNoteCancel' => "cancel",
|
||||
'error' => "Some error occurred (click for details)",
|
||||
'denied' => "Access denied",
|
||||
'invalidpass' => "Wrong password",
|
||||
'readonly' => "read-only",
|
||||
'tagfilter' => "Tag:",
|
||||
);
|
||||
|
||||
var $inc = array
|
||||
(
|
||||
'My Tiny Todolist' => "My Tiny Todolist",
|
||||
'tab_newtask' => "new task",
|
||||
'tab_search' => "search",
|
||||
'btn_add' => "Add",
|
||||
'btn_search' => "Search",
|
||||
'searching' => "Searching for",
|
||||
'tasks' => "Tasks",
|
||||
'edit_task' => "Edit Task",
|
||||
'priority' => "Priority",
|
||||
'task' => "Task",
|
||||
'note' => "Note",
|
||||
'save' => "Save",
|
||||
'cancel' => "Cancel",
|
||||
'password' => "Password",
|
||||
'btn_login' => "Login",
|
||||
'a_login' => "Login",
|
||||
'a_logout' => "Logout",
|
||||
'tags' => "Tags",
|
||||
'tagfilter_cancel' => "cancel filter",
|
||||
'sortByHand' => "Sort by hand",
|
||||
'sortByPriority' => "Sort by priority",
|
||||
'sortByDueDate' => "Sort by due date",
|
||||
'due' => "Due",
|
||||
'daysago' => "%d days ago",
|
||||
'indays' => "in %d days",
|
||||
'months_short' => array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),
|
||||
'days_min' => array("Su","Mo","Tu","We","Th","Fr","Sa"),
|
||||
'date_md' => "%1\$s %2\$d",
|
||||
'date_ymd' => "%2\$s %3\$d, %1\$d",
|
||||
'today' => "today",
|
||||
'yesterday' => "yesterday",
|
||||
'tomorrow' => "tomorrow",
|
||||
'f_past' => "Overdue",
|
||||
'f_today' => "Today and tomorrow",
|
||||
'f_soon' => "Soon",
|
||||
'tasks_and_compl' => "Tasks + completed",
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
45
src/pda.css
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
body { margin:0px; }
|
||||
h2 { margin:0; margin-bottom:2px; font-size:18px; }
|
||||
h3 { margin-bottom:4px; padding:4px 0; }
|
||||
#footer { padding:4px; margin-top:8px; }
|
||||
#body { margin-left:1px; margin-right:1px; padding:1px; }
|
||||
|
||||
#bar_login, #bar_logout { padding-right:1px; }
|
||||
|
||||
#tabs ul { margin-top:0px; }
|
||||
#tabs ul li { width:70px; margin-right: 1px; }
|
||||
.tab-content { padding:4px; }
|
||||
#task, #search { color:#444444; width:65%; max-width:300px; }
|
||||
#newtaskadv_t { display: none; }
|
||||
|
||||
#tasklist li { padding:4px 1px; overflow:hidden; }
|
||||
.task-actions { float:none; display:none; margin-left:2px; text-align:right; padding:3px 3px; margin-bottom:2px; width:100%; /*background-color:#e0e0e0;*/ }
|
||||
.task-actions a, .task-note-actions a { padding:4px 4px; /*background-color:#c0c0c0; color:#000000; text-decoration:none; font-weight:bold;*/ }
|
||||
.task-date { display:none; }
|
||||
.task-note-actions { display:block; padding-top:8px; }
|
||||
div.task-note-block { margin-left:12px; border-left:1px solid #777777; background:none; padding-left:4px; margin-top:1px; padding-top:0px; display:none; }
|
||||
div.task-note-area textarea { width:95%; }
|
||||
.nobr { white-space:nowrap; }
|
||||
.task-middle { margin-right:0px; }
|
||||
|
||||
#tasklist li:hover { background-color:#ffffff; }
|
||||
#tasklist li.clicked { background-color:#f6f6f6; }
|
||||
#tasklist li.clicked .task-date { display:none; }
|
||||
#tasklist li.clicked .task-actions { display:block; }
|
||||
#tasklist li.clicked div.task-note-block { display:block; }
|
||||
#tasklist li.clicked div.task-note-block.hidden { display:none; }
|
||||
#tasklist li.clicked .nobr { white-space:normal; }
|
||||
#tasklist li.clicked.doubleclicked .task-actions { display:none; }
|
||||
#tasklist li.clicked.doubleclicked div.task-note-block { display:none; }
|
||||
#tasklist li.clicked.doubleclicked .nobr { white-space:nowrap; }
|
||||
|
||||
#page_taskedit { max-width:100%; padding:0px; }
|
||||
.form-table { width:100%; }
|
||||
.form-table .in500 { width:95%; max-width:500px; color:#444444; }
|
||||
.form-table textarea { height: 70px; }
|
||||
|
||||
#loading { padding:0px; padding-top:1px; padding-right:1px; height:16px; overflow:hidden; }
|
||||
#loading img { /*width:8px; height:8px;*/ }
|
||||
#authstr { float:none; }
|
||||
|
||||
#tagcloud { max-width:100%; }
|
||||
26
src/print.css
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
html { height:0; }
|
||||
body { height:0; min-height:0; margin:0; }
|
||||
h2{ display: none; }
|
||||
h3 { border-bottom:2px solid #777777; }
|
||||
#tabs { display: none; }
|
||||
.small-bar { display:none; }
|
||||
.task-actions { display:none; }
|
||||
|
||||
#bar { display:none; }
|
||||
#taskviewcontainer { border:none; }
|
||||
#taskviewcontainer img { display:none; }
|
||||
|
||||
#tasklist { list-style-type: decimal; list-style-position: outside; }
|
||||
#tasklist li { padding-left:0px; margin-left:30px; border-bottom:none; padding-bottom: 8px; }
|
||||
div.task-note-block { border-left:1px solid #777777; background:none; padding-left:5px; margin-top:5px; padding-top:0px; font-size:9pt; color:#333333; }
|
||||
.task-middle { margin-left:0px; margin-right:3px; }
|
||||
.task-left { display:none; }
|
||||
|
||||
.task-date { white-space:nowrap; margin-left:10px; }
|
||||
#tasklist li.today, #tasklist li.past { background-color:#ffffff; border-color:#dedede; }
|
||||
|
||||
#footer_content { border-top:1px solid #777777; background:none; }
|
||||
#footer_content a { text-decoration:none; color:#000000; }
|
||||
|
||||
#sort { display:none; }
|
||||
#tagcloudbtn { display:none; }
|
||||
245
src/setup.php
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
This file is part of myTinyTodo.
|
||||
(C) Copyright 2009 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
require_once('./init.php');
|
||||
if($needAuth && !is_logged())
|
||||
{
|
||||
die("Access denied!<br> Disable password protection or Log in.");
|
||||
}
|
||||
$dbclass = strtolower(get_class($db));
|
||||
$dbtype = ($dbclass == 'database_mysql') ? 'mysql' : 'sqlite';
|
||||
|
||||
$lastVer = '1.2';
|
||||
echo '<html><head><meta name="robots" content="noindex,nofollow"></head><body>';
|
||||
echo "<b>myTinyTodo v$lastVer Setup</b><br><br>";
|
||||
|
||||
# exclude sqlite2
|
||||
if($dbclass == 'database_sqlite') {
|
||||
exitMessage("Install/update is not available for sqlite2. Use sqlite v3.");
|
||||
}
|
||||
|
||||
# determine current installed version
|
||||
$ver = get_ver($db, $dbtype);
|
||||
|
||||
if(!$ver)
|
||||
{
|
||||
# install database
|
||||
if(!isset($_POST['install'])) {
|
||||
exitMessage("This will create myTinyTodo database <form method=post><input type=hidden name=install value=1><input type=submit value=' Install '></form>");
|
||||
}
|
||||
|
||||
if($dbtype == 'mysql')
|
||||
{
|
||||
try
|
||||
{
|
||||
$db->ex(
|
||||
"CREATE TABLE todolist (
|
||||
`id` INT UNSIGNED NOT NULL auto_increment,
|
||||
`d` DATETIME NOT NULL,
|
||||
`compl` TINYINT UNSIGNED NOT NULL default 0,
|
||||
`title` VARCHAR(250) NOT NULL,
|
||||
`note` TEXT,
|
||||
`prio` TINYINT NOT NULL default 0, /* priority -,0,+ */
|
||||
`ow` INT NOT NULL default 0, /* order weight */
|
||||
`tags` VARCHAR(250) NOT NULL default '', /* denormalization - for fast access to task tags */
|
||||
`duedate` DATE default NULL,
|
||||
PRIMARY KEY(`id`)
|
||||
) CHARSET=utf8 ");
|
||||
|
||||
$db->ex(
|
||||
"CREATE TABLE tags (
|
||||
`id` INT UNSIGNED NOT NULL auto_increment,
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`tags_count` INT default 0,
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE KEY(`name`)
|
||||
) CHARSET=utf8 ");
|
||||
|
||||
$db->ex(
|
||||
"CREATE TABLE tag2task (
|
||||
`tag_id` INT UNSIGNED NOT NULL,
|
||||
`task_id` INT UNSIGNED NOT NULL,
|
||||
KEY(`tag_id`),
|
||||
KEY(`task_id`)
|
||||
) CHARSET=utf8 ");
|
||||
|
||||
} catch (Exception $e) {
|
||||
exitMessage("<b>Error:</b> ". htmlarray($e->getMessage()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
$db->ex(
|
||||
"CREATE TABLE todolist (
|
||||
id INTEGER PRIMARY KEY,
|
||||
d DATETIME NOT NULL default '0000-00-00',
|
||||
compl TINYINT UNSIGNED NOT NULL default 0,
|
||||
title VARCHAR(250) NOT NULL,
|
||||
note TEXT,
|
||||
prio TINYINT NOT NULL default 0,
|
||||
ow INT NOT NULL default 0,
|
||||
tags VARCHAR(250) NOT NULL default '',
|
||||
duedate DATE default NULL
|
||||
) ");
|
||||
|
||||
$db->ex(
|
||||
"CREATE TABLE tags (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name VARCHAR(50) NOT NULL COLLATE NOCASE UNIQUE,
|
||||
tags_count INT default 0
|
||||
) ");
|
||||
|
||||
$db->ex(
|
||||
"CREATE TABLE tag2task (
|
||||
tag_id INTEGER NOT NULL,
|
||||
task_id INTEGER NOT NULL
|
||||
) ");
|
||||
|
||||
$db->ex("CREATE INDEX tag_id ON tag2task (tag_id)");
|
||||
$db->ex("CREATE INDEX task_id ON tag2task (task_id)");
|
||||
|
||||
} catch (Exception $e) {
|
||||
exitMessage("<b>Error:</b> ". htmlarray($e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($ver == $lastVer)
|
||||
{
|
||||
exitMessage("Installed version (v$ver) does not require database update.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!in_array($ver, array('1.1'))) {
|
||||
exitMessage("Can not update database. Unsupported version ($ver).");
|
||||
}
|
||||
if(!isset($_POST['update'])) {
|
||||
exitMessage("Update database from v$ver to v1.2 <form method=post><input type=hidden name=update value=1><input type=submit value=' Update '></form>");
|
||||
}
|
||||
|
||||
# update process
|
||||
if($ver == '1.1')
|
||||
{
|
||||
update_11_12($db, $dbtype);
|
||||
}
|
||||
}
|
||||
echo "Done<br><br> <b>Attention!</b> Delete this file for security reasons.";
|
||||
printFooter();
|
||||
|
||||
|
||||
function get_ver($db, $dbtype)
|
||||
{
|
||||
if(!$db->table_exists('todolist')) return '';
|
||||
$v = '1.0';
|
||||
if(!$db->table_exists('tags')) return $v;
|
||||
$v = '1.1';
|
||||
if($dbtype == 'mysql') {
|
||||
if(!has_field_mysql($db, 'todolist', 'duedate')) return $v;
|
||||
} else {
|
||||
if(!has_field_sqlite($db, 'todolist', 'duedate')) return $v;
|
||||
}
|
||||
$v = '1.2';
|
||||
return $v;
|
||||
}
|
||||
|
||||
function exitMessage($s)
|
||||
{
|
||||
echo $s;
|
||||
printFooter();
|
||||
exit;
|
||||
}
|
||||
|
||||
function printFooter()
|
||||
{
|
||||
echo "</body></html>";
|
||||
}
|
||||
|
||||
|
||||
function has_field_sqlite($db, $table, $field)
|
||||
{
|
||||
$q = $db->dq("PRAGMA table_info(". $db->quote($table). ")");
|
||||
while($r = $q->fetch_row()) {
|
||||
if($r[1] == $field) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function has_field_mysql($db, $table, $field)
|
||||
{
|
||||
$q = $db->dq("DESCRIBE `$table`");
|
||||
while($r = $q->fetch_row()) {
|
||||
if($r[0] == $field) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
### 1.1-1.2 ##########
|
||||
function update_11_12($db, $dbtype)
|
||||
{
|
||||
echo "Changing database structure...<br>";
|
||||
if($dbtype == 'mysql') $db->ex("ALTER TABLE todolist ADD `duedate` DATE default NULL");
|
||||
else $db->ex("ALTER TABLE todolist ADD duedate DATE default NULL");
|
||||
|
||||
echo "Fixing broken tags...<br>";
|
||||
$db->ex("BEGIN");
|
||||
$db->ex("DELETE FROM tags");
|
||||
$db->ex("DELETE FROM tag2task");
|
||||
$q = $db->dq("SELECT id,tags FROM todolist");
|
||||
while($r = $q->fetch_assoc())
|
||||
{
|
||||
if($r['tags'] == '') continue;
|
||||
$tag_ids = prepare_tags($r['tags']);
|
||||
if($tag_ids) update_task_tags($r['id'], $tag_ids);
|
||||
}
|
||||
$db->ex("COMMIT");
|
||||
}
|
||||
|
||||
function prepare_tags(&$tags_str)
|
||||
{
|
||||
$tag_ids = array();
|
||||
$tag_names = array();
|
||||
$tags = explode(',', $tags_str);
|
||||
foreach($tags as $v)
|
||||
{
|
||||
# remove duplicate tags?
|
||||
$tag = str_replace(array('"',"'"),array('',''),trim($v));
|
||||
if($tag == '') continue;
|
||||
list($tag_id,$tag_name) = get_or_create_tag($tag);
|
||||
if($tag_id && !in_array($tag_id, $tag_ids)) {
|
||||
$tag_ids[] = $tag_id;
|
||||
$tag_names[] = $tag_name;
|
||||
}
|
||||
}
|
||||
$tags_str = implode(',', $tag_names);
|
||||
return $tag_ids;
|
||||
}
|
||||
|
||||
function get_or_create_tag($name)
|
||||
{
|
||||
global $db;
|
||||
$tag = $db->sq("SELECT id,name FROM tags WHERE name=?", $name);
|
||||
if($tag) return $tag;
|
||||
|
||||
# need to create tag
|
||||
$db->ex("INSERT INTO tags (name) VALUES (?)", $name);
|
||||
return array($db->last_insert_id(), $name);
|
||||
}
|
||||
|
||||
function update_task_tags($id, $tag_ids)
|
||||
{
|
||||
global $db;
|
||||
foreach($tag_ids as $v) {
|
||||
$db->ex("INSERT INTO tag2task (task_id,tag_id) VALUES ($id,$v)");
|
||||
}
|
||||
$db->ex("UPDATE tags SET tags_count=tags_count+1 WHERE id IN (". implode(',', $tag_ids). ")");
|
||||
}
|
||||
|
||||
### end 1.1-1.2 #####
|
||||
|
||||
?>
|
||||
166
src/style.css
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
body, td, th, input,textarea,select { font-family: arial; font-size:10pt; }
|
||||
html { height:100%; }
|
||||
body { margin:0px; padding:0px; height:100%; min-height:100%; }
|
||||
#wrapper { margin:0px auto; max-width:1000px; height:100%; }
|
||||
#container { height:auto !important;height:100%;min-height:100%; }
|
||||
#body { padding:8px; padding-bottom:16px; }
|
||||
form { display: inline; }
|
||||
h2,h3 { margin:0; }
|
||||
h2 { font-size:15pt; float:left; padding-right:10px; background-color:#ffffff; }
|
||||
h3 { border-bottom:2px solid #B5D5FF; margin-bottom:10px; padding:6px 0; font-size:11pt; }
|
||||
a { color:#0000ff; }
|
||||
#space { height:30px; }
|
||||
#footer { height:30px; margin-top:-30px; }
|
||||
#footer_content { background:#b5d5ff; padding:5px; font-size:8pt; }
|
||||
#footer_content a { color:#000000; }
|
||||
|
||||
#bar { border-bottom:1px solid #b5d5ff; padding-bottom:5px; height:15px; }
|
||||
.nodecor { text-decoration:none; }
|
||||
#bar_logout { display:none; }
|
||||
#bar_auth { display:none; }
|
||||
#authform { overflow: hidden; z-index:101; background-color:#f9f9f9; border:1px solid #cccccc; padding:5px; width:160px; }
|
||||
#authform div { padding:2px 0px; }
|
||||
#authform div.h { font-weight:bold; }
|
||||
|
||||
#tabs ul { list-style: none; padding:0; margin:0; }
|
||||
#tabs ul li { margin:0; font-size: 9pt; font-weight:bold; float: left; width:90px; text-align:center; margin-right: 6px; }
|
||||
#tabs ul a { margin:0px; text-decoration: none; color:#444444; display: block; height:24px; width: 100%; padding-top: 4px; outline:none; }
|
||||
#tabs ul li.ui-tabs-selected { background-color: #ededed; }
|
||||
#tabs ul li.ui-state-hover a { color: #888888; }
|
||||
.ui-tabs .ui-tabs-hide { display: none; }
|
||||
#tabs ul li.ui-state-disabled a { color: #cccccc; }
|
||||
|
||||
.tab-content { background-color: #ededed; padding:8px; border-bottom:2px solid #DEDEDE; }
|
||||
#loading { float:left; padding-top:5px; background-color:#ffffff; display:none; padding-right:6px;}
|
||||
|
||||
#task, #search { color:#444444; width:300px; }
|
||||
.small-bar{ font-size:8pt; color:#999999; font-weight:normal;}
|
||||
#msg { background-color:#ff3333; padding:1px 4px; display:none; font-weight:bold; cursor:pointer; }
|
||||
#msgdetails { padding:1px 4px; border:1px solid #ff3333; background-color:#fff; display:none; max-width:700px; }
|
||||
#searchbar { font-size:10pt; font-weight:normal; display:none; margin-top:5px; }
|
||||
#searchbarkeyword { font-weight:bold; }
|
||||
|
||||
#sort { margin-left:5px; font-size:8pt; font-weight:normal; border-bottom:1px dashed #ccc; padding:2px; cursor:pointer; -moz-user-select:none; -webkit-user-select: none; }
|
||||
#sort:hover { border-bottom:1px solid #bbb; }
|
||||
#sortform { overflow: hidden; z-index:101; background-color:#f9f9f9; border:1px solid #cccccc; padding:3px; }
|
||||
#sortform .li { margin:1px 0px; padding:2px; cursor:pointer; }
|
||||
#sortform .li:hover { background-color:#316AC5; color:white; }
|
||||
|
||||
.task-left { width:25px; float:left; }
|
||||
.task-middle { margin-left:25px; margin-right:65px; }
|
||||
.nobr input { margin-left:0px; margin-right:4px; }
|
||||
#tasklist { list-style-type: none; margin: 0; padding: 0;}
|
||||
#tasklist li { padding:6px 2px 6px 6px; border-bottom:1px solid #DEDEDE; min-height:18px; margin-bottom:1px; background-color:#fff; }
|
||||
#tasklist li:hover { background-color:#f6f6f6; }
|
||||
.task-actions { float:right; width:65px; text-align:right; }
|
||||
.task-actions a { margin-left:2px; margin-right:2px; }
|
||||
.task-actions img { border:none; width:16px; height:16px; }
|
||||
.task-date { color:#999999; font-size:8pt; margin-left:4px; display:none; }
|
||||
.task-title a { color:#000000; }
|
||||
.task-title a:hover { color:#af0000; }
|
||||
#tasklist.readonly li .task-actions { display:none; }
|
||||
.task-tags { margin-left:4px; padding:0px 2px; }
|
||||
.task-tags .tag { font-size:8pt; font-weight:bold; color:#333333; text-decoration:underline; }
|
||||
.task-tags .tag:hover { }
|
||||
.duedate { color:#333333; border-bottom:1px dotted #333333; padding:0px; padding-left:1px; margin-left:5px; float:right; }
|
||||
#tasklist li.soon .duedate { color:#008000; border-color:#008000; }
|
||||
#tasklist li.today .duedate { color:#FF0000; border-color:#FF0000; }
|
||||
#tasklist li.past .duedate { color:#A52A2A; border-color:#A52A2A; }
|
||||
li.task-completed span.task-through { text-decoration:line-through; color:#777777; }
|
||||
li.task-completed .task-title a { color:#777777; }
|
||||
li.task-completed .task-actions a { color:#7070ff; }
|
||||
#tasklist li.task-completed .duedate { color:#777777; border-color:#777777; }
|
||||
li.task-completed { opacity:0.7; }
|
||||
|
||||
#tasklist.filter-past li, #tasklist.filter-today li, #tasklist.filter-soon li { display:none; }
|
||||
#tasklist.filter-past li.past, #tasklist.filter-today li.today, #tasklist.filter-soon li.soon { display:block; }
|
||||
#tasklist.filter-past li.task-completed, #tasklist.filter-today li.task-completed, #tasklist.filter-soon li.task-completed { display:none; }
|
||||
|
||||
div.task-note-block { margin-left:2px; color:#777777; background:url(images/page_white_text.png) left 2px no-repeat; padding-left:19px; padding-top:2px; min-height:16px; margin-top:2px; }
|
||||
li.task-completed div.task-note-block div.task-note { text-decoration:line-through; }
|
||||
div.task-note-area { display:none; margin-bottom:5px; }
|
||||
div.task-note-area textarea { color:#999999; width:100%; display:block; height:65px; }
|
||||
.task-note-actions { font-size:8pt; }
|
||||
.hidden { display:none; }
|
||||
.in500 { width:500px; color:#444444; }
|
||||
.in100 { width:100px; color:#444444; }
|
||||
.task-note span a { color:#777777; }
|
||||
.task-note span a:hover { color:#af0000; }
|
||||
|
||||
.task-prio { padding-left:2px; padding-right:2px; margin-left: 2px; margin-right:3px; cursor:default; }
|
||||
.prio-neg { background-color:#3377ff; color:#ffffff; }
|
||||
.prio-pos { background-color:#ff3030; color:#ffffff; }
|
||||
.prio-o { background-color:#dedede; }
|
||||
#tasklist li .prio-o { display:none; }
|
||||
|
||||
#authstr { display: none; color:#999999; }
|
||||
#authstr.attention { color:#ff0000; }
|
||||
|
||||
.form-row { margin-top:4px; margin-bottom:4px; }
|
||||
.form-row span.h { font-weight:bold; color:#333333; }
|
||||
#overlay { position:fixed; z-index:200; background-color:#111111; display:none; top:0px; left:0px; width:100%; height:100%; }
|
||||
#page_taskedit { position:fixed; z-index:201; background-color:#fdfdfd; padding:8px; border:1px solid #cccccc; width:510px; }
|
||||
#page_taskedit .form-row .in500 { width:99%; }
|
||||
#page_taskedit .form-row textarea.in500 { height:130px; /*resize:none;*/ }
|
||||
.ui-icon-gripsmall-diagonal-se { background-image:url(images/resizegrip.gif); }
|
||||
|
||||
/* autocomplete */
|
||||
.ac_results { padding: 0px; border: 1px solid #cccccc; background-color: #f0f0f0; overflow: hidden; z-index: 99999; }
|
||||
.ac_results ul { width: 100%; list-style-position: outside; list-style: none; padding: 0; margin: 0; }
|
||||
.ac_results li { margin: 0px; padding: 2px 5px; cursor: default; display: block; line-height: 16px; overflow: hidden; }
|
||||
.ac_over { background-color: #bbbbbb; color: white; }
|
||||
|
||||
#priopopup { overflow: hidden; z-index:101; background-color:#f9f9f9; border:1px solid #cccccc; padding:5px; }
|
||||
#priopopup .prio-o { display:inline; }
|
||||
#priopopup span { cursor:pointer; border:1px solid #f9f9f9; }
|
||||
#priopopup .prio-o:hover { border:1px solid #dedede; }
|
||||
#priopopup .prio-neg:hover { border:1px solid #3377ff; }
|
||||
#priopopup .prio-pos:hover { border:1px solid #ff3030; }
|
||||
|
||||
#tagcloudbtn { margin-left:5px; font-size:8pt; font-weight:normal; border-bottom:1px dashed #ccc; padding:2px; cursor:pointer; -moz-user-select:none; -webkit-user-select: none; }
|
||||
#tagcloudbtn:hover { border-bottom:1px solid #bbb; }
|
||||
#tagcloudbtn .tag { font-weight:bold; }
|
||||
#tagcloudload { display:none; }
|
||||
#tagcloud { overflow: hidden; z-index:101; background-color:#f9f9f9; border:1px solid #cccccc; padding:5px; width:400px; text-align:center; }
|
||||
#tagcloud .tag { margin:1px; padding:2px; line-height:140%; color:black; }
|
||||
#tagcloud .tag:hover { background-color:#999988; color:white; }
|
||||
#tagcloud .w0 { font-size:80%; }
|
||||
#tagcloud .w1 { font-size:90%; }
|
||||
#tagcloud .w2 { font-size:100%; }
|
||||
#tagcloud .w3 { font-size:110%; }
|
||||
#tagcloud .w4 { font-size:120%; }
|
||||
#tagcloud .w5 { font-size:130%; }
|
||||
#tagcloud .w6 { font-size:140%; }
|
||||
#tagcloud .w7 { font-size:150%; }
|
||||
#tagcloud .w8 { font-size:160%; }
|
||||
#tagcloud .w9 { font-size:170%; }
|
||||
#tagcloudcancel { border:1px solid #cccccc; padding:2px; margin-bottom:4px; cursor:pointer; background-color:#fdfdfd; }
|
||||
#tagcloudcancel:hover { border-color:#aaaaaa; }
|
||||
|
||||
.ui-datepicker { width:180px; z-index:202; border: 1px solid #cccccc; background: #ffffff; display:none; padding:2px; }
|
||||
.ui-datepicker-trigger { cursor:pointer; vertical-align:text-bottom; margin-left:1px; }
|
||||
.ui-datepicker-calendar { width:100%; border-collapse:collapse; }
|
||||
.ui-datepicker-calendar thead th { text-align:center; padding:0px; font-size:9pt; }
|
||||
.ui-datepicker-calendar tbody td { text-align:right; padding:1px; }
|
||||
.ui-datepicker-calendar td a { display:block; text-decoration:none; color:#444444; border:1px solid #cccccc; background-color:#f9f9f9; color:#111; padding:0px 1px; }
|
||||
.ui-datepicker-calendar td.ui-datepicker-today a { color:#666666; background-color:#fff; }
|
||||
.ui-datepicker-calendar td.ui-datepicker-current-day a { background-color:#EAF5FF; color:#222222; border-color:#5980FF; }
|
||||
.ui-datepicker-calendar td a:hover { color:#5980FF; }
|
||||
.ui-datepicker-header { padding:3px 0px; }
|
||||
.ui-datepicker-prev { position:absolute; left:2px;}
|
||||
.ui-datepicker-next { position:absolute; right:2px;}
|
||||
.ui-datepicker-title { text-align:center; }
|
||||
.ui-datepicker-prev, .ui-datepicker-next { cursor:pointer; padding:0px 3px; }
|
||||
|
||||
#taskviewcontainer { border-bottom:1px dashed #ccc; padding:1px 2px; }
|
||||
#taskviewcontainer:hover { cursor:pointer; border-bottom:1px solid #bbb; }
|
||||
#taskview { overflow: hidden; z-index:103; background-color:#f9f9f9; border:1px solid #cccccc; padding:3px; }
|
||||
#taskview .li { margin:1px 0px; padding:2px; cursor:pointer; }
|
||||
#taskview .li:hover { background-color:#316AC5; color:white; }
|
||||
|
||||
.ui-resizable { position:relative;}
|
||||
.ui-resizable-handle { position:absolute; font-size:0.1px; z-index:99999; display:block;}
|
||||
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display:none; }
|
||||
.ui-resizable-s { cursor:s-resize; height:7px; width:100%; bottom:-5px; left:0px; }
|
||||
.ui-resizable-e { cursor:e-resize; width:7px; right:-5px; top:0px; height:100%; }
|
||||
.ui-resizable-se { cursor:se-resize; width:12px; height:12px; right:1px; bottom:1px; }
|
||||
1
src/tmp/.htaccess
Normal file
|
|
@ -0,0 +1 @@
|
|||
deny from all
|
||||