webglade

JavaScript library to dynamically create XUL GUI from Glade XML files
git clone https://logand.com/git/webglade.git/
Log | Files | Refs | README | LICENSE

commit df1a349e0a4b04865f682c4cb11494b811e72c45
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sat, 18 Sep 2010 01:28:42 +0200

Initial commit

Diffstat:
ACHANGES | 5+++++
ACOPYING | 674+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AREADME | 4++++
Ahtv3/htv3.glade | 274+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahtv3/htv3.gladep | 8++++++++
Ahtv3/htv3.js | 19+++++++++++++++++++
Ahtv3/htv3.ls | 15+++++++++++++++
Ahtv3/htv3.xul | 8++++++++
Ahw/hw.glade | 38++++++++++++++++++++++++++++++++++++++
Ahw/hw.gladep | 8++++++++
Ahw/hw.js | 25+++++++++++++++++++++++++
Ahw/hw.ls | 18++++++++++++++++++
Ahw/hw.xul | 8++++++++
Ahw2/hw2.glade | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahw2/hw2.gladep | 13+++++++++++++
Ahw2/hw2.js | 19+++++++++++++++++++
Ahw2/hw2.ls | 20++++++++++++++++++++
Ahw2/hw2.xul | 8++++++++
Amab/TODO | 44++++++++++++++++++++++++++++++++++++++++++++
Amab/skin/images/abort.png | 0
Amab/skin/images/abort_disabled.png | 0
Amab/skin/images/clear.png | 0
Amab/skin/images/clear_disabled.png | 0
Amab/skin/images/comment.png | 0
Amab/skin/images/comment_disabled.png | 0
Amab/skin/images/context_menu.png | 0
Amab/skin/images/delete.png | 0
Amab/skin/images/delete_disabled.png | 0
Amab/skin/images/expired.png | 0
Amab/skin/images/filenew.png | 0
Amab/skin/images/filenew_disabled.png | 0
Amab/skin/images/fileopen.png | 0
Amab/skin/images/fileopen_disabled.png | 0
Amab/skin/images/filesave.png | 0
Amab/skin/images/filesave_disabled.png | 0
Amab/skin/images/forward.png | 0
Amab/skin/images/forward_disabled.png | 0
Amab/skin/images/goamazon.png | 0
Amab/skin/images/goamazon_disabled.png | 0
Amab/skin/images/gogoogle.png | 0
Amab/skin/images/gogoogle_disabled.png | 0
Amab/skin/images/gohome.png | 0
Amab/skin/images/label.png | 0
Amab/skin/images/mablogo.png | 0
Amab/skin/images/reload.png | 0
Amab/skin/images/rows_header.png | 0
Amab/skin/images/search.png | 0
Amab/skin/images/search_disabled.png | 0
Amab/skin/images/status_bar.png | 0
Amab/skin/images/status_unread.png | 0
Amab/skin/mab.css | 202+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/html/about.html | 34++++++++++++++++++++++++++++++++++
Amab/xul/html/allinfo.html | 12++++++++++++
Amab/xul/html/comment.html | 11+++++++++++
Amab/xul/html/cover.html | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/html/exportHTML.html | 23+++++++++++++++++++++++
Amab/xul/html/exportXML.html | 10++++++++++
Amab/xul/html/mab_help.html | 394+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/images/mablogo.png | 0
Amab/xul/js/AmazonParser.js | 143+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/Connection.js | 266+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/DisplayController.js | 891+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/DocOpenManager.js | 158+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/FileManager.js | 197+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/ProductLine.js | 149+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/ProductLineController.js | 676+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/ProgressBar.js | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/QueryStringBuilder.js | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/SearchController.js | 365+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/SearchHistory.js | 41+++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/XMDManager.js | 621+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/config.js | 103+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/mab.js | 864+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/settings.js | 41+++++++++++++++++++++++++++++++++++++++++
Amab/xul/js/utils.js | 167+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/mab.css | 202+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/mab.glade | 2145+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/mab.gladep | 11+++++++++++
Amab/xul/mab.js | 455+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/mab.ls | 360+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amab/xul/mab.xul | 26++++++++++++++++++++++++++
Awebglade.js | 1007+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Awebglade.ls | 794+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
83 files changed, 11908 insertions(+), 0 deletions(-)

diff --git a/CHANGES b/CHANGES @@ -0,0 +1,5 @@ +* 18sep10 v0.2 + - git repository published + +* 26aug08 v0.1 + - Initial version diff --git a/COPYING b/COPYING @@ -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>. diff --git a/README b/README @@ -0,0 +1,4 @@ +webglade -- JavaScript library to dynamically create XUL GUI from +Glade XML files. + +Written by Tomas Hlavaty <tom at logand.com> diff --git a/htv3/htv3.glade b/htv3/htv3.glade @@ -0,0 +1,274 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkWindow" id="window1"> + <property name="visible">True</property> + <property name="title" translatable="yes">window1</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <widget class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkFrame" id="frame2"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + + <child> + <widget class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkEntry" id="apples"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + <signal name="changed" handler="update" last_modification_time="Sat, 24 Feb 2007 18:05:42 GMT"/> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">apples</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkFrame" id="frame3"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + + <child> + <widget class="GtkAlignment" id="alignment3"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkEntry" id="bananas"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + <signal name="changed" handler="update" last_modification_time="Sat, 24 Feb 2007 18:05:52 GMT"/> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">bananas</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkFrame" id="frame4"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + + <child> + <widget class="GtkAlignment" id="alignment4"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkEntry" id="total"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">total</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">shopping list</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/htv3/htv3.gladep b/htv3/htv3.gladep @@ -0,0 +1,8 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd"> + +<glade-project> + <name>Htv3</name> + <program_name>htv3</program_name> + <gnome_support>FALSE</gnome_support> +</glade-project> diff --git a/htv3/htv3.js b/htv3/htv3.js @@ -0,0 +1,19 @@ +function main() { + loadXml + ('htv3.glade', + function (glade) { + var widgets = parseGlade(glade); + wbuild(document.documentElement, [ widgets['window1'] ]); + }); +}; + +WHANDLER['update'] = +function () { + var apples = wget('apples'); + var bananas = wget('bananas'); + var total = wget('total'); + wsetp + (total, 'value', + '' + wgetp(apples, 'value') + ' + ' + wgetp(bananas, 'value')); +}; + diff --git a/htv3/htv3.ls b/htv3/htv3.ls @@ -0,0 +1,15 @@ +;;; http://haskell.org/haskellwiki/TV section 2.3 + +(defun main () + (load-xml "htv3.glade" + (lambda (glade) + (let ((widgets (parse-glade glade))) + (wbuild document.document-element + (array (slot-value widgets "window1"))))))) + +(defhandler "update" () + (let ((apples (wget "apples")) + (bananas (wget "bananas")) + (total (wget "total"))) + (wsetp total "value" (+ "" (wgetp apples "value") + " + " (wgetp bananas "value"))))) diff --git a/htv3/htv3.xul b/htv3/htv3.xul @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> +<window + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + onload="main()"> +<script src="../webglade.js" type="application/x-javascript"/> +<script src="htv3.js" type="application/x-javascript"/> +</window> diff --git a/hw/hw.glade b/hw/hw.glade @@ -0,0 +1,38 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkWindow" id="window1"> + <property name="visible">True</property> + <property name="title" translatable="yes">window1</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <signal name="delete_event" handler="delete_event" last_modification_time="Sat, 24 Feb 2007 14:09:51 GMT"/> + <signal name="destroy" handler="destroy" last_modification_time="Sat, 24 Feb 2007 14:10:07 GMT"/> + + <child> + <widget class="GtkButton" id="button1"> + <property name="border_width">10</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Hello World!</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="hw" last_modification_time="Sat, 24 Feb 2007 14:09:10 GMT"/> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/hw/hw.gladep b/hw/hw.gladep @@ -0,0 +1,8 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd"> + +<glade-project> + <name></name> + <program_name></program_name> + <gnome_support>FALSE</gnome_support> +</glade-project> diff --git a/hw/hw.js b/hw/hw.js @@ -0,0 +1,25 @@ +function main() { + loadXml + ('hw.glade', + function (glade) { + var widgets = parseGlade(glade); + wbuild(document.documentElement, [ widgets['window1'] ]); + }); +}; + +WHANDLER['hw'] = +function (e) { + alert('Hello world! ' + e + ' ' + e.target); +}; + +WHANDLER['delete_event'] = +function () { + alert('delete_event'); +}; + +WHANDLER['destroy'] = +function () { + alert('destroy'); + gtkMainQuit(); +}; + diff --git a/hw/hw.ls b/hw/hw.ls @@ -0,0 +1,18 @@ +;;; http://common-lisp.net/project/lgtk/hw.html + +(defun main () + (load-xml "hw.glade" + (lambda (glade) + (let ((widgets (parse-glade glade))) + (wbuild document.document-element + (array (slot-value widgets "window1"))))))) + +(defhandler "hw" (e) + (alert (+ "Hello world! " e " " e.target))) + +(defhandler "delete_event" () + (alert "delete_event")) + +(defhandler "destroy" () + (alert "destroy") + (gtk-main-quit)) diff --git a/hw/hw.xul b/hw/hw.xul @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> +<window + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + onload="main()"> +<script src="../webglade.js" type="application/x-javascript"/> +<script src="hw.js" type="application/x-javascript"/> +</window> diff --git a/hw2/hw2.glade b/hw2/hw2.glade @@ -0,0 +1,67 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkWindow" id="window1"> + <property name="border_width">10</property> + <property name="visible">True</property> + <property name="title" translatable="yes">Hello Buttons!</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <signal name="delete_event" handler="delete-handler" last_modification_time="Sat, 24 Feb 2007 14:17:39 GMT"/> + + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">True</property> + <property name="spacing">4</property> + + <child> + <widget class="GtkButton" id="button1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Button 1</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="callback" last_modification_time="Sat, 24 Feb 2007 14:21:24 GMT"/> + </widget> + <packing> + <property name="padding">10</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="button2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Button 2</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="callback" last_modification_time="Sat, 24 Feb 2007 14:21:32 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/hw2/hw2.gladep b/hw2/hw2.gladep @@ -0,0 +1,13 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd"> + +<glade-project> + <name>Hw2</name> + <program_name>hw2</program_name> + <gnome_support>FALSE</gnome_support> + <gettext_support>FALSE</gettext_support> + <output_main_file>FALSE</output_main_file> + <output_support_files>FALSE</output_support_files> + <output_build_files>FALSE</output_build_files> + <backup_source_files>FALSE</backup_source_files> +</glade-project> diff --git a/hw2/hw2.js b/hw2/hw2.js @@ -0,0 +1,19 @@ +function main() { + loadXml + ('hw2.glade', + function (glade) { + var widgets = parseGlade(glade); + wbuild(document.documentElement, [ widgets['window1'] ]); + }); +}; + +WHANDLER['callback'] = +function (e) { + alert('Hello again - ' + e.target.id + ' was pressed.'); +}; + +WHANDLER['delete_handler'] = +function (hw2) { + gtkMainQuit(); +}; + diff --git a/hw2/hw2.ls b/hw2/hw2.ls @@ -0,0 +1,20 @@ +;;; http://common-lisp.net/project/lgtk/hw.html + +(defun main () + (load-xml "hw2.glade" + (lambda (glade) + (let ((widgets (parse-glade glade))) + (wbuild document.document-element + (array (slot-value widgets "window1"))))))) + +;; TODO handler args? + +(defhandler "callback" (e) ;;(wid num) + ;;(let ((num (if (eq source (find-widget-by-name app "button1")) 1 2))) + (alert (+ "Hello again - " e.target.id " was pressed."))) + +(defhandler "delete_handler" (hw2) + (gtk-main-quit)) + +;;(g-signal-connect button1 gtkclicked #'callback :data 1) +;;(g-signal-connect button2 gtkclicked #'callback :data 2) diff --git a/hw2/hw2.xul b/hw2/hw2.xul @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> +<window + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + onload="main()"> +<script src="../webglade.js" type="application/x-javascript"/> +<script src="hw2.js" type="application/x-javascript"/> +</window> diff --git a/mab/TODO b/mab/TODO @@ -0,0 +1,44 @@ +!!! iframe problem? + +<image src="" id="ImageUrlMedium" onclick="getImageLarge()" tooltiptext="Click to see the larger image"> +<window id="amazWindow" width="800" height="600" type="mab:main" persist="screenX screenY width height sizemode"> +<textbox id="find-text" ... allowevents="false" /> ??? + +persist=? + +? <!ENTITY goGoogle.label "Go to Google"> +? <!ENTITY imageLarge.tooltip "Click to see the larger image"> + +gladep images dir? + +fix DocOpenManager:-( + +;; tree + + <popupset> + <popup id="relatedcontext"> + <!-- TODO Use overaly to prevent replicate code. The above code is the same that is in main_menubar (edit) --> + <menu label="&label.label;"> + <menupopup> + <menuitem label="None" style="margin: 3px 3px 3px 3px;border: 1px solid" oncommand="setLabel('none')"/> + <menuseparator/> + <menuitem label="Orange" style="background-color: #FF4500;margin: 3px 3px 0px 3px;border: 1px solid" oncommand="setLabel('Orange')"/> + <menuitem label="Blue" style="background-color: Blue;margin: 3px 3px 0px 3px;border: 1px solid" oncommand="setLabel('Blue')"/> + <menuitem label="Green" style="background-color: Green;margin: 3px 3px 0px 3px;border: 1px solid" oncommand="setLabel('Green')"/> + <menuitem label="Maroon" style="background-color: Maroon;margin: 3px 3px 0px 3px;border: 1px solid" oncommand="setLabel('Maroon')"/> + <menuitem label="Olive" style="background-color: Olive;margin: 3px 3px 0px 3px;border: 1px solid" oncommand="setLabel('Olive')"/> + <menuitem label="Teal" style="background-color: Teal;margin: 3px 3px 0px 3px;border: 1px solid" oncommand="setLabel('Teal')"/> + <menuitem label="Purple" style=" background-color: Purple;margin: 3px 3px 3px 3px;border: 1px solid" oncommand="setLabel('Purple')"/> + </menupopup> + </menu> + <menuitem label="Text Summary" command="exportTXTCmd"/> + <menuitem label="Make CD Cover" command="makeCoverCmd"/> + <menuseparator/> + <menuitem label="Go to Amazon" command="goAmazonCmd"/> + <menuitem label="Add to cart" command="addCartCmd" /> + <menuitem label="Go to Google" command="goGoogleCmd" /> + <menuseparator/> + <menuitem label="Reload" command="reloadCmd"/> + <menuitem label="Load Review" command="commentCmd"/> + <menuitem label="Load Similar Products" command="simProductCmd"/> + <menuitem label="Delete" command="deleteCmd"/> diff --git a/mab/skin/images/abort.png b/mab/skin/images/abort.png Binary files differ. diff --git a/mab/skin/images/abort_disabled.png b/mab/skin/images/abort_disabled.png Binary files differ. diff --git a/mab/skin/images/clear.png b/mab/skin/images/clear.png Binary files differ. diff --git a/mab/skin/images/clear_disabled.png b/mab/skin/images/clear_disabled.png Binary files differ. diff --git a/mab/skin/images/comment.png b/mab/skin/images/comment.png Binary files differ. diff --git a/mab/skin/images/comment_disabled.png b/mab/skin/images/comment_disabled.png Binary files differ. diff --git a/mab/skin/images/context_menu.png b/mab/skin/images/context_menu.png Binary files differ. diff --git a/mab/skin/images/delete.png b/mab/skin/images/delete.png Binary files differ. diff --git a/mab/skin/images/delete_disabled.png b/mab/skin/images/delete_disabled.png Binary files differ. diff --git a/mab/skin/images/expired.png b/mab/skin/images/expired.png Binary files differ. diff --git a/mab/skin/images/filenew.png b/mab/skin/images/filenew.png Binary files differ. diff --git a/mab/skin/images/filenew_disabled.png b/mab/skin/images/filenew_disabled.png Binary files differ. diff --git a/mab/skin/images/fileopen.png b/mab/skin/images/fileopen.png Binary files differ. diff --git a/mab/skin/images/fileopen_disabled.png b/mab/skin/images/fileopen_disabled.png Binary files differ. diff --git a/mab/skin/images/filesave.png b/mab/skin/images/filesave.png Binary files differ. diff --git a/mab/skin/images/filesave_disabled.png b/mab/skin/images/filesave_disabled.png Binary files differ. diff --git a/mab/skin/images/forward.png b/mab/skin/images/forward.png Binary files differ. diff --git a/mab/skin/images/forward_disabled.png b/mab/skin/images/forward_disabled.png Binary files differ. diff --git a/mab/skin/images/goamazon.png b/mab/skin/images/goamazon.png Binary files differ. diff --git a/mab/skin/images/goamazon_disabled.png b/mab/skin/images/goamazon_disabled.png Binary files differ. diff --git a/mab/skin/images/gogoogle.png b/mab/skin/images/gogoogle.png Binary files differ. diff --git a/mab/skin/images/gogoogle_disabled.png b/mab/skin/images/gogoogle_disabled.png Binary files differ. diff --git a/mab/skin/images/gohome.png b/mab/skin/images/gohome.png Binary files differ. diff --git a/mab/skin/images/label.png b/mab/skin/images/label.png Binary files differ. diff --git a/mab/skin/images/mablogo.png b/mab/skin/images/mablogo.png Binary files differ. diff --git a/mab/skin/images/reload.png b/mab/skin/images/reload.png Binary files differ. diff --git a/mab/skin/images/rows_header.png b/mab/skin/images/rows_header.png Binary files differ. diff --git a/mab/skin/images/search.png b/mab/skin/images/search.png Binary files differ. diff --git a/mab/skin/images/search_disabled.png b/mab/skin/images/search_disabled.png Binary files differ. diff --git a/mab/skin/images/status_bar.png b/mab/skin/images/status_bar.png Binary files differ. diff --git a/mab/skin/images/status_unread.png b/mab/skin/images/status_unread.png Binary files differ. diff --git a/mab/skin/mab.css b/mab/skin/mab.css @@ -0,0 +1,201 @@ +/** +* +* +* @FileName: mab.css +* @$LastChangedDate: 2004-07-16 17:48:44 +0200 (Fri, 16 Jul 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + +#find-text { + border: 2px solid; + margin: 4px 6px 4px 3px; + padding-bottom: 2px; + padding-top: 2px; +} + +#mab-status-bar{ + border-top: none; + margin: 0; +} + + +textbox[readonly="true"] { + background-color: Window; +} + +.detail { + background-color: Window; + color: WindowText; +} + +/* +.info-head { + font-size: larger; +} + +.info-title { + color: HighlightText; + background-color: Highlight; +}*/ + + + +body.comment { + background-color: Window; + color: WindowText; + font: -moz-document; +} + +body.help { + font-family: Arial, Helvetica, sans-serif; + background-color: White; + font-size: 12px; +} + +.numeric { + text-align: right; +} + +.date { + text-align: right; +} + +.treecol-icon { + text-align: center; +} + +/*Icon Buttons*/ + +#new-icon { + list-style-image: url(../skin/images/filenew.png); +} + +#new-icon[disabled="true"] { + list-style-image: url(../skin/images/filenew_disabled.png); +} + +#open-icon { + list-style-image: url(../skin/images/fileopen.png); +} + +#open-icon[disabled="true"] { + list-style-image: url(../skin/images/fileopen_disabled.png); +} + +#abort-icon { + list-style-image: url(../skin/images/abort.png); +} + +#abort-icon[disabled="true"] { + list-style-image: url(../skin/images/abort_disabled.png); +} + +#save-icon { + list-style-image: url(../skin/images/filesave.png); +} + +#save-icon[disabled="true"] { + list-style-image: url(../skin/images/filesave_disabled.png); +} + +#goAmazon-icon { + list-style-image: url(../skin/images/gohome.png); +} + +/* +#goAmazon-icon[disabled="true"] { + list-style-image: url(../skin/images/goamazon_disabled.png); +} +*/ +#addCart-icon { + list-style-image: url(../skin/images/goamazon.png); +} + +#goGoogle-icon { + list-style-image: url(../skin/images/gogoogle.png); +} + +#goGoogle-icon[disabled="true"] { + list-style-image: url(../skin/images/gogoogle_disabled.png); +} + +#comment-button { + list-style-image: url(../skin/images/comment.png); +} + +#comment-button[disabled="true"] { + list-style-image: url(../skin/images/comment_disabled.png); +} + +#reload-btn { + list-style-image: url(../skin/images/reload.png); +} + +#search-btn { + list-style-image: url(../skin/images/search.png); +} + +#search-btn[disabled="true"] { + list-style-image: url(../skin/images/search_disabled.png); +} + +#next-btn { + list-style-image: url(../skin/images/forward.png); +} + +#next-btn[disabled="true"] { + list-style-image: url(../skin/images/forward_disabled.png); +} + +#clear-btn { + list-style-image: url(../skin/images/clear.png); +} + +#clear-btn[disabled="true"] { + list-style-image: url(../skin/images/clear_disabled.png); +} + +#delete-btn { + list-style-image: url(../skin/images/delete.png); +} + +#delete-btn[disabled="true"] { + list-style-image: url(../skin/images/delete_disabled.png); +} + +/*Custom treecell color*/ +treechildren:-moz-tree-cell-text(Orange) { + color: #FF4500; +} + +treechildren:-moz-tree-cell-text(Blue) { + color: Blue; + } + +treechildren:-moz-tree-cell-text(Green) { + color: Green; +} + +treechildren:-moz-tree-cell-text(Maroon) { + color: Maroon; +} + +treechildren:-moz-tree-cell-text(Olive) { + color: Olive; +} + +treechildren:-moz-tree-cell-text(Teal) { + color: Teal; +} + +treechildren:-moz-tree-cell-text(Purple) { + color: Purple; +} + +treechildren:-moz-tree-cell-text(Expired) { + color: Red; + font-weight: bold; +} +\ No newline at end of file diff --git a/mab/xul/html/about.html b/mab/xul/html/about.html @@ -0,0 +1,34 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<!-- +/** +* About HTML page +* +* @filename: about.html +* @$LastChangedDate: 2005-02-03 23:23:39 +0100 (Thu, 03 Feb 2005) $ +* @author: Fabio Serra <faser@faser.net> +* @copyright: Fabio Serra (The Initial Developer of the Original Code) +* @license: Mozilla Public License Version 1.1 +* +*/ +--> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<title>About</title> +<link rel="STYLESHEET" type="text/css" href="../../skin/mab.css"> +</head> +<body> +<strong>MAB - The Mozilla Amazon Browser</strong><p/> +<div><strong>Version:<span id="version"></span></strong></div> +<div><strong>Author:</strong> Fabio Serra (<a href="mailto:mab@faser.net">mab@faser.net</a>)</div> + +<div><strong>License:</strong> Mozilla Public License Version 1.1</div> +<div><strong>Copyright:</strong> Fabio Serra</div> +<p/> +<img src="../../skin/images/associate_com.png" width="130" height="60" vspace="4" border="0"><br> +<img src="../../skin/images/associate_co_uk.png" width="110" height="40" vspace="4" border="0"><br> +<img src="../../skin/images/associate_de.png" width="130" height="66" vspace="4" border="0"><br> +<img src="../../skin/images/associate_fr.gif" width="130" height="60" vspace="4" border="0"><br> +<img src="../../skin/images/associate_ca.gif" width="130" height="60" vspace="4" border="0"><br> +</body> +</html> diff --git a/mab/xul/html/allinfo.html b/mab/xul/html/allinfo.html @@ -0,0 +1,11 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<title>Comment</title> +<link rel="STYLESHEET" type="text/css" href="../../skin/mab.css"> +</head> +<body class="comment"> +<div id="allInfoOutput"></div> +</body> +</html> +\ No newline at end of file diff --git a/mab/xul/html/comment.html b/mab/xul/html/comment.html @@ -0,0 +1,11 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<title>Comment</title> +<link rel="STYLESHEET" type="text/css" href="../../skin/mab.css"> +</head> +<body class="comment"> +<div id="commentOutput"></div> +</body> +</html> diff --git a/mab/xul/html/cover.html b/mab/xul/html/cover.html @@ -0,0 +1,78 @@ +<!-- +/** +* Template to create a simple CD Cover +* @filename cover.html +* @$LastChangedDate: 2006-02-24 23:01:00 +0100 (Fri, 24 Feb 2006) $ +* @author Fabio Serra <faser@faser.net> +* @copyright Fabio Serra (The Initial Developer of the Original Code) +* @license Mozilla Public License Version 1.1 +* +*/ +--> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <title></title> + <link href="../../skin/cover_print.css" rel="stylesheet" type="text/css" media="print"> + <link href="../../skin/cover_screen.css" rel="stylesheet" type="text/css" media="screen"> + <script language="JavaScript" type="application/x-javascript"> +function makeCover() { + var op = window.opener; + var XMDManager = op.myDocOpened.getCurrentDocument(); + var index = op.myDisplayController.getSelectedRowIndex(); + var primaryKey = op.myDisplayController.getRowPrimaryKey(index); + + cBuilder = new CoverBuilder(window.document,XMDManager); + cBuilder.populateTemplate(primaryKey); +} + +function maximize() { + cBuilder.maximize(); + var elBtn = document.getElementById('btnResize'); + elBtn.setAttribute("onclick","resize()"); +} + +function resize() { + cBuilder.setImgOriginalSize(); + var elBtn = document.getElementById('btnResize'); + elBtn.setAttribute("onclick","maximize()"); +} + +function reload() { + + if(cBuilder.img.src != "") { + cBuilder.loadImage(cBuilder.img.src); + } else { + alert("Image is missing"); + } +} + +function writeFront() { + cBuilder.writeFront(); +} + </script> + <script src="../js/CoverBuilder.js" type="application/x-javascript"/> +</head> +<body onload="makeCover()"> +<table id="cover" class="cover" align="center"> + <tr> + <td align="center" valign="middle" class="front" id="front" width="50%"> + <img src="" name="img_cover" id="img_cover" border="0"> + </td> + <td id="back" valign="top" width="50%"> + <div id="title" class="title"></div> + <div id="artist" class="artist"></div> + <div id="track_list" class="track_list"></div> + </td> + </tr> +</table> +<div id="no_print"> +<div align="center"> +<input type="button" class="button" value="Resize Image" onclick="maximize()" id="btnResize"> +<input type="button" class="button" value="Load Image" onclick="reload()"> +<input type="button" class="button" value="Write Front" onclick="writeFront()"> +<input type="button" class="button" value="Print Cover" onclick="window.print()"> +</div> +</div> +</body> +</html> diff --git a/mab/xul/html/exportHTML.html b/mab/xul/html/exportHTML.html @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<title>MAB HTML Export</title> +<link href="../../skin/mab_print.css" rel="stylesheet" type="text/css"> +</head> +<body> +<table border="1" cellspacing="2" cellpadding="2" align="center"> +<thead> + <tr> + <th colspan="2" id="page-title"></th> + </tr> +</thead> +<tfoot> + <tr> + <td colspan="2">Made with MAB [<a href="http://faser.net/mab">http://faser.net/mab</a>]</td> + </tr> +</tfoot> +<tbody align="top" id="export-content"></tbody> +</table> +</body> +</html> diff --git a/mab/xul/html/exportXML.html b/mab/xul/html/exportXML.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<title>MAB XML Export</title> +</head> +<body> +<pre id="result"></pre> +</body> +</html> diff --git a/mab/xul/html/mab_help.html b/mab/xul/html/mab_help.html @@ -0,0 +1,394 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Brief Guide to get the most out of MAB</title> +<link rel="stylesheet" href="../../skin/mab_help.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.65.1"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> + <div class="article" lang="en"> + <div class="titlepage"> + <div> + <div><h2 class="title"><a name="d0e1"></a>Brief Guide to get the most out of MAB</h2> + + </div> + </div> + <div> + </div> +<hr> + </div> + <div class="toc"> + <dl> + <dt><span class="section"><a href="#d0e4">1. Introduction</a></span></dt> + + <dt><span class="section"><a href="#d0e9">2. Using MAB</a></span></dt> + <dd> + <dl> + <dt><span class="section"><a href="#d0e12">2.1. Searching</a></span></dt> + <dt><span class="section"><a href="#d0e56">2.2. Displaying Results</a></span></dt> + <dt><span class="section"><a href="#d0e119">2.3. Saving Result</a></span></dt> + <dt><span class="section"><a href="#d0e124">2.4. Adding Products to shopping cart</a></span></dt> + + <dt><span class="section"><a href="#d0e132">2.5. Settings</a></span></dt> + <dt><span class="section"><a href="#d0e169">2.6. Status Bar</a></span></dt> + <dt><span class="section"><a href="#d0e210">2.7. Notes on duplicated results</a></span></dt> + </dl></dd> + <dt><span class="section"><a href="#d0e215">3. Using keyboard shortcuts</a></span></dt> + <dt><span class="section"><a href="#d0e319">4. FAQ</a></span></dt> + + </dl> + </div> + <div class="section" lang="en"> + <div class="titlepage"> + <div> + <div><h2 class="title" style="clear: both"><a name="d0e4"></a>1.&nbsp;Introduction</h2> + </div> + </div> + + <div> + </div> + </div> +<p>Mab is an application to search products on Amazon.com, Amazon.co.uk, Amazon.de and Amazon.jp sites, showing results in a handy interface, typical of desktop programs, without distracting you with plenty of images and texts not concerning what you are effectively looking for.</p> + </div> + <div class="section" lang="en"> + <div class="titlepage"> + <div> + <div><h2 class="title" style="clear: both"><a name="d0e9"></a>2.&nbsp;Using MAB</h2> + + </div> + </div> + <div> + </div> + </div> + <div class="section" lang="en"> + <div class="titlepage"> + <div> + <div><h3 class="title"><a name="d0e12"></a>2.1.&nbsp;Searching</h3> + + </div> + </div> + <div> + </div> + </div> +<p>First of all, you find a Search Toolbar to select the site you need and to set criteria's research. Secondly, you have to select the<span><b class="command">Catalog</b></span>(sometimes a catalog can be no available on a certain site). Infact, different sites have different catalogs, for example, &#8220;<span class="quote">English Books</span>&#8221; is valid only for Amazon.de and Amazon.jp, and &#8220;<span class="quote">Baby</span>&#8221; only for Amazon.com and so on. After that, you decide the<span><b class="command">Search Type</b></span>which is determined by the catalog you selected. For instance, if you are looking for a CD in the catalog Popular Music, you can't use Author but Artist. Finally, selecting<span><b class="command">Sort</b></span>, you can decide the products to be showed first among those corresponding to set criteria. Don't worry if the combination among the Amazon site, the<span><b class="command">Catalog</b></span>, the<span><b class="command">Search Type</b></span>and the<span><b class="command">Sort Type</b></span>is incorrect, MAB will alert you with an &#8220;<span class="quote">alert box</span>&#8221;. Clicking on<span><b class="command">Search</b></span>you start the research. If you want additional results, you have to click on<span><b class="command">More</b></span>and you will have them on bottom of the list. If button<span><b class="command">More</b></span>is disabled, no more results correspond to your criteria.</p> + + <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3> +<p>Remind that whenever you select All Catalogs, MAB researches on all catalogs available. This will return up to 3 results for up to 15 products categories with items matching your search terms.</p> + </div> + </div> + <div class="section" lang="en"> + <div class="titlepage"> + <div> + <div><h3 class="title"><a name="d0e56"></a>2.2.&nbsp;Displaying Results</h3> + + </div> + </div> + <div> + </div> + </div> +<p>In the results list you will find all the products found during your research session. They can be ordered by clicking on the heading of the columns. Available columns are:</p> + <div class="figure"><a name="d0e61"></a> +<p class="title"><b>Figure&nbsp;1.&nbsp;</b></p> + + <div class="mediaobject"><img src="../../skin/images/rows_header.png"> + </div> + </div> + <div class="itemizedlist"> + <ul type="disc"> + <li> +<p><span><b class="command">Ex: </b></span>tells you if all information on your product are still valid. Information on prices, for example, are valid for 24 hours and then eliminate. Other kind of information are valid foe 3 months. When you bump into some expired information, click on the Refresh button to get an updating.</p></li> + <li> + +<p><span><b class="command">Status:</b></span>it indicates if an item has been read</p></li> + <li> +<p><span><b class="command">Product name:</b></span>it indicates the name of the product.</p></li> + <li> +<p><span><b class="command">Catalog:</b></span>it identifies which Catalog the product belongs to.</p></li> + <li> +<p><span><b class="command">Country:</b></span>it identifies the Amazon site on which you can find your product.</p></li> + + <li> +<p><span><b class="command">Our Price:</b></span>it is the Amazon selling price.</p></li> + <li> +<p><span><b class="command">Used Price</b></span>: it is the first least expensive used product price.</p></li> + <li> +<p><span><b class="command">Rating:</b></span>it is the average rate given by all those who made a review.</p></li> + <li> + +<p><span><b class="command">Rank:</b></span>it is the best seller products' position in the Amazon list.</p></li> + <li> +<p><span><b class="command">Released:</b></span>it indicates the releasing year of the product.</p></li> + <li> +<p><span><b class="command">Label:</b></span>it indicates the label you gave to your product in order to highlight and catalog the results of your research.</p></li> + </ul> + </div> + +<p>If you want to add or eliminate the columns, you just need to click on the little button on the right hand side of the results' list.</p> + </div> + <div class="section" lang="en"> + <div class="titlepage"> + <div> + <div><h3 class="title"><a name="d0e119"></a>2.3.&nbsp;Saving Result</h3> + </div> + </div> + + <div> + </div> + </div> +<p>You can save your results on your hard disk only using the installed version of MAB. Files are saved with the extension .mab and are normal XML files that you can open with every editor.</p> + </div> + <div class="section" lang="en"> + <div class="titlepage"> + <div> + <div><h3 class="title"><a name="d0e124"></a>2.4.&nbsp;Adding Products to shopping cart</h3> + + </div> + </div> + <div> + </div> + </div> +<p>Click on<span><b class="command">Add to cart</b></span>, MAB will add the selected products to your shopping cart, and every time you want to see its content you have always to refer to the Amazon site. Infact, Mab doesn't handle either the login between you and Amazon or the exchange of personal data.</p> + </div> + <div class="section" lang="en"> + + <div class="titlepage"> + <div> + <div><h3 class="title"><a name="d0e132"></a>2.5.&nbsp;Settings</h3> + </div> + </div> + <div> + </div> + </div> + +<p>The parameters you can set are.</p> + <div class="itemizedlist"> + <ul type="disc"> + <li> +<p><span><b class="command">Response Type</b></span>: to select the kind of response you want to get from Amazon. A &#8220;<span class="quote">lite</span>&#8221; response contains essential catalog information such as a product's name or price, and a &#8220;<span class="quote">heavy</span>&#8221; response contains more complete product information such as sales ranking and customers' reviews. This is the reason why, generally, a research with Response Type set on &#8220;<span class="quote">Heavy</span>&#8221; is slower. You can get all the information about the selected product with a &#8220;<span class="quote">lite</span>&#8221; response too, simply clicking on the<span><b class="command">Load Reviews</b></span>icon.</p></li> + + <li> +<p><span><b class="command">Limit Result:</b></span>you can use it to set the number of results you want to get every time you click on<span><b class="command">Search</b></span>or<span><b class="command">More</b></span>. The suggested number is 20, a higher number could slightly slow the research.</p></li> + </ul> + </div> + </div> + <div class="section" lang="en"> + + <div class="titlepage"> + <div> + <div><h3 class="title"><a name="d0e169"></a>2.6.&nbsp;Status Bar</h3> + </div> + </div> + <div> + </div> + </div> + + <div class="figure"><a name="d0e172"></a> +<p class="title"><b>Figure&nbsp;2.&nbsp;</b></p> + <div class="mediaobject"><img src="../../skin/images/status_bar.png"> + </div> + </div> +<p>It informs you about the researches' results. In the Status Bar you find:</p> + <div class="itemizedlist"> + <ul type="disc"> + + <li> +<p><span><b class="command">Listed products</b></span>: number of products loaded at the moment.</p></li> + <li> +<p><span><b class="command">New</b></span>: number of new products loaded in the current list.</p></li> + <li> +<p><span><b class="command">Duplicated</b></span>: number of products never loaded because duplicated.</p></li> + <li> + +<p><span><b class="command">Reloaded</b></span>: number of products whose information have been reloaded.</p></li> + <li> +<p><span><b class="command">Products found</b></span>:number of products found on Amazon on your criteria basis.</p></li> + <li> +<p><span><b class="command">Products retrieved</b></span>: number of products found by the last research.</p></li> + </ul> + </div> + + </div> + <div class="section" lang="en"> + <div class="titlepage"> + <div> + <div><h3 class="title"><a name="d0e210"></a>2.7.&nbsp;Notes on duplicated results</h3> + </div> + </div> + <div> + + </div> + </div> +<p>Whenever MAB downloads information from Amazon about found products, it eliminates all the products already downloaded. Doing so, you can do many researches without downloading duplicated information. MAB records all retrieved products, so, when a product a product gets eliminated from the results' list, it will be automatically skipped if found following to further researches. To reload a cancelled product, you need to open a new document and do another research. Thanks to this procedure, crossed researches will be always precise and the results' list won't get full of duplicated products.</p> + </div> + </div> + <div class="section" lang="en"> + <div class="titlepage"> + <div> + <div><h2 class="title" style="clear: both"><a name="d0e215"></a>3.&nbsp;Using keyboard shortcuts</h2> + + </div> + </div> + <div> + </div> + </div> +<p>The keyboard shortcuts for MAB are as follows:</p> + <div class="table"><a name="d0e220"></a> +<p class="title"><b>Table&nbsp;1.&nbsp;</b></p> + + <table border="1"> + <colgroup> + <col> + <col> + </colgroup> + <tbody> + <tr> + <td><span><b class="command">enter</b></span> + + </td> + <td> Search + </td> + </tr> + <tr> + <td><span><b class="command">canc</b></span> + </td> + <td> Delete selected products + </td> + + </tr> + <tr> + <td><span><b class="command">esc</b></span> + </td> + <td> Stops any connection currently in progress + </td> + </tr> + <tr> + + <td><span><b class="command">Alt + f</b></span> + </td> + <td> Open File menu + </td> + </tr> + <tr> + <td><span><b class="command">Alt + e</b></span> + </td> + + <td> Open Edit menu + </td> + </tr> + <tr> + <td><span><b class="command">Alt + t</b></span> + </td> + <td> Open Options menu + </td> + + </tr> + <tr> + <td><span><b class="command">Alt + w</b></span> + </td> + <td> Open Windows menu + </td> + </tr> + <tr> + + <td><span><b class="command">Alt + m</b></span> + </td> + <td> Get more records from the last search + </td> + </tr> + <tr> + <td><span><b class="command">Alt + h</b></span> + </td> + + <td> Open Help menu + </td> + </tr> + <tr> + <td><span><b class="command">Alt + a</b></span> + </td> + <td> Go to the Amazon page + </td> + + </tr> + <tr> + <td><span><b class="command">Alt + d</b></span> + </td> + <td> Add products to shopping cart + </td> + </tr> + <tr> + + <td><span><b class="command">Alt + g</b></span> + </td> + <td> Go to Google + </td> + </tr> + <tr> + <td><span><b class="command">Ctrl + n</b></span> + </td> + + <td> New search list + </td> + </tr> + <tr> + <td><span><b class="command">Ctrl + w</b></span> + </td> + <td> Close current list + </td> + + </tr> + <tr> + <td><span><b class="command">Ctrl + s</b></span> + </td> + <td> Save current list + </td> + </tr> + <tr> + + <td><span><b class="command">Ctrl + r</b></span> + </td> + <td> Load Reviews + </td> + </tr> + </tbody> + </table> + </div> + + </div> + <div class="section" lang="en"> + <div class="titlepage"> + <div> + <div><h2 class="title" style="clear: both"><a name="d0e319"></a>4.&nbsp;FAQ</h2> + </div> + </div> + <div> + + </div> + </div> + <div class="orderedlist"> + <ol type="1"> + <li> +<p><span class="emphasis"><em>How can I carry out a research writing more Asin/ISBN as a Search Term?</em></span></p> +<p>You can use up to 10 ASIN/ISBN in one search for "heavy" Response Type, and up to 30 ASINs for "lite" Response Type. ASIN/ISBN in the Search Term input box should be separated by commas.</p></li> + <li> +<p><span class="emphasis"><em>What are Amazon Web Services and Amazon Associates?</em></span></p> + +<p>Amazon gives to all developers the opportunity to browse the catalog using the Web Services technology. Web services are applications whose logic and functions are accessible using standard Internet protocols and data formats such as XML (Extensible Markup Language), and SOAP (Simple Object Access Protocol). Using these services, Associates can create applications capable of interacting with Amazon. If you like MAB and you wish to support its development, just before buying something remember to select the item directly from MAB. In this way Amazon Associate can give a fee to support the programmers who use their Web Service.</p></li> + <li> +<p><span class="emphasis"><em>How can I copy and paste the most relevant information about a selected product?</em></span></p> +<p>You have to click on Text Summary. This can be done from the Edit Menu or from the Context Menu. The Context Menu can be activated pressing the right mouse button on the selected product.</p> + <div class="figure"><a name="d0e347"></a> +<p class="title"><b>Figure&nbsp;3.&nbsp;</b></p> + <div class="mediaobject"><img src="../../skin/images/context_menu.png"> + </div> + + </div></li> + <li> +<p><span class="emphasis"><em>How to see the bigger image about the selected product?</em></span></p> +<p>Just click on the small image and the bigger one will be showed in a pop up window.</p></li> + </ol> + </div> + </div> + </div> +</body> + +</html> diff --git a/mab/xul/images/mablogo.png b/mab/xul/images/mablogo.png Binary files differ. diff --git a/mab/xul/js/AmazonParser.js b/mab/xul/js/AmazonParser.js @@ -0,0 +1,142 @@ +/** + * + * Used to merge more concurrent response from Amazon. + * + * @fileName AmazonParser.js + * @$LastChangedDate: 2004-05-07 16:58:00 +0200 (Fri, 07 May 2004) $ + * @author Fabio Serra <faser@faser.net> + * @copyright Fabio Serra (The Initial Developer of the Original Code) + * @license Mozilla Public License Version 1.1 + * +*/ + +/** + * Construct a new AmazonParser object + * @class This class is used to manage all the XML Amazon response arrived from + * one or multiple request in the same Connection + * @constructor + * @return A new AmazonParser object + * +*/ +function AmazonParser(xmlDoc) { + if(xmlDoc) {this.xmlDoc = xmlDoc;} +} + +/** + * Get the total pages available for the search + * @type int +*/ +AmazonParser.prototype.getTotalPages = function() { + if(!this.xmlDoc) {return false;} + var path = "//ProductInfo/TotalPages"; + var xpathResult = this.xmlDoc.evaluate(path,this.xmlDoc,null,XPathResult.ANY_TYPE,null).iterateNext(); + if(xpathResult != null) { + return xpathResult.textContent; + } else { + throw("AmazonParser Exception: TotalPages not found"); + } +} + +/** + * Get the total items for the search + * @type int +*/ +AmazonParser.prototype.getTotalResults = function() { + if(!this.xmlDoc) {return false;} + var path = "//ProductInfo/TotalResults"; + var xpathResult = this.xmlDoc.evaluate(path,this.xmlDoc,null,XPathResult.ANY_TYPE,null).iterateNext(); + if(xpathResult != null) { + return xpathResult.textContent; + } else { + throw("AmazonParser Exception: TotalResult not found"); + } +} + +/** + * Check if the valid XML has the error tag + * @type bool +*/ +AmazonParser.prototype.hasError = function() { + var path = "//ErrorMsg"; + var xpathResult = this.xmlDoc.evaluate(path,this.xmlDoc,null,XPathResult.ANY_TYPE,null).iterateNext(); + if(xpathResult != null) { + return true; + } else { + return false; + } +} + +/** + * Get the error message from the valid xml Amazon response + * @throw ErrorMsg not found + * @type string +*/ +AmazonParser.prototype.getErrorMsg = function() { + var path = "//ErrorMsg"; + var xpathResult = this.xmlDoc.evaluate(path,this.xmlDoc,null,XPathResult.ANY_TYPE,null).iterateNext(); + if(xpathResult != null) { + return xpathResult.textContent; + } else { + throw("AmazonParser Exception: ErrorMsg not found"); + } +} + +/** + * Count how many Details node are present in the xml response + * type int +*/ +AmazonParser.prototype.getNrDetails = function() { + var el = this.xmlDoc.getElementsByTagName("Details"); + if(el.length) { + return el.length; + }else{ + return 0; + } +} + +/** + * Merge the new Amazon document with the current document + * Once the documents are merged TotalPages, TotalResults are not more valid + * because they referer to the first original amazon page. + * @param {XML Document} docToMerge + * @return true if the document has been merged or created + * @type bool +*/ +AmazonParser.prototype.mergeDocument = function(docToMerge) { + if(!this.xmlDoc) { + this.xmlDoc = docToMerge; + return true; + } + //I can merge an amazon response only if there are not error + if(this.hasError()) {return false;} + + var reference = this.xmlDoc.getElementsByTagName('ProductInfo').item(0); + var details = docToMerge.getElementsByTagName('Details'); + if(details.length > 0) { + for (var i=0;i< details.length ;i++) { + var node = details.item(i).cloneNode(true); + reference.appendChild(node); + } + } + + return true; +} + +/** + * Add an empty review tag if it's missing from heavy search. In this way the life + * is more easy for the DisplayController. + * @return void +*/ +AmazonParser.prototype.setMissingReviews = function() { + var parser = new DOMParser(); + var strTag = "<Reviews/>" + var reviews; + var nodes = this.xmlDoc.getElementsByTagName("Details"); + for(var i= 0; i < nodes.length; i++) { + reviews = nodes[i].getElementsByTagName("Reviews").item(0); + if(reviews == null) { + innerXML(nodes.item(i),strTag); + } + + } +} +\ No newline at end of file diff --git a/mab/xul/js/Connection.js b/mab/xul/js/Connection.js @@ -0,0 +1,266 @@ +/** + * Contain the Connection class + * + * @filename Connection.js + * @$LastChangedDate$ + * @author Fabio Serra <faser@faser.net> + * @copyright Fabio Serra (The Initial Developer of the Original Code) + * @license Mozilla Public License Version 1.1 + * +*/ + +/** + * Construct a new Connection object + * @class Used to send GET or POST request to a server. The object provide a timeout and + * return a connectionID that can be used to track multiple request made at the same time + * @constructor + * @param {string} targetUrl The URL to make a connection + * @param {bool} permission Ask permission in case of MAB is not running as an extension + * @throws XMLHttpRequest exception when unable to create an XMLHttpRequest object + * @return A new Connection + * +*/ +function Connection(targetUrl,permission) { + /** + * The target URL + * @type string + */ + this.url = targetUrl; + + /** + * Need permission + * @type bool + */ + this.blPermission = false; + if(permission) {this.blPermission = true;} + + /** + * How long I have to wait for an answer before aborting. Default 1 minute + * @type int + */ + this.timeout = 60000; + + /** + * The interval id returned by the setInterval + * @private + * @type int + */ + this.intervalID = null; + + /** + * Connection ID to use with the callback function. + * The caller have to know from which obj receive the result. + * @private + * @type int + */ + this.connectionID = Math.round(Math.random()*(10000000-1))+1; + + /** + * The server answer has been loaded? + * @const + * @type int + */ + this.COMPLETED = 4; + + /** + * This object contain all fields that should be returned after a connection + * @type object + */ + this.retParams = {}; + /** Unique identifier */ + this.retParams.connectionID = this.connectionID; + /** + * Returned status code. 0 means everything is OK + * @type int + */ + this.retParams.status = 0; + /** + * Associated text message + * @type string + */ + this.retParams.message = ""; + /** + * Full response content as requested (XML or TXT) + */ + this.retParams.content = ""; + /** + * The URL that generated the response + */ + this.retParams.requestedURL = ""; + + + //Create XMLHttpRequest object + try { + /** + * The XMLHttpRequest object + * @type XMLHttpRequest + */ + this.req = new XMLHttpRequest(); + }catch(e){ + throw("Creating XMLHttpRequest:" + e); + } +} + +/** + * Send a request to the target url + * @param {string} string The query string + * @param {string} method The HTTP request method (GET | POST) + * @param {string} responseType The requested response type (txt | xml) + * @return void + * @throw netscape.security + * @throw XMLHttpRequest open or send exceptions +*/ +Connection.prototype.send = function(string,method,responseType) { + //Request permission for remote application + if(this.blPermission) { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); + }catch (e){ + throw(e); + } + } + + //encode string + var params = encodeURI(string); + + var me = this; + var lambda = function myScopeFunction(){ + me.getResponse(responseType); + } + + //Abort current connection + var timedOut = function() { + me.abortConnection(10); + } + + if(responseType == "xml") {this.req.overrideMimeType("text/xml");} + + switch(method) { + case "GET": + var qString = this.url + '?' + params; + try { + //Check for timeout + this.intervalID = setInterval(timedOut,this.timeout); + this.req.open("GET",qString,true); + //Save the request url + this.retParams.requestedURL = qString; + this.req.send(null); + }catch(e){ + throw(e); + } + + break; + case "POST": + try { + //Check for timeout + this.intervalID = setInterval(timedOut,this.timeout); + this.req.open("POST",this.url,true); + this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); + this.req.send(params); + }catch(e){ + throw(e); + } + break; + default: + throw("Connection Exception: method not supported"); + + } + + + this.req.onload = lambda; +} + +/** + * Handle the server response and send the result to the defined callback function + * @param {string} responseType The requested response type (txt | xml) + * @return void +*/ + +Connection.prototype.getResponse = function(responseType) { + if(this.req.readyState == this.COMPLETED) { + //Clear Inteval for timeout checking + clearInterval(this.intervalID); + if(this.req.status !=200) { + this.connectionException(20); + this.errorCallback(this.retParams); + } else { + if(responseType == "txt") { + this.retParams.content = this.req.responseText; + this.callBack(this.retParams); + }else{ + var responseXML = new DOMParser().parseFromString(this.req.responseText, 'text/xml'); + this.retParams.content = this.req.responseXML; + this.callBack(this.retParams); + } + } + } +} + +/** + * To pass the reference to the function to be called when the data is available. + * @param {string} fRef function name + * @return void +*/ +Connection.prototype.setCallback= function (fRef) { + this.callBack=fRef; +} + +/** + * To pass the reference to the function in case of errors + * @param {string} fRef function name + * @return void +*/ +Connection.prototype.setErrorCallback= function (fRef) { + this.errorCallback=fRef; +} + +/** + * Abort in progress connection + * @param {int} errorCode provide a properly error code + * @return void + * @throw exception +*/ +Connection.prototype.abortConnection = function(errorCode) { + try { + this.req.abort(); + clearInterval(this.intervalID); + this.connectionException(errorCode); + this.errorCallback(this.retParams); + }catch(e){ + throw(e); + } +} + +/** + * Set the status code and a message in case of error + * @param {int} errorCode An error code + * @return void +*/ +Connection.prototype.connectionException = function (errorCode) { + switch(errorCode) { + //TimeOut + case 10: + this.retParams.status = errorCode; + this.retParams.message = "Connection has timed out"; + break; + case 20: + this.retParams.status = errorCode; + this.retParams.message = "The server respond with a bad status code: " + this.req.status; + //check if the response have some more info in html format + if(this.req.responseText) { + //TODO - LIMIT TEXT + this.retParams.message += "\n" + stripHTML(this.req.responseText); + } + break; + case 30: + this.retParams.status = errorCode; + this.retParams.message = "Connection cancelled by user"; + break; + case 40: + this.retParams.status = errorCode; + this.retParams.message = "General connection failure"; + break; + + } + +} diff --git a/mab/xul/js/DisplayController.js b/mab/xul/js/DisplayController.js @@ -0,0 +1,890 @@ +/** + * + * + * @filename DisplayController.js + * @$LastChangedDate: 2004-05-16 19:57:10 +0200 (Sun, 16 May 2004) $ + * @author Fabio Serra <faser@faser.net> + * @copyright Fabio Serra (The Initial Developer of the Original Code) + * @license Mozilla Public License Version 1.1 + * +*/ + +/** + * Construct a new DisplayController object + * @class This class should be used as a Controller between the GUI (View) and the + * XMDManager (Data) object. + * @final + * @constructor + * @return A new DisplayController + * +*/ +function DisplayController() { + //Set windows title + window.title = "M A B"; + //Search Input + this.elSearchTerm = document.getElementById('find-text'); + //Main Result Tree + this.guiMainTree = document.getElementById('result-tree'); + //TreeChildren + this.guiListTree = document.getElementById('list-tree'); + //Details Box + this.guiDetailBox = document.getElementById('detail-box'); + //Price Box + this.guiPriceBox = document.getElementById('price-box'); + //ProductName + this.guiProductName = document.getElementById("ProductName"); + //Author + this.guiAuthor = document.getElementById("Author"); + //Manufacturer + this.guiManufacturer = document.getElementById("Manufacturer"); + //ReleaseDate + this.guiReleaseDate = document.getElementById("ReleaseDate"); + //List Price + this.guiListPrice = document.getElementById("ListPrice"); + //OurPrice + this.guiOurPrice = document.getElementById("OurPrice"); + //UsedPrice + this.guiUsedPrice = document.getElementById("UsedPrice"); + + //Image + this.guiTheImg = document.getElementById('ImageUrlMedium'); + //All Info + this.winProductInfo = window.frames[0]; + this.guiProductInfo = this.winProductInfo.document.getElementById('allInfoOutput'); + //Comment iframe + this.winReview = window.frames[1]; + this.guiReview = this.winReview.document.getElementById('commentOutput'); + this.guiCommentBtn = document.getElementById('comment-button'); + //Image + this.guiImageSmall = document.getElementById('ImageUrlMedium'); + + //Broadcaster + this.isSearchRunning = document.getElementById("isSearchRunning"); + + //Status Bar + this.guiRecordStatus = document.getElementById("record-status"); + this.guiOutStatus = document.getElementById("out-status"); + + //Hidden xul spacer to mantain the user preferences + this.elSettingsSpacer = document.getElementById('settings-spacer'); +} + + +//Columns: Name, Catalog, Locale, OurPrice, Rating, Released, MABLabel, MABTSLastUpdate, Status +/** + * Build the xul tree + * @param {XMDManager} XMDManager + * @param {bool} appendItems Indicate if the new elements should be added to the xul + * tree or if the tree should be destroyed and completly rebuild + * @throws exception if the XMDManager has no Details node in the xml document + * @return void +*/ +DisplayController.prototype.buildTree = function(XMDManager,appendItems) { + //Default is rebuild the entire tree + var append = false; + //In case of addItem the new item are added at the top of the tree + if(appendItems) {append = true;} + + try { + var rows = XMDManager.xmlDoc.getElementsByTagName("Details"); + }catch(e){ + return; + } + + + var pk = ""; + var treeRow = false; + var strRow, productName, catalog, country, ourPrice, usedPrice, rating, rank, MABStatus; + var releaseDate, lastUpdate, mabLabel, src, srcStatus, res; + var today = new Date(); + + for(var i=0;i<rows.length;i++) { + + pk = XMDManager.getSingleElement(rows[i],"MABPrimaryKey"); + //Skip rows without primary key + if(!pk){continue;} + //Check if the record is present in the current tree if it exists update the row + if(append == true) { + treeRow = document.getElementById(pk); + if(treeRow) { + res = this.updateRow(treeRow,rows[i],XMDManager); + continue; + } + } + + //Check if product info are expired + lastUpdate = XMDManager.getLastUpdate(rows[i]); + src = ""; + if(lastUpdate > EXPIRED_LONG) { src = "../skin/images/expired.png";} + + //Check status + MABStatus = XMDManager.getSingleElement(rows[i],"MABStatus"); + srcStatus = ""; + if(MABStatus == "unread") { srcStatus = "../skin/images/status_unread.png";} + + productName = XMDManager.getSingleElement(rows[i],"ProductName"); + if(!productName) {productName = "";} + + catalog = XMDManager.getSingleElement(rows[i],"Catalog"); + if(!catalog) {catalog = "";} + + country = XMDManager.getSingleElement(rows[i],"MABLocale"); + if(!country) {country = "";} + + ourPrice = XMDManager.getSingleElement(rows[i],"OurPrice"); + if(!ourPrice) {ourPrice = "";} + + usedPrice = XMDManager.getSingleElement(rows[i],"UsedPrice"); + if(!usedPrice) {usedPrice = "";} + + rating = XMDManager.getSingleElement(rows[i],"AvgCustomerRating"); + if(!rating) {rating = "";} + + rank = XMDManager.getSingleElement(rows[i],"SalesRank"); + if(!rank) {rank = "";} + + releaseDate = XMDManager.getSingleElement(rows[i],"ReleaseDate"); + if(!releaseDate) {releaseDate = ""}; + + mabLabel = XMDManager.getSingleElement(rows[i],"MABLabel"); + if(!mabLabel) {mabLabel = ""} + + + strRow += ''+ + '\n<treeitem>\n' + + ' <treerow id="'+ pk +'">\n' + + ' <treecell src="'+ src + '" properties="'+ mabLabel +'"/>\n' + + ' <treecell src="'+ srcStatus + '" properties="'+ mabLabel +'"/>\n' + + ' <treecell label="'+ escapeXML(productName) +'" properties="'+ mabLabel +'"/>\n' + + ' <treecell label="'+ escapeXML(catalog) + '" properties="'+ mabLabel +'"/>\n' + + ' <treecell label="'+ country.toUpperCase() + '" properties="'+ mabLabel +'"/>\n' + + ' <treecell label="'+ escapeXML(ourPrice) + '" properties="'+ mabLabel +'"/>\n' + + ' <treecell label="'+ escapeXML(usedPrice) + '" properties="'+ mabLabel +'"/>\n' + + ' <treecell label="'+ rating + '" properties="'+ mabLabel +'"/>\n' + + ' <treecell label="'+ rank + '" properties="'+ mabLabel +'"/>\n' + + ' <treecell label="'+ toYear(releaseDate) + '" properties="'+ mabLabel +'"/>\n' + + ' <treecell label="'+ mabLabel + '" properties="'+ mabLabel +'"/>\n' + + ' </treerow>\n' + + '</treeitem>\n'; + + } + + + if(append == false) {this.removeTree();} + + if(strRow != "") { innerXML(this.guiListTree,strRow,true,false);} + + //Set the window title to the document name + var name = myDocOpened.getCurrentDocumentName(); + window.title = "M A B - " + name; + + //Set Focus on the first row + if(append == false) {this.setFocusOnRow(0);} + + //Remove sort direction indicator + this.clearRowHeader(); + + //Write on status bar how many record are present in the list + this.writeRowStatus(); +} + +/** + * Update a single row + * @param {XUL Element} treeRow a reference to a treerow element + * @param {XML node} nodeDetail + * @param {XMDManager} XMDManager + * @return true if the row has been updated, false otherwise + * @type bool +*/ +DisplayController.prototype.updateRow = function(treeRow,nodeDetail,XMDManager) { + var cells = treeRow.getElementsByTagName("treecell"); + var pk = XMDManager.getSingleElement(nodeDetail,"MABPrimaryKey"); + //Skip rows without primary key + if(!pk){return false;} + var mabLabel = XMDManager.getSingleElement(nodeDetail,"MABLabel"); + if(!mabLabel) {mabLabel = ""} + + //Set treerow attributes + cells.item(0).parentNode.setAttribute("id",pk); + + var lastUpdate = XMDManager.getLastUpdate(nodeDetail); + var src = ""; + if(lastUpdate > EXPIRED_LONG) { src = "../skin/images/expired.png";} + + cells.item(0).setAttribute("src",src); + cells.item(0).setAttribute("properties",mabLabel); + + var status = XMDManager.getSingleElement(nodeDetail,"MABStatus"); + var srcStatus = ""; + if(status == "unread") { srcStatus = "../skin/images/status_unread.png";} + + cells.item(1).setAttribute("src",srcStatus); + cells.item(1).setAttribute("properties",mabLabel); + + var productName = XMDManager.getSingleElement(nodeDetail,"ProductName"); + if(!productName) {productName = "";} + cells.item(2).setAttribute("label",productName); + cells.item(2).setAttribute("properties",mabLabel); + + var catalog = XMDManager.getSingleElement(nodeDetail,"Catalog"); + if(!catalog) {catalog = "";} + cells.item(3).setAttribute("label",catalog); + cells.item(3).setAttribute("properties",mabLabel); + + var country = XMDManager.getSingleElement(nodeDetail,"MABLocale"); + if(!country) {country = "";} + cells.item(4).setAttribute("label",country.toUpperCase()); + cells.item(4).setAttribute("properties",mabLabel); + + var ourPrice = XMDManager.getSingleElement(nodeDetail,"OurPrice"); + if(!ourPrice) {ourPrice = "";} + cells.item(5).setAttribute("label",ourPrice); + cells.item(5).setAttribute("properties",mabLabel); + + var usedPrice = XMDManager.getSingleElement(nodeDetail,"UsedPrice"); + if(!usedPrice) {usedPrice = "";} + cells.item(6).setAttribute("label",usedPrice); + cells.item(6).setAttribute("properties",mabLabel); + + var rating = XMDManager.getSingleElement(nodeDetail,"AvgCustomerRating"); + if(!rating) {rating = "";} + cells.item(7).setAttribute("label",rating); + cells.item(7).setAttribute("properties",mabLabel); + + var rank = XMDManager.getSingleElement(nodeDetail,"SalesRank"); + if(!rank) {rank = ""}; + cells.item(8).setAttribute("label",rank); + cells.item(8).setAttribute("properties",mabLabel); + + var releaseDate = XMDManager.getSingleElement(nodeDetail,"ReleaseDate"); + if(!releaseDate) {releaseDate = ""}; + cells.item(9).setAttribute("label",toYear(releaseDate)); + cells.item(9).setAttribute("properties",mabLabel); + + cells.item(10).setAttribute("label",mabLabel); + cells.item(10).setAttribute("properties",mabLabel); + + return true; +} + +/** + * Syncronize tree with XMDManager mantaining consistence between the model and + * the view + * @param {XMDManager} XMDManager + * @return void +*/ +DisplayController.prototype.syncTree = function(XMDManager) { + var myXMDManager = XMDManager; + var rows = myXMDManager.xmlDoc.getElementsByTagName("Details"); + var treeNode = this.guiMainTree.getElementsByTagName("treerow"); + + var nodeDetail, treeRow; + + for(var i=0;i<rows.length;i++) { + nodeDetail = rows[i]; + treeRow = treeNode.item(i) + this.updateRow(treeRow,nodeDetail,myXMDManager) + } +} + +/** + * Get the correct Amazon URL ff the selected product + * @param {XMDManager} XMDManager + * @param {string} type The type of link that should be returned (directLink || xmlLink || listManiaLink) + * @param {XML nodeDetail} node + * @return the correct url or false if no URL can be determined + * @type string +*/ +DisplayController.prototype.getProductAmazonUrl = function(XMDManager,type,node) { + var myXMDManager = XMDManager; + var nodeDetail; + if(typeof node == "undefined") { + var idx = this.getSelectedRowIndex(); + if(idx < 0) {return false;} + + var primaryKey = this.getRowPrimaryKey(idx); + if(!primaryKey) {return false;} + nodeDetail = myXMDManager.getNodeDetail(primaryKey); + } else { + nodeDetail = node; + } + + var linkType = "xmlLink"; + if(type) linkType = type ; + + + + var theUrl = false; + var locale = ""; + if(linkType == "xmlLink") { + theUrl = nodeDetail.getAttribute("url"); + }else if(linkType == "listManiaLink") { + var listId = myXMDManager.getSingleElement(nodeDetail,"ListId"); + locale = myXMDManager.getSingleElement(nodeDetail,"MABLocale"); + theUrl = AMAZONURL[locale] + "/exec/obidos/tg/listmania/list-browse/-/" + listId + "/" + ASSID[locale] + "/"; + }else{ + var amazAsin = myXMDManager.getSingleElement(nodeDetail,"Asin"); + locale = myXMDManager.getSingleElement(nodeDetail,"MABLocale"); + theUrl = AMAZONURL[locale] + "/exec/obidos/ASIN/" + amazAsin + "/" + ASSID[locale] + "/"; + } + + if(theUrl) { + return theUrl; + }else{ + return false; + } +} + +/** + * Remove all XUL treeitem from the tree +*/ +DisplayController.prototype.removeTree = function() { + //Remove only treeitem + while(this.guiListTree.hasChildNodes()) { + this.guiListTree.removeChild(this.guiListTree.lastChild); + } +} + +/** + * Remove a row (treeitem ) in tree passing the id to identify the treerow + * @param {string} id that correspond to the treerow attribute + * @return true if the row has been removed + * @type bool +*/ +DisplayController.prototype.removeRow = function(id) { + var theRow = document.getElementById(id); + if(!theRow) {return false;} + this.guiListTree.removeChild(theRow.parentNode); + + //Write on status bar how many record are present in the list + this.writeRowStatus(); + return true; +} + +/** + * Clear all GUI elements to reset the status +*/ +DisplayController.prototype.clearAll = function() { + this.removeTree(); + this.clearRowHeader(); + this.clearTextBox(); + this.clearInfo(); + this.clearReview(); + this.clearImage(); + this.clearStatusBar(); + this.writeRowStatus(); + this.elSearchTerm.focus(); +} + +/** + * Clear all textbox GUI elements +*/ +DisplayController.prototype.clearTextBox = function() { + var txtInput = document.getElementsByTagName('textbox'); + for(var i=0;i<txtInput.length;i++) { + txtInput[i].setAttribute('value',''); + } +} + +/** + * Clear the product information panel +*/ +DisplayController.prototype.clearInfo = function() { + //First Panel + this.guiProductInfo.innerHTML = ""; +} + +/** + * Clear the Customer Reviews panel +*/ +DisplayController.prototype.clearReview = function() { + //Second Panel + this.guiReview.innerHTML = ""; +} + +/** + * Clear the product image +*/ +DisplayController.prototype.clearImage = function() { + this.guiImageSmall.setAttribute("src",""); +} + +/** + * Clear the sort indicator in the row header +*/ +DisplayController.prototype.clearRowHeader = function() { + //Set all sortDirection attribute to normal + var treeCol = document.getElementsByTagName("treecol"); + for(var i=0; i < treeCol.length;i++) { + treeCol[i].setAttribute("sortDirection","normal"); + } +} + +/** + * Clear all info in the status bar +*/ +DisplayController.prototype.clearStatusBar = function() { + this.guiRecordStatus.setAttribute('label',''); + this.guiOutStatus.setAttribute('label',''); +} + +/** + * Show details about the selected product in the treerow + * @param {XMDManager} XMDManager + * @param {int} rowIndex the selected rowIndex is not mandatory + * @return false if the selected row cannot be determined + * @type bool +*/ +DisplayController.prototype.showDetails = function(XMDManager,rowIndex) { + + var idx = -1; + if(typeof rowIndex == 'undefined') { + idx = this.getSelectedRowIndex(); + } else { + idx = rowIndex; + } + + if(idx < 0) {return false;} + + var primaryKey = this.getRowPrimaryKey(idx); + if(!primaryKey) {return false;} + var nodeDetail = XMDManager.getNodeDetail(primaryKey); + + //Populate Detail Box. For compatibility with all product author refer to + //Author for books, artist for music, director for movies + var author = ""; + var authorArray = XMDManager.getArrayElement(nodeDetail,"Author"); + if(authorArray.length == 0) authorArray = XMDManager.getArrayElement(nodeDetail,"Artist"); + if(authorArray.length == 0) authorArray = XMDManager.getArrayElement(nodeDetail,"Director"); + if(authorArray.length > 0) { + for(var i=0;i<authorArray.length;i++) { + if(i < authorArray.length-1) { + author += authorArray[i] + ', '; + } else{ + author += authorArray[i]; + } + } + } + this.guiAuthor.setAttribute('value',author); + + var productName = XMDManager.getSingleElement(nodeDetail,"ProductName"); + if(!productName) productName = ""; + this.guiProductName.setAttribute("value",productName); + + var manufacturer = XMDManager.getSingleElement(nodeDetail,"Manufacturer"); + if(!manufacturer) manufacturer = ""; + this.guiManufacturer.setAttribute("value",manufacturer); + + var released = XMDManager.getSingleElement(nodeDetail,"ReleaseDate"); + if(!released) released = ""; + this.guiReleaseDate.setAttribute("value",released); + + + //Populate price box + var listPrice = XMDManager.getSingleElement(nodeDetail,"ListPrice"); + if(!listPrice) listPrice = ""; + this.guiListPrice.setAttribute("value",listPrice); + + var ourPrice = XMDManager.getSingleElement(nodeDetail,"OurPrice"); + if(!ourPrice) ourPrice = ""; + this.guiOurPrice.setAttribute("value",ourPrice); + + var usedPrice = XMDManager.getSingleElement(nodeDetail,"UsedPrice"); + if(!usedPrice) usedPrice = ""; + this.guiUsedPrice.setAttribute("value",usedPrice); + + //Image Small + var imgSrc = XMDManager.getSingleElement(nodeDetail,"ImageUrlMedium"); + if(!imgSrc) imgSrc = ""; + this.guiImageSmall.setAttribute('src',imgSrc); + + + //ProductInfo and Reviews Panels + var allInfo = this.getFormattedInfo(XMDManager,nodeDetail); + + //Move ScrollBar at the top + window.frames[0].scrollTo(0,0); + + if(allInfo) { + this.guiProductInfo.innerHTML = allInfo; + } else { + this.clearInfo(); + } + + + window.frames[1].scrollTo(0,0); + //Comments + var comments = this.getFormattedReview(XMDManager,nodeDetail); + if(comments) { + this.guiCommentBtn.setAttribute('disabled','true'); + this.guiReview.innerHTML = comments; + }else{ + this.clearReview(); + this.guiCommentBtn.setAttribute('disabled','false'); + + } + + return true; +} + +/** + * Get all info (Product Info and Customer Reviews) from a product and format them + * with a minimal HTML + * @param {XMDManager} XMDManager + * @param {XML nodeDetail} nodeDetail + * @param {string} infoLevel How many formatted info have to be returned can be [base | full ] + * @return the requested info with HTML markup + * @type string HTML +*/ +DisplayController.prototype.getFormattedInfo = function(XMDManager,nodeDetail,infoLevel) { + var myXMDManager = XMDManager; + var content = ""; + var returnLevel = "full" + if(infoLevel) {returnLevel = infoLevel;} + + //BASE INFO + + var amazonURL = this.getProductAmazonUrl(myXMDManager,"directLink",nodeDetail); + + if(amazonURL) {content += "<a href='" + amazonURL + "' target='Amazon' title='Go to the product Amazon homepage'>";} + + var productName = myXMDManager.getSingleElement(nodeDetail,"ProductName"); + if(productName) {content += "<strong class='info-head'>"+productName+"</strong>\n"} + + if(amazonURL) { content+= "</a>";} + + content += "<br>"; + + var authorArray = myXMDManager.getArrayElement(nodeDetail,"Author"); + if(authorArray.length == 0) authorArray = myXMDManager.getArrayElement(nodeDetail,"Artist"); + if(authorArray.length == 0) authorArray = myXMDManager.getArrayElement(nodeDetail,"Actor"); + + if(authorArray.length > 0) { + for(var i=0;i<authorArray.length;i++) { + content += "<li>"+authorArray[i]+"</li>\n"; + //No more than 4 artist + if(i == 3) {break;} + } + } + + var director = myXMDManager.getArrayElement(nodeDetail,"Director"); + if(director.length > 0) { + for(i=0;i<director.length;i++) { + content += "<li>"+director+" (Director)</li>\n"; + //No more than 4 director + if(i == 3) {break;} + } + } + + var manufacturer = myXMDManager.getSingleElement(nodeDetail,'Manufacturer'); + if(manufacturer) {content += manufacturer +"<br>\n";} + + var releaseDate = myXMDManager.getSingleElement(nodeDetail,'ReleaseDate'); + if(releaseDate) { content += releaseDate + "<p/>\n";} + + var ASIN = myXMDManager.getSingleElement(nodeDetail,'Asin'); + if(ASIN) { content += "<strong class='info-title'>ASIN: </strong>"+ASIN+"<br>\n";} + + var ISBN = myXMDManager.getSingleElement(nodeDetail,'Isbn'); + if(ISBN) {content += "<strong class='info-title'>ISBN: </strong>"+ISBN+"<br>\n";} + + var media = myXMDManager.getSingleElement(nodeDetail,'Media'); + if(media) {content += "<strong class='info-title'>Media: </strong>"+media+"<br>\n";} + + var salesRank = myXMDManager.getSingleElement(nodeDetail,'SalesRank'); + if(salesRank) {content += "<strong class='info-title'>Sales Rank: </strong>"+salesRank+"<br>\n";} + + var availability = myXMDManager.getSingleElement(nodeDetail,'Availability'); + if(availability) {content += "<strong class='info-title'>Availability: </strong>"+availability+"<br>\n";} + + var lastUpdate = myXMDManager.getSingleElement(nodeDetail,"MABTSLastUpdate"); + var strLastUpdate = ""; + if(lastUpdate) { + lastUpdate = new Date(parseInt(lastUpdate)); + strLastUpdate = "<strong class='info-title'>MAB Last Update: </strong>" + lastUpdate.toLocaleDateString(); + } + content += strLastUpdate +"<br>\n"; + + + var feature = myXMDManager.getArrayElement(nodeDetail,'Feature'); + if(feature.length > 0) { + content += "<strong class='info-title'>Features:</strong>"; + for(i=0;i<feature.length;i++) { + content += "<li>"+feature[i]+"</li>\n"; + } + content += "<br>"; + } + + if(returnLevel == "base"){return content;} + + //FULL INFO + var productDescription = myXMDManager.getSingleElement(nodeDetail,'ProductDescription'); + if(productDescription) {content += "<strong class='info-title'>Product Description: </strong><br>"+productDescription+"<p/>\n"; + } + + //Music + var track = myXMDManager.getArrayElement(nodeDetail,'Track'); + if(track.length > 0) { + content += "<strong class='info-title'>Tracks</strong><br/><ol>"; + for(i=0;i<track.length;i++) { + content += "<li>"+track[i]+"</li>\n"; + } + content += "</ol><br>\n"; + } + + /*Listmania + var listMania = this.getProductAmazonUrl(myXMDManager,"listManiaLink"); + if(listMania) { + content += "<strong class='info-title'>List Mania:</strong>"; + content += "<a href='" + listMania + "' target='Amazon' title='Check this ListMania'>View List Mania</a>\n"; + } + */ + + return content; + +} + +/** + * Get the Customers Review and apply a minimum HTML formatting + * @param {XMDManage} XMDManager + * @param {XML nodeDetail} nodeDetail + * @return the customer reviews or a "Not Available" string + * @type string +*/ +DisplayController.prototype.getFormattedReview = function(XMDManager,nodeDetail){ + var myXMDManager = XMDManager; + if(!myXMDManager) {return false;} + var content = "<strong class='info-head'>Customer Reviews:</strong><br>"; + + var reviews = myXMDManager.tagExists(nodeDetail,"Reviews"); + if(!reviews) {return false;} + + var customerReview = myXMDManager.tagExists(nodeDetail,"CustomerReview"); + if(!customerReview) { + content += "<strong>Not Available</strong>"; + return content; + }else{ + customerReview = nodeDetail.getElementsByTagName("CustomerReview"); + } + + var totReviews = myXMDManager.getSingleElement(nodeDetail,'TotalCustomerReviews'); + if(!totReviews) {totReviews = "";} + var avgRating = myXMDManager.getSingleElement(nodeDetail,'AvgCustomerRating'); + if(!avgRating) {avgRating = "";} + + content += "<i>Average Rating: " + avgRating + " out of " + totReviews + " reviews</i><br><br>"; + + + + if(customerReview) { + var summary, rating, comment, node, date; + for(var i=0;i<customerReview.length;i++) { + node = customerReview.item(i); + summary = myXMDManager.getSingleElement(node,'Summary'); + if(summary) {content += "<strong>"+summary+"<br>"} + + rating = myXMDManager.getSingleElement(node,'Rating'); + if(rating) {content += "Rating: "+rating +"</strong><br><br>";} + + comment = myXMDManager.getSingleElement(node,'Comment'); + if(comment) {content += comment + "<br>";} + + date = myXMDManager.getSingleElement(node,'Date'); + if(date) {content += date;} + + content += "<br>"; + } + + } + return content; +} + +/** + * Count how many rows are in the xul tree + * @type int +*/ +DisplayController.prototype.getNumberRows = function() { + return this.guiMainTree.view.rowCount; +} + +/** + * Write on the status bar how many rows (products) are currently listed + * @return void +*/ +DisplayController.prototype.writeRowStatus = function() { + var nrRows = this.getNumberRows(); + this.guiRecordStatus.setAttribute('label',nrRows + ' listed products '); +} + +/** + * Get the id value (the primary key) of a xul treerow by his row index + * @param {int} rowIndex + * @return the id value or false + * @type int +*/ +DisplayController.prototype.getRowPrimaryKey = function(rowIndex) { + if(typeof rowIndex == "undefined" || rowIndex < 0) { + return false; + } else{ + var idx = rowIndex; + } + + var theRows = this.guiMainTree.getElementsByTagName('treerow'); + if(typeof theRows[idx] != "undefined") { + var pk = theRows[idx].getAttribute('id'); + }else{ + return false; + } + + return pk; +} + +/** + * Gets rows index for all selected rows of the tree + * @return the array with the rows index + * @type array +*/ +DisplayController.prototype.getAllSelectedRowIndex = function() { + var indexList = new Array(); + var numRanges = this.guiMainTree.view.selection.getRangeCount(); + + var start = {}; + var end = {}; + for (var t=0; t<numRanges; t++){ + this.guiMainTree.view.selection.getRangeAt(t,start,end); + for (var v=start.value; v<=end.value; v++){ + indexList.push(v); + } + } + return indexList; +} + +/** + * Return row index of the currently selected row in the tree + * @return the index or -1 if it is undefined + * @type int +*/ +DisplayController.prototype.getSelectedRowIndex = function() { + var idx = this.guiMainTree.currentIndex; + if(idx == "undefined") { + return -1; + }else{ + return idx; + } +} + +/** + * Find the correponding row Index + * @param {string} id the id attribute + * @return the row Index + * @type int +*/ +DisplayController.prototype.getRowIndexById = function(id) { + var rows = this.guiMainTree.getElementsByTagName("treerow"); + var pk; + for(var i=0;i<rows.length;i++) { + pk = rows[i].getAttribute("id"); + if(pk == id) { + return i + } + } + + return -1; +} + +/** + * Get the search preference + * @type string +*/ +DisplayController.prototype.getSearchPreference = function() { + return this.elSettingsSpacer.getAttribute("search"); +} + +/** + * Get how many records should be requested for each connection + * @type int +*/ +DisplayController.prototype.getRecordPreference = function() { + return this.elSettingsSpacer.getAttribute("nrResult"); +} + +/** + * Sort rows in the tree + * @param {XMDMnager} XMDManager + * @param {XUL Element} el the reference to the xul treecol + * @param {string} sortTag the xml tag to use for sorting rows + * @param {bool} virtualSort apply virtual sort, so the XMDManager model remain untouched. + * @return void +*/ +DisplayController.prototype.sort = function(XMDManager,el,sortTag,virtualSort) { + //reorder the XML Document + var myXMDManager = XMDManager; + var sortType = el.getAttribute('class'); + //Get only first class style + var firstClass = sortType.split(" "); + sortType = firstClass[0]; + + var sortDirection = el.getAttribute('sortDirection'); + + this.clearRowHeader(); + + var asc = true; + el.setAttribute('sortDirection','ascending'); + + if(sortDirection == "ascending"){ + asc = false; + el.setAttribute('sortDirection','descending'); + }else if (sortDirection == "descending"){ + asc = true; + el.setAttribute('sortDirection','ascending'); + } + + //get Currently selected row + var rowSelected = this.getSelectedRowIndex(); + var pk = this.getRowPrimaryKey(rowSelected); + + //Set cursor to wait + if((typeof window.setCursor != "undefined") && (typeof window.setCursor == "function")) { + window.setCursor("wait"); + } + + //VirtualSort, the xml document is not really sorted, we sort only the view in the tree + if(virtualSort) { + var nodeSorted = myXMDManager.virtualSort(sortType,sortTag,asc); + var treeNode = this.guiMainTree.getElementsByTagName("treerow"); + var treeRow; + //Update every rows; + for(var i=0; i < nodeSorted.length;i++) { + treeRow = treeNode.item(i) + this.updateRow(treeRow,nodeSorted[i],myXMDManager); + } + + }else{ + //sort first the XML document + myXMDManager.sort(sortType,sortTag,asc); + //Sync tree with the new sorted xml document + this.syncTree(myXMDManager); + } + + //reset the focus on the previous selected row + var newIndex = this.getRowIndexById(pk); + if(newIndex) {this.setFocusOnRow(newIndex);} + + //Set cursor to normal + if((typeof window.setCursor != "undefined") && (typeof window.setCursor == "function")) { + window.setCursor("auto"); + } +} + +/** + * Set Focus on a row ensuring it remains visible if the tree has too many rows + * @param {int} index + * return void if index < 0 +*/ +DisplayController.prototype.setFocusOnRow = function(index) { + if(index < 0) {return;} + + this.guiMainTree.view.selection.select(index); + this.guiMainTree.focus(); + this.guiMainTree.treeBoxObject.ensureRowIsVisible(index); +} +\ No newline at end of file diff --git a/mab/xul/js/DocOpenManager.js b/mab/xul/js/DocOpenManager.js @@ -0,0 +1,157 @@ +/** + * + * Mantain the list of all open document and display the list in the windows menu + * bar. + * + * @fileName DocOpenManager.js + * @$LastChangedDate: 2004-06-02 13:40:33 +0200 (Wed, 02 Jun 2004) $ + * @author Fabio Serra <faser@faser.net> + * @copyright Fabio Serra (The Initial Developer of the Original Code) + * @license Mozilla Public License Version 1.1 + * +*/ + +/** + * Construct a new DocOpenManager object + * @class This class is used to record the list of all opened documents and to + * display it in the window menubar + * @final + * @constructor + * @return A new DocOpenManager object + * +*/ +function DocOpenManager() { + //references to the windows pop-up + this.winMenu = document.getElementById("windows-menu"); + // THL this.winPopup = document.getElementById("windows-popup"); + this.winPopup = document.getElementById("windows-menu_menu"); + //List all opened document - LIFO + this.docOpened = new Array(); + this.docCounter = 0; +} + +/** + * Add a new document to the list + * @param {XMDManager} XMDManager +*/ +DocOpenManager.prototype.addDoc = function(XMDManager) { + + this.docOpened[this.docCounter] = XMDManager; + var name = XMDManager.name; + if(name == "") { + name = "Document " + (this.docCounter + 1); + } + var id = "windows_doc_" + this.docCounter; + var newItem = '<menuitem id="'+ id +'" doccounter="'+ this.docCounter +'" type="radio" name="openDocuments" checked="false" label="'+ name +'" oncommand="loadDoc('+ this.docCounter +')"/>'; + innerXML(this.winPopup,newItem,true); + this.checkDoc(this.docCounter); + + this.docCounter++; +} + +/** + * Rename the currently loaded document + * @param {string} newName + * @return void +*/ +DocOpenManager.prototype.renameCurrentDoc = function(newName) { + var docCounter = this.getCurrentDocCounter(); + var el = document.getElementById("windows_doc_"+docCounter); + el.setAttribute("label",newName); +} + +/** + * Remove the document from the window menubar list + * @param {int} docCounter The current index of the document + * @return void +*/ +DocOpenManager.prototype.removeDoc = function(docCounter) { + this.docOpened[docCounter] = null; + var elRemoved = document.getElementById("windows_doc_"+docCounter); + this.winPopup.removeChild(elRemoved); +} + +/** + * Check the corresponding menuitem + * @param {int} docCounter + * @return void +*/ +DocOpenManager.prototype.checkDoc = function(docCounter) { + var el = document.getElementById("windows_doc_"+docCounter); + var elOld = this.winMenu.getElementsByTagName("menuitem"); + for(var i=0;i<elOld.length;i++) { + elOld[i].setAttribute("checked","false"); + } + el.setAttribute("checked","true"); +} + +/** + * Get the checked menuitem + * @return the checked element or false +*/ +DocOpenManager.prototype.getCheckedItem = function() { +//selectedItem and selectIndex doesn't work + var el = this.winMenu.getElementsByTagName("menuitem"); + var checked = false; + for(var i=0;i<el.length;i++) { + checked = el[i].getAttribute("checked"); + if(checked == "true") { + return el[i]; + } + } + return false; + +} + +/** + * Return the current document index + * @type int +*/ +DocOpenManager.prototype.getCurrentDocCounter = function() { + var el = this.getCheckedItem(); + var docCounter = el.getAttribute("doccounter"); + return docCounter; +} + +/** + * Get a selected XMDManager + * @return the reference to the selected XMDManager + * @param {int} docCounter + * @return the XMDManager or false +*/ +DocOpenManager.prototype.getDocument = function(docCounter){ + if(this.docOpened[docCounter]) { + return this.docOpened[docCounter]; + } else { + return false; + } +} + +/** + * Get the current XMDManager + * @return the XMDManager or false +*/ +DocOpenManager.prototype.getCurrentDocument = function () { + //selectedItem doesn't works !??? + var el = this.getCheckedItem(); + if(el) { + var theDoc = this.getDocument(el.getAttribute("doccounter")); + return theDoc; + }else{ + return false; + } +} + +/** + * Retrieve the name of the current document as stated in the menuitem + * @return the string name or false +*/ +DocOpenManager.prototype.getCurrentDocumentName = function () { + //selectedItem doesn't works ??? + var el = this.getCheckedItem(); + if(el) { + return el.getAttribute("label"); + }else{ + return false; + } +} +\ No newline at end of file diff --git a/mab/xul/js/FileManager.js b/mab/xul/js/FileManager.js @@ -0,0 +1,196 @@ +/** + * + * @filename FileManager.js + * @$LastChangedDate: 2004-06-26 13:51:10 +0200 (Sat, 26 Jun 2004) $ + * @author Fabio Serra AKA Faser - faser@faser.net + * @copyright Fabio Serra (The Initial Developer of the Original Code) + * @license Mozilla Public License Version 1.1 + * +*/ + +/** + * Construct a new FileManager object + * @class This class is used To manage file from disk. + * It can be used only with installed application.Remote MAB have to read and write from memory + * @constructor + * @return A new FileManager object + * +*/ +function FileManager() { + /** + *@type string + */ + this.path = ""; + + /** + *@type string + */ + this.leafName = ""; +} + +/** + * Read a .mab file + * @throw exception reading file + * @return the file content + * @type string +*/ +FileManager.prototype.readFile = function() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { + alert("Permission to read file was denied."); + } + + try { + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + }catch(e) { + alert(e); + } + + fp.init(window, "Select a MAB File", nsIFilePicker.modeOpen); + fp.appendFilter("MAB Files","*.mab;"); + + var res=fp.show(); + if (res==nsIFilePicker.returnOK){ + var is = Components.classes["@mozilla.org/network/file-input-stream;1"] + .createInstance( Components.interfaces.nsIFileInputStream ); + + is.init(fp.file,0x01, 00004, null); + var sis = Components.classes["@mozilla.org/scriptableinputstream;1"] + .createInstance( Components.interfaces.nsIScriptableInputStream ); + + sis.init(is); + var tmp, output; + try { + tmp = sis.read(sis.available()); + }catch(e){ + throw(e); + } + + try { + //File should be in UTF-8 + output = this.convertToUnicode("UTF-8",tmp); + }catch(e) { + output = tmp; + } + + sis.close(); + + //Set some properties that have to be saved in the XMDManager that contain + //the current document + this.path = fp.file.path; + this.leafName = fp.file.leafName; + return output; + }else{ + return false; + } + +} + +/** + * Save on file the document in UTF-8 + * @param {XML Document} XMLDoc the XML document + * @param {string} fullPath the absolute path where to save the file + * @throw alert if it fails +*/ +FileManager.prototype.saveFile = function(XMLDoc,fullPath) { + if(!fullPath) {return false;} + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { + alert("Permission to save file was denied."); + } + + try{ + var f = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); + f.initWithPath(fullPath); + if(f.exists == false) { + f.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 ); + + } + } catch (e) { + alert("Component: \n" + e + '\n fullpath:' + fullPath ); + } + + try { + var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"] + .createInstance( Components.interfaces.nsIFileOutputStream ); + }catch(e) { + alert("OutputStrem:" + e); + } + + try { + outputStream.init(f, 0x04 | 0x08 | 0x20, 420, 0 ); + var xmlSerializer = new XMLSerializer(); + //Force to save file in UTF-8 + xmlSerializer.serializeToStream(XMLDoc, outputStream, 'UTF-8'); + outputStream.close(); + } catch (e) { + alert("Unable to write to file: " + e); + } finally { + outputStream.close(); + } + + return true; +} + +/** + *@param {string} aCharset + *@param {string} aSrc + *@type string +*/ +FileManager.prototype.convertToUnicode = function (aCharset, aSrc ) { + // http://lxr.mozilla.org/mozilla/source/intl/uconv/idl/nsIScriptableUConv.idl + var unicodeConverter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter); + unicodeConverter.charset = aCharset; + return unicodeConverter.ConvertToUnicode(aSrc); +} + +/** + * @return the full path where to save the file + * @type string +*/ +FileManager.prototype.saveAs = function() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { + alert("Permission to write file was denied."); + } + + try { + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + }catch(e) { + alert(e); + } + + fp.init(window, "Select As", nsIFilePicker.modeSave); + fp.appendFilter("MAB Files","*.mab;"); + + var res=fp.show(); + if (res==nsIFilePicker.returnOK || nsIFilePicker.returnReplace){ + if(res == nsIFilePicker.returnCancel) {return false;} + this.path = fp.file.path; + this.leafName = fp.file.leafName; + + var extension = ".mab"; + var exProvided = ""; + + var extSeparator = fp.file.leafName.lastIndexOf("."); + if (extSeparator == -1) { + this.leafName = fp.file.leafName + extension; + this.path = fp.file.path + extension; + }else{ + extProvided = fp.file.leafName.substr(extSeparator); + if(extProvided != extension) { + this.leafName = fp.file.leafName + extension; + this.path = fp.file.leafName + extension; + } + } + + return this.path; + }else{ + return false; + } +} +\ No newline at end of file diff --git a/mab/xul/js/ProductLine.js b/mab/xul/js/ProductLine.js @@ -0,0 +1,148 @@ +/** + * + * + * @filename ProductLine.js + * @$LastChangedDate: 2004-07-04 19:24:15 +0200 (Sun, 04 Jul 2004) $ + * @author Fabio Serra AKA Faser - faser@faser.net + * @copyright Fabio Serra (The Initial Developer of the Original Code) + * @license Mozilla Public License Version 1.1 +* +*/ + +/** + * Construct a new ProductLine object + * @class This class store available Amazon catalogs and related search and sort type + * because for each country Amazon has a little different catalogs (mode) with related + * sort and search types. + * @constructor + * @return A new ProductLine object + * +*/ + +function ProductLine() { + this.catalog = {}; +} + + +/** + * Add a Catalog with the associate mode parameter and the list of valid search type + * @param {string} key + * @param {string} value +*/ +ProductLine.prototype.addCatalog = function(key,value) { + this.catalog[key] = new Array(3); + //Mode parameter + this.catalog[key][0] = value; + //Array of valid search type + this.catalog[key][1] = ""; + //Properties of valid sort type + this.catalog[key][2] = {}; +} + +/** + * @param {string} key + * @return the catalog value + * @type string +*/ +ProductLine.prototype.getCatalogValue = function(key) { + if(typeof this.catalog[key] == "undefined") { + return false + }else{ + return this.catalog[key][0]; + } +} + +/** + * Add a search type to a catalog + * @param {string} catalogKey + * @param {string} listSearchType + * @throw catalogKey not valid +*/ +ProductLine.prototype.addSearchType = function(catalogKey,listSearchType) { + if (typeof this.catalog[catalogKey] == "undefined") { + throw("catalogKey not valid"); + } + this.catalog[catalogKey][1] = listSearchType.split(','); +} + +/** + * Add sort type related a catalog + * @param {string} catalogKey + * @param {string} sortKey + * @param {string} sortValue + * @throw catalogKey not valid +*/ +ProductLine.prototype.addSort = function(catalogKey,sortKey,sortValue) { + if (typeof this.catalog[catalogKey] == "undefined") { + throw("catalogKey not valid"); + } + this.catalog[catalogKey][2][sortKey] = sortValue; +} + +/** + * @param {string} catalogKey + * @param {string} sortKey +*/ +ProductLine.prototype.getSortValue = function(catalogKey,sortKey) { + return this.catalog[catalogKey][2][sortKey]; +} + +/** + * Check if the catalog has been added to the object + * @param {string} catalogKey +*/ +ProductLine.prototype.isValidProductLine = function(catalogKey) { + var key = catalogKey; + if(typeof this.catalog[key] != "undefined") { + return true; + }else{ + return false; + } +} + +/** + * Check if the search type is valid for the selected catalog + * @param {string} catalogKey + * @param {string} searchType + * @type bool +*/ +ProductLine.prototype.isValidSearchType = function(catalogKey, searchType) { + //Check catalog + if (typeof this.catalog[catalogKey] == "undefined") { + return false; + } + + //Verify searchType + for(var i=0;i<this.catalog[catalogKey][1].length;i++) { + if(this.catalog[catalogKey][1][i] == searchType) return true; + } + return false; +} + +/** + * Check if the sort type is valid for the selected catalog + * @param {string} catalogKey + * @param {string} sort + * @type bool +*/ +ProductLine.prototype.isValidSort = function(catalogKey,sort) { + //Check catalog + if (typeof this.catalog[catalogKey] == "undefined") { + return false; + } else { + return this.propertyExist(this.catalog[catalogKey][2],sort); + } +} + +/** + * Verify if an object have a property + * @param {Object} obj + * @param {string} prop + * @type bool +*/ +ProductLine.prototype.propertyExist = function(obj,prop) { + for (var i in obj) { + if(i == prop) return true; + } + return false; +} +\ No newline at end of file diff --git a/mab/xul/js/ProductLineController.js b/mab/xul/js/ProductLineController.js @@ -0,0 +1,676 @@ +/** +* +* +* @FileName: ProductLineController.js +* @$LastChangedDate: 2004-07-04 19:24:15 +0200 (Sun, 04 Jul 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + +function ProductLineController() { + //reference to the GUI element + this.elLocale = document.getElementById('locale-popup'); + this.elCatalog = document.getElementById('mode-popup'); + this.elSearch = document.getElementById('search-popup'); + this.elSort = document.getElementById('sort-popup'); + + //Base Object to store different Product Line Object + this.myProductLine = {}; + +} + +//Update the product line toolbar +ProductLineController.prototype.update = function () { + var locale = this.elLocale.selectedItem.getAttribute('value'); + if(typeof this.myProductLine[locale] == "undefined") { + this.myProductLine[locale] = new ProductLine(); + + switch(locale) { + case "us": + this.createProductLineUS(this.myProductLine[locale]); + break; + case "uk": + this.createProductLineUK(this.myProductLine[locale]); + break; + case "de": + this.createProductLineDE(this.myProductLine[locale]); + break; + case "fr": + this.createProductLineFR(this.myProductLine[locale]); + break; + case "ca": + this.createProductLineCA(this.myProductLine[locale]); + break; + case "jp": + this.createProductLineJP(this.myProductLine[locale]); + break; + } + } + + this.checkCatalog(locale); + this.checkSearch(locale); + this.checkSort(locale); +} + +//Check valid catalog for defined locale +ProductLineController.prototype.checkCatalog = function(locale) { + var catalogItem = this.elCatalog.getElementsByTagName('menuitem'); + for(var i=0;i<catalogItem.length;i++) { + if(!this.myProductLine[locale].isValidProductLine(catalogItem[i].value)) { + catalogItem[i].setAttribute('disabled','true'); + }else{ + catalogItem[i].setAttribute('disabled','false'); + } + } +} + +//Check valid search for defined locale +ProductLineController.prototype.checkSearch = function(locale) { + var currentCatalog = this.elCatalog.selectedItem.getAttribute('value'); + var searchItem = this.elSearch.getElementsByTagName('menuitem'); + for(var i=0;i<searchItem.length;i++) { + if(!this.myProductLine[locale].isValidSearchType(currentCatalog,searchItem[i].value)) { + searchItem[i].setAttribute('disabled','true'); + }else{ + searchItem[i].setAttribute('disabled','false'); + } + } +} + +//Check valid sort for defined locale +ProductLineController.prototype.checkSort = function(locale) { + var currentCatalog = this.elCatalog.selectedItem.getAttribute('value'); + var sortItem = this.elSort.getElementsByTagName('menuitem'); + for(var i=0;i<sortItem.length;i++) { + if(!this.myProductLine[locale].isValidSort(currentCatalog,sortItem[i].value)) { + sortItem[i].setAttribute('disabled','true'); + }else{ + sortItem[i].setAttribute('disabled','false'); + } + } +} + +//Return the selected locale if enabled +ProductLineController.prototype.getLocale = function() { + var disabled = this.elLocale.selectedItem.getAttribute('disabled'); + if(disabled == "false") { + return this.elLocale.selectedItem.getAttribute('value'); + }else{ + return false; + } +} + + +//Return catalog value if the item is not been disabled +ProductLineController.prototype.getCatalog = function() { + var disabled = this.elCatalog.selectedItem.getAttribute('disabled'); + if(disabled == "false") { + return this.elCatalog.selectedItem.getAttribute('value'); + }else{ + return false; + } +} + +ProductLineController.prototype.getCatalogValue = function() { + var locale = this.getLocale(); + var key = this.getCatalog(); + if(!key || !locale) { + return false; + }else{ + return this.myProductLine[locale].getCatalogValue(key); + } +} + + + +//Return search value if the item is not been disabled +ProductLineController.prototype.getSearch = function() { + var disabled = this.elSearch.selectedItem.getAttribute('disabled'); + if(disabled == "false") { + return this.elSearch.selectedItem.getAttribute('value'); + }else{ + return false; + } +} + +//Return sort if the item is not been disabled +ProductLineController.prototype.getSort = function() { + var disabled = this.elSort.selectedItem.getAttribute('disabled'); + if(disabled == "false") { + return this.elSort.selectedItem.getAttribute('value'); + }else{ + return false; + } +} + +ProductLineController.prototype.getSortValue = function() { + var locale = this.getLocale(); + var catalogKey = this.getCatalog(); + var sortKey = this.getSort(); + if(!locale || !catalogKey || !sortKey) { + return false + }else{ + return this.myProductLine[locale].getSortValue(catalogKey,sortKey); + } +} + + + +//Create the objetc for the provided locale +//Amazon.com +ProductLineController.prototype.createProductLineUS = function(obj) { + //Blended + obj.addCatalog('blended','blended'); + obj.addSearchType('blended','KeywordSearch'); + obj.addSort('blended','+salesrank','+salesrank'); + //Books + obj.addCatalog('books','books'); + obj.addSearchType('books','KeywordSearch,AsinSearch,AuthorSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('books','+pmrank','+pmrank'); + obj.addSort('books','+salesrank','+salesrank'); + obj.addSort('books','+reviewrank','+reviewrank'); + obj.addSort('books','+pricerank','+pricerank'); + obj.addSort('books','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('books','+daterank','+daterank'); + obj.addSort('books','+titlerank','+titlerank'); + obj.addSort('books','-titlerank','-titlerank'); + //Magazines + obj.addCatalog('magazines','magazines'); + obj.addSearchType('magazines','KeywordSearch,AsinSearch'); + obj.addSort('magazines','+salesrank','+salesrank'); + //Popular Music + obj.addCatalog('music','music'); + obj.addSearchType('music','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('music','+pmrank','+psrank'); + obj.addSort('music','+salesrank','+salesrank'); + obj.addSort('music','+artistrank','+artistrank'); + obj.addSort('music','+orig-rel-date','+orig-rel-date'); + obj.addSort('music','+titlerank','+titlerank'); + //Classical Music + obj.addCatalog('classical','classical'); + obj.addSearchType('classical','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('classical','+pmrank','+psrank'); + obj.addSort('classical','+salesrank','+salesrank'); + obj.addSort('classical','+artistrank','+artistrank'); + obj.addSort('classical','+orig-rel-date','+orig-rel-date'); + obj.addSort('classical','+titlerank','+titlerank'); + //DVD + obj.addCatalog('dvd','dvd'); + obj.addSearchType('dvd','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('dvd','+salesrank','+salesrank'); + obj.addSort('dvd','+titlerank','+titlerank'); + //Video (vhs) + obj.addCatalog('vhs','vhs'); + obj.addSearchType('vhs','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('vhs','+salesrank','+salesrank'); + obj.addSort('vhs','+titlerank','+titlerank'); + obj.addSort('vhs','+pmrank','+psrank'); + //Electronics + obj.addCatalog('electronics','electronics'); + obj.addSearchType('electronics','KeywordSearch,AsinSearch,UpcSearch'); + obj.addSort('electronics','+salesrank','+salesrank'); + obj.addSort('electronics','+titlerank','+titlerank'); + obj.addSort('electronics','+pmrank','+pmrank'); + obj.addSort('electronics','+reviewrank','+reviewrank'); + //Software + obj.addCatalog('software','software'); + obj.addSearchType('software','KeywordSearch,AsinSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('software','+salesrank','+salesrank'); + obj.addSort('software','+titlerank','+titlerank'); + obj.addSort('software','+pmrank','+pmrank'); + obj.addSort('software','+pricrerank','+price'); + obj.addSort('software','+inverse-pricerank','-price'); + //Videogames + obj.addCatalog('videogames','videogames'); + obj.addSearchType('videogames','KeywordSearch,AsinSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('videogames','+salesrank','+salesrank'); + obj.addSort('videogames','+titlerank','+titlerank'); + obj.addSort('videogames','+pmrank','+pmrank'); + obj.addSort('videogames','+pricerank','+price'); + obj.addSort('videogames','+inverse-pricerank','-price'); + //Camera + obj.addCatalog('photo','photo'); + obj.addSearchType('photo','KeywordSearch,AsinSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('photo','+salesrank','+salesrank'); + obj.addSort('photo','+pmrank','+pmrank'); + obj.addSort('photo','+titlerank','+titlerank'); + obj.addSort('photo','-titlerank','-titlerank'); + //Toys + obj.addCatalog('toys','toys'); + obj.addSearchType('toys','KeywordSearch,AsinSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('toys','+salesrank','+salesrank'); + obj.addSort('toys','+pmrank','+pmrank'); + obj.addSort('toys','+titlerank','+titlerank'); + obj.addSort('toys','+pricerank','+pricerank'); + obj.addSort('toys','+inverse-pricerank','+inverse-pricerank'); + //Housewares + obj.addCatalog('kitchen','kitchen'); + obj.addSearchType('kitchen','KeywordSearch,AsinSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('kitchen','+salesrank','+salesrank'); + obj.addSort('kitchen','+pmrank','+pmrank'); + obj.addSort('kitchen','+titlerank','+titlerank'); + obj.addSort('kitchen','-titlerank','-titlerank') + obj.addSort('kitchen','+pricerank','+price'); + obj.addSort('kitchen','+inverse-pricerank','-price'); + obj.addSort('kitchen','+manufactrank','+manufactrank'); + obj.addSort('kitchen','-manufactrank','-manufactrank'); + //Tools + obj.addCatalog('tools','tools'); + obj.addSearchType('tools','KeywordSearch,AsinSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('tools','+salesrank','+salesrank'); + obj.addSort('tools','+pmrank','+psrank'); + obj.addSort('tools','+titlerank','+titlerank'); + obj.addSort('tools','-titlerank','-titlerank') + obj.addSort('tools','+pricerank','+price'); + obj.addSort('tools','+inverse-pricerank','-price'); + obj.addSort('tools','+manufactrank','+manufactrank'); + obj.addSort('tools','-manufactrank','-manufactrank'); + //Outdoor Living + obj.addCatalog('garden','garden'); + obj.addSearchType('garden','KeywordSearch,AsinSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('garden','+salesrank','+salesrank'); + obj.addSort('garden','+pmrank','+psrank'); + obj.addSort('garden','+titlerank','+titlerank'); + obj.addSort('garden','-titlerank','-titlerank') + obj.addSort('garden','+pricerank','+price'); + obj.addSort('garden','+inverse-pricerank','-price'); + obj.addSort('garden','+manufactrank','+manufactrank'); + obj.addSort('garden','-manufactrank','-manufactrank'); + //Baby + obj.addCatalog('baby','baby'); + obj.addSearchType('baby','KeywordSearch,AsinSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('garden','+salesrank','+salesrank'); + //jewelry + obj.addCatalog('jewelry','jewelry'); + obj.addSearchType('jewelry','KeywordSearch,AsinSearch,ManufacturerSearch,UpcSearch'); + obj.addSort('jewelry','+salesrank','+salesrank'); +} + +//Amazon.co.uk +ProductLineController.prototype.createProductLineUK = function(obj) { + //Blended + obj.addCatalog('blended','blended'); + obj.addSearchType('blended','KeywordSearch'); + obj.addSort('blended','+salesrank','+salesrank'); + //Books + obj.addCatalog('books','books-uk'); + obj.addSearchType('books','KeywordSearch,AsinSearch,AuthorSearch,ManufacturerSearch'); + obj.addSort('books','+pmrank','+pmrank'); + obj.addSort('books','+salesrank','+salesrank'); + obj.addSort('books','+reviewrank','+reviewrank'); + obj.addSort('books','+pricerank','+pricerank'); + obj.addSort('books','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('books','+daterank','+daterank'); + obj.addSort('books','+titlerank','+titlerank'); + obj.addSort('books','-titlerank','-titlerank'); + //Popular Music + obj.addCatalog('music','music'); + obj.addSearchType('music','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('music','+pmrank','+psrank'); + obj.addSort('music','+salesrank','+salesrank'); + obj.addSort('music','+artistrank','+artistrank'); + obj.addSort('music','+orig-rel-date','+orig-rel-date'); + obj.addSort('music','+titlerank','+titlerank'); + //Classical Music + obj.addCatalog('classical','classical'); + obj.addSearchType('classical','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('classical','+pmrank','+psrank'); + obj.addSort('classical','+salesrank','+salesrank'); + obj.addSort('classical','+artistrank','+artistrank'); + obj.addSort('classical','+orig-rel-date','+orig-rel-date'); + obj.addSort('classical','+titlerank','+titlerank'); + //DVD + obj.addCatalog('dvd','dvd-uk'); + obj.addSearchType('dvd','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('dvd','+salesrank','+salesrank'); + obj.addSort('dvd','+titlerank','+titlerank'); + //Video (vhs) + obj.addCatalog('vhs','vhs-uk'); + obj.addSearchType('vhs','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('vhs','+salesrank','+salesrank'); + obj.addSort('vhs','+titlerank','+titlerank'); + obj.addSort('vhs','+pmrank','+psrank'); + //Electronics + obj.addCatalog('electronics','electronics-uk'); + obj.addSearchType('electronics','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('electronics','+salesrank','+salesrank'); + obj.addSort('electronics','+titlerank','+titlerank'); + obj.addSort('electronics','+pmrank','+pmrank'); + obj.addSort('electronics','+reviewrank','+reviewrank'); + //Software + obj.addCatalog('software','software-uk'); + obj.addSearchType('software','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('software','+salesrank','+salesrank'); + obj.addSort('software','+titlerank','+titlerank'); + obj.addSort('software','+pmrank','+pmrank'); + obj.addSort('software','+pricrerank','+price'); + obj.addSort('software','+inverse-pricerank','-price'); + //Videogames + obj.addCatalog('videogames','video-games-uk'); + obj.addSearchType('videogames','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('videogames','+salesrank','+salesrank'); + obj.addSort('videogames','+titlerank','+titlerank'); + obj.addSort('videogames','+pmrank','+pmrank'); + obj.addSort('videogames','+pricerank','+price'); + obj.addSort('videogames','+inverse-pricerank','-price'); + //Toys + obj.addCatalog('toys','toys-uk'); + obj.addSearchType('toys','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('toys','+salesrank','+salesrank'); + obj.addSort('toys','+pmrank','+pmrank'); + obj.addSort('toys','+titlerank','+titlerank'); + obj.addSort('toys','+pricerank','+pricerank'); + obj.addSort('toys','+inverse-pricerank','+inverse-pricerank'); + //Housewares + obj.addCatalog('kitchen','kitchen-uk'); + obj.addSearchType('kitchen','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('kitchen','+salesrank','+salesrank'); + obj.addSort('kitchen','+pmrank','+pmrank'); + obj.addSort('kitchen','+titlerank','+titlerank'); + obj.addSort('kitchen','-titlerank','-titlerank') + obj.addSort('kitchen','+pricerank','+price'); + obj.addSort('kitchen','+inverse-pricerank','-price'); + obj.addSort('kitchen','+manufactrank','+manufactrank'); + obj.addSort('kitchen','-manufactrank','-manufactrank'); +} + +//Amazon.de +ProductLineController.prototype.createProductLineDE = function(obj) { + //Blended + obj.addCatalog('blended','blended'); + obj.addSearchType('blended','KeywordSearch'); + obj.addSort('blended','+salesrank','+salesrank'); + //Books + obj.addCatalog('books','books-de'); + obj.addSearchType('books','KeywordSearch,AsinSearch,AuthorSearch,ManufacturerSearch'); + obj.addSort('books','+pmrank','+pmrank'); + obj.addSort('books','+salesrank','+salesrank'); + obj.addSort('books','+reviewrank','+reviewrank'); + obj.addSort('books','+pricerank','+pricerank'); + obj.addSort('books','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('books','+daterank','+daterank'); + obj.addSort('books','+titlerank','+titlerank'); + obj.addSort('books','-titlerank','-titlerank'); + //Magazines + obj.addCatalog('magazines','magazines-de'); + obj.addSearchType('magazines','KeywordSearch,AsinSearch'); + obj.addSort('magazines','+salesrank','+salesrank'); + //Popular Music + obj.addCatalog('music','pop-music-de'); + obj.addSearchType('music','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('music','+pmrank','+psrank'); + obj.addSort('music','+salesrank','+salesrank'); + obj.addSort('music','+artistrank','+artistrank'); + obj.addSort('music','+orig-rel-date','+orig-rel-date'); + obj.addSort('music','+titlerank','+titlerank'); + //Classical Music + obj.addCatalog('classical','classical-de'); + obj.addSearchType('classical','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('classical','+pmrank','+psrank'); + obj.addSort('classical','+salesrank','+salesrank'); + obj.addSort('classical','+artistrank','+artistrank'); + obj.addSort('classical','+orig-rel-date','+orig-rel-date'); + obj.addSort('classical','+titlerank','+titlerank'); + //DVD + obj.addCatalog('dvd','dvd-de'); + obj.addSearchType('dvd','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('dvd','+salesrank','+salesrank'); + obj.addSort('dvd','+titlerank','+titlerank'); + //Video (vhs) + obj.addCatalog('vhs','vhs-de'); + obj.addSearchType('vhs','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('vhs','+salesrank','+salesrank'); + obj.addSort('vhs','+titlerank','+titlerank'); + obj.addSort('vhs','+pmrank','+psrank'); + //Electronics + obj.addCatalog('electronics','ce-de'); + obj.addSearchType('electronics','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('electronics','+salesrank','+salesrank'); + obj.addSort('electronics','+titlerank','+titlerank'); + obj.addSort('electronics','+pmrank','+pmrank'); + obj.addSort('electronics','+reviewrank','+reviewrank'); + //Software + obj.addCatalog('software','software-de'); + obj.addSearchType('software','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('software','+salesrank','+salesrank'); + obj.addSort('software','+titlerank','+titlerank'); + obj.addSort('software','+pmrank','+pmrank'); + obj.addSort('software','+pricrerank','+price'); + obj.addSort('software','+inverse-pricerank','-price'); + //Videogames + obj.addCatalog('videogames','video-games-de'); + obj.addSearchType('videogames','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('videogames','+salesrank','+salesrank'); + obj.addSort('videogames','+titlerank','+titlerank'); + obj.addSort('videogames','+pmrank','+pmrank'); + obj.addSort('videogames','+pricerank','+price'); + obj.addSort('videogames','+inverse-pricerank','-price'); + //International Books + obj.addCatalog('books-int','books-de-intl-us'); + obj.addSearchType('books-int','KeywordSearch,AsinSearch,AuthorSearch,ManufacturerSearch'); + obj.addSort('books-int','+pmrank','+pmrank'); + obj.addSort('books-int','+salesrank','+salesrank'); + obj.addSort('books-int','+reviewrank','+reviewrank'); + obj.addSort('books-int','+pricerank','+pricerank'); + obj.addSort('books-int','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('books-int','+daterank','+daterank'); + obj.addSort('books-int','+titlerank','+titlerank'); + obj.addSort('books-int','-titlerank','-titlerank'); +} + +//Amazon.fr +ProductLineController.prototype.createProductLineFR = function(obj) { + //Blended + obj.addCatalog('blended','blended'); + obj.addSearchType('blended','KeywordSearch'); + obj.addSort('blended','+salesrank','+salesrank'); + //Books + obj.addCatalog('books','books-fr'); + obj.addSearchType('books','KeywordSearch,AsinSearch,AuthorSearch,ManufacturerSearch'); + obj.addSort('books','+salesrank','+salesrank'); + obj.addSort('books','+pricerank','+pricerank'); + obj.addSort('books','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('books','+daterank','+daterank'); + obj.addSort('books','+titlerank','+titlerank'); + obj.addSort('books','-titlerank','-titlerank'); + //Popular Music + obj.addCatalog('music','music-fr'); + obj.addSearchType('music','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('music','+salesrank','+salesrank'); + obj.addSort('music','+pricerank','+pricerank'); + obj.addSort('music','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('music','+titlerank','+titlerank'); + obj.addSort('music','-titlerank','-titlerank'); + //Classical Music + obj.addCatalog('classical','classical-fr'); + obj.addSearchType('classical','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('classical','+salesrank','+salesrank'); + obj.addSort('classical','+pricerank','+pricerank'); + obj.addSort('classical','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('classical','+titlerank','+titlerank'); + obj.addSort('classical','-titlerank','-titlerank'); + //DVD + obj.addCatalog('dvd','dvd-fr'); + obj.addSearchType('dvd','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('dvd','+salesrank','+salesrank'); + obj.addSort('dvd','+orig-rel-date','-pubdate'); + obj.addSort('dvd','+titlerank','+titlerank'); + obj.addSort('dvd','-titlerank','-titlerank'); + //Video (vhs) + obj.addCatalog('vhs','vhs-fr'); + obj.addSearchType('vhs','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('vhs','+salesrank','+salesrank'); + obj.addSort('vhs','+titlerank','+titlerank'); + obj.addSort('vhs','-titlerank','-titlerank'); + //Software + obj.addCatalog('software','software-fr'); + obj.addSearchType('software','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('software','+salesrank','+salesrank'); + obj.addSort('software','+titlerank','+titlerank'); + obj.addSort('software','-titlerank','-titlerank'); + obj.addSort('software','+pricrerank','+price'); + obj.addSort('software','+inverse-pricerank','-price'); + //Videogames + obj.addCatalog('videogames','video-games-fr'); + obj.addSearchType('videogames','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('videogames','+salesrank','+salesrank'); + obj.addSort('videogames','+titlerank','+titlerank'); + obj.addSort('videogames','-titlerank','-titlerank'); + obj.addSort('videogames','+pricerank','+price'); + obj.addSort('videogames','+inverse-pricerank','-price'); + obj.addSort('videogames','+daterank','date'); + //International Books + obj.addCatalog('books-int','books-fr-intl-us'); + obj.addSearchType('books-int','KeywordSearch,AsinSearch,AuthorSearch,ManufacturerSearch'); + obj.addSort('books-int','+salesrank','+salesrank'); + obj.addSort('books-int','+pricerank','+pricerank'); + obj.addSort('books-int','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('books-int','+daterank','-daterank'); + obj.addSort('books-int','+titlerank','+titlerank'); + obj.addSort('books-int','-titlerank','-titlerank'); +} + +//Amazon.ca +ProductLineController.prototype.createProductLineCA = function(obj) { + //Blended + obj.addCatalog('blended','blended'); + obj.addSearchType('blended','KeywordSearch'); + obj.addSort('blended','+salesrank','+salesrank'); + //Books + obj.addCatalog('books','books-ca'); + obj.addSearchType('books','KeywordSearch,AsinSearch,AuthorSearch,ManufacturerSearch'); + obj.addSort('books','+salesrank','+salesrank'); + obj.addSort('books','+pricerank','+pricerank'); + obj.addSort('books','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('books','+daterank','+daterank'); + obj.addSort('books','+titlerank','+titlerank'); + obj.addSort('books','-titlerank','-titlerank'); + //Popular Music + obj.addCatalog('music','music-ca'); + obj.addSearchType('music','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('music','+salesrank','+salesrank'); + obj.addSort('music','+titlerank','+titlerank'); + obj.addSort('music','+orig-rel-date','+orig-rel-date'); + //Classical Music + obj.addCatalog('classical','classical-ca'); + obj.addSearchType('classical','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('classical','+salesrank','+salesrank'); + obj.addSort('classical','+titlerank','+titlerank'); + obj.addSort('classical','+orig-rel-date','+orig-rel-date'); + //DVD + obj.addCatalog('dvd','dvd-ca'); + obj.addSearchType('dvd','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('dvd','+salesrank','+salesrank'); + obj.addSort('dvd','+titlerank','+titlerank'); + //Video (vhs) + obj.addCatalog('vhs','vhs-ca'); + obj.addSearchType('vhs','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('vhs','+salesrank','+salesrank'); + obj.addSort('vhs','+titlerank','+titlerank'); + //Software + obj.addCatalog('software','software-ca'); + obj.addSearchType('software','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('software','+salesrank','+salesrank'); + obj.addSort('software','+titlerank','+titlerank'); + obj.addSort('software','+pricrerank','+price'); + obj.addSort('software','+inverse-pricerank','-price'); + obj.addSort('software','+daterank','date'); + //Videogames + obj.addCatalog('videogames','video-games-ca'); + obj.addSearchType('videogames','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('videogames','+salesrank','+salesrank'); + obj.addSort('videogames','+titlerank','+titlerank'); + obj.addSort('videogames','+pricerank','+price'); + obj.addSort('videogames','+inverse-pricerank','-price'); + obj.addSort('videogames','+daterank','-daterank'); +} +//Amazon.co.jp +ProductLineController.prototype.createProductLineJP = function(obj) { + //Blended + obj.addCatalog('blended','blended'); + obj.addSearchType('blended','KeywordSearch'); + obj.addSort('blended','+salesrank','+salesrank'); + //Books + obj.addCatalog('books','books-jp'); + obj.addSearchType('books','KeywordSearch,AsinSearch,AuthorSearch,ManufacturerSearch'); + obj.addSort('books','+pmrank','+pmrank'); + obj.addSort('books','+salesrank','+salesrank'); + obj.addSort('books','+reviewrank','+reviewrank'); + obj.addSort('books','+pricerank','+pricerank'); + obj.addSort('books','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('books','+daterank','+daterank'); + obj.addSort('books','+titlerank','+titlerank'); + obj.addSort('books','-titlerank','-titlerank'); + //Popular Music + obj.addCatalog('music','music-jp'); + obj.addSearchType('music','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('music','+pmrank','+psrank'); + obj.addSort('music','+salesrank','+salesrank'); + obj.addSort('music','+artistrank','+artistrank'); + obj.addSort('music','+orig-rel-date','+orig-rel-date'); + obj.addSort('music','+titlerank','+titlerank'); + //Classical Music + obj.addCatalog('classical','classical-jp'); + obj.addSearchType('classical','KeywordSearch,AsinSearch,ArtistSearch,ManufacturerSearch'); + obj.addSort('classical','+pmrank','+psrank'); + obj.addSort('classical','+salesrank','+salesrank'); + obj.addSort('classical','+artistrank','+artistrank'); + obj.addSort('classical','+orig-rel-date','+orig-rel-date'); + obj.addSort('classical','+titlerank','+titlerank'); + //DVD + obj.addCatalog('dvd','dvd-jp'); + obj.addSearchType('dvd','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('dvd','+salesrank','+salesrank'); + obj.addSort('dvd','+titlerank','+titlerank'); + //Video (vhs) + obj.addCatalog('vhs','vhs-jp'); + obj.addSearchType('vhs','KeywordSearch,AsinSearch,ArtistSearch,ActorSearch,DirectorSearch,ManufacturerSearch'); + obj.addSort('vhs','+salesrank','+salesrank'); + obj.addSort('vhs','+titlerank','+titlerank'); + obj.addSort('vhs','+pmrank','+psrank'); + //Electronics + obj.addCatalog('electronics','electronics-jp'); + obj.addSearchType('electronics','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('electronics','+salesrank','+salesrank'); + obj.addSort('electronics','+titlerank','+titlerank'); + obj.addSort('electronics','+pmrank','+pmrank'); + obj.addSort('electronics','+reviewrank','+reviewrank'); + //Software + obj.addCatalog('software','software-jp'); + obj.addSearchType('software','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('software','+salesrank','+salesrank'); + obj.addSort('software','+titlerank','+titlerank'); + obj.addSort('software','+pmrank','+pmrank'); + obj.addSort('software','+pricerank','+price'); + obj.addSort('software','+inverse-pricerank','-price'); + //Videogames + obj.addCatalog('videogames','videogames-jp'); + obj.addSearchType('videogames','KeywordSearch,AsinSearch,,ManufacturerSearch'); + obj.addSort('videogames','+salesrank','+salesrank'); + obj.addSort('videogames','+titlerank','+titlerank'); + obj.addSort('videogames','+pmrank','+pmrank'); + obj.addSort('videogames','+pricerank','+price'); + obj.addSort('videogames','+inverse-pricerank','-price'); + //Toys + obj.addCatalog('toys','toys-jp'); + obj.addSearchType('toys','KeywordSearch,AsinSearch,ManufacturerSearch'); + obj.addSort('toys','+salesrank','+salesrank'); + obj.addSort('toys','+pmrank','+pmrank'); + obj.addSort('toys','+titlerank','+titlerank'); + obj.addSort('toys','+pricerank','+pricerank'); + obj.addSort('toys','+inverse-pricerank','+inverse-pricerank'); + //International Books + obj.addCatalog('books-int','books-us'); + obj.addSearchType('books-int','KeywordSearch,AsinSearch,AuthorSearch,ManufacturerSearch'); + obj.addSort('books-int','+pmrank','+pmrank'); + obj.addSort('books-int','+salesrank','+salesrank'); + obj.addSort('books-int','+reviewrank','+reviewrank'); + obj.addSort('books-int','+pricerank','+pricerank'); + obj.addSort('books-int','+inverse-pricerank','+inverse-pricerank'); + obj.addSort('books-int','+daterank','+daterank'); + obj.addSort('books-int','+titlerank','+titlerank'); + obj.addSort('books-int','-titlerank','-titlerank'); + +} diff --git a/mab/xul/js/ProgressBar.js b/mab/xul/js/ProgressBar.js @@ -0,0 +1,96 @@ +/** +* +* Undetermined Progress Meter have to be emulated using the determined one, +* because it doesn't work correctly in every platform and with every skins. +* Ie: FireFox 0.8 doesn't have the undetermined progressmeter. +* +* @FileName: ProgressBar.js +* @$LastChangedDate: 2004-06-26 13:51:10 +0200 (Sat, 26 Jun 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + +function ProgressBar(elProgressMeter,busyCursor) { + //Reference to the ProgressMeter widget + this.guiMeter = elProgressMeter; + + //Automatically activate Busy Cursor + if(!busyCursor) { + this.busyCursor = false; + } else { + this.busyCursor = true; + } + this.refresh = 500; + this.timeStart = null; + this.timeStop = null; +} + +ProgressBar.prototype.start = function() { + this.timeStart = new Date(); + if(this.busyCursor) { + this.setBusyCursor(true); + } + + this.intervalID = setInterval(this.increment,this.refresh); +} + +//Increment the ProgressMeter. When it arrives to 100 back to 10 +ProgressBar.prototype.increment = function() { + var curValue = parseInt(this.guiMeter.getAttribute('value')); + + if(curValue >= 100) { + curValue = 10; + + }else{ + curValue +=10; + } + + this.guiMeter.setAttribute('value',curValue + "%"); +} + +//Stop ProgressMeter. Fill in all the bar and then go to 0% +ProgressBar.prototype.stop = function() { + + if(this.busyCursor) {this.setBusyCursor(false);} + + if(!this.intervalID) { + this.guiMeter.setAttribute('value',0+"%"); + return; + } + + clearInterval(this.intervalID); + + this.guiMeter.setAttribute('value',100+"%"); + + var resetProgressMeter = function() { + this.guiMeter.setAttribute('value',0+"%"); + } + setTimeout(resetProgressMeter,this.refresh); + this.timeStop = new Date(); +} + +//Return elapsed time from the start to the final stop in seconds +ProgressBar.prototype.getElapsedTime = function() { + if(!this.timeStart || !this.timeStop) return false; + var elapsedTime = ((this.timeStop - this.timeStart) + this.refresh)/1000; + return elapsedTime; +} + +ProgressBar.prototype.setBusyCursor = function(enable) { + if((typeof window.setCursor == "undefined") || (typeof window.setCursor != "function")) { + return false; + } + + var numFrames = window.frames.length; + for(var i = 0; i < numFrames; i++) { + if(enable) { + window.frames[i].setCursor("wait"); + }else{ + window.frames[i].setCursor("auto"); + } + } + + return true; + } +\ No newline at end of file diff --git a/mab/xul/js/QueryStringBuilder.js b/mab/xul/js/QueryStringBuilder.js @@ -0,0 +1,90 @@ +/** +* +* Create a Query String from the current widget status +* +* Example of a KeywordSearch query: +* [Amazon URL]?t=[Associates ID goes here]&dev-t=[Developer Token goes here]&KeywordSearch=[subject keyword goes here]&mode=[product line goes here]&type=[lite or heavy]&page=[page # goes here]&f=xml +* +* @FileName: QueryStringBuilder.js +* @$LastChangedDate: 2004-07-04 22:42:15 +0200 (Sun, 04 Jul 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + +function QueryStringBuilder(ProductLineController) { + this.myProductLineController = ProductLineController; + this.elSearchTerm = document.getElementById('find-text'); + + this.query = trim(this.elSearchTerm.value); + this.locale = this.myProductLineController.getLocale(); + + this.amazonURL = AWSURL[this.locale]; + this.t = ASSID[this.locale]; + //Catalog (Request Search) + this.catalog = this.myProductLineController.getCatalogValue(); + //Search Type + this.search = this.myProductLineController.getSearch(); + //Sort + this.sort = this.myProductLineController.getSortValue(); +} + +QueryStringBuilder.prototype.createQueryString = function(pageStart,type) { + var qString = ""; + var page = pageStart; + var requestType = type; + + if(this.query == "") { + alert("Please, insert a search term"); + this.elSearchTerm.focus(); + return false; + } + + if(!this.catalog) { + alert("The selected catalog is invalid"); + this.myProductLineController.elCatalog.focus(); + return false; + } + + if(!this.search) { + alert("The selected search type is invalid"); + this.myProductLineController.elSearch.focus(); + return false; + } + + if(!this.sort) { + alert("The selected sort type is invalid"); + this.myProductLineController.elSort.focus(); + return false; + } + + //Prepare Query String + qString += this.amazonURL + "?t=" + this.t + "&dev-t=" + DEVT; + + + //Blended search must be treated in a particular way + if(this.catalog == "blended") { + qString += "&BlendedSearch=" + this.query; + //Asin Search doesn't need mode + } else if (this.search == "AsinSearch") { + qString += "&AsinSearch=" + this.query; + } else { + qString += "&" + this.search + "=" + this.query + "&mode=" + this.catalog + "&sort=" + this.sort; + } + + //Type (Lite or heavy) - page - format (xml) + qString += "&type="+ requestType + "&page=" + page + "&f=xml"; + + if(this.locale != "us") { + qString += "&locale=" + this.locale; + } + + //Jp Short term fix + if(this.locale == "jp") { + qString += '&__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A'; + } + return encodeURI(trim(qString)); +} + + diff --git a/mab/xul/js/SearchController.js b/mab/xul/js/SearchController.js @@ -0,0 +1,365 @@ +/** +* +* +* @FileName: SearchController.js +* @$LastChangedDate: 2004-07-16 17:49:47 +0200 (Fri, 16 Jul 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + +function SearchController(mabRequestType,requestPage) { + //Object to handle the progress meter + this.myProgressBar = new ProgressBar(guiMeter,true); + //More Products button + this.guiNext = document.getElementById("next-btn"); + //Status Bar + this.guiRecordStatus = document.getElementById("record-status"); + //Status Bar display total record found and total records retrived + this.guiOutStatus = document.getElementById("out-status"); + //To enable stop button + this.elBroadcaster = document.getElementById('isSearchRunning'); + this.guiAbort = document.getElementById("abort-icon"); + + //Track multiple connections when the user wants to receive more than 10 records at time. + this.myThread = new Array(); + //How many Amazon results pages I have to fetch? + this.requestPageToFetch = requestPage; + //Mab Search type + this.mabRequestType = mabRequestType; + //Amazon Search Type + this.searchType = ""; + + //Fill in the array. + for(var i=0;i<requestPage;i++) { + this.myThread[i] = {}; + this.myThread[i].connObj = ""; + this.myThread[i].connectionID = ""; + this.myThread[i].status = -1; + this.myThread[i].content = ""; + } + +} + +//Start a search +SearchController.prototype.search = function(qString,currentThread) { + var me = this; + + //Get Properly search type + if(this.getQueryParam(qString,"AsinSearch")) { + this.searchType = "asin"; + }else if (this.getQueryParam(qString,"BlendedSearch")){ + this.searchType = "blended"; + } else { + this.searchType = this.getQueryParam(qString,"type"); + } + + + //Get ESC key to abort all active connections + var stopConnection = function(e) { + if(e.keyCode == e.DOM_VK_ESCAPE || e.target.id == me.guiAbort.id) { + window.removeEventListener('keypress',stopConnection,false); + me.guiAbort.removeEventListener('click',stopConnection,false); + //Aborted by user + me.abortThreads(30); + me.resetGUI(); + me.parseResponse(); + } + + } + + //If this is the first search (thread) start the Progress Meter + if(currentThread == 0) { + this.initGUI(); + //Listener to abort the search + window.addEventListener('keypress',stopConnection,false); + this.guiAbort.addEventListener('click',stopConnection,false); + } + + var url = qString.split("?"); + var blPermission = false; + if(MAB_RUN == "local") {blPermission = true;} + var myConnection = new Connection(url[0],blPermission); + this.myThread[currentThread].connObj = myConnection; + this.myThread[currentThread].connectionID = myConnection.connectionID; + + + //Callback from connection + var callback = function(res) { + //Save all connection result waiting that every threads is properly returned + for(var i=0;i<me.myThread.length;i++) { + if(me.myThread[i].connectionID == res.connectionID) { + me.myThread[i].status = res.status; + me.myThread[i].content = res.content; + me.myThread[i].requestedURL = res.requestedURL; + } + } + + + //If this is the first thread check that the response from connection is Ok + if(me.myThread[0].connectionID == res.connectionID) { + + if(res.status > 0) { + me.myThread.splice(0,me.myThread.length); + me.abortThreads(); + me.resetGUI(); + alert(res.message); + return true; + + } + + //Check Amazon Response + var responseXML = new DOMParser().parseFromString(res.content, 'text/xml'); + var firstDoc = new AmazonParser(responseXML); + + var error = firstDoc.hasError(); + if(error) { + me.abortThreads(); + me.resetGUI(); + window.removeEventListener('keypress',stopConnection,true); + alert(firstDoc.getErrorMsg()); + + return true; + } + + //Everything is ok so check if there are more result and that I can start + //new thread as requested. This is not applicable to BlendedSearch, or my refresh Asin search + //Because they don't have pages and limit records so only one connection is requested + if(me.searchType == "asin" || me.searchType == "blended"){ + me.requestPageToFetch = 0; + }else{ + var pagesAvailable = 0; + try { + pagesAvailable = firstDoc.getTotalPages(); + }catch(e){ + //pass + } + var currentPage = me.getCurrentPage(qString); + var pageRest = pagesAvailable - currentPage; + if(pageRest < me.requestPageToFetch) {me.requestPageToFetch = pageRest;} + } + + if(me.requestPageToFetch > 1) { + //Ok there are more page so start the new thread + for(i=1;i<me.myThread.length;i++) { + currentPage++ + var newQString = me.setCurrentPage(qString,currentPage); + me.search(newQString,i); + //Limit 1 request for second. License Agreement Limit + if(i != me.myThread.length) { + pause(CALL_INTERVAL); //Problem - the gui becomes unresponsive + } + + } + return true; + }else{ + //Remove array element and stop the execution + me.abortThreads(); + me.resetGUI(); + window.removeEventListener('keypress',stopConnection,true); + me.parseResponse(); + return true; + } + } + + //Check if there are more running thread + + if(me.getRunningThread() == 0) { + me.abortThreads(); + me.resetGUI(); + window.removeEventListener('keypress',stopConnection,true); + me.parseResponse(); + return true; + } + + return false; + } + + //Set the callback + myConnection.setCallback(callback); + myConnection.setErrorCallback(callback); + + //Request a txt response to prevent permission problem + myConnection.send(url[1],"GET","txt"); + return true; +} + + +//Pass all connection results to be parsed to the Amazon Parser and then to the +//XMDManager +SearchController.prototype.parseResponse = function() { + var myParser = new AmazonParser(); + var responseXML, requestedURL, res, lastPage; + var validResponse = false; + for(var i=0;i<this.myThread.length;i++) { + if(this.myThread[i].status == 0) { + //needed to bypass permission problem + responseXML = new DOMParser().parseFromString(this.myThread[i].content, 'text/xml'); + requestedURL = this.myThread[i].requestedURL; + res = myParser.mergeDocument(responseXML); + if(res) {validResponse = true;} + } + + } + + //There aren't any valid response, so exit; + if(validResponse == false) {return false;} + + //If the search is a mabRequestType == "asin" doesn't modify the searchHistory + if(this.mabRequestType != "asin") { + //Not Applicable to AsinSearch and BlendedSearch - SearchHistory is not valid + if(this.searchType == "asin" || this.searchType == "blended"){ + mySearchHistory.totalPages = 1; + mySearchHistory.totalResults = myParser.getNrDetails(); + }else{ + try { + mySearchHistory.totalPages = myParser.getTotalPages(); + mySearchHistory.totalResults = myParser.getTotalResults(); + }catch(e) { + mySearchHistory.totalPages = 0; + mySearchHistory.totalResults = 0; + } + } + //Modify the SearchHistory to save the last useful search only if the + //mabRequestType is not asin + mySearchHistory.lastURL = decodeURI(requestedURL); + lastPage = this.getCurrentPage(requestedURL); + mySearchHistory.lastPage = lastPage; + mySearchHistory.recordRetrieved = myParser.getNrDetails(); + } + + + var pagesAvailable, totalResults; + if(this.mabRequestType == "asin") { + totalResults = myParser.getNrDetails(); + productRetrieved = totalResults; + pagesAvailable = 0; + }else{ + totalResults = mySearchHistory.totalResults; + productRetrieved = mySearchHistory.recordRetrieved; + pagesAvailable = mySearchHistory.getPagesAvailable(); + } + + //In case of heavy search check if reviews tags are present + //if not, insert empty tags + if(this.searchType == "heavy") { + myParser.setMissingReviews(); + } + + //Button More and status bar + if(this.mabRequestType == "asin") { + //do nothing + }else if(pagesAvailable > 0 ) { + this.guiNext.setAttribute("disabled","false"); + } else { + this.guiNext.setAttribute("disabled","true"); + } + + var strProductsFound = "Products Found: " + totalResults; + strProductsFound += " - Products Retrieved: " + productRetrieved; + this.guiOutStatus.setAttribute("label",strProductsFound); + + //Ok, now pass the merged Amazon results to the current XMABModel + //After the model has been created syncronize with the view + //This is the current loaded mab model form XMDManager + var myXMDManager = myDocOpened.getCurrentDocument(); + if(!myXMDManager) { + myXMDManager = new XMDManager(); + myDocOpened.addDoc(myXMDManager); + } + + //AsinSearch request to overwrite old node because could be refresh or comment + var refresh = false; + var addItem = true; + if(this.searchType == "asin") { + refresh = true; + addItem = true; + } + var result = myXMDManager.merge(myParser.xmlDoc,refresh); + myDisplayController.buildTree(myXMDManager,addItem); + + //Update record status + var oldStr = this.guiRecordStatus.getAttribute("label"); + var newStr = oldStr + "("+ result.nrMergedNode + " new - " + result.nrDuplicatedNode + " duplicated - " + result.nrReloadedNode + " reloaded)"; + this.guiRecordStatus.setAttribute("label",newStr); + + showDetails(); + return true; + +} + +//Check how many thread have not received an answer yet +SearchController.prototype.getRunningThread = function() { + var runningThread = 0; + for(var i=0;i<this.myThread.length;i++) { + if(this.myThread[i].status < 0) { + runningThread ++; + } + } + return runningThread; +} + +//Get the requested current page from the query string +SearchController.prototype.getCurrentPage = function(qString) { + var res = this.getQueryParam(qString,"page"); + if(res) { + return parseInt(res); + }else{ + return false; + } +} + +//Set the requested page in to the query string +SearchController.prototype.setCurrentPage = function(qString,newPage) { + var newQString = this.setQueryParam(qString,"page",newPage); + return newQString; +} + +SearchController.prototype.getQueryParam = function(qString,param) { + if(!qString || !param) {return false;} + + var arString = qString.split("?"); + var params = arString[1]; + var vars = params.split("&"); + for (var i=0;i<vars.length;i++) { + var pair = vars[i].split("="); + if (pair[0] == param) { + return pair[1]; + + } + } + return false; +} + +SearchController.prototype.setQueryParam = function(qString,param,newValue) { + var oldValue = this.getQueryParam(qString,param) + if(!oldValue) {return false;} + var newQString = qString.replace('&'+param+'='+oldValue,'&'+ param +'='+newValue); + return newQString; +} + + +//Abort current and all running threads +SearchController.prototype.abortThreads = function(errorCode) { + var error = 40; + if(errorCode) {error = errorCode;} + for(var i=0;i<this.myThread.length;i++) { + if(this.myThread[i].status < 0) { + if(this.myThread[i].connObj) { + this.myThread[i].connObj.abortConnection(error); + } + } + } +} + +SearchController.prototype.initGUI = function() { + this.myProgressBar.start(); + this.elBroadcaster.setAttribute("disabled","false"); +} + +//Stop the progress meter, reset the broadcatser +SearchController.prototype.resetGUI = function() { + this.myProgressBar.stop(); + this.elBroadcaster.setAttribute("disabled","true"); +} diff --git a/mab/xul/js/SearchHistory.js b/mab/xul/js/SearchHistory.js @@ -0,0 +1,41 @@ +/** +* +* +* +* @FileName: SearchHistory.js +* @$LastChangedDate: 2004-06-26 13:51:10 +0200 (Sat, 26 Jun 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + +function SearchHistory() { + this.isValid = false; + this.totalResults = 0; + this.totalPages = 0; + this.recordRetrieved = 0; + this.lastPage = 0; + this.lastURL = ""; +} + +SearchHistory.prototype.getPagesAvailable = function() { + var pagesAvailable = this.totalPages - this.lastPage; + return pagesAvailable; +} + + +/* +SearchHistory.prototype.getProductRetrieved = function() { + if(this.recordRetrieved != false) {return this.recordRetrieved;} + var pages; + if(this.lastPage > this.totalPages) { + pages = this.totalPages; + }else{ + pages = this.lastPage; + } + //BUG doesn't work if there are fewer record!! + var productRetrieved = pages * 10; + return productRetrieved; +} +*/ diff --git a/mab/xul/js/XMDManager.js b/mab/xul/js/XMDManager.js @@ -0,0 +1,621 @@ +/** + * XMD (XML Mab Document Manager) + * + * @filename XMDManager.js + * $LastChangedDate: 2004-12-06 13:08:50 +0100 (Mon, 06 Dec 2004) $ + * @author Fabio Serra <faser@faser.net> + * @copyright Fabio Serra (The Initial Developer of the Original Code) + * @license Mozilla Public License Version 1.1 + * +*/ + +/** + * Construct a new XMD Manager object + * @class This class is used to manage the XML resulting from the transformation of Amazon XML + * response. The XML Mab Document is the data model. + * @constructor + * @return A new XMD Manager + * +*/ +function XMDManager() { + /** + * This flag is valid for the current session. It means that when a details (record) + * has been deleted from the loaded document, it can't be inserted again. In this way I + * prevent unuseful duplicated records + * @type bool + */ + this.preventDuplicateDetails = true; + + /** + * Save all primary keys that are going to be processed + * @type object array + */ + this.primaryKeys = new Array(); + + /** + * Save a reference in array of each details node present in the XML document + * @type DOM nodes array + */ + this.hashTable = new Array(); + + /** + * This property is used to remember if this document was saved (file or memory is the same) + * @type bool + */ + this.wasSaved = false; + + /** + * The name of the current document. + * @type string + */ + this.name = ""; + + /** + * The full path including the file name and extension if the document has + * been saved on file system + * @type string + */ + this.fullPath = ""; + + /** + * The Mab Xml Document + * @type XML Doc + */ + this.xmlDoc = this.make(); +} + + +/** + * Create an empty XML Document to use as a Mab model data + * @return A new XML Dcoument + * @type XMLDocument +*/ +XMDManager.prototype.make = function() { + var today = new Date(); + var tsDocumentCreated = Date.parse(today); + + var xmlStr = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'+ + '<MABInfo xmlns="http://www.faser.net/mab/NS/MABInfo">\n' + + '<MABTSDocumentCreated>' + tsDocumentCreated + '</MABTSDocumentCreated>\n' + + '<MABDetails/>\n' + + '</MABInfo>'; + + var xmlDoc = new DOMParser().parseFromString(xmlStr, 'text/xml'); + + return xmlDoc; +} + +/** + * Build the hashtable for the current document. When a document is merged the + * hashtable is created by default. This method should be used when an XMD document + * is loaded from file + * @return void + */ +XMDManager.prototype.buildHashTable = function() { + //remove all previous key + this.hashTable = null; + this.hashTable = new Array(); + //build + var details = this.xmlDoc.getElementsByTagName('Details'); + var pk = ""; + for(var i=0;i<details.length;i++) { + pk = this.getSingleElement(details.item(i),"MABPrimaryKey"); + if(pk) {this.hashTable[pk] = details.item(i);} + } +} + +/** + * Merge the Details node of the new xml document with the current one. + * The last xml nodes are inserted at the top of the document + * @param {XMLDocument} docToMerge the new XML document + * @param {bool} overwrite means that the new details overwrite the old ones + * @return object with properties to show how many nodes was merged, duplicated + * and reloaded + * @type object +*/ +XMDManager.prototype.merge = function(docToMerge,overwrite) { + if(typeof overwrite == "undefined") {overwrite = true;} + + //Check if the new document was created by MAB or come from an Amazon search + var bAmazonResult = true; + if(this.isValidMABDoc(docToMerge)) {bAmazonResult = false;} + + var mabRootDetails = this.xmlDoc.getElementsByTagName("MABDetails").item(0); + var details = docToMerge.getElementsByTagName('Details'); + + var node, replacedNode, pk, lastUpdate, oldDetail, mabLabel; + + var today = new Date(); + var isNewNode = false; + var oldNode = false; + + var result = {}; + result.nrMergedNode = 0; + result.nrDuplicatedNode = 0; + result.nrReloadedNode = 0; + + + //LIFO - Insert new records before the old ones + var lifo = this.xmlDoc.getElementsByTagName("Details").item(0); + + if(bAmazonResult) { + //Default locale if missing + var locale = "us"; + var path = "//Request/Args/Arg[@name='locale']"; + var xpathResult = docToMerge.evaluate(path,docToMerge,null,XPathResult.ANY_TYPE,null).iterateNext(); + if(xpathResult != null) { locale = xpathResult.getAttribute("value");} + var amazAsin = ""; + } + + for (var i=0;i<details.length; i++) { + //node from the document that I have to process + node = details.item(i).cloneNode(true); + if(bAmazonResult) { + amazAsin = this.getSingleElement(node,"Asin"); + pk = amazAsin + '_' + locale; + //Add mandatory tags for details that come from Amazon + this.addMABTag(node,pk); + }else{ + pk = this.getSingleElement(node,"MABPrimaryKey") + } + + + //Check the details date according to the Amazon Licence Agreement (November 5, 2003) + //http://forums.prospero.com/n/mb/message.asp?webtag=am-assosdev&msg=91.1&ctx=0 + + //Price Information must be refreshed every 24 hours, the other details every 3 months + //So, if these info are expired remove them from the XML + //The user have to be update the info + + lastUpdate = this.getLastUpdate(node); + if(lastUpdate > EXPIRED_LONG) { + this.removeExpiredInfo(node); + }else if(lastUpdate > EXPIRED_SHORT) { + this.removeExpiredPrice(node); + } + + //prevent duplicate records + isNewNode = this.setPK(pk); + oldNode = this.getNodeDetail(pk); + + //The record is new + if(isNewNode || (!this.preventDuplicateDetails && !oldNode)) { + if(lifo) { + lifo.parentNode.insertBefore(node,lifo); + }else{ + mabRootDetails.appendChild(node); + } + + this.hashTable[pk] = node; + result.nrMergedNode++; + + //The records is currently present in xml doc and I can overwrite it + //but avoid to replace MABLabel + }else if(overwrite && oldNode) { + + mabLabel = this.getSingleElement(oldNode,"MABLabel"); + + //mabRootDetails.replaceChild(node,oldNode.parentNode); + mabRootDetails.removeChild(oldNode); + replacedNode = mabRootDetails.appendChild(node); + this.hashTable[pk] = replacedNode; + + //No comments? Create a new fake one to prevent comment request + var comment = this.getSingleElement(replacedNode); + if(!comment) { + var comElem = this.xmlDoc.createElement("Reviews"); + replacedNode.appendChild(comElem); + } + + //Reset the old Mab Label + //replacedNode.getElementsByTagName("MABLabel").item(0).firstChild.nodeValue = mabLabel; + result.nrReloadedNode++; + //Skip node + }else{ + result.nrDuplicatedNode ++; + } + } + return result; +} + +/** + * Add mandatory MAB tags to a new detail node coming from an Amazon search + * @param {xml node} node The node to which append the new MAB tags + * @param {string} pk The mab items primary key + * @return void +*/ +XMDManager.prototype.addMABTag = function(node,pk) { + //Timestamp + var today = new Date(); + var ts = Date.parse(today); + + //MAB Status (read | unread) + var MABStatus = "unread"; + + //Locale + var locale = pk.substr((pk.length-2),pk.length); + + var strMabTag = "<MABPrimaryKey>" + pk + "</MABPrimaryKey>\n" + + "<MABTSLastUpdate>" + ts + "</MABTSLastUpdate>\n" + + "<MABLabel/>\n" + + "<MABLocale>" + locale + "</MABLocale>\n" + + "<MABStatus>" + MABStatus + "</MABStatus>\n"; + + //Append new tag to the passed node + innerXML(node,strMabTag); +} + +/** + * Get all products older than an elapsed time determined by Amazon license + * @param {int} dayBefore Maximum days that should be passed from the last product update + * @return object array contains the asinList grouped by locale + * @type array associative +*/ +XMDManager.prototype.getAllExpiredProducts = function(dayBefore) { + if(typeof dayBefore == "undefined") {dayBefore = EXPIRED_SHORT;} + var node, lastUpdate, locale, amazAsin; + var asinList = {}; + for(var d in this.hashTable) { + node = this.hashTable[d]; + lastUpdate = this.getLastUpdate(node); + if(lastUpdate > dayBefore) { + locale = this.getSingleElement(node,"MABLocale"); + amazAsin = this.getSingleElement(node,"Asin"); + if(!locale || !amazAsin) {continue;} + + if(typeof asinList[locale] == "undefined") { + asinList[locale] = new Array(); + } + + asinList[locale].push(amazAsin); + } + } + + return asinList; +} + +/** + * Count how many days are passed from the node last update + * @param {xml node} nodeDetail + * @return the elapsed days + * @type int +*/ +XMDManager.prototype.getLastUpdate = function(nodeDetail) { + var today = new Date(); + var dayElapsed = 0; + var lastUpdate = this.getSingleElement(nodeDetail,"MABTSLastUpdate"); + if(lastUpdate) { + dayElapsed = Math.round((Date.parse(today) - parseInt(lastUpdate)) / 86400000); + } + + return dayElapsed; +} + +/** + * Remove all tags from a node except the most relevant + * @param {xml node} nodeDetail an XML node + * @return void +*/ +XMDManager.prototype.removeExpiredInfo = function(nodeDetail) { + var tagExcluded = new Array("Asin","ProductName","Catalog","Authors","Artists","Directors","MABPrimaryKey","MABTSLastUpdate","MABLabel","MABLocale","MABStatus"); + var clonedNode = new Array(); + var i, cNode; + while(nodeDetail.hasChildNodes()) { + for(i=0; i<tagExcluded.length; i++) { + if(nodeDetail.lastChild.nodeName == tagExcluded[i]) { + cNode = nodeDetail.lastChild.cloneNode(true); + clonedNode.push(cNode); + } + } + + nodeDetail.removeChild(nodeDetail.lastChild); + } + + //Write back the excluded tag + for(i=0; i<clonedNode.length; i++) { + nodeDetail.appendChild(clonedNode[i]); + } + + this.wasSaved = false; +} + +/** + * Remove expired main prices tag + * @param {node xml} nodeDetail + * @return void +*/ +XMDManager.prototype.removeExpiredPrice = function(nodeDetail) { + var tags = new Array("ListPrice","OurPrice","UsedPrice"); + var el; + for(var i=0; i < tags.length; i++) { + el = nodeDetail.getElementsByTagName(tags[i]).item(0); + if(el) {nodeDetail.removeChild(el);} + } + + this.wasSaved = false; +} + +/** + * Set the primary key to prevent duplicate + * @param {string} pk A Mab primary key + * @return true if a primary key has been added, false if the primary key already exist + * @type bool +*/ +XMDManager.prototype.setPK = function(pk) { + var res = this.checkPK(pk); + if(!res) { + this.primaryKeys.push(pk); + return true; + }else{ + return false; + } +} + +/** + * Check if the primary key has been saved + * @param {string} pk + * @return bool + * @type bool +*/ +XMDManager.prototype.checkPK = function(pk) { + for(var i=0;i<this.primaryKeys.length;i++){ + if(this.primaryKeys[i] == pk) { + return true; + } + } + return false; +} + +/** + * Check if the loaded file is a valid MAB file looking for MABInfo tag + * @param {XMLDocument} xmlDoc + * @return bool + * @type bool +*/ +XMDManager.prototype.isValidMABDoc = function(xmlDoc) { + var root = xmlDoc.documentElement.nodeName; + var XMDRoot = "MABInfo"; + if(root == XMDRoot) { + return true; + }else{ + return false; + } +} + +/** + *Get a Details node looking for the primary key using the hashtable + *@param {string} primaryKey The node primary key + *@return nodeDetail + *@type XML Node +*/ +XMDManager.prototype.getNodeDetail = function(primaryKey) { + if(typeof this.hashTable[primaryKey] == "undefined"){return false;} + var nodeDetail = this.hashTable[primaryKey]; + if(nodeDetail) { + return nodeDetail; + }else{ + return false; + } +} + +/** + * Remove a node detail from the XMD Document + * @param {string} primaryKey The primary key of the node to remove + * @return bool + * @type bool +*/ +XMDManager.prototype.removeDetail = function(primaryKey) { + var nodeDetail = this.getNodeDetail(primaryKey); + if(nodeDetail) { + nodeDetail.parentNode.removeChild(nodeDetail); + delete this.hashTable[primaryKey]; + this.wasSaved = false; + return true; + }else{ + return false; + } +} + +/** + * Get text from the first node element + * @param {node xml} nodeDetail + * @param {string} tagName + * @return The text contained inside the element + * @type string +*/ +XMDManager.prototype.getSingleElement = function(nodeDetail,tagName) { + if(!nodeDetail) {return false;} + var el = nodeDetail.getElementsByTagName(tagName).item(0); + if(el && el.hasChildNodes()) { + return el.firstChild.nodeValue; + }else{ + return false; + } +} + +/** + * Return an array with the text got from all elements + * @param {node xml} nodeDetail + * @param {string} tagName + * @return array + * @type array +*/ +XMDManager.prototype.getArrayElement = function(nodeDetail,tagName) { + var elArray = new Array(); + if(!nodeDetail) {return elArray;} + var el = nodeDetail.getElementsByTagName(tagName).item(0); + if(el) { + var node = nodeDetail.getElementsByTagName(tagName); + var content; + for(var i=0;i<node.length;i++) { + content = node.item(i).firstChild.nodeValue; + if(content) {elArray[i] = content;} + } + } + return elArray; +} + +/** + * Check if an element exists inside the xml node + * @param {node xml} nodeDetail + * @param {string} tagName + * @return true if tag exists + * @type bool +*/ +XMDManager.prototype.tagExists = function(nodeDetail,tagName) { + if(!nodeDetail) {return false;} + var el = nodeDetail.getElementsByTagName(tagName).item(0); + if(el) { + return true; + }else{ + return false; + } +} + +/** + * Set a new value text inside the provided tag only for the first child element. + * If newValue is "none" the child element is removed. If the child element doesn't + * exists a text node will be created. + * @param {node xml} node + * @param {string} tagName + * @param {string} newValue + * @return True if something has been modified + * @type bool +*/ +XMDManager.prototype.setNodeValue = function(node,tagName,newValue) { + var el = node.getElementsByTagName(tagName).item(0); + if(el) { + if(newValue == "none") { + if(el.hasChildNodes()) {el.removeChild(el.firstChild);} + } else if(el.hasChildNodes()) { + el.firstChild.nodeValue = newValue; + }else{ + var text = document.createTextNode(newValue); + el.appendChild(text); + } + return true; + }else{ + return false; + } +} + +/** + * Remove all Details node from the document + * @return void +*/ +XMDManager.prototype.removeAllDetails = function() { + var root = this.xmlDoc.getElementsByTagName("MABDetails").item(0); + while(root.hasChildNodes()) { + root.removeChild(root.lastChild); + } +} + +/** + * Sort the xml document + * Unfortunately this sort method is too slow, pratically unusable when there are + * more than 150 node. TODO (try using XSLT) + * @param {string} sortType The kind of value to sort (numeric | date | string) + * @param {string} sortTag The xml tag to use for sorting the node + * @param {bool} bAscending Ascending or descending sorting + * @return void +*/ +XMDManager.prototype.sort = function(sortType,sortTag,bAscending) { + + var theBody = this.xmlDoc.getElementsByTagName("MABDetails").item(0); + + var numRows = 0; + var theSortedRows = new Array(); + for (var i in this.hashTable) { + theSortedRows[numRows] = this.hashTable[i].cloneNode(true); + numRows++; + } + + theSortedRows.sort(this.sortCallBack(sortType,sortTag,bAscending)); + + //Clear current xml document + this.removeAllDetails(); + + //recreate + for(i=0;i<numRows;i++) { + theBody.appendChild(theSortedRows[i]) + } + //rebuild the hashtable + this.buildHashTable(); +} + +/** + * Calculate how should be sorted the xml node. Actually the xml document is not re-ordered + * @param {string} sortType The kind of value to sort (numeric | date | string) + * @param {string} sortTag The xml tag to use for sorting the node + * @param {bool} bAscending Ascending or descending sorting + * @return an array with virtually sorted xml node. + * @type array +*/ +XMDManager.prototype.virtualSort = function(sortType,sortTag,bAscending) { + var numRows = 0; + var theSortedRows = new Array(); + for (var i in this.hashTable) { + theSortedRows[numRows] = this.hashTable[i]; + numRows++; + } + + theSortedRows.sort(this.sortCallBack(sortType,sortTag,bAscending)); + + return theSortedRows; +} + +/** + * Callback method used in the sort javascript. + * @private + * @param {string} sortType The kind of value to sort (numeric | date | string) + * @param {string} sortTag The xml tag to use for sorting the node + * @param {bool} bAscending Ascending or descending sorting + * @type int +*/ +XMDManager.prototype.sortCallBack = function(sortType,sortTag,bAscending) { + + var fTypeCast = String; + var asc = bAscending; + + switch(sortType) { + case "numeric": + fTypeCast = toNumber; + break; + case "date": + fTypeCast = toYear; + break; + default: + fTypeCast = CaseInsensitiveString; + } + + var me = this; + return function (a,b) { + + var col1 = me.getSingleElement(a,sortTag); + var col2 = me.getSingleElement(b,sortTag); + + var text1 = ""; + var text2 = ""; + + if(col1) {text1 = col1;} + if(col2) {text2 = col2;} + + //Sort Tag SalesRank remove decimal separator + if(sortTag == "SalesRank") { + text1 = text1.replace(/,/g,""); + text1 = text1.replace(/\./g,""); + + text2 = text2.replace(/,/g,""); + text2 = text2.replace(/\./g,""); + } + + if (fTypeCast(text1) < fTypeCast(text2)) { + return asc ? -1 : 1; + } else if (fTypeCast(text1) > fTypeCast(text2)) { + return asc ? 1 : -1; + }else{ + return 0; + } + }; +} + diff --git a/mab/xul/js/config.js b/mab/xul/js/config.js @@ -0,0 +1,103 @@ +/** +* +* +* @FileName: config.js +* @$LastChangedDate: 2004-07-16 18:44:40 +0200 (Fri, 16 Jul 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + +const MAB_NAME = "MAB - The Mozilla Amazon Browser"; +const MAB_VERSION = "1.3.4"; +const MAB_HOMEPAGE = "http://www.faser.net/mab"; +const MAB_FEEDBACK_PAGE = "http://www.faser.net/mab/feedback.cfm"; +const GUID = "{D580BE35-9342-4622-A635-08F640066C97}"; + + +//local || remote +//Local have more permissione than the remote version. +//eg: Local MAB can save file on disk +const MAB_RUN = "remote"; + +//Connect to proxy when MAB is used remotely +//const AWSPROXY = "server/proxy.cfm"; +//const AWSPROXYPOST = "server/proxy_post.cfm"; +const AWSPROXY = "/cgi-bin/mab"; +const AWSPROXYPOST = "/cgi-bin/mab"; + +//Amazon Web Service URL for each locale +const AWSURL = {}; + +if(MAB_RUN == "local") { + AWSURL["us"] = "http://xml.amazon.com/onca/xml3"; + AWSURL["uk"] = "http://xml-eu.amazon.com/onca/xml3"; + AWSURL["de"] = "http://xml-eu.amazon.com/onca/xml3"; + AWSURL["jp"] = "http://xml.amazon.co.jp/onca/xml3"; + AWSURL["fr"] = "http://xml-eu.amazon.com/onca/xml3"; + AWSURL["ca"] = "http://xml.amazon.ca/onca/xml3"; +}else{ + AWSURL["us"] = AWSPROXY; + AWSURL["uk"] = AWSPROXY; + AWSURL["de"] = AWSPROXY; + AWSURL["jp"] = AWSPROXY; + AWSURL["fr"] = AWSPROXY; + AWSURL["ca"] = AWSPROXY; +} + + +//Developer Token +const DEVT = "D3MAIAYX2Q6JLY"; + +//Associate ID +const ASSID = {}; + ASSID["us"] = "faser-20"; + ASSID["uk"] = "faser-21"; + ASSID["de"] = "faser0f-21"; + ASSID["jp"] = "webservices-20"; + ASSID["fr"] = "faser02-21"; + ASSID["ca"] = "faser07-20"; + +//Amazon HomePage URL +const AMAZONURL = {}; + AMAZONURL["us"] = "http://www.amazon.com"; + AMAZONURL["uk"] = "http://www.amazon.co.uk"; + AMAZONURL["de"] = "http://www.amazon.de"; + AMAZONURL["jp"] = "http://www.amazon.co.jp"; + AMAZONURL["fr"] = "http://www.amazon.fr"; + AMAZONURL["ca"] = "http://www.amazon.ca"; + +//Amazon Shopping Card URL +const AMAZONCARD = {}; +if(MAB_RUN == "local") { + AMAZONCARD["us"] = "http://www.amazon.com/exec/obidos/dt/assoc/handle-buy-box="; + AMAZONCARD["uk"] = "http://www.amazon.co.uk/exec/obidos/dt/assoc/handle-buy-box="; + AMAZONCARD["de"] = "http://www.amazon.de/exec/obidos/dt/assoc/handle-buy-box="; + AMAZONCARD["fr"] = "http://www.amazon.fr/exec/obidos/dt/assoc/handle-buy-box="; + AMAZONCARD["ca"] = "http://www.amazon.ca/exec/obidos/dt/assoc/handle-buy-box="; + AMAZONCARD["jp"] = "http://www.amazon.co.jp/exec/obidos/dt/assoc/handle-buy-box="; +}else{ + AMAZONCARD["us"] = AWSPROXYPOST + "?locale=us&asin="; + AMAZONCARD["uk"] = AWSPROXYPOST + "?locale=uk&asin="; + AMAZONCARD["de"] = AWSPROXYPOST + "?locale=de&asin="; + AMAZONCARD["fr"] = AWSPROXYPOST + "?locale=fr&asin="; + AMAZONCARD["ca"] = AWSPROXYPOST + "?locale=ca&asin="; + AMAZONCARD["jp"] = AWSPROXYPOST + "?locale=jp&asin="; +} + +//Google HomePage URL +const GOOGLEURL = {}; + GOOGLEURL["us"] = "http://www.google.com"; + GOOGLEURL["uk"] = "http://www.google.co.uk"; + GOOGLEURL["de"] = "http://www.google.de"; + GOOGLEURL["jp"] = "http://www.google.jp"; + GOOGLEURL["fr"] = "http://www.google.fr"; + GOOGLEURL["ca"] = "http://www.google.ca"; + +//How many days before a products should be considered expired +const EXPIRED_SHORT = 1; +const EXPIRED_LONG = 90; + +//CALL_INTERVAL - Call per second +const CALL_INTERVAL = 500; //ms diff --git a/mab/xul/js/mab.js b/mab/xul/js/mab.js @@ -0,0 +1,864 @@ +/** +* +* +* @FileName: mab.js +* @$LastChangedDate: 2004-07-16 17:49:47 +0200 (Fri, 16 Jul 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + + +//Main +function main() { + //Initialize global Search ToolBar that have to mantain the consistence between + //the various menuitem in the search toolbar + myProductLineController = new ProductLineController(); + myProductLineController.update(); + + //Initialize global Display Controller. Display Controller visualize the + //XML Mab Document (XMDManager) in the tree and in the left panels + myDisplayController = new DisplayController(); + + //This global objetc mantain the list of all opened document + //and display them in the windows menubar item. + myDocOpened = new DocOpenManager(); + + //Save searches made in this session + mySearchHistory = new SearchHistory(); + + //Main ProgressMeter. I have to put the reference here in a global var because + //in some circumstance when ProgressBar class is called lost the reference to the progressmeter element + //To investigate. + guiMeter = document.getElementById("meter"); + + //Focus on Search textbox + window.focus(); + document.getElementById('find-text').focus(); + + //If MAB is running from remote disable some buttons + if(MAB_RUN == "remote") { + var broadcaster = document.getElementById("isMabRemote"); + broadcaster.setAttribute("disabled","true"); + } + + +} + +//Start a new search +function newSearch() { + var searchType = myDisplayController.getSearchPreference(); + var requestedRecord = myDisplayController.getRecordPreference(); + var recordForPage = 10; + var requestPage = requestedRecord/recordForPage; + + //Object to get the first query string + var myQueryStringBuilder = new QueryStringBuilder(myProductLineController); + var qString = myQueryStringBuilder.createQueryString(1,searchType); + + if(!qString) { + return false; + } else { + var mabRequestType = "default"; + var mySearchController = new SearchController(mabRequestType,requestPage); + var nrThread = 0; + mySearchController.search(qString,nrThread); + return true; + } +} + +//Get more products using the last search criteria +function nextRecord() { + var pagesAvailable = mySearchHistory.getPagesAvailable(); + if( pagesAvailable < 1) { + alert("No more products available"); + return false; + } + + var searchType = myDisplayController.getSearchPreference(); + var requestedRecord = myDisplayController.getRecordPreference(); + var recordForPage = 10; + var requestPage = requestedRecord/recordForPage; + + if(pagesAvailable < requestPage) {requestPage = pagesAvailable;} + + + var mabRequestType = "default"; + var mySearchController = new SearchController(mabRequestType,requestPage); + var qString = mySearchHistory.lastURL; + var pageToStart = mySearchHistory.lastPage + 1; + var newQString = mySearchController.setCurrentPage(qString,pageToStart) + + //Check if searchType has been modified respect the previous search + var oldSearchType = mySearchController.getQueryParam(newQString,"type"); + if(searchType != oldSearchType) { + newQString = mySearchController.setQueryParam(newQString,"type",searchType); + } + var nrThread = 0; + mySearchController.search(newQString,nrThread); + return true; +} + +//Retrieve and/or refresh all info about the selected products +function getComment(){ + var myXMDManager = myDocOpened.getCurrentDocument(); + var rows = myDisplayController.getAllSelectedRowIndex(); + + if(rows.length == 0) { + alert("No rows selected."); + return false; + } + + //Create asin list grouped by locale + var asinList = {}; + var pk,node, locale,amazAsin; + for(var i=0; i< rows.length; i++) { + pk = myDisplayController.getRowPrimaryKey(rows[i]); + if(pk) { + node = myXMDManager.getNodeDetail(pk); + if(node) { + locale = myXMDManager.getSingleElement(node,"MABLocale"); + amazAsin = myXMDManager.getSingleElement(node,"Asin"); + + if(!locale || !amazAsin) {continue;} + + if(typeof asinList[locale] == "undefined") { + asinList[locale] = new Array(); + } + + asinList[locale].push(amazAsin); + } + } + } + + //ok, now call asinSearch + var res = asinSearch(asinList); + return res; +} + +function asinSearch(asinList) { + + var query = ""; + var list = ""; + var qString = ""; + var countItem = 0; + var nrThread = 0; + var done = false; + var mySearchController; + var mabRequestType = "asin"; + for(var loc in asinList) { + qString = AWSURL[loc]+'?t='+ASSID[loc]+'&dev-t='+DEVT+'&type=heavy&f=xml&locale='+loc+'&AsinSearch='; + countItem = 1; + + for(var i=0; i < asinList[loc].length;i++) { + list += asinList[loc][i]; + if(countItem % 10 == 0 || countItem == asinList[loc].length) { + query = qString + list; + //Short term fix for japanese site + if(loc == "jp") {query += '&__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A';} + mySearchController = new SearchController(mabRequestType,1); + mySearchController.search(query,nrThread); + list = ""; + query = ""; + done = true; + } else { + list += "," + } + + countItem++; + } + } + //Asin List is empty and no asinSearch has been made? + return done; +} + +//Reload all info about the selected products +function reload() { + getComment(); +} + + +//Reload all expired products +function reloadExpired() { + var myXMDManager = myDocOpened.getCurrentDocument(); + if(!myXMDManager) {return false;} + var asinList = myXMDManager.getAllExpiredProducts(EXPIRED_SHORT); + var expired = false + for(var p in asinList) { + if(asinList[p].length > 0) { + expired = true; + break; + } + } + + if(!expired) { + alert("There are not expired products to reload"); + return false; + } else { + return asinSearch(asinList); + } + +} + + +//Get Similar Products +function getSimilarProducts() { + var myXMDManager = myDocOpened.getCurrentDocument(); + var rows = myDisplayController.getAllSelectedRowIndex(); + + if(rows.length == 0) { + alert("No rows selected."); + return false; + } + + //Create asin list of similar products grouped by locale + var asinList = {}; + var tmpList = {}; + var item, result; + var retry = 0; + var pk, node, locale, amazAsin, testReviews; + var i, j = 0; + for(i=0; i< rows.length; i++) { + pk = myDisplayController.getRowPrimaryKey(rows[i]); + + if(pk) { + node = myXMDManager.getNodeDetail(pk); + if(node) { + + locale = myXMDManager.getSingleElement(node,"MABLocale"); + amazAsin = myXMDManager.getArrayElement(node,"Product"); + + if(!locale) {continue;} + //Maybe we can't find the similar products because we don't have loaded + //an heavy XML + if(amazAsin.length == 0) { + item = myXMDManager.getSingleElement(node,"Asin"); + testReviews = myXMDManager.getSingleElement(node,"Reviews"); + //Load all xml + if(!testReviews) { + tmpList[locale] = new Array(); + tmpList[locale][0] = item; + result = asinSearch(tmpList); + } else { + continue; + } + } else { + if(typeof asinList[locale] == "undefined") { + asinList[locale] = new Array(); + } + + for(j=0;j<amazAsin.length;j++) { + asinList[locale].push(amazAsin[j]); + } + } + } + } + } + + var res = asinSearch(asinList); + return res; +} + +//Create a new document +function newDoc() { + var myXMDManager = new XMDManager(); + + //Add new doc to windows list + myDocOpened.addDoc(myXMDManager); + myDisplayController.clearAll(); + return myXMDManager; +} + +//Load a previuos opened or created document that is listed in the windows menu bar +function loadDoc(docCounter) { + var myXMDManager = myDocOpened.getDocument(docCounter); + if(myXMDManager) { + myDocOpened.checkDoc(docCounter); + myDisplayController.clearAll(); + myDisplayController.buildTree(myXMDManager); + return true; + }else{ + alert("An error has occured loading the document"); + return false; + } +} + +//Open a previous saved document. MAB Remote can only open memory saved doc +//local MAB can open files +function openDoc(mode) { + //Docs are listed in the windows menu item + if(MAB_RUN == "remote") {return false;} + + //Local + var myXMDManager; + var myFileManager = new FileManager(); + var f = myFileManager.readFile(); + + if(f == false) {return false;} + + try { + var mabXML = new DOMParser().parseFromString(f,'text/xml'); + }catch(e) { + alert(e); + } + + //Merge Mode + if(mode == "merge") { + myXMDManager = myDocOpened.getCurrentDocument(); + if(!myXMDManager) {myXMDManager = newDoc();} + var res = myXMDManager.isValidMABDoc(mabXML); + if(!res) { + alert("The document is not a valid MAB file"); + return false; + } else{ + myXMDManager.merge(mabXML); + myXMDManager.wasSaved = false; + myDisplayController.buildTree(myXMDManager,true); + } + + }else if(mode == "open") { + //Single Open Mode + myXMDManager = new XMDManager(); + if(!myXMDManager.isValidMABDoc(mabXML)) { + alert("The document is not a valid MAB file"); + return false; + } else { + myXMDManager.merge(mabXML); + //Get full path and file name without the extension + myXMDManager.fullPath = myFileManager.path; + var fileName = myFileManager.leafName; + fileName = fileName.substr(0,fileName.lastIndexOf(".")); + myXMDManager.name = fileName; + myXMDManager.wasSaved = true; + //Build HasTable + myXMDManager.buildHashTable(); + //Add the current document to windows menu-item and to the array list + myDocOpened.addDoc(myXMDManager); + //Display result + myDisplayController.clearAll(); + myDisplayController.buildTree(myXMDManager); + } + } + + return true; +} + +function saveAsDoc() { + if(MAB_RUN == "remote") {return false;} + + var doc = myDocOpened.getCurrentDocument(); + if(!doc) { + alert("The document is empty. Can not be saved."); + return false; + } + + var fm = new FileManager(); + //Loaded from disk or previously saved + var path = fm.saveAs(); + var res = fm.saveFile(doc.xmlDoc,path); + if(res == true) { + doc.wasSaved = true; + doc.fullPath = fm.path; + doc.name = fm.leafName; + //Pay attention to the file extension + myDocOpened.renameCurrentDoc(doc.name); + return true; + }else{ + return false; + } + +} + +function saveDoc() { + if(MAB_RUN == "remote") {return false;} + + var doc = myDocOpened.getCurrentDocument(); + if(!doc) { + alert("The document is empty. Can not be saved."); + return false; + } + + var path = doc.fullPath; + var res; + if(path == "") { + res = saveAsDoc(); + }else{ + var fm = new FileManager(); + res = fm.saveFile(doc.xmlDoc,path); + } + + return res; +} + +//Close the current open document +function closeDoc() { + if(MAB_RUN == "remote") { + var result = closeDocRemote(); + return result; + } + + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { + alert("Permission denied:" + e); + } + + var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + + + var flags=promptService.BUTTON_TITLE_SAVE * promptService.BUTTON_POS_0 + + promptService.BUTTON_TITLE_DONT_SAVE * promptService.BUTTON_POS_1 + + promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_2; + + var doc = myDocOpened.getCurrentDocument(); + if(!doc) { + myDisplayController.clearAll(); + return false; + } + + var path = doc.fullPath; + var proceed = false; + + if(path == "") { + proceed = promptService.confirmEx(window,"Save file?","Save changes to this new document, " + myDocOpened.getCurrentDocumentName() + "?",flags, null, null, null, null, {}); + //Save + if(proceed == 0) { + var res = saveAsDoc(); + //Cancel + }else if(proceed == 2) { + return false; + } + + }else if(!doc.wasSaved) { + proceed = confirm("Save changes to " + path + '?'); + if(proceed) {saveDoc();} + } + + //Clear memory reference to this document and remove from list + myDocOpened.removeDoc(myDocOpened.getCurrentDocCounter()); + myDisplayController.clearAll(); + return true; +} + +function closeDocRemote() { + myDocOpened.removeDoc(myDocOpened.getCurrentDocCounter()); + myDisplayController.clearAll(); +} + + +function clearAll() { + //Clear from GUI + myDisplayController.clearAll(); + //Remove records from model + var myXMDManager = myDocOpened.getCurrentDocument(); + if(myXMDManager) { + myXMDManager.removeAllDetails(); + } +} + +function showDetails() { + var myXMDManager = myDocOpened.getCurrentDocument(); + myDisplayController.showDetails(myXMDManager); + //Change status to read + changeStatus("read"); +} + + +//Go to the Amazon +function goAmazon() { + var myXMDManager = myDocOpened.getCurrentDocument(); + var res = myDisplayController.getProductAmazonUrl(myXMDManager); + if(!res) { + var proceed = confirm("No rows selected. Go to Amazon HomePage?"); + if(proceed) { + var locale = myProductLineController.getLocale(); + window.open(AMAZONURL[locale],"Amazon"); + } + }else{ + window.open(res,"Amazon"); + } +} + +//Search on Google by ProductName +function goGoogle() { + var myXMDManager = myDocOpened.getCurrentDocument(); + var idx = myDisplayController.getSelectedRowIndex(); + if(idx < 0) { + var proceed = confirm("No rows selected. Go to Google HomePage?"); + if(proceed) window.open(GOOGLEURL[locale],"Google"); + } else { + var primaryKey = myDisplayController.getRowPrimaryKey(idx); + var nodeDetail = myXMDManager.getNodeDetail(primaryKey); + var searchString = myXMDManager.getSingleElement(nodeDetail,"ProductName"); + var locale = myXMDManager.getSingleElement(nodeDetail,"MABLocale"); + if(searchString) { + var words = searchString.split(" "); + //Google limit to 10 words + if(words.length > 10) { + searchString = ""; + for(var i=0;i<10;i++){ + searchString +=words[i]+' '; + } + } + searchString = encodeURI('"'+searchString+'"'); + var googleUrl = GOOGLEURL[locale] + '/search?q=' + searchString + ' -site:'+ AMAZONURL[locale]; + void(window.open(googleUrl,"Google")); + } + } +} + +//Add the selected item to the Amazon Shopping Card +function addCart() { + var myXMDManager = myDocOpened.getCurrentDocument(); + var rows = myDisplayController.getAllSelectedRowIndex(); + + if(rows.length == 0) { + alert("No row selected."); + return false; + } + + var pk, nodeDetail, temp; + var Asin = new Array(); + var checkLocale = new Array; + for(var i=0; i< rows.length; i++) { + pk = myDisplayController.getRowPrimaryKey(rows[i]); + if(!pk) {continue;} + nodeDetail = myXMDManager.getNodeDetail(pk); + temp = myXMDManager.getSingleElement(nodeDetail,"Asin"); + Asin.push(temp); + checkLocale[i] = myXMDManager.getSingleElement(nodeDetail,"MABLocale"); + if(i == 0) {continue;} + if(checkLocale[i] != checkLocale[i-1]) { + alert("You can add item to only one shopping cart at time\nYou have selected products from differents Amazon shop"); + return false; + } + } + if(Asin.length == 0) {return false;} + var locale = checkLocale[0]; + var params = ""; + for(i=0;i< Asin.length; i++) { + params += "asin." + Asin[i] +"=1&"; + } + params += "tag-value="+ ASSID[locale] + "&"; + params += "tag_value=" + ASSID[locale] + "&"; + params += "dev-tag-value=" + DEVT; + + var me = this; + var baseHREF = AMAZONURL[locale]; + + var callback = function(res) { + me.myProgressBar.stop(); + var strBaseHREF = "<base href=" + baseHREF + ">"; + if(res.status > 0) { + alert(res.message); + return false; + }else{ + ow = window.open("","Amazon"); + ow.document.open('text/html'); + ow.document.write(strBaseHREF + res.content); + ow.document.close(); + ow.focus(); + return true; + } + } + + var targetURL = AMAZONCARD[locale]; + targetURL += Asin; + + this.myProgressBar = new ProgressBar(guiMeter,true); + this.myProgressBar.start(); + try { + var blPermission = false; + if(MAB_RUN == "local") {blPermission = true;} + var myConnection = new Connection(targetURL,blPermission); + myConnection.setCallback(callback); + myConnection.setErrorCallback(callback); + myConnection.send(params,"POST","txt"); + }catch(e){ + alert("An error as occured \n" + e); + this.myProgressBar.stop() + return false; + } + + return true; +} + + +//Delete seleted rows from the tree and from the xml document +function deleteRow() { + var myXMDManager = myDocOpened.getCurrentDocument(); + var rows = myDisplayController.getAllSelectedRowIndex(); + if(rows.length == 0) { + alert("No rows selected"); + return false; + } + + var pk; + var isRowDeleted = false; + var len = rows.length-1; + //Reverse loop to prevent mess with row index that are live + for(var i=len; i >= 0; i--) { + pk = myDisplayController.getRowPrimaryKey(rows[i]); + if(pk) { + myDisplayController.removeRow(pk); + isRowDeleted = myXMDManager.removeDetail(pk); + } + } + + //Set Focus on the last -1 element + if(isRowDeleted) { + var indexRow = rows[0]-1; + myDisplayController.setFocusOnRow(indexRow); + } + + return isRowDeleted; +} + +//Sort result in the tree based on the column clicked. The XML Document is +// sort too. +function sortResult(el,tagName,columnPosition) { + var myXMDManager = myDocOpened.getCurrentDocument(); + if(!myXMDManager) {return false;} + + // If virtualSort is false the under hood xml document is not sorted + // in this case when products list is saved the items are not sorted, same + // thing when the user switch between documets loaded or in exportxml and exporthtml function + + var virtualSort = false; + myDisplayController.sort(myXMDManager,el,tagName,virtualSort); + return true; +} + + + +//Export Doc in XML - open a news browser window. +//I can't find a way to display the document in source mode or to open the new window with text/xml type +function exportXMLDoc() { + var myXMDManager = myDocOpened.getCurrentDocument(); + if(!myXMDManager){return false;} + var strTitle = myXMDManager.name; + var str = serializeXML(myXMDManager.xmlDoc); + var param = "toolbar=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,location=no,directories=no"; + var ow = window.open("html/exportXML.html","Export",param); + + //It seems that with Mozilla 1.7 and Firefox 0.9 onload doesn't work anymore in the installed version. + //why it doesn't work ? setTimeout is an orrible solution! + + //ow.onload = insertXML; + setTimeout(insertXML,500); + function insertXML() { + ow.document.title = strTitle.toUpperCase(); + ow.document.getElementById('result').appendChild(ow.document.createTextNode(str)); + ow.focus(); + return true; + } + + return true; +} + +//Export HTML Doc opening a new browser window +function exportHTMLDoc() { + var myXMDManager = myDocOpened.getCurrentDocument(); + if(!myXMDManager) {return false;} + var strTitle = myXMDManager.name; + var strHTML = ""; + var imgSrc = ""; + var info = ""; + var nodeList = myXMDManager.xmlDoc.getElementsByTagName("Details"); + + var param = "toolbar=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,location=no,directories=no"; + var ow = window.open("html/exportHTML.html","Export",param); + + + for(var i=0;i< nodeList.length;i++) { + imgSrc = myXMDManager.getSingleElement(nodeList[i],"ImageUrlMedium"); + info = myDisplayController.getFormattedInfo(myXMDManager,nodeList[i],"base"); + strHTML += '<tr><td valign="top" class="img"><img src="'+ imgSrc +'" border="0"></td>'; + strHTML += '<td valign="top" class="product">' + info + '</td></tr>'; + } + + //ow.onload = insertHTML; //why this? see exportXML :-( + setTimeout(insertHTML,500); + function insertHTML() { + ow.document.title = strTitle.toUpperCase(); + ow.document.getElementById("page-title").innerHTML = strTitle.toUpperCase(); + ow.document.getElementById("export-content").innerHTML = strHTML; + ow.focus(); + } + + return true; +} + +//Export in txt a information summary about the selected rows. +function exportTXTDoc() { + var myXMDManager = myDocOpened.getCurrentDocument(); + var rows = myDisplayController.getAllSelectedRowIndex(); + var len = rows.length; + if(len == 0) { + alert("No rows selected"); + return false; + } + + var txt = ""; + var pk,node,amazAsin,locale,theUrl; + + for(var i=0; i < len; i++) { + pk = myDisplayController.getRowPrimaryKey(rows[i]); + if(pk) { + node = myXMDManager.getNodeDetail(pk); + txt += myDisplayController.getFormattedInfo(myXMDManager,node,"base"); + amazAsin = myXMDManager.getSingleElement(node,"Asin"); + locale = myXMDManager.getSingleElement(node,"MABLocale"); + theUrl = AMAZONURL[locale] + "/exec/obidos/ASIN/" + amazAsin + "/" + ASSID[locale] + "/"; + txt += "Amazon page: " + theUrl + "\n\n"; + } + } + + //Remove HTML Info + txt = stripHTML(txt); + txt = "<pre>" + txt + "</pre>"; + + var param = "toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no"; + var ow = window.open("","Export",param); + ow.document.open("text/html", ""); + ow.document.writeln(txt); + ow.document.close(); + ow.focus(); + return true; +} + +/** + * Open a new window to display a fake CD cover + * @return true if the selected item is a music products + * @type bool +*/ +function openCoverWin() { + + //Check the selected items is in music catalog + var XMDManager = myDocOpened.getCurrentDocument(); + var index = myDisplayController.getSelectedRowIndex(); + var primaryKey = myDisplayController.getRowPrimaryKey(index); + + var node = XMDManager.getNodeDetail(primaryKey); + if(node) { + var catalog = XMDManager.getSingleElement(node,"Catalog"); + if(catalog != "Music") { + alert('You need to select a music CD'); + return false; + } + } else { + return false; + } + + var param = "toolbar=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,location=no,directories=no"; + var ow = window.open("html/cover.html","Cover",param); + ow.focus(); + return true; +} + +//Get the bigger product image +function getImageLarge() { + var myXMDManager = myDocOpened.getCurrentDocument(); + var index = myDisplayController.getSelectedRowIndex(); + var pk = myDisplayController.getRowPrimaryKey(index); + var node = myXMDManager.getNodeDetail(pk); + //get large image URL + var imgLarge = myXMDManager.getSingleElement(node,'ImageUrlLarge'); + //Open Win for large image + var openWindow = function() { + void(window.open(this.src,'','centerscreen,resizable,width=' + this.width + ',height=' + this.height + '')); + } + + if(imgLarge) { + var img = new Image(); + img.src = imgLarge; + img.onload = openWindow; + return true; + }else{ + return false; + } +} + +//Set a background color on selected rows +function setLabel(color) { + + var myXMDManager = myDocOpened.getCurrentDocument(); + var rows = myDisplayController.getAllSelectedRowIndex(); + if(rows.length == 0) { + alert("No rows selected"); + return false; + } + var done = false; + var pk, node, treeRow; + var len = rows.length; + for(var i=0; i < len; i++) { + pk = myDisplayController.getRowPrimaryKey(rows[i]); + if(pk) { + node = myXMDManager.getNodeDetail(pk); + treeRow = document.getElementById(pk); + myXMDManager.setNodeValue(node,"MABLabel",color) + myDisplayController.updateRow(treeRow,node,myXMDManager); + done = true; + } + } + + return done; +} + +function changeStatus(MABStatus) { + var myXMDManager = myDocOpened.getCurrentDocument(); + var idx = myDisplayController.getSelectedRowIndex(); + if(idx >= 0) { + var pk = myDisplayController.getRowPrimaryKey(idx); + var node = myXMDManager.getNodeDetail(pk); + if(!node) {return false;} + var treeRow = document.getElementById(pk); + myXMDManager.setNodeValue(node,"MABStatus",MABStatus) + myDisplayController.updateRow(treeRow,node,myXMDManager); + return true; + }else{ + return false; + } +} + +//Add the selected items to bookmark (sidebar) +function addBookmark() { + + var myXMDManager = myDocOpened.getCurrentDocument(); + var idx = myDisplayController.getSelectedRowIndex(); + if(idx < 0) { return false;} + var primaryKey = myDisplayController.getRowPrimaryKey(idx); + var nodeDetail = myXMDManager.getNodeDetail(primaryKey); + var title = myXMDManager.getSingleElement(nodeDetail,"ProductName"); + var urlLink = myDisplayController.getProductAmazonUrl(myXMDManager,"directLink",nodeDetail); + + //Require Privilege for remote version + try { + //Mozilla - Problem with Firefox 1.0 RC - So pass directly to sidebar + if(navigator.vendor == "Firefox"){throw("e");} + + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect") + var b = Components.classes["@mozilla.org/browser/bookmarks-service;1"].getService(); + b = b.QueryInterface(Components.interfaces.nsIBookmarksService); + b.addBookmarkImmediately(urlLink,title,0,null); + return true; + }catch(e) { + try{ + if(typeof(window.sidebar)!="undefined" && typeof(window.sidebar.addPanel)!="undefined") { + window.sidebar.addPanel (title,urlLink,""); + return true; + }else{ + return false; + } + }catch(e){ + alert("This function is not supported by your browser"); + var el = document.getElementById("mabAddBookmark"); + el.setAttribute("disabled","true"); + return false; + } + + } +} + diff --git a/mab/xul/js/settings.js b/mab/xul/js/settings.js @@ -0,0 +1,41 @@ +/** +* +* Settings are saved in a hidden spacer located in mab.xul, using the persist attribute +* +* @FileName: settings.js +* @$LastChangedDate: 2004-05-13 18:49:36 +0200 (Thu, 13 May 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + + +function getSettings() { + //Get settings from spacer + var op = window.opener; + var searchType = op.document.getElementById('settings-spacer').getAttribute("search"); + var nrResult = op.document.getElementById('settings-spacer').getAttribute("nrResult"); + + //Display settings in the dialog windows + document.getElementById(searchType).setAttribute('selected','true'); + if(!nrResult) { + nrResult = 10; + } + var nrResultIndex = (nrResult/10) -1; + document.getElementById("max-results").selectedIndex = nrResultIndex; +} + +function setSettings() { + var op = window.opener; + + //Get settings + var searchType = document.getElementById('search').selectedItem.value; + var nrResult = document.getElementById('max-results').selectedItem.value; + + //Save settings + op.document.getElementById('settings-spacer').setAttribute("search",searchType); + op.document.getElementById('settings-spacer').setAttribute("nrResult",nrResult); + + window.close(); +} diff --git a/mab/xul/js/utils.js b/mab/xul/js/utils.js @@ -0,0 +1,167 @@ +/** + * + * @filename utils.js + * @$LastChangedDate: 2004-06-26 13:51:10 +0200 (Sat, 26 Jun 2004) $ + * @author Fabio Serra <faser@faser.net> + * @copyright Fabio Serra (The Initial Developer of the Original Code) + * @license Mozilla Public License Version 1.1 +*/ + + +function trim(s){ + return s.replace(/\s+$|^\s+/g,""); +} + +function toNumber(s) { + if(!s || s == "") return 0; + return Number(s.replace(/[^0-9\.]/g, "")); +} + +function CaseInsensitiveString(s) { + return String(s).toUpperCase(); +} + +function toYear(s) { + var date = new Date(s); + var year = 0; + if(date && date != "Invalid Date") { + year = date.getFullYear(); + } else { + year = s.substr((s.length-4),s.length); + } + + if(isNaN(year)) { + year = 0; + } + + return year; +} + +function wordCount(str) { + var wc = str.split(" ").lenght; +} + +//Busy Waiting +function pause(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) return; + } +} + + +function stripHTML(string) { + return string.replace(/(<([^>]+)>)/ig,""); +} + +function escapeXML(str) { + var newString = ""; + newString = str.replace(/&/g,"&amp;"); + newString = newString.replace(/</g,"&lt;"); + newString = newString.replace(/>/g,"&gt;"); + //To prevent xul errors + newString = newString.replace(/"/g,"''"); + + return newString; +} + +function serializeXML(xmlDoc) { + var s = new XMLSerializer(); + try { + var str = s.serializeToString(xmlDoc); + }catch(e){ + alert(e); + } + return str; +} + +/** + * Insert an XML string in a XML/XUL document + * + * @param {XML Element} node + * @param {string} sxml The XML string + * @param {bool} isXul Indicate if the string is a XUL XML + * @param {bool} insertBefore Indicate if the XML should be appended or inserted before the XML element + * @return bool + * Thanks to Zero (zer0.shock@libero.it) +*/ +function innerXML(node,sxml,isXUL,insertBefore) { + var appendChild = true; + if(insertBefore) {appendChild = false;} + var doc = ""; + if(isXUL) { + var boxContainerOpen = '<box id="xul-data" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">' + var boxContainerClose = '</box>'; + doc = (new DOMParser()).parseFromString(boxContainerOpen + sxml + boxContainerClose, "text/xml"); + }else{ + doc = (new DOMParser()).parseFromString("<root>"+sxml+"</root>", "text/xml"); + } + + if (doc.firstChild.tagName=="parsererror"){ + alert(doc.firstChild.childNodes[0].nodeValue +'\n'); + + return false; + }else{ + doc=doc.firstChild; + for (var i=0;i < doc.childNodes.length;i++) { + if(appendChild) { + node.appendChild(node.ownerDocument.importNode(doc.childNodes[i],true)); + }else{ + node.insertBefore(node.ownerDocument.importNode(doc.childNodes[i],true),node.firstChild); + } + } + return true; + } +} + +//Elapsed time +function ElapsedTime() { + this.timeStart = new Date(); +} + +ElapsedTime.prototype.getElapsedTime = function() { + var timeStop = new Date() + var elapsedTime = (timeStop - this.timeStart)/1000; + return elapsedTime; +} + +//Dump to console the properties of an object +function dumpProp(obj) { + var str = ""; + for (var i in obj) { + str += i + '\n'; + } + dump(str); +} + +function eDump(e) { + dump("\n" + e.type + ":"+e.target.tagName); +} + +/** + * @deprecated too slow, use convertToUnicode + * http://aktuell.de.selfhtml.org/artikel/javascript/utf8b64/utf8.htm#a4 + * @author tobias@justdreams.de +*/ +function decode_utf8(utftext) { +var plaintext = ""; var i=0; var c=c1=c2=c3=0; +// while-Schleife, weil einige Zeichen uebersprungen werden + while(i<utftext.length) + { + c = utftext.charCodeAt(i); + if (c<128) { + plaintext += String.fromCharCode(c); + i++;} + else if((c>191) && (c<224)) { + c2 = utftext.charCodeAt(i+1); + plaintext += String.fromCharCode(((c&31)<<6) | (c2&63)); + i+=2;} + else { + c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); + plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63)); + i+=3;} + } + return plaintext; + } diff --git a/mab/xul/mab.css b/mab/xul/mab.css @@ -0,0 +1,201 @@ +/** +* +* +* @FileName: mab.css +* @$LastChangedDate: 2004-07-16 17:48:44 +0200 (Fri, 16 Jul 2004) $ +* @Author: Fabio Serra AKA Faser - faser@faser.net +* @Copyright: Fabio Serra +* @Licenze: MPL 1.1 +* +*/ + +#find-text { + border: 2px solid; + margin: 4px 6px 4px 3px; + padding-bottom: 2px; + padding-top: 2px; +} + +#mab-status-bar{ + border-top: none; + margin: 0; +} + + +textbox[readonly="true"] { + background-color: Window; +} + +.detail { + background-color: Window; + color: WindowText; +} + +/* +.info-head { + font-size: larger; +} + +.info-title { + color: HighlightText; + background-color: Highlight; +}*/ + + + +body.comment { + background-color: Window; + color: WindowText; + font: -moz-document; +} + +body.help { + font-family: Arial, Helvetica, sans-serif; + background-color: White; + font-size: 12px; +} + +.numeric { + text-align: right; +} + +.date { + text-align: right; +} + +.treecol-icon { + text-align: center; +} + +/*Icon Buttons*/ + +#new-icon { + list-style-image: url(../skin/images/filenew.png); +} + +#new-icon[disabled="true"] { + list-style-image: url(../skin/images/filenew_disabled.png); +} + +#open-icon { + list-style-image: url(../skin/images/fileopen.png); +} + +#open-icon[disabled="true"] { + list-style-image: url(../skin/images/fileopen_disabled.png); +} + +#abort-icon { + list-style-image: url(../skin/images/abort.png); +} + +#abort-icon[disabled="true"] { + list-style-image: url(../skin/images/abort_disabled.png); +} + +#save-icon { + list-style-image: url(../skin/images/filesave.png); +} + +#save-icon[disabled="true"] { + list-style-image: url(../skin/images/filesave_disabled.png); +} + +#goAmazon-icon { + list-style-image: url(../skin/images/gohome.png); +} + +/* +#goAmazon-icon[disabled="true"] { + list-style-image: url(../skin/images/goamazon_disabled.png); +} +*/ +#addCart-icon { + list-style-image: url(../skin/images/goamazon.png); +} + +#goGoogle-icon { + list-style-image: url(../skin/images/gogoogle.png); +} + +#goGoogle-icon[disabled="true"] { + list-style-image: url(../skin/images/gogoogle_disabled.png); +} + +#comment-button { + list-style-image: url(../skin/images/comment.png); +} + +#comment-button[disabled="true"] { + list-style-image: url(../skin/images/comment_disabled.png); +} + +#reload-btn { + list-style-image: url(../skin/images/reload.png); +} + +#search-btn { + list-style-image: url(../skin/images/search.png); +} + +#search-btn[disabled="true"] { + list-style-image: url(../skin/images/search_disabled.png); +} + +#next-btn { + list-style-image: url(../skin/images/forward.png); +} + +#next-btn[disabled="true"] { + list-style-image: url(../skin/images/forward_disabled.png); +} + +#clear-btn { + list-style-image: url(../skin/images/clear.png); +} + +#clear-btn[disabled="true"] { + list-style-image: url(../skin/images/clear_disabled.png); +} + +#delete-btn { + list-style-image: url(../skin/images/delete.png); +} + +#delete-btn[disabled="true"] { + list-style-image: url(../skin/images/delete_disabled.png); +} + +/*Custom treecell color*/ +treechildren:-moz-tree-cell-text(Orange) { + color: #FF4500; +} + +treechildren:-moz-tree-cell-text(Blue) { + color: Blue; + } + +treechildren:-moz-tree-cell-text(Green) { + color: Green; +} + +treechildren:-moz-tree-cell-text(Maroon) { + color: Maroon; +} + +treechildren:-moz-tree-cell-text(Olive) { + color: Olive; +} + +treechildren:-moz-tree-cell-text(Teal) { + color: Teal; +} + +treechildren:-moz-tree-cell-text(Purple) { + color: Purple; +} + +treechildren:-moz-tree-cell-text(Expired) { + color: Red; + font-weight: bold; +} +\ No newline at end of file diff --git a/mab/xul/mab.glade b/mab/xul/mab.glade @@ -0,0 +1,2145 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> +<requires lib="gnome"/> + +<widget class="GtkWindow" id="amazWindow"> + <property name="visible">True</property> + <property name="title" translatable="yes">MAB/webglade</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkMenuBar" id="main-menu"> + <property name="visible">True</property> + <property name="pack_direction">GTK_PACK_DIRECTION_LTR</property> + <property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property> + + <child> + <widget class="GtkMenuItem" id="file-menu"> + <property name="visible">True</property> + <property name="label" translatable="yes">_File</property> + <property name="use_underline">True</property> + + <child> + <widget class="GtkMenu" id="file-menu_menu"> + + <child> + <widget class="GtkMenuItem" id="new1"> + <property name="visible">True</property> + <property name="label" translatable="yes">New</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_new" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + <accelerator key="n" modifiers="GDK_CONTROL_MASK" signal="activate"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="open1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Open</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_open" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="merge1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Merge</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_merge" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="close2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Close</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_close" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + <accelerator key="w" modifiers="GDK_CONTROL_MASK" signal="activate"/> + </widget> + </child> + + <child> + <widget class="GtkSeparatorMenuItem" id="separator4"> + <property name="visible">True</property> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="save1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Save</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_save" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="save_as1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Save as</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_save_as" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkSeparatorMenuItem" id="separator1"> + <property name="visible">True</property> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="export_html1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Export HTML</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_export_html" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="export_xml1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Export XML</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_export_xml" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkSeparatorMenuItem" id="separator5"> + <property name="visible">True</property> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="quit1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Quit</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_quit" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="edit-menu"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Edit</property> + <property name="use_underline">True</property> + + <child> + <widget class="GtkMenu" id="edit-menu_menu"> + + <child> + <widget class="GtkMenuItem" id="label-menu"> + <property name="visible">True</property> + <property name="label" translatable="yes">Change Label</property> + <property name="use_underline">True</property> + + <child> + <widget class="GtkMenu" id="label-menu_menu"> + + <child> + <widget class="GtkMenuItem" id="none1"> + <property name="visible">True</property> + <property name="label" translatable="yes">None</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_none" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkSeparatorMenuItem" id="separator6"> + <property name="visible">True</property> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="orange1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Orange</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_orange" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="blue1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Blue</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_blue" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="green1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Green</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_green" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="maroon1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Maroon</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_maroon" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="olive1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Olive</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_olive" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="teal1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Teal</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_teal" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="purple1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Purple</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_purple" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="mabAddBookmark"> + <property name="visible">True</property> + <property name="label" translatable="yes">Bookmark (Sidebar)</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_bookmark_sidebar" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="reload1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Reload</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_reload" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="load_reviews1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Load Reviews</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_load_reviews" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + <accelerator key="r" modifiers="GDK_CONTROL_MASK" signal="activate"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="load_similar_products1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Load Similar Products</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_load_similar_products" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="delete_rows1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Delete rows</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_delete_rows" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkSeparatorMenuItem" id="separator7"> + <property name="visible">True</property> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="text_summary1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Text Summary</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_text_summary" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="make_cd_cover1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Make CD Cover</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_make_cd_cover" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkSeparatorMenuItem" id="separator8"> + <property name="visible">True</property> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="reload_expired1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Reload Expired</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_reload_expired" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="trash_all1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Trash All</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_trash_all" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="options-menu"> + <property name="visible">True</property> + <property name="label" translatable="yes">Op_tions</property> + <property name="use_underline">True</property> + + <child> + <widget class="GtkMenu" id="options-menu_menu"> + + <child> + <widget class="GtkMenuItem" id="settings1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Settings</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_settings" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="windows-menu"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Windows</property> + <property name="use_underline">True</property> + + <child> + <widget class="GtkMenu" id="windows-menu_menu"> + + <child> + <widget class="GtkMenuItem" id="dummy1"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">dummy to create windows-menu_menu</property> + <property name="label" translatable="yes">???</property> + <property name="use_underline">True</property> + </widget> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="help-menu"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Help</property> + <property name="use_underline">True</property> + + <child> + <widget class="GtkMenu" id="help-menu_menu"> + + <child> + <widget class="GtkMenuItem" id="content1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Content</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_content" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="feedback1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Feedback</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_feedback" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="about1"> + <property name="visible">True</property> + <property name="label" translatable="yes">About</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_about" last_modification_time="Sat, 14 Jul 2007 18:52:31 GMT"/> + </widget> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkToolbar" id="toolbar1"> + <property name="visible">True</property> + <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> + <property name="toolbar_style">GTK_TOOLBAR_ICONS</property> + <property name="tooltips">True</property> + <property name="show_arrow">True</property> + + <child> + <widget class="GtkToolButton" id="new-icon"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Create a new empty document</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_new" last_modification_time="Sun, 15 Jul 2007 00:52:29 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="open-icon"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Open saved searches</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_open" last_modification_time="Sun, 15 Jul 2007 00:52:35 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="save-icon"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Save current list</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_save" last_modification_time="Sun, 15 Jul 2007 00:52:41 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkSeparatorToolItem" id="separatortoolitem3"> + <property name="visible">True</property> + <property name="draw">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="goAmazon-icon"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Go to the product homepage</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_home" last_modification_time="Sun, 15 Jul 2007 00:52:47 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="addCart-icon"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Add item to the Amazon shopping cart</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_add" last_modification_time="Sun, 15 Jul 2007 00:52:52 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="goGoogle-icon"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Go to the Google Page</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_google" last_modification_time="Sun, 15 Jul 2007 00:52:59 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkSeparatorToolItem" id="separatortoolitem2"> + <property name="visible">True</property> + <property name="draw">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="comment-button"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Load reviews</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_reviews" last_modification_time="Sun, 15 Jul 2007 00:53:05 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="reload-btn"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Reload</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_reload" last_modification_time="Sun, 15 Jul 2007 00:53:10 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="delete-btn"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Delete selected record</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_delete" last_modification_time="Sun, 15 Jul 2007 00:53:20 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="clear-btn"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Delete current list</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_clear" last_modification_time="Sun, 15 Jul 2007 00:53:35 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + + <child> + <widget class="GtkSeparatorToolItem" id="separatortoolitem1"> + <property name="visible">True</property> + <property name="draw">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + + <child> + <widget class="GtkToolButton" id="abort-icon"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Stop connection</property> + <property name="label"></property> + <property name="use_underline">True</property> + <property name="visible_horizontal">True</property> + <property name="visible_vertical">True</property> + <property name="is_important">False</property> + <signal name="clicked" handler="on_abort" last_modification_time="Sun, 15 Jul 2007 00:53:47 GMT"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Amazon:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="locale-popup"> + <property name="visible">True</property> + <property name="items" translatable="yes">us|.com +ca|.ca +uk|.co.uk +de|.de +fr|.fr +jp|.co.jp</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + <signal name="changed" handler="on_domain_changed"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Catalog:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="mode-popup"> + <property name="visible">True</property> + <property name="items" translatable="yes">books|Books +magazines|Magazine +music|Popular Music +classical|Classical Music +dvd|DVD +vhs|Video +electronics|Electronics +software|Software +videogames|Video Games +jewerly|Jewelry +camera|Camera +toys|Toys +kitchen|Housewares +tools|Tools &amp; Hardware +garden|Outdoor Living +baby|Baby +books-int|English Books +blended|All Catalogs</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + <signal name="changed" handler="on_catalog_changed"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">Search Type:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="search-popup"> + <property name="visible">True</property> + <property name="items" translatable="yes">KeywordSearch|Keyword +AsinSearch|ASIN/ISBN +AuthorSearch|Author +ArtistSearch|Artist +ActorSearch|Actor +DirectorSearch|Director +ManufacturerSearch|Manufacturer +UpcSearch|UPC</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">Sort:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="sort-popup"> + <property name="visible">True</property> + <property name="items" translatable="yes">+salesrank|Bestselling ++pmrank|Featured Items ++reviewrank|Customer Review ++pricerank|Price (High to Low) ++inverse-pricerank|Price (Low to High) ++daterank|Publication Date ++titlerank|Alphabetical (A-Z) +-titlerank|Alphabetical (Z-A) ++artistrank|Artist Name ++orig-rel-date|Original Release Date ++manufactrank|Manufacturer (A-Z) +-manufactrank|Manufacturer (Z-A)</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="label" translatable="yes">Search Term:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="find-text"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">200</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="search-btn"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Search</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_search" last_modification_time="Sun, 15 Jul 2007 00:42:10 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="next-btn"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="tooltip" translatable="yes">Get more records from the last search</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">More</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_more" last_modification_time="Sun, 15 Jul 2007 00:55:31 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label17"> + <property name="visible">True</property> + <property name="label" translatable="yes"></property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHPaned" id="hpaned1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + + <child> + <widget class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="result-tree"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">True</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="detail-box"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkTable" id="table2"> + <property name="visible">True</property> + <property name="n_rows">4</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">0</property> + <property name="column_spacing">0</property> + + <child> + <widget class="GtkEntry" id="ReleaseDate"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="Manufacturer"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="Author"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label14"> + <property name="visible">True</property> + <property name="label" translatable="yes">Released:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label13"> + <property name="visible">True</property> + <property name="label" translatable="yes">Manufacturer:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label12"> + <property name="visible">True</property> + <property name="label" translatable="yes">Author:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label11"> + <property name="visible">True</property> + <property name="label" translatable="yes">Product Name:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="ProductName"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkImage" id="ImageUrlMedium"> + <property name="visible">True</property> + <property name="stock">gtk-missing-image</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkHSeparator" id="hseparator1"> + <property name="visible">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkTable" id="price-box"> + <property name="visible">True</property> + <property name="n_rows">2</property> + <property name="n_columns">4</property> + <property name="homogeneous">True</property> + <property name="row_spacing">0</property> + <property name="column_spacing">0</property> + + <child> + <widget class="GtkEntry" id="UsedPrice"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="OurPrice"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="ListPrice"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label10"> + <property name="visible">True</property> + <property name="label" translatable="yes">Used Price</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label9"> + <property name="visible">True</property> + <property name="label" translatable="yes">Our Price</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="label" translatable="yes">List Price</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkHButtonBox" id="hbuttonbox1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkButton" id="goAmazon-button"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Go to the Amazon Page</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Go to Amazon</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_home_clicked"/> + </widget> + </child> + + <child> + <widget class="GtkButton" id="addCart-button"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Add to your Amazon shopping cart</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Add to Cart</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="on_add_clicked"/> + </widget> + </child> + </widget> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="shrink">True</property> + <property name="resize">False</property> + </packing> + </child> + + <child> + <widget class="GtkNotebook" id="extra-info-tab"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_tabs">True</property> + <property name="show_border">True</property> + <property name="tab_pos">GTK_POS_TOP</property> + <property name="scrollable">False</property> + <property name="enable_popup">False</property> + + <child> + <widget class="Custom" id="allInfo-selected"> + <property name="visible">True</property> + <property name="creation_function">xul:iframe</property> + <property name="string1">html/allinfo.html</property> + <property name="string2">on_allinfo_loaded</property> + <property name="int1">0</property> + <property name="int2">0</property> + <property name="last_modification_time">Sun, 29 Jul 2007 00:29:28 GMT</property> + </widget> + <packing> + <property name="tab_expand">False</property> + <property name="tab_fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="label" translatable="yes">Product Info</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> + + <child> + <widget class="Custom" id="comment-selected"> + <property name="visible">True</property> + <property name="creation_function">xul:iframe</property> + <property name="string1">html/comment.html</property> + <property name="string2">on_comment_loaded</property> + <property name="int1">0</property> + <property name="int2">0</property> + <property name="last_modification_time">Sun, 29 Jul 2007 00:30:14 GMT</property> + </widget> + <packing> + <property name="tab_expand">False</property> + <property name="tab_fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="label" translatable="yes">Review</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> + </widget> + <packing> + <property name="shrink">True</property> + <property name="resize">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + <accessibility> + <atkproperty name="AtkObject::accessible_name" translatable="yes">statusbar</atkproperty> + </accessibility> + + <child> + <widget class="GtkStatusbar" id="record-status"> + <property name="visible">True</property> + <property name="has_resize_grip">False</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkStatusbar" id="out-status"> + <property name="visible">True</property> + <property name="has_resize_grip">False</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkProgressBar" id="meter"> + <property name="visible">True</property> + <property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property> + <property name="fraction">0</property> + <property name="pulse_step">0.10000000149</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> +</widget> + +<widget class="GtkDialog" id="settings"> + <property name="visible">True</property> + <property name="title" translatable="yes">M A B</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <property name="has_separator">True</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="cancel-button"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-6</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="ok-button"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-ok</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-5</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="settings-header"> + <property name="visible">True</property> + <property name="label" translatable="yes">Settings</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="vbox4"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label20"> + <property name="visible">True</property> + <property name="label" translatable="yes">Response type:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="light"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Light (Fastest)</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">True</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="heavy"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Heavy (Contains more complete product information reviews included)</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <property name="group">light</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox5"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label21"> + <property name="visible">True</property> + <property name="label" translatable="yes">Limit results for each search to:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="max-results"> + <property name="visible">True</property> + <property name="items" translatable="yes">10 +20 +30 +40 +50</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label19"> + <property name="visible">True</property> + <property name="label" translatable="yes">General</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +<widget class="GtkDialog" id="about"> + <property name="visible">True</property> + <property name="title" translatable="yes">M A B - About</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <property name="has_separator">True</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area2"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="button1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">OK</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">0</property> + <signal name="clicked" handler="gtk_widget_destroy" last_modification_time="Sun, 07 Oct 2007 02:19:49 GMT"/> + </widget> + </child> + + <child> + <widget class="GtkButton" id="button2"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Info</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">0</property> + <signal name="clicked" handler="switch_deck" last_modification_time="Sun, 07 Oct 2007 02:20:08 GMT"/> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="about-deck"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkVBox" id="vbox6"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="pixbuf">mablogo.png</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox7"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="Custom" id="custom1"> + <property name="visible">True</property> + <property name="creation_function">xul:iframe</property> + <property name="string1">html/about.html</property> + <property name="int1">0</property> + <property name="int2">0</property> + <property name="last_modification_time">Sun, 07 Oct 2007 02:15:29 GMT</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +<widget class="GtkWindow" id="helpWin"> + <property name="visible">True</property> + <property name="title" translatable="yes">window1</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <widget class="GtkHPaned" id="hpaned2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="position">0</property> + + <child> + <widget class="GtkList" id="help-list"> + <property name="visible">True</property> + <property name="selection_mode">GTK_SELECTION_SINGLE</property> + <signal name="selection_changed" handler="on_change_help_page" last_modification_time="Mon, 08 Oct 2007 20:17:48 GMT"/> + </widget> + <packing> + <property name="shrink">True</property> + <property name="resize">False</property> + </packing> + </child> + + <child> + <widget class="Custom" id="help-iframe"> + <property name="visible">True</property> + <property name="creation_function">xul:iframe</property> + <property name="string1">html/mab_help.html</property> + <property name="int1">0</property> + <property name="int2">0</property> + <property name="last_modification_time">Mon, 08 Oct 2007 20:18:51 GMT</property> + </widget> + <packing> + <property name="shrink">True</property> + <property name="resize">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/mab/xul/mab.gladep b/mab/xul/mab.gladep @@ -0,0 +1,11 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd"> + +<glade-project> + <name>Mab</name> + <program_name>mab</program_name> + <pixmaps_directory>images</pixmaps_directory> + <output_main_file>FALSE</output_main_file> + <output_support_files>FALSE</output_support_files> + <output_build_files>FALSE</output_build_files> +</glade-project> diff --git a/mab/xul/mab.js b/mab/xul/mab.js @@ -0,0 +1,455 @@ +var LOADED = 0; + +WHANDLER['on_allinfo_loaded'] = +function () { + ++LOADED; + if (2 < LOADED) { + main(); + }; +}; + +WHANDLER['on_comment_loaded'] = +function () { + ++LOADED; + if (2 < LOADED) { + main(); + }; +}; + +function main2() { + if (LOADED == 0) { + ++LOADED; + wremove(wget('loading')); + if (window.name) { + switch (window.name) { + case 'Settings': + loadXml + ('mab.glade', + function (glade) { + { + var widgets = parseGlade(glade); + wbuild + (document.documentElement, [ widgets['settings'] ]); + }; + initSettings(); + }); + break; + case 'About': + loadXml + ('mab.glade', + function (glade) { + var widgets = parseGlade(glade); + wbuild + (document.documentElement, [ widgets['about'] ]); + }); + break; + case 'Help': + loadXml + ('mab.glade', + function (glade) { + var widgets = parseGlade(glade); + wbuild + (document.documentElement, [ widgets['helpWin'] ]); + }); + }; + } else { + loadXml + ('mab.glade', + function (glade) { + { + var widgets = parseGlade(glade); + wbuild + (document.documentElement, [ widgets['amazWindow'] ]); + }; + init(); + }); + }; + }; +}; + +function settingsDialog() { + window.open + ('mab.xul', 'Settings', 'chrome,centerscreen,modal,width=440,height=300'); +}; + +function aboutDialog() { + window.open + ('mab.xul', 'About', 'chrome,centerscreen,modal,width=450,height=350'); +}; + +function helpDialog() { + window.open + ('mab.xul', 'Help', 'chrome,centerscreen,resizable,width=640,height=500'); +}; + +function init() { + { + var w = wget('amazWindow'); + var cs = wmake(w, 'xul:commandset', { id : 'mabCommand' }); + var ks = wmake(w, 'xul:keyset'); + var ms = wmake(cs, 'xul:commandset', { id : 'menubarCommand' }); + wmake + (w, 'xul:broadcaster', + { id : 'isSearchRunning', + disabled : 'true' }); + wmake + (w, 'xul:broadcaster', + { id : 'isMabRemote', + disabled : 'false' }); + wmake + (w, 'xul:spacer', + { id : 'settings-spacer', + hidden : 'true', + search : 'lite', + nrResult : 20, + persist : 'search nrResult' }); + { + var tmpArr1 = + [ [ 'newSearchCmd', 'newSearch()' ], [ 'nextCmd', 'nextRecord()' ], + [ 'clearCmd', 'clearAll()' ], [ 'commentCmd', 'getComment()' ], + [ 'goAmazonCmd', 'goAmazon()' ], [ 'addCartCmd', 'addCart()' ], + [ 'goGoogleCmd', 'goGoogle()' ], [ 'deleteCmd', 'deleteRow()' ] ]; + if (tmpArr1) { + for (var tmpI2 = 0; tmpI2 < tmpArr1.length; tmpI2 = tmpI2 + 1) { + var obj = tmpArr1[tmpI2]; + wmake + (cs, 'xul:command', + { id : obj[0], + oncommand : obj[1] }); + }; + }; + }; + { + var tmpArr3 = + [ [ 'newCmd', 'newDoc()' ], + [ 'openCmd', 'openDoc(\'open\')', 'isMabRemote' ], + [ 'closeCmd', 'closeDoc()' ], + [ 'mergeCmd', 'openDoc(\'merge\')', 'isMabRemote' ], + [ 'saveCmd', 'saveDoc()', 'isMabRemote' ], + [ 'saveAsCmd', 'saveAsDoc()', 'isMabRemote' ], + [ 'exportXMLCmd', 'exportXMLDoc()' ], + [ 'exportHTMLCmd', 'exportHTMLDoc()' ], + [ 'exportTXTCmd', 'exportTXTDoc()' ], + [ 'makeCoverCmd', 'openCoverWin()' ], + [ 'exitCmd', 'window.close()' ], + [ 'simProductCmd', 'getSimilarProducts()' ], + [ 'reloadExpiredCmd', 'reloadExpired()' ], + [ 'reloadCmd', 'reload()' ], [ 'abortCmd', 'abort()' ], + [ 'bookmarkCmd', 'addBookmark()' ], + [ 'settingsCmd', 'settingsDialog()' ], + [ 'topicsCmd', 'helpDialog()' ], + [ 'feedbackCmd', 'window.open(MAB_FEEDBACK_PAGE)' ], + [ 'aboutCmd', 'aboutDialog()' ] ]; + if (tmpArr3) { + for (var tmpI4 = 0; tmpI4 < tmpArr3.length; tmpI4 = tmpI4 + 1) { + var obj = tmpArr3[tmpI4]; + wmake + (ms, 'xul:command', + { id : obj[0], + oncommand : obj[1], + observes : 2 < obj.length ? obj[2] : undefined }); + }; + }; + }; + { + var tmpArr5 = + [ [ 'search-key', 'VK_RETURN', 'newSearchCmd' ], + [ 'search-key', 'VK_ENTER', 'newSearchCmd' ], + [ 'deleteKey', 'VK_DELETE', 'deleteCmd' ] ]; + if (tmpArr5) { + for (var tmpI6 = 0; tmpI6 < tmpArr5.length; tmpI6 = tmpI6 + 1) { + var obj = tmpArr5[tmpI6]; + wmake + (ks, 'xul:key', + { id : obj[0], + keycode : obj[1], + command : obj[2] }); + }; + }; + }; + var tmpArr7 = + [ [ 'new-key', 'accel', 'n', 'newCmd' ], + [ 'close-key', 'accel', 'w', 'closeCmd' ], + [ 'save-key', 'accel', 's', 'saveCmd' ], + [ 'review-key', 'accel', 'r', 'commentCmd' ] ]; + if (tmpArr7) { + for (var tmpI8 = 0; tmpI8 < tmpArr7.length; tmpI8 = tmpI8 + 1) { + var obj = tmpArr7[tmpI8]; + wmake + (ks, 'xul:key', + { id : obj[0], + modifiers : obj[1], + key : obj[2], + command : obj[3] }); + }; + }; + }; + { + var tmpArr9 = + [ [ 'new-icon', 'newCmd', 'new-key' ], + [ 'save-icon', 'saveCmd', 'save-key' ], + [ 'comment-button', 'commentCmd', 'review-key' ], + [ 'delete-btn', 'deleteCmd', 'delete-key' ], + [ 'open-icon', 'openCmd' ], [ 'reload-btn', 'reloadCmd' ], + [ 'clear-btn', 'clearCmd' ], [ 'new1', 'newCmd', 'new-key' ], + [ 'open1', 'openCmd' ], [ 'merge1', 'mergeCmd' ], + [ 'close2', 'closeCmd', 'close-key' ], + [ 'save1', 'saveCmd', 'save-key' ], [ 'save_as1', 'saveAsCmd' ], + [ 'export_html1', 'exportHTMLCmd' ], + [ 'export_xml1', 'exportXMLCmd' ], [ 'quit1', 'exitCmd' ], + [ 'mabAddBookmark', 'bookmarkCmd' ], [ 'reload1', 'reloadCmd' ], + [ 'load_reviews1', 'commentCmd', 'review-key' ], + [ 'load_similar_products1', 'simProductCmd' ], + [ 'delete_rows1', 'deleteCmd' ], + [ 'text_summary1', 'exportTXTCmd' ], + [ 'make_cd_cover1', 'makeCoverCmd' ], + [ 'reload_expired1', 'reloadExpiredCmd' ], + [ 'trash_all1', 'clearCmd' ], [ 'settings1', 'settingsCmd' ], + [ 'content1', 'topicsCmd' ], [ 'feedback1', 'feedbackCmd' ], + [ 'about1', 'aboutCmd' ], [ 'search-btn', 'newSearchCmd' ] ]; + if (tmpArr9) { + for (var tmpI10 = 0; tmpI10 < tmpArr9.length; tmpI10 = tmpI10 + 1) { + var obj = tmpArr9[tmpI10]; + var w = wget(obj[0]); + wsetp(w, 'command', obj[1]); + if (2 < obj.length) { + wsetp(w, 'key', obj[2]); + }; + }; + }; + }; + { + var tmpArr11 = + [ [ 'goAmazon-icon', 'goAmazonCmd', 'a' ], + [ 'addCart-icon', 'addCartCmd', 'd' ], + [ 'goGoogle-icon', 'goGoogleCmd', 'g' ], + [ 'goAmazon-button', 'goAmazonCmd', 'a' ], + [ 'addCart-button', 'addCartCmd', 'd' ], + [ 'next-btn', 'nextCmd', 'm' ] ]; + if (tmpArr11) { + for (var tmpI12 = 0; tmpI12 < tmpArr11.length; tmpI12 = tmpI12 + 1) { + var obj = tmpArr11[tmpI12]; + var w = wget(obj[0]); + wsetp(w, 'command', obj[1]); + wsetp(w, 'accesskey', obj[2]); + }; + }; + }; + { + var tmpArr13 = + [ [ 'none1', 'setLabel(\'none\')' ], + [ 'orange1', 'setLabel(\'Orange\')' ], + [ 'blue1', 'setLabel(\'Blue\')' ], + [ 'green1', 'setLabel(\'Green\')' ], + [ 'maroon1', 'setLabel(\'Maroon\')' ], + [ 'olive1', 'setLabel(\'Olive\')' ], + [ 'teal1', 'setLabel(\'Teal\')' ], + [ 'purple1', 'setLabel(\'Purple\')' ], + [ 'locale-popup', null, 'value' ], [ 'mode-popup', null, 'value' ], + [ 'search-popup', null, 'value' ], [ 'sort-popup', null, 'value' ] ]; + if (tmpArr13) { + for (var tmpI14 = 0; tmpI14 < tmpArr13.length; tmpI14 = tmpI14 + 1) { + var obj = tmpArr13[tmpI14]; + var w = wget(obj[0]); + if (obj[1]) { + wsetp(w, 'oncommand', obj[1]); + }; + if (obj[2]) { + wsetp(w, 'persist', obj[2]); + }; + }; + }; + }; + { + var tmpArr15 = + [ 'ProductName', 'Author', 'Manufacturer', 'ReleaseDate', 'ListPrice', + 'OurPrice', 'UsedPrice' ]; + if (tmpArr15) { + for (var tmpI16 = 0; tmpI16 < tmpArr15.length; tmpI16 = tmpI16 + 1) { + var obj = tmpArr15[tmpI16]; + wsetp(wget(obj), 'class', 'detail'); + }; + }; + }; + { + var w = wget('abort-icon'); + wsetp(w, 'keycode', 'VK_ESCAPE'); + wsetp(w, 'observes', 'isSearchRunning'); + }; + { + var w = wget('meter'); + wsetp(w, 'value', 0); + wsetp(w, 'mode', 'determined'); + }; + { + var tmpArr17 = [ 'isMabRemote', 'search-btn' ]; + if (tmpArr17) { + for (var tmpI18 = 0; tmpI18 < tmpArr17.length; tmpI18 = tmpI18 + 1) { + var n = tmpArr17[tmpI18]; + wsetp(wget(n), 'disabled', 'false'); + }; + }; + }; + { + var tmpArr19 = + [ 'locale-popup', 'mode-popup', 'search-popup', 'sort-popup' ]; + if (tmpArr19) { + for (var tmpI20 = 0; tmpI20 < tmpArr19.length; tmpI20 = tmpI20 + 1) { + var n = tmpArr19[tmpI20]; + var w = wget(n); + var tmpArr21 = w.childNodes[0].childNodes; + if (tmpArr21) { + for (var tmpI22 = 0; tmpI22 < tmpArr21.length; + tmpI22 = tmpI22 + 1) { + var w2 = tmpArr21[tmpI22]; + wsetp(w2, 'disabled', 'false'); + }; + }; + }; + }; + }; + wempty(wget('windows-menu_menu')); + var w = wget('result-tree'); + var h = wmake(w, 'xul:treecols'); + wsetp(w, 'enableColumnDrag', 'true'); + wsetp(w, 'onselect', 'showDetails()'); + { + var tmpArr23 = + [ { id : 'expired-col', + src : '../skin/images/expired.png', + label : 'Expired', + fixed : 'true', + hidden : 'true', + persist : 'ordinal hidden', + class : 'numeric treecol-image', + sortDirection : 'normal', + tooltiptext : 'Click to sort by expired products information', + onclick : 'sortResult(this,\'MABTSLastUpdate\')' }, + { id : 'status-col', + src : '../skin/images/status_unread.png', + label : 'Status', + fixed : 'true', + persist : 'ordinal hidden', + class : 'string treecol-image', + sortDirection : 'normal', + tooltiptext : 'Click to sort by read', + onclick : 'sortResult(this,\'MABStatus\')' }, + { id : 'name-col', + label : 'Product Name', + flex : '2', + persist : 'width ordinal', + class : 'string', + sortDirection : 'normal', + tooltiptext : 'Click to sort by product name', + onclick : 'sortResult(this,\'ProductName\')' }, + { id : 'catalog-col', + label : 'Catalog', + flex : '1', + persist : 'width ordinal hidden', + class : 'string', + sortDirection : 'normal', + tooltiptext : 'Click to sort by catalog', + onclick : 'sortResult(this,\'Catalog\')' }, + { id : 'locale-col', + label : 'Country', + flex : '1', + hidden : 'true', + persist : 'width ordinal hidden', + class : 'string', + sortDirection : 'normal', + tooltiptext : 'Click to sort by country', + onclick : 'sortResult(this,\'MABLocale\')' }, + { id : 'price-col', + label : 'Our Price', + flex : '1', + persist : 'width ordinal hidden', + class : 'numeric', + sortDirection : 'normal', + tooltiptext : 'Click to sort by our Price', + onclick : 'sortResult(this,\'OurPrice\')' }, + { id : 'used-price-col', + label : 'Used Price', + flex : '1', + persist : 'width ordinal hidden', + class : 'numeric', + sortDirection : 'normal', + tooltiptext : 'Click to sort by used Price', + onclick : 'sortResult(this,\'UsedPrice\')' }, + { id : 'rating-col', + label : 'Rating', + flex : '1', + hidden : 'true', + persist : 'width ordinal hidden', + class : 'numeric', + sortDirection : 'normal', + tooltiptext : 'Click to sort by customers rating', + onclick : 'sortResult(this,\'AvgCustomerRating\')' }, + { id : 'rank-col', + label : 'Rank', + flex : '1', + hidden : 'true', + persist : 'width ordinal hidden', + class : 'numeric', + sortDirection : 'normal', + tooltiptext : 'Click to sort by sales rank', + onclick : 'sortResult(this,\'SalesRank\')' }, + { id : 'released-col', + label : 'Released', + flex : '1', + hidden : 'true', + persist : 'width ordinal hidden', + class : 'date', + sortDirection : 'normal', + tooltiptext : 'Click to sort by released year', + onclick : 'sortResult(this,\'ReleaseDate\')' }, + { id : 'label-col', + src : '../skin/images/label.png', + label : 'Label', + flex : '1', + hidden : 'true', + persist : 'width ordinal hidden', + class : 'string treecol-image', + sortDirection : 'normal', + tooltiptext : 'Click to sort by your labels', + onclick : 'sortResult(this,\'MABLabel\')' } ]; + if (tmpArr23) { + for (var tmpI24 = 0; tmpI24 < tmpArr23.length; tmpI24 = tmpI24 + 1) { + var x = tmpArr23[tmpI24]; + wmake(h, 'xul:treecol', x); + wmake(h, 'xul:splitter', { class : 'tree-splitter' }); + }; + }; + }; + wmake + (w, 'xul:treechildren', + { id : 'list-tree', + flex : 1, + contextmenu : 'relatedcontext' }); +}; + +function initSettings() { + ; +}; + +WHANDLER['on_domain_changed'] = +function () { + myProductLineController.update(); +}; + +WHANDLER['on_catalog_changed'] = +function () { + myProductLineController.update(); +}; + +WHANDLER['on_abort'] = +function () { + ; +}; + +WHANDLER['on_change_help_page'] = +function () { + var wframe = wget('help-iframe'); + var wlist = wget('help-list'); + wsetp(wframe, 'src', wgetp(wlist.selectedItem, 'value')); +}; + diff --git a/mab/xul/mab.ls b/mab/xul/mab.ls @@ -0,0 +1,360 @@ +(defvar *loaded* 0) ;; onload counter + +(defhandler "on_allinfo_loaded" () + (incf *loaded*) + (when (< 2 *loaded*) ;; call original code, both iframes loaded + (main))) + +(defhandler "on_comment_loaded" () + (incf *loaded*) + (when (< 2 *loaded*) ;; call original code, both iframes loaded + (main))) + +(defun main2 () + (when (zerop *loaded*) + (incf *loaded*) + (wremove (wget "loading")) + (if window.name + (case window.name + ("Settings" + (load-xml "mab.glade" + (lambda (glade) + (let ((widgets (parse-glade glade))) + (wbuild document.document-element + (array (slot-value widgets "settings")))) + (init-settings)))) + ("About" + (load-xml "mab.glade" + (lambda (glade) + (let ((widgets (parse-glade glade))) + (wbuild document.document-element + (array (slot-value widgets "about")))) + #+nil(init)))) + ("Help" + (load-xml "mab.glade" + (lambda (glade) + (let ((widgets (parse-glade glade))) + (wbuild document.document-element + (array (slot-value widgets "helpWin")))) + #+nil(init))))) + (load-xml "mab.glade" + (lambda (glade) + (let ((widgets (parse-glade glade))) + (wbuild document.document-element + (array (slot-value widgets "amazWindow")))) + (init)))))) + +(defun settings-dialog () + #+nil(window.open-dialog "mab.xul" "Settings" + "chrome,centerscreen,modal,width=440,height=300" + settings) + (window.open "mab.xul" "Settings" + "chrome,centerscreen,modal,width=440,height=300")) + +(defun about-dialog () + (window.open "mab.xul" "About" + "chrome,centerscreen,modal,width=450,height=350")) + +(defun help-dialog () + (window.open "mab.xul" "Help" + "chrome,centerscreen,resizable,width=640,height=500")) + +(defun init () + (let ((w (wget "amazWindow")) + (cs (wmake w "xul:commandset" (create :id "mabCommand"))) + (ks (wmake w "xul:keyset")) + (ms (wmake cs "xul:commandset" (create :id "menubarCommand")))) + ;; Some buttons that have to be disabled in remote MAB + (wmake w "xul:broadcaster" (create :id "isSearchRunning" :disabled "true")) + (wmake w "xul:broadcaster" (create :id "isMabRemote" :disabled "false")) + ;; This invisible spacer is used to store preferences. In this way I + ;; can store preferences for remote and installed MAB version + (wmake w "xul:spacer" (create :id "settings-spacer" + :hidden "true" + :search "lite" + :nr-result 20 + :persist "search nrResult")) + (dolist (obj (list (list "newSearchCmd" "newSearch()") + (list "nextCmd" "nextRecord()") + (list "clearCmd" "clearAll()") + (list "commentCmd" "getComment()") + (list "goAmazonCmd" "goAmazon()") + (list "addCartCmd" "addCart()") + (list "goGoogleCmd" "goGoogle()") + (list "deleteCmd" "deleteRow()"))) + (wmake cs "xul:command" (create :id (aref obj 0) + :oncommand (aref obj 1)))) + (dolist (obj (list (list "newCmd" "newDoc()") + (list "openCmd" "openDoc('open')" "isMabRemote") + (list "closeCmd" "closeDoc()") + (list "mergeCmd" "openDoc('merge')" "isMabRemote") + (list "saveCmd" "saveDoc()" "isMabRemote") + (list "saveAsCmd" "saveAsDoc()" "isMabRemote") + (list "exportXMLCmd" "exportXMLDoc()") + (list "exportHTMLCmd" "exportHTMLDoc()") + (list "exportTXTCmd" "exportTXTDoc()") + (list "makeCoverCmd" "openCoverWin()") + (list "exitCmd" "window.close()") + (list "simProductCmd" "getSimilarProducts()") + (list "reloadExpiredCmd" "reloadExpired()") + (list "reloadCmd" "reload()") + (list "abortCmd" "abort()") + (list "bookmarkCmd" "addBookmark()") + ;;(list "settingsCmd" "window.open('settings.xul','Settings','chrome,centerscreen,modal,width=440,height=300');") + (list "settingsCmd" "settingsDialog()") + ;;(list "topicsCmd" "window.open('help.xul','Help','chrome,centerscreen,resizable,width=640,height=500');") + (list "topicsCmd" "helpDialog()") + (list "feedbackCmd" "window.open(MAB_FEEDBACK_PAGE)") + ;;(list "aboutCmd" "window.open('about.xul','About','chrome,centerscreen,modal,width=450,height=350');"))) + (list "aboutCmd" "aboutDialog()"))) + (wmake ms "xul:command" (create :id (aref obj 0) + :oncommand (aref obj 1) + :observes (when (< 2 (length obj)) + (aref obj 2))))) + (dolist (obj (list (list "search-key" "VK_RETURN" "newSearchCmd") + (list "search-key" "VK_ENTER" "newSearchCmd") + (list "deleteKey" "VK_DELETE" "deleteCmd"))) + (wmake ks "xul:key" (create :id (aref obj 0) + :keycode (aref obj 1) + :command (aref obj 2)))) + (dolist (obj (list (list "new-key" "accel" "n" "newCmd") + (list "close-key" "accel" "w" "closeCmd") + (list "save-key" "accel" "s" "saveCmd") + (list "review-key" "accel" "r" "commentCmd"))) + (wmake ks "xul:key" (create :id (aref obj 0) + :modifiers (aref obj 1) + :key (aref obj 2) + :command (aref obj 3))))) + ;; now set up existing widgets + (dolist (obj (list (list "new-icon" "newCmd" "new-key") + (list "save-icon" "saveCmd" "save-key") + (list "comment-button" "commentCmd" "review-key") + (list "delete-btn" "deleteCmd" "delete-key") + (list "open-icon" "openCmd") + (list "reload-btn" "reloadCmd") + (list "clear-btn" "clearCmd") + ;; menuitems + (list "new1" "newCmd" "new-key") + (list "open1" "openCmd") + (list "merge1" "mergeCmd") + (list "close2" "closeCmd" "close-key") + (list "save1" "saveCmd" "save-key") + (list "save_as1" "saveAsCmd") + (list "export_html1" "exportHTMLCmd") + (list "export_xml1" "exportXMLCmd") + (list "quit1" "exitCmd") + (list "mabAddBookmark" "bookmarkCmd") + (list "reload1" "reloadCmd") + (list "load_reviews1" "commentCmd" "review-key") + (list "load_similar_products1" "simProductCmd") + (list "delete_rows1" "deleteCmd") + (list "text_summary1" "exportTXTCmd") + (list "make_cd_cover1" "makeCoverCmd") + (list "reload_expired1" "reloadExpiredCmd") + (list "trash_all1" "clearCmd") + (list "settings1" "settingsCmd") + (list "content1" "topicsCmd") + (list "feedback1" "feedbackCmd") + (list "about1" "aboutCmd") + ;; buttons + (list "search-btn" "newSearchCmd"))) + (let ((w (wget (aref obj 0)))) + (wsetp w "command" (aref obj 1)) + (when (< 2 (length obj)) + (wsetp w "key" (aref obj 2))))) + (dolist (obj (list (list "goAmazon-icon" "goAmazonCmd" "a") + (list "addCart-icon" "addCartCmd" "d") + (list "goGoogle-icon" "goGoogleCmd" "g") + (list "goAmazon-button" "goAmazonCmd" "a") + (list "addCart-button" "addCartCmd" "d") + (list "next-btn" "nextCmd" "m"))) + (let ((w (wget (aref obj 0)))) + (wsetp w "command" (aref obj 1)) + (wsetp w "accesskey" (aref obj 2)))) + (dolist (obj (list (list "none1" "setLabel('none')") + (list "orange1" "setLabel('Orange')") + (list "blue1" "setLabel('Blue')") + (list "green1" "setLabel('Green')") + (list "maroon1" "setLabel('Maroon')") + (list "olive1" "setLabel('Olive')") + (list "teal1" "setLabel('Teal')") + (list "purple1" "setLabel('Purple')") + ;; combo boxes + (list "locale-popup" + nil ;;"myProductLineController.update()" + "value") + (list "mode-popup" + nil ;;"myProductLineController.update()" + "value") + (list "search-popup" nil "value") + (list "sort-popup" nil "value"))) + (let ((w (wget (aref obj 0)))) + (when (aref obj 1) + ;;(alert (+ w " " (aref obj 1))) + (wsetp w "oncommand" (aref obj 1))) ;; oncommand + (when (aref obj 2) + (wsetp w "persist" (aref obj 2))))) + (dolist (obj (list "ProductName" "Author" "Manufacturer" "ReleaseDate" + "ListPrice" "OurPrice" "UsedPrice")) + (wsetp (wget obj) "class" "detail")) + (let ((w (wget "abort-icon"))) + ;;(wsetp w "oncommand" " ") ;; TODO override on_abort oncommand + (wsetp w "keycode" "VK_ESCAPE") + (wsetp w "observes" "isSearchRunning")) + (let ((w (wget "meter"))) + (wsetp w "value" 0) + (wsetp w "mode" "determined")) + ;; set disabled to false (due to some hack in original code?) + (dolist (n (list "isMabRemote" "search-btn")) + (wsetp (wget n) "disabled" "false")) + (dolist (n (list "locale-popup" "mode-popup" "search-popup" "sort-popup")) + (let ((w (wget n))) + ;; each menupopup/menuitem + (dolist (w2 (slot-value (aref w.child-nodes 0) 'child-nodes)) + (wsetp w2 "disabled" "false")))) + ;; remove dummy menu item added in glade to create windows-menu_menu + (wempty (wget "windows-menu_menu")) + ;; TODO build tree + (let ((w (wget "result-tree")) + (h (wmake w "xul:treecols"))) + (wsetp w "enableColumnDrag" "true") + (wsetp w "onselect" "showDetails()") + (dolist (x (list + (create + :id "expired-col" + :src "../skin/images/expired.png" + :label "Expired" + :fixed "true" + :hidden "true" + :persist "ordinal hidden" + :class "numeric treecol-image" + :sort-direction "normal" + :tooltiptext "Click to sort by expired products information" + :onclick "sortResult(this,'MABTSLastUpdate')") + (create + :id "status-col" + :src "../skin/images/status_unread.png" + :label "Status" + :fixed "true" + :persist "ordinal hidden" + :class "string treecol-image" + :sort-direction "normal" + :tooltiptext "Click to sort by read" + :onclick "sortResult(this,'MABStatus')") + (create + :id "name-col" + :label "Product Name" + :flex "2" + :persist "width ordinal" + :class "string" + :sort-direction "normal" + :tooltiptext "Click to sort by product name" + :onclick "sortResult(this,'ProductName')") + (create + :id "catalog-col" + :label "Catalog" + :flex "1" + :persist "width ordinal hidden" + :class "string" + :sort-direction "normal" + :tooltiptext "Click to sort by catalog" + :onclick "sortResult(this,'Catalog')") + (create + :id "locale-col" + :label "Country" + :flex "1" + :hidden "true" + :persist "width ordinal hidden" + :class "string" + :sort-direction "normal" + :tooltiptext "Click to sort by country" + :onclick "sortResult(this,'MABLocale')") + (create + :id "price-col" + :label "Our Price" + :flex "1" + :persist "width ordinal hidden" + :class "numeric" + :sort-direction "normal" + :tooltiptext "Click to sort by our Price" + :onclick "sortResult(this,'OurPrice')") + (create + :id "used-price-col" + :label "Used Price" + :flex "1" + :persist "width ordinal hidden" + :class "numeric" + :sort-direction "normal" + :tooltiptext "Click to sort by used Price" + :onclick "sortResult(this,'UsedPrice')") + (create + :id "rating-col" + :label "Rating" + :flex "1" + :hidden "true" + :persist "width ordinal hidden" + :class "numeric" + :sort-direction "normal" + :tooltiptext "Click to sort by customers rating" + :onclick "sortResult(this,'AvgCustomerRating')") + (create + :id "rank-col" + :label "Rank" + :flex "1" + :hidden "true" + :persist "width ordinal hidden" + :class "numeric" + :sort-direction "normal" + :tooltiptext "Click to sort by sales rank" + :onclick "sortResult(this,'SalesRank')") + (create + :id "released-col" + :label "Released" + :flex "1" + :hidden "true" + :persist "width ordinal hidden" + :class "date" + :sort-direction "normal" + :tooltiptext "Click to sort by released year" + :onclick "sortResult(this,'ReleaseDate')") + (create + :id "label-col" + :src "../skin/images/label.png" + :label "Label" + :flex "1" + :hidden "true" + :persist "width ordinal hidden" + :class "string treecol-image" + :sort-direction "normal" + :tooltiptext "Click to sort by your labels" + :onclick "sortResult(this,'MABLabel')"))) + (wmake h "xul:treecol" x) + ;; TODO splitter even for the last one??? + (wmake h "xul:splitter" (create :class "tree-splitter"))) + (wmake w "xul:treechildren" (create :id "list-tree" + :flex 1 + :contextmenu "relatedcontext"))) + ;; fix DocOpenManager;-( + #+nil(setf *doc-open-manager.prototype.win-popup (wget "windows-popup_menu"))) + +(defun init-settings () + ;; TODO + #+nil(let ((w (wget "settings-header"))) + (wadda w.parent-node + (wmake h "xul:dialogheader" (create :title (wgetp w "value")))) + (wremove w))) + +(defhandler "on_domain_changed" () + (my-product-line-controller.update)) + +(defhandler "on_catalog_changed" () + (my-product-line-controller.update)) + +(defhandler "on_abort" () + ;; empty handler, handler by observes/command + ) + +(defhandler "on_change_help_page" () + (let ((wframe (wget "help-iframe")) + (wlist (wget "help-list"))) + (wsetp wframe "src" (wgetp wlist.selected-item "value")))) diff --git a/mab/xul/mab.xul b/mab/xul/mab.xul @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> +<?xml-stylesheet href="mab.css" type="text/css"?> +<window + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + onload="main2()"> +<script src="js/ProductLine.js" type="application/x-javascript"/> +<script src="js/ProductLineController.js" type="application/x-javascript"/> +<script src="js/DisplayController.js" type="application/x-javascript"/> +<script src="js/SearchController.js" type="application/x-javascript"/> +<script src="js/SearchHistory.js" type="application/x-javascript"/> +<script src="js/ProgressBar.js" type="application/x-javascript"/> +<script src="js/QueryStringBuilder.js" type="application/x-javascript"/> +<script src="js/Connection.js" type="application/x-javascript"/> +<script src="js/FileManager.js" type="application/x-javascript"/> +<script src="js/AmazonParser.js" type="application/x-javascript"/> +<script src="js/XMDManager.js" type="application/x-javascript"/> +<script src="js/DocOpenManager.js" type="application/x-javascript"/> +<script src="js/config.js" type="application/x-javascript"/> +<script src="js/utils.js" type="application/x-javascript"/> +<script src="js/mab.js" type="application/x-javascript"/> +<script src="../../webglade.js" type="application/x-javascript"/> +<script src="mab.js" type="application/x-javascript"/> +<label id="loading" value="Loading..."/> +<!--noscript>Please turn on JavaScript</noscript--> +</window> diff --git a/webglade.js b/webglade.js @@ -0,0 +1,1007 @@ +function member(item, lst) { + if (lst) { + var tmpArr1 = lst; + if (tmpArr1) { + for (var tmpI2 = 0; tmpI2 < tmpArr1.length; tmpI2 = tmpI2 + 1) { + var i = tmpArr1[tmpI2]; + if (i == item) { + return true; + }; + }; + }; + }; +}; + +function pop(place) { + return place.pop(); +}; + +function push(item, place) { + place.push(item); +}; + +function pushnew(item, place) { + if (!member(item, place)) { + push(item, place); + }; + return place; +}; + +function object2alist(obj) { + if (obj && 'object' == typeof obj && !obj.length) { + var result = [ ]; + for (var i in obj) { + push(cons(i, obj[i]), result); + }; + return result; + }; +}; + +function copySeq(seq) { + if (seq) { + var result = [ ]; + { + var tmpArr3 = seq; + if (tmpArr3) { + for (var tmpI4 = 0; tmpI4 < tmpArr3.length; tmpI4 = tmpI4 + 1) { + var i = tmpArr3[tmpI4]; + push(i, result); + }; + }; + }; + return result; + }; +}; + +function nreverse(seq) { + if (seq) { + return seq.reverse(); + }; +}; + +function reverse(seq) { + return nreverse(copySeq(seq)); +}; + +function sort(sequence, predicate) { + sequence.sort(function (x, y) { + return predicate(x, y) ? -1 : 1; + }); + return sequence; +}; + +var ns = + { 'xul' : 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', + 'html' : 'http://www.w3.org/1999/xhtml' }; + +function wget(id, doc) { + return doc ? doc.getElementById(id) : document.getElementById(id); +}; + +var WHANDLER = { }; + +function whandler(sig) { + if (sig) { + var h = WHANDLER[sig]; + if (h) { + return h; + } else { + return function (e) { + alert('Unhandled event ' + sig + '.'); + }; + }; + }; +}; + +function wgetp(w, prop) { + return w[prop]; +}; + +function wsetp(w, prop, value) { + w.setAttribute(prop, value); + return value; +}; + +function wgets(w, style) { + return w.style[style]; +}; + +function wsets(w, style, value) { + w.style[style] = value; + return value; +}; + +function wsete(w, event, handler, useCapture) { + w.addEventListener(event, handler, useCapture ? true : false); +}; + +function wunsete(w, event, handler, useCapture) { + w.removeEventListener(event, handler, useCapture ? true : false); +}; + +function wmake(pw, tag, props, sigs) { + if (tag == 'string') { + var w = document.createTextNode(props); + if (pw) { + pw.appendChild(w); + }; + return w; + } else { + var w = + tag.match('^xul:') ? + document.createElementNS(ns.xul, tag.substring(4)) : + document.createElementNS(ns.html, tag); + if (pw) { + pw.appendChild(w); + }; + if (props) { + for (var i in props) { + if (undefined != props[i]) { + wsetp(w, i, props[i]); + }; + }; + }; + if (sigs) { + for (var i in sigs) { + if (undefined != sigs[i]) { + wsete(w, i, whandler(sigs[i])); + }; + }; + }; + return w; + }; +}; + +function wadda(w, child) { + w.firstChild().insertBefore(child); + return child; +}; + +function waddz(w, child) { + w.appendChild(child); + return child; +}; + +function wreplace(w, ow, nw) { + w.replaceChild(nw, ow); + return nw; +}; + +function wshow(w) { + wsets(w, 'visibility', 'visible'); + wsets(w, 'display', ''); +}; + +function whide(w) { + wsets(w, 'visibility', 'hidden'); + wsets(w, 'display', 'none'); +}; + +function changeVisibility(w, show) { + if (show) { + wshow(w); + } else { + whide(w); + }; +}; + +function toggleVisibility(w) { + if ('hidden' == wgets(w, 'visibility')) { + wshow(w); + } else { + whide(w); + }; +}; + +function wempty(w) { + if (w.hasChildNodes()) { + var tmpArr5 = w.childNodes; + if (tmpArr5) { + for (var tmpI6 = 0; tmpI6 < tmpArr5.length; tmpI6 = tmpI6 + 1) { + var child = tmpArr5[tmpI6]; + w.removeChild(child); + }; + }; + }; +}; + +function wremove(w) { + w.parentNode.removeChild(w); +}; + +function xmlToString(doc) { + var s = new XMLSerializer(); + return s.serializeToString(doc); +}; + +function loadXml(url, callback) { + if (window.ActiveXObject) { + var doc = new ActiveXObject('Microsoft.XMLDOM'); + doc.async = false; + doc.load(url); + callback(doc); + } else { + if (document.implementation && document.implementation.createDocument) { + var doc = document.implementation.createDocument('', '', null); + doc.onload = + function () { + callback(doc); + }; + doc.load(url); + } else { + alert('Your browser cannot handle this script.'); + }; + }; +}; + +var WBUILD = { }; + +var WPACK = { }; + +function wclass(widget) { + if (widget.class == 'Custom') { + return getProperty(widget, 'creation_function'); + } else { + return widget.class; + }; +}; + +function parseGlade(glade) { + var widgets = { }; + { + var attrs = + function (node) { + var name = node.getAttribute('name'); + var value = + node.childNodes[0] ? node.childNodes[0].nodeValue : undefined; + var result = { name : name }; + if (value) { + result.value = value; + }; + { + var tmpArr7 = node.attributes; + if (tmpArr7) { + for (var tmpI8 = 0; tmpI8 < tmpArr7.length; + tmpI8 = tmpI8 + 1) { + var a = tmpArr7[tmpI8]; + result[a.nodeName] = a.nodeValue; + }; + }; + }; + return result; + }; + var recWidget = + function (parent, node) { + var id = node.getAttribute('id'); + var class = node.getAttribute('class'); + var widget = + { id : id, + parent : parent, + children : [ ], + class : class, + property : { }, + signal : { }, + packing : { } }; + if (parent) { + pushnew(widget, parent.children); + }; + widgets[id] = widget; + rec(widget, node.childNodes); + return widget; + }; + var recChild = + function (parent, node) { + var current = null; + var tmpArr9 = node.childNodes; + if (tmpArr9) { + for (var tmpI10 = 0; tmpI10 < tmpArr9.length; + tmpI10 = tmpI10 + 1) { + var child = tmpArr9[tmpI10]; + switch (child.tagName) { + case 'widget': + current = recWidget(parent, child); + break; + case 'packing': recPacking(parent, child, current); + }; + }; + }; + }; + var recProperty = + function (parent, node) { + var as = attrs(node); + parent.property[as.name] = as; + }; + var recSignal = + function (parent, node) { + var as = attrs(node); + parent.signal[as.name] = as; + }; + var recPacking = + function (parent, node, current) { + var tmpArr11 = node.childNodes; + if (tmpArr11) { + for (var tmpI12 = 0; tmpI12 < tmpArr11.length; + tmpI12 = tmpI12 + 1) { + var child = tmpArr11[tmpI12]; + if ('property' == child.tagName) { + var as = attrs(child); + current.packing[as.name] = as; + }; + }; + }; + }; + var rec = + function (parent, nodes, current) { + var tmpArr13 = nodes; + if (tmpArr13) { + for (var tmpI14 = 0; tmpI14 < tmpArr13.length; + tmpI14 = tmpI14 + 1) { + var node = tmpArr13[tmpI14]; + switch (node.tagName) { + case 'glade-interface': + rec(parent, node.childNodes); + break; + case 'widget': + recWidget(parent, node); + break; + case 'child': + recChild(parent, node); + break; + case 'property': + recProperty(parent, node); + break; + case 'signal': + recSignal(parent, node); + break; + case 'packing': recPacking(parent, node, current); + }; + }; + }; + }; + rec(null, [ glade.documentElement ]); + }; + return widgets; +}; + +function wbuild(pw, widgets) { + var result = null; + { + var tmpArr15 = widgets; + if (tmpArr15) { + for (var tmpI16 = 0; tmpI16 < tmpArr15.length; tmpI16 = tmpI16 + 1) { + var widget = tmpArr15[tmpI16]; + var fbuild = WBUILD[wclass(widget)]; + var fpack = + widget && widget.parent ? WPACK[wclass(widget.parent)] : + undefined; + var w = + fbuild ? fbuild(pw, widget) : + wmake + (pw, 'string', '{ ' + wclass(widget) + ' not implemented! }'); + if (fpack) { + fpack(pw, w, widget); + }; + result = w; + }; + }; + }; + return result; +}; + +function getProperty(widget, name) { + var it = widget.property[name]; + if (it) { + return it.value; + }; +}; + +function getSignal(widget, name) { + var it = widget.signal[name]; + if (it) { + return it.handler; + }; +}; + +function getPacking(widget, name) { + var it = widget.packing[name]; + if (it) { + return it.value; + }; +}; + +WBUILD['GtkWindow'] = +function (pw, self) { + var title = getProperty(self, 'title'); + if ('window' == pw.tagName) { + wsetp(pw, 'id', self.id); + wsetp(pw, 'title', title); + wbuild(pw, self.children); + return pw; + } else { + var w = + wmake + (pw, 'xul:window', + { id : self.id, + title : title }); + wbuild(w, self.children); + return w; + }; +}; + +WPACK['GtkWindow'] = +function (pw, w, self) { + var resizable = 'True' == getProperty(self.parent, 'resizable'); + if (resizable) { + wsetp(w, 'flex', 1); + }; +}; + +WBUILD['GtkDialog'] = +function (pw, self) { + return WBUILD['GtkWindow'](pw, self); +}; + +WPACK['GtkDialog'] = +function (pw, w, self) { + return WPACK['GtkWindow'](pw, w, self); +}; + +WBUILD['GtkButton'] = +function (pw, self) { + var tooltip = getProperty(self, 'tooltip'); + var label = getProperty(self, 'label'); + var sensitive = getProperty(self, 'sensitive'); + var clicked = getSignal(self, 'clicked'); + var w = + wmake + (pw, 'xul:button', + { id : self.id, + tooltip : tooltip, + disabled : 'False' == sensitive, + label : label }, + { command : clicked }); + wbuild(w, self.children); + return w; +}; + +WBUILD['GtkCheckButton'] = +function (pw, self) { + var active = getProperty(self, 'active'); + var label = getProperty(self, 'label'); + var toggled = getSignal(self, 'toggled'); + return wmake + (pw, 'xul:checkbox', + { id : self.id, + checked : active ? true : undefined, + label : label }, + { command : toggled }); +}; + +WBUILD['GtkLabel'] = +function (pw, self) { + var label = getProperty(self, 'label'); + return wmake + (pw, 'xul:label', + { id : self.id, + value : label }); +}; + +WBUILD['GtkEntry'] = +function (pw, self) { + var text = getProperty(self, 'text'); + var tooltip = getProperty(self, 'tooltip'); + var editable = getProperty(self, 'editable'); + var changed = getSignal(self, 'changed'); + return wmake + (pw, 'xul:textbox', + { id : self.id, + value : text, + tooltip : tooltip, + readonly : 'False' == editable ? true : undefined }, + { change : changed }); +}; + +WBUILD['GtkTextView'] = +function (pw, self) { + var text = getProperty(self, 'text'); + var tooltip = getProperty(self, 'tooltip'); + var editable = getProperty(self, 'editable'); + var changed = getSignal(self, 'changed'); + return wmake + (pw, 'xul:textbox', + { id : self.id, + value : text, + tooltip : tooltip, + readonly : 'False' == editable ? true : undefined, + multiline : true }, + { change : changed }); +}; + +WBUILD['GtkFrame'] = +function (pw, self) { + var w = wmake(pw, 'xul:groupbox', { id : self.id }); + var w2 = wmake(w, 'xul:caption'); + var label = [ ]; + var body = [ ]; + { + var tmpArr17 = self.children; + if (tmpArr17) { + for (var tmpI18 = 0; tmpI18 < tmpArr17.length; tmpI18 = tmpI18 + 1) { + var child = tmpArr17[tmpI18]; + if ('label_item' == getPacking(child, 'type')) { + push(child, label); + } else { + push(child, body); + }; + }; + }; + }; + wbuild(w2, label); + wbuild(w, body); +}; + +WBUILD['GtkAlignment'] = +function (pw, self) { + wbuild(pw, self.children); +}; + +WBUILD['GtkComboBox'] = +function (pw, self) { + var items = getProperty(self, 'items'); + var changed = getSignal(self, 'changed'); + var w = + wmake(null, 'xul:menulist', { id : self.id }, { command : changed }); + var w2 = wmake(w, 'xul:menupopup'); + var n = 0; + if (items) { + var tmpArr19 = items.split('\n'); + if (tmpArr19) { + for (var tmpI20 = 0; tmpI20 < tmpArr19.length; + tmpI20 = tmpI20 + 1) { + var item = tmpArr19[tmpI20]; + { + var pair = item.split('|'); + wmake + (w2, 'xul:menuitem', + { value : pair[0], + label : pair[1] || pair[0] }); + }; + ++n; + }; + }; + }; + waddz(pw, w); + return w; +}; + +WBUILD['GtkMenuBar'] = +function (pw, self) { + var w = wmake(null, 'xul:menubar', { id : self.id }); + wbuild(w, self.children); + waddz(pw, w); + return w; +}; + +WBUILD['GtkMenu'] = +function (pw, self) { + var w = wmake(pw, 'xul:menupopup', { id : self.id }); + wbuild(w, self.children); + return w; +}; + +WBUILD['GtkSeparatorMenuItem'] = +function (pw, self) { + return wmake(pw, 'xul:menuseparator', { id : self.id }); +}; + +function findAccessKey(str) { + var pos = str.indexOf('_'); + if (pos >= 0) { + return str[pos + 1]; + }; +}; + +function removeAccessKey(str) { + return str.replace('_', ''); +}; + +WBUILD['GtkMenuItem'] = +function (pw, self) { + var label = getProperty(self, 'label'); + var activate = getSignal(self, 'activate'); + if ('GtkMenuBar' == wclass(self.parent) || 0 < self.children.length) { + var w = + wmake + (pw, 'xul:menu', + { id : self.id, + label : removeAccessKey(label), + accesskey : findAccessKey(label) }, + { command : activate }); + if (0 < self.children.length) { + wbuild(w, self.children); + } else { + wmake(w, 'xul:menupopup'); + }; + return w; + } else { + return wmake + (pw, 'xul:menuitem', + { id : self.id, + label : removeAccessKey(label), + accesskey : findAccessKey(label) }, + { command : activate }); + }; +}; + +WBUILD['GtkHBox'] = +function (pw, self) { + var w = + wmake + (pw, 'xul:hbox', + { id : self.id, + align : 'center' }); + wbuild(w, self.children); + return w; +}; + +WPACK['GtkHBox'] = +function (pw, w, self) { + var padding = getPacking(self, 'padding'); + var expand = getPacking(self, 'expand'); + var fill = getPacking(self, 'fill'); + var pack_type = getPacking(self, 'pack_type'); + if ('True' == expand) { + wsetp(w, 'flex', 1); + }; +}; + +WBUILD['GtkVBox'] = +function (pw, self) { + var w = wmake(pw, 'xul:vbox', { id : self.id }); + wbuild(w, self.children); + return w; +}; + +WPACK['GtkVBox'] = +function (pw, w, self) { + var padding = getPacking(self, 'padding'); + var expand = getPacking(self, 'expand'); + var fill = getPacking(self, 'fill'); + var pack_type = getPacking(self, 'pack_type'); + if ('True' == expand) { + wsetp(w, 'flex', 1); + }; +}; + +WBUILD['GtkHButtonBox'] = +function (pw, self) { + var w = wmake(pw, 'xul:hbox', { id : self.id }); + wbuild(w, self.children); + return w; +}; + +WBUILD['GtkVButtonBox'] = +function (pw, self) { + var w = wmake(pw, 'xul:vbox', { id : self.id }); + wbuild(w, self.children); + return w; +}; + +WBUILD['GtkHSeparator'] = +function (pw, self) { + return wmake + (pw, 'xul:separator', + { id : self.id, + orient : 'horizontal', + class : 'groove' }); +}; + +WBUILD['GtkVSeparator'] = +function (pw, self) { + return wmake + (pw, 'xul:separator', + { id : self.id, + orient : 'vertical', + class : 'groove' }); +}; + +WBUILD['GtkHPaned'] = +function (pw, self) { + var w = wmake(pw, 'xul:hbox', { id : self.id }); + var left = self.children[0]; + var right = self.children[1]; + wbuild(w, [ left ]); + { + var w2 = wmake(w, 'xul:splitter', { id : self.id + '-splitter' }); + wmake(w2, 'xul:grippy', { id : self.id + '-grippy' }); + }; + wbuild(w, [ right ]); + return w; +}; + +WPACK['GtkHPaned'] = +function (pw, w, self) { + var shrink = getPacking(self, 'shrink'); + var resize = getPacking(self, 'resize'); + if ('True' == resize) { + wsetp(w, 'flex', 1); + }; +}; + +WBUILD['GtkVPaned'] = +function (pw, self) { + var w = wmake(pw, 'xul:vbox', { id : self.id }); + var top = self.children[0]; + var bottom = self.children[1]; + wbuild(w, [ top ]); + { + var w2 = wmake(w, 'xul:splitter', { resizeafter : 'grow' }); + wmake(w2, 'xul:grippy'); + }; + wbuild(w, [ bottom ]); + return w; +}; + +WPACK['GtkVPaned'] = +function (pw, w, self) { + var shrink = getPacking(self, 'shrink'); + var resize = getPacking(self, 'resize'); +}; + +WBUILD['GtkNotebook'] = +function (pw, self) { + var tabs = [ ]; + var bodies = [ ]; + { + var tmpArr21 = self.children; + if (tmpArr21) { + for (var tmpI22 = 0; tmpI22 < tmpArr21.length; tmpI22 = tmpI22 + 1) { + var child = tmpArr21[tmpI22]; + if ('tab' == getPacking(child, 'type')) { + push(child, tabs); + } else { + push(child, bodies); + }; + }; + }; + }; + var w = wmake(null, 'xul:tabbox', { id : self.id }); + var w2 = wmake(w, 'xul:tabs'); + var w3 = wmake(w, 'xul:tabpanels', { flex : 1 }); + { + var tmpArr23 = tabs; + if (tmpArr23) { + for (var tmpI24 = 0; tmpI24 < tmpArr23.length; tmpI24 = tmpI24 + 1) { + var tab = tmpArr23[tmpI24]; + var w4 = wmake(w2, 'xul:tab'); + if ('GtkLabel' == tab.class) { + wsetp(w4, 'label', tab.property.label.value); + } else { + wbuild(w4, [ tab ]); + }; + }; + }; + }; + { + var tmpArr25 = bodies; + if (tmpArr25) { + for (var tmpI26 = 0; tmpI26 < tmpArr25.length; tmpI26 = tmpI26 + 1) { + var body = tmpArr25[tmpI26]; + var w5 = wmake(w3, 'xul:tabpanel'); + wbuild(w5, [ body ]); + }; + }; + }; + waddz(pw, w); + return w; +}; + +WPACK['GtkNotebook'] = +function (pw, w, self) { + var type = getPacking(self, 'type'); + var expand = 'True' == getPacking(self, 'tab_expand'); + var fill = 'True' == getPacking(self, 'tab_fill'); + if ('tab' != type) { + wsetp(w, 'flex', 1); + }; +}; + +WBUILD['GtkToolbar'] = +function (pw, self) { + var w = + wmake + (pw, 'xul:toolbar', + { id : self.id, + align : 'center' }); + wbuild(w, self.children); + return w; +}; + +WPACK['GtkToolbar'] = +function (pw, w, self) { + var expand = getPacking(self, 'expand'); + var homogeneous = getPacking(self, 'homogeneous'); + if ('True' == expand) { + wsetp(w, 'flex', 1); + }; +}; + +WBUILD['GtkToolItem'] = +function (pw, self) { + var w = wmake(pw, 'xul:toolbaritem', { id : self.id }); + wbuild(w, self.children); + return w; +}; + +WBUILD['GtkSeparatorToolItem'] = +function (pw, self) { + var w = wmake(pw, 'xul:toolbarseparator', { id : self.id }); + wbuild(w, self.children); + return w; +}; + +function imageUrl(url) { + if (url) { + return 'images/' + url; + }; +}; + +WBUILD['GtkToolButton'] = +function (pw, self) { + var label = getProperty(self, 'label'); + var icon = getProperty(self, 'icon'); + var tooltip = getProperty(self, 'tooltip'); + var clicked = getSignal(self, 'clicked'); + var showLabel = true; + var showImage = true; + return wmake + (pw, 'xul:toolbarbutton', + { id : self.id, + label : showLabel ? label : undefined, + image : showImage ? imageUrl(icon) : undefined, + tooltiptext : tooltip }, + { command : clicked }); +}; + +WBUILD['GtkImage'] = +function (pw, self) { + var pixbuf = getProperty(self, 'pixbuf'); + return wmake + (pw, 'xul:image', + { id : self.id, + src : imageUrl(pixbuf) }); +}; + +WBUILD['GtkProgressBar'] = +function (pw, self) { + return wmake + (pw, 'xul:progressmeter', + { id : self.id, + mode : 'determined' }); +}; + +WBUILD['GtkStatusbar'] = +function (pw, self) { + return wmake + (pw, 'xul:statusbarpanel', + { id : self.id, + flex : 1 }); +}; + +function scan(regexp, string) { + if (string) { + return string.match(regexp); + }; +}; + +WBUILD['GtkTable'] = +function (pw, self) { + var nRows = getProperty(self, 'n_rows'); + var nColumns = getProperty(self, 'n_columns'); + var rowSpacing = getProperty(self, 'row_spacing'); + var columnSpacing = getProperty(self, 'column_spacing'); + var homogeneous = 'True' == getProperty(self, 'homogeneous'); + var earlier = + function (x, y) { + var xleft = getPacking(x, 'left_attach'); + var xright = getPacking(x, 'right_attach'); + var xtop = getPacking(x, 'top_attach'); + var xbottom = getPacking(x, 'bottom_attach'); + var yleft = getPacking(y, 'left_attach'); + var yright = getPacking(y, 'right_attach'); + var ytop = getPacking(y, 'top_attach'); + var ybottom = getPacking(y, 'bottom_attach'); + return xtop < ytop || xtop == ytop && xleft < yleft; + }; + var getfcols = + function (sorted) { + if (!homogeneous) { + var fcols = [ ]; + var sorted = copySeq(sorted); + var child = pop(sorted); + for (var row = 0; row < nRows; row = row + 1) { + for (var col = 0; col < nColumns; col = col + 1) { + var left = getPacking(child, 'left_attach'); + var right = getPacking(child, 'right_attach'); + var top = getPacking(child, 'top_attach'); + var bottom = getPacking(child, 'bottom_attach'); + var xOptions = getPacking(child, 'x_options'); + if (top == row && left == col) { + if (null == child.packing.x_options || scan('expand', xOptions)) { + for (var i = 0; i < (right - left) + 1; + i = i + 1) { + pushnew(col, fcols); + }; + }; + child = pop(sorted); + }; + }; + }; + return fcols; + }; + }; + var nRows = getProperty(self, 'n_rows'); + var nColumns = getProperty(self, 'n_columns'); + var rowSpacing = getProperty(self, 'row_spacing'); + var columnSpacing = getProperty(self, 'column_spacing'); + var homogeneous = 'True' == getProperty(self, 'homogeneous'); + var sorted = reverse(sort(copySeq(self.children), earlier)); + var fcols = getfcols(sorted); + var w = wmake(pw, 'xul:grid', { id : self.id }); + var w2 = wmake(w, 'xul:columns'); + var w3 = wmake(w, 'xul:rows'); + for (var col = 0; col < nColumns; col = col + 1) { + wmake + (w2, 'xul:column', + { flex : homogeneous || member(col, fcols) ? 1 : undefined }); + }; + { + var child = pop(sorted); + for (var row = 0; row < nRows; row = row + 1) { + var w4 = wmake(w3, 'xul:row', { align : 'center' }); + for (var col = 0; col < nColumns; col = col + 1) { + var left = getPacking(child, 'left_attach'); + var right = getPacking(child, 'right_attach'); + var top = getPacking(child, 'top_attach'); + var bottom = getPacking(child, 'bottom_attach'); + if (top == row && left == col) { + wbuild(w4, [ child ]); + child = pop(sorted); + }; + }; + }; + }; + return w; +}; + +WBUILD['GtkScrolledWindow'] = +function (pw, self) { + var child = self.children[0]; + var w = wbuild(pw, [ child ]); + return w; +}; + +WBUILD['GtkTreeView'] = +function (pw, self) { + return wmake(pw, 'xul:tree', { id : self.id }); +}; + +WBUILD['xul:iframe'] = +function (pw, self) { + var string1 = getProperty(self, 'string1'); + var string2 = getProperty(self, 'string2'); + return wmake + (pw, 'xul:iframe', + { id : self.id, + src : string1 }, + { load : string2 }); +}; + +function closeWindow() { + window.open('javascript:window.close();', '_self', ''); +}; + +function gtkMainQuit() { + closeWindow(); +}; + diff --git a/webglade.ls b/webglade.ls @@ -0,0 +1,794 @@ +;; TODO remove & fix push/pop etc + +(defun member (item lst) + (when lst + (dolist (i lst) + (when (= i item) + (return true))))) + +(defun pop (place) + (return (.pop place))) + +(defun push (item place) + (.push place item)) + +(defun pushnew (item place) + (unless (member item place) + (push item place)) + (return place)) + +(defun object2alist (obj) + (when (and obj + (= "object" (typeof obj)) + (not (length obj))) + (let ((result (list))) + (doeach (i obj) + (push (cons i (slot-value obj i)) result)) + (return result)))) ;; note push adds on the tail! + +(defun copy-seq (seq) + (when seq + (let ((result (list))) + (dolist (i seq) + (push i result)) ;; careful, push puts it at the end! (should be reverse) + (return result)))) + +(defun nreverse (seq) + (when seq + (return (.reverse seq)))) + +(defun reverse (seq) + (return (nreverse (copy-seq seq)))) + +;;(let ((lst (list 1 2 3 4))) (alert (+ lst #\newline (copy-seq lst)))) +;;(let ((lst (list 1 2 3 4))) (alert (+ lst #\newline (reverse lst)))) +;;(let ((lst (list 1 2 3 4))) (alert (+ lst #\newline (nreverse lst)))) + +(defun sort (sequence predicate) + ;; < relationship + (.sort sequence + (lambda (x y) + (return (if (predicate x y) -1 1)))) + (return sequence)) + +;;; + +(defvar ns (create "xul" "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + "html" "http://www.w3.org/1999/xhtml")) + +(defun wget (id doc) + (return (if doc + (doc.get-element-by-id id) ;; why this doesn't work (on glade)? + (document.get-element-by-id id)))) + +(defvar *whandler* (create)) + +(defun whandler (sig) + (when sig + (let ((h (aref *whandler* sig))) + (if h + (return h) + (return (lambda (e) + (alert (+ "Unhandled event " sig ".")))))))) + +(defun wgetp (w prop) + ;;(return (w.get-attribute prop))) + (return (slot-value w prop))) + +(defun wsetp (w prop value) + (w.set-attribute prop value) + ;;(setf (slot-value w prop) value) + (return value)) + +(defun wgets (w style) + (return (slot-value w.style style))) + +(defun wsets (w style value) + (setf (slot-value w.style style) value) + ;;tempEl.style.setAttribute('cssText', 'left:150px; top:150px;', 0) + ;;(w.set-style style value) + (return value)) + +(defun wsete (w event handler use-capture) + (w.add-event-listener event handler (if use-capture true false))) + +(defun wunsete (w event handler use-capture) + (w.remove-event-listener event handler (if use-capture true false))) + +(defun wmake (pw tag props sigs) + (if (= tag "string") + ;; text + (let ((w (document.create-text-node props))) + (when pw + (pw.append-child w)) + (return w)) + ;; xul or html + (let ((w (if (tag.match "^xul:") + (document.create-element-n-s ns.xul (tag.substring 4)) + (document.create-element-n-s ns.html tag)))) + (when pw + (pw.append-child w)) + (when props + (doeach (i props) + (unless (= undefined (slot-value props i)) + ;;(w.set-attribute i (slot-value props i)) + (wsetp w i (slot-value props i))))) + (when sigs + (doeach (i sigs) + (unless (= undefined (slot-value sigs i)) + #+nil(w.add-event-listener i (whandler (slot-value sigs i)) false) + (wsete w i (whandler (slot-value sigs i)))))) + ;;(pw.append-child w) + (return w)))) + +(defun wadda (w child) + (.insert-before (.first-child w) child) + (return child)) + +(defun waddz (w child) + (.append-child w child) + (return child)) + +;; function insertAfter(newElement, targetElement) +;; { +;; var parent = targetElement.parentNode; +;; if(parent.lastChild == targetElement) +;; { +;; parent.appendChild(newElement); +;; } +;; else +;; { +;; parent.insertBefore(newElement, targetElement.nextSibling); +;; } +;; } + +;; (defun winsert (w pid) +;; (.insert-before (wget pid) id)) + +(defun wreplace (w ow nw) + (.replace-child w nw ow) + (return nw)) + +(defun wshow (w) + (wsets w "visibility" "visible") + (wsets w "display" "")) + +(defun whide (w) + (wsets w "visibility" "hidden") + (wsets w "display" "none")) + +(defun change-visibility (w show) + (if show + (wshow w) + (whide w))) + +(defun toggle-visibility (w) + (if (= "hidden" (wgets w "visibility")) + (wshow w) + (whide w))) + +;; widget constructors + +(defun wempty (w) + (when (w.has-child-nodes) + (dolist (child w.child-nodes) + (w.remove-child child)))) + +(defun wremove (w) + (w.parent-node.remove-child w)) + +(defun xml-to-string (doc) + (let ((s (new (*x-m-l-serializer)))) + (return (s.serialize-to-string doc)))) + +(defun load-xml (url callback) + ;; http://dean.edwards.name/weblog/2006/04/easy-xml/ + ;; http://www.w3schools.com/xml/xml_parser.asp + (if window.*active-x-object + (let ((doc (new (*active-x-object "Microsoft.XMLDOM")))) + (setf doc.async false) + (doc.load url) + (callback doc)) + #+nil(let ((xml (wmake "xml"))) + (setf xml.src url) + (waddz (wget "body") xml) + (let ((doc xml.*x-m-l-document)) + (document.body.remove-child xml) + (callback doc))) + (if (and document.implementation + document.implementation.create-document) + (let ((doc (document.implementation.create-document "" "" nil))) + (setf doc.onload (lambda () (callback doc))) + (doc.load url)) + (alert "Your browser cannot handle this script.")))) + +(defvar *wbuild* (create)) + +(defvar *wpack* (create)) + +(defun wclass (widget) + (if (= widget.class "Custom") + (return (get-property widget "creation_function")) + (return widget.class))) + +(defun parse-glade (glade) + ;;(netscape.security.*privilege-manager.enable-privilege "UniversalXPConnect") + (let ((widgets (create))) + (labels ((attrs (node) + (let ((name (node.get-attribute "name")) + (value (when node.child-nodes[0] + node.child-nodes[0].node-value)) + (result (create :name name))) + (when value + (setf result.value value)) + (dolist (a node.attributes) + (setf (slot-value result a.node-name) a.node-value)) + (return result))) + (rec-widget (parent node) + (let ((id (node.get-attribute "id")) + (class (node.get-attribute "class")) + (widget (create :id id + :parent parent + :children (list) + :class class + :property (create) + :signal (create) + :packing (create)))) + (when parent + (pushnew widget parent.children)) ;; appends! + (setf (slot-value widgets id) widget) + (rec widget node.child-nodes) + ;; TODO return local to widget! + (return widget))) + (rec-child (parent node) + (let ((current nil)) + (dolist (child node.child-nodes) + (case child.tag-name + ("widget" (setf current (rec-widget parent child))) + ("packing" (rec-packing parent child current)))))) + (rec-property (parent node) + (let ((as (attrs node))) + (setf (slot-value parent.property as.name) as))) + (rec-signal (parent node) + (let ((as (attrs node))) + (setf (slot-value parent.signal as.name) as))) + (rec-packing (parent node current) + (dolist (child node.child-nodes) + (when (= "property" child.tag-name) + (let ((as (attrs child))) + (setf (slot-value current.packing as.name) as))))) + (rec (parent nodes current) + (dolist (node nodes) + (case node.tag-name + ("glade-interface" (rec parent node.child-nodes)) + ("widget" (rec-widget parent node)) + ("child" (rec-child parent node)) + ("property" (rec-property parent node)) + ("signal" (rec-signal parent node)) + ("packing" (rec-packing parent node current)))))) + (rec nil (list glade.document-element))) + (return widgets))) + +(defun wbuild (pw widgets) + (let ((result nil)) + (dolist (widget widgets) + (let ((fbuild (aref *wbuild* (wclass widget))) + (fpack (when (and widget widget.parent) + (aref *wpack* (wclass widget.parent)))) + (w (if fbuild + (fbuild pw widget) + (wmake pw "string" (+ "{ " (wclass widget) " not implemented! }"))))) + (when fpack + (fpack pw w widget)) + (setf result w))) + (return result))) ;; return only one for whole container??? + +(defun get-property (widget name) + (awhen (slot-value widget.property name) + (return (slot-value it 'value)))) + +(defun get-signal (widget name) + (awhen (slot-value widget.signal name) + (return (slot-value it 'handler)))) + +(defun get-packing (widget name) + (awhen (slot-value widget.packing name) + (return (slot-value it 'value)))) + +(defbuild "GtkWindow" () + (with-properties (title) + (if (= "window" pw.tag-name) + (progn + (wsetp pw "id" self.id) + (wsetp pw "title" title) + (wbuild pw self.children) + (return pw)) ;; ??? + (let ((w (wmake pw "xul:window" (create :id self.id :title title)))) + (wbuild w self.children) + (return w))))) + +;; <property name="decorated">True</property> +;; <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + +(defpack "GtkWindow" () + (let ((resizable (= "True" (get-property self.parent "resizable")))) + (when resizable + (wsetp w "flex" 1)))) + +(defbuild "GtkDialog" () + (return (funcall (aref *wbuild* "GtkWindow") pw self))) + +(defpack "GtkDialog" () + (return (funcall (aref *wpack* "GtkWindow") pw w self))) + +(defbuild "GtkButton" () + (with-properties (tooltip label sensitive) + (with-signals (clicked) + (let ((w (wmake pw "xul:button" + (create :id self.id + ;;:class-name (get-property self "class-name") + :tooltip tooltip + :disabled (= "False" sensitive) + :label label) + (create :command clicked)))) + (wbuild w self.children) + (return w))))) + +(defbuild "GtkCheckButton" () + (with-properties (active label) + (with-signals (toggled) + (return (wmake pw "xul:checkbox" + (create :id self.id + :checked (when active true) + :label label) + (create :command toggled)))))) + +(defbuild "GtkLabel" () + (with-properties (label) + (return (wmake pw "xul:label" (create :id self.id :value label))))) + +(defbuild "GtkEntry" () + (with-properties (text tooltip editable) + (with-signals (changed) + (return (wmake pw "xul:textbox" + (create :id self.id + :value text + :tooltip tooltip + ;; ff3 cant be just (= "False" editable) + :readonly (if (= "False" editable) + true + undefined)) + (create :change changed)))))) + +(defbuild "GtkTextView" () + (with-properties (text tooltip editable) + (with-signals (changed) + (return (wmake pw "xul:textbox" + (create :id self.id + :value text + :tooltip tooltip + ;; ff3 cant be just (= "False" editable) + :readonly (if (= "False" editable) + true + undefined) + :multiline t) + (create :change changed)))))) + +(defbuild "GtkFrame" () + (let ((w (wmake pw "xul:groupbox" (create :id self.id))) + (w2 (wmake w "xul:caption")) + (label (list)) + (body (list))) + (dolist (child self.children) + ;; TODO fix label_item... (alert (+ (object2alist child) #\newline "---" #\newline child.packing.type)) + (if (= "label_item" (get-packing child "type")) + (push child label) + (push child body))) + (wbuild w2 label) + (wbuild w body))) + +;; TODO do something meaningful +(defbuild "GtkAlignment" () + (wbuild pw self.children) + #+nil(return ???)) + +(defbuild "GtkComboBox" () + ;; why must be created first and then inserted? + (with-properties (items) + (with-signals (changed) + (let ((w (wmake nil "xul:menulist" + (create :id self.id) + (create :command changed))) + (w2 (wmake w "xul:menupopup")) + (n 0)) + ;;(alert (get-property self "active")) + (when items + (dolist (item (.split items #\newline)) + (let ((pair (.split item "|"))) + (wmake w2 "xul:menuitem" + (create :value (aref pair 0) + :label (or (aref pair 1) (aref pair 0)) + ;; TODO :selected (when (= n (get-property self "active")) t) + ))) + (incf n))) + (waddz pw w) + (return w))))) + +(defbuild "GtkMenuBar" () + (let ((w (wmake nil "xul:menubar" (create :id self.id)))) + (wbuild w self.children) + (waddz pw w) + (return w))) + +(defbuild "GtkMenu" () + (let ((w (wmake pw "xul:menupopup" (create :id self.id)))) + (wbuild w self.children) + (return w))) + +(defbuild "GtkSeparatorMenuItem" () + (return (wmake pw "xul:menuseparator" (create :id self.id)))) + +(defun find-access-key (str) + ;; use (position item seq)? + (let ((pos (str.index-of #\_))) + (unless (minusp pos) + ;; use (subseq str (1+ pos) (+ 2 pos)))))? + (return (aref str (1+ pos)))))) + +;;(alert (find-access-key "hell_o")) +;;(alert (find-access-key "hi")) + +(defun remove-access-key (str) + (return (str.replace #\_ ""))) + +(defbuild "GtkMenuItem" () + ;; used to be (= "menubar" pw.tag-name) + (with-properties (label) + (with-signals (activate) + (if (or (= "GtkMenuBar" (wclass self.parent)) + (plusp (length self.children))) + (let ((w (wmake pw "xul:menu" + (create :id self.id + :label (remove-access-key label) + ;; TODO :acceltext (find-access-key label) + :accesskey (find-access-key label)) + (create :command activate)))) + (if (plusp (length self.children)) + (wbuild w self.children) + (wmake w "xul:menupopup")) + (return w)) + (return (wmake pw "xul:menuitem" + (create :id self.id + :label (remove-access-key label) + ;; TODO :acceltext (find-access-key label) + :accesskey (find-access-key label)) + (create :command activate))))))) + +(defbuild "GtkHBox" () + (let ((w (wmake pw "xul:hbox" + (create :id self.id + ;; TODO align for label & combo + ;;:equalsize (when (= "True" (get-property self "homogeneous")) "always") + ;;:pack "center" + :align "center")))) + (wbuild w self.children) + (return w))) + +(defpack "GtkHBox" () + (with-packing (padding expand fill pack_type) + (when (= "True" expand) + (wsetp w "flex" 1)) + ;;(wsetp w "pack" "end") + #+nil(when (= "GTK_PACK_END" pack_type) + (wsetp w "pack" "end")))) + +(defbuild "GtkVBox" () + (let ((w (wmake pw "xul:vbox" (create :id self.id)))) + (wbuild w self.children) + (return w))) + +(defpack "GtkVBox" () + (with-packing (padding expand fill pack_type) + (when (= "True" expand) + (wsetp w "flex" 1)) + ;;(wsetp w "pack" "end") + #+nil(when (= "GTK_PACK_END" pack_type) + (wsetp w "pack" "end")))) + +(defbuild "GtkHButtonBox" () + (let ((w (wmake pw "xul:hbox" (create :id self.id)))) + (wbuild w self.children) + (return w))) + +(defbuild "GtkVButtonBox" () + (let ((w (wmake pw "xul:vbox" (create :id self.id)))) + (wbuild w self.children) + (return w))) + +(defbuild "GtkHSeparator" () + (return (wmake pw "xul:separator" + (create :id self.id + :orient "horizontal" + :class "groove")))) + +(defbuild "GtkVSeparator" () + (return (wmake pw "xul:separator" + (create :id self.id + :orient "vertical" + :class "groove")))) + +(defbuild "GtkHPaned" () + (let ((w (wmake pw "xul:hbox" (create :id self.id))) + (left self.children[0]) + (right self.children[1])) + (wbuild w (list left)) + ;; splitters are poor in xul, we do not worry about collapse & resize + (let ((w2 (wmake w "xul:splitter" (create :id (+ self.id "-splitter"))))) + (wmake w2 "xul:grippy" (create :id (+ self.id "-grippy")))) + (wbuild w (list right)) + (return w))) + +(defpack "GtkHPaned" () + (with-packing (shrink resize) + ;; is this the right test? + (when (= "True" resize) + (wsetp w "flex" 1)))) + +(defbuild "GtkVPaned" () + (let ((w (wmake pw "xul:vbox" (create :id self.id))) + (top self.children[0]) + (bottom self.children[1])) + (wbuild w (list top)) + (let ((w2 (wmake w "xul:splitter" (create :resizeafter "grow")))) + (wmake w2 "xul:grippy")) + (wbuild w (list bottom)) + (return w))) + +(defpack "GtkVPaned" () + (with-packing (shrink resize) + ;; TODO + #+nil(when (= "True" resize) + (wsetp w "flex" 1)))) + +(defbuild "GtkNotebook" () + (let ((tabs (list)) + (bodies (list))) + (dolist (child self.children) + (if (== "tab" (get-packing child "type")) + (push child tabs) ;; appends! + (push child bodies))) + (let ((w (wmake nil "xul:tabbox" (create :id self.id))) + (w2 (wmake w "xul:tabs")) + (w3 (wmake w "xul:tabpanels" (create :flex 1)))) + (dolist (tab tabs) + (let ((w4 (wmake w2 "xul:tab"))) + ;; TODO image? + (if (= "GtkLabel" tab.class) + (wsetp w4 "label" tab.property.label.value) + (wbuild w4 (list tab))))) + (dolist (body bodies) + (let ((w5 (wmake w3 "xul:tabpanel"))) + (wbuild w5 (list body)))) + (waddz pw w) + (return w)))) + +(defpack "GtkNotebook" () + (with-packing (type) + (let ((expand (= "True" (get-packing self "tab_expand"))) + (fill (= "True" (get-packing self "tab_fill")))) + (unless (= "tab" type) + (wsetp w "flex" 1))))) + +(defbuild "GtkToolbar" () + (let ((w (wmake pw "xul:toolbar" + (create :id self.id + :align "center")))) ;; like hbox + (wbuild w self.children) + (return w))) + +(defpack "GtkToolbar" () + (with-packing (expand homogeneous) + ;; TODO homogeneous + (when (= "True" expand) + (wsetp w "flex" 1)))) + +(defbuild "GtkToolItem" () + (let ((w (wmake pw "xul:toolbaritem" (create :id self.id)))) + (wbuild w self.children) + (return w))) + +(defbuild "GtkSeparatorToolItem" () + ;; why not draw line? + (let ((w (wmake pw "xul:toolbarseparator" (create :id self.id)))) + ;; TODO why need children? + (wbuild w self.children) + (return w))) + +(defun image-url (url) + (when url + ;; TODO and more like http etc? + (return (+ "images/" url)))) + +(defbuild "GtkToolButton" () + ;; TODO show label/image + (with-properties (label icon tooltip) + (with-signals (clicked) + (let ((show-label t) + (show-image t)) + (return (wmake pw "xul:toolbarbutton" + (create :id self.id + :label (when show-label label) + :image (when show-image (image-url icon)) + :tooltiptext tooltip) + (create :command clicked))))))) + +(defbuild "GtkImage" () + (with-properties (pixbuf) + (return (wmake pw "xul:image" + (create :id self.id :src (image-url pixbuf)))))) + +(defbuild "GtkProgressBar" () + (return (wmake pw "xul:progressmeter" + (create :id self.id :mode "determined")))) + +(defbuild "GtkStatusbar" () + (return (wmake pw "xul:statusbarpanel" (create :id self.id :flex 1))) + ;; TODO need packhook to set flex of the panel + #+nil(let ((w (wmake pw "xul:statusbar" (create :id self.id)))) + (wmake w "xul:statusbarpanel" (create :flex 1)) + (return w))) + +(defun scan (regexp string) + (when string + (return (.match string regexp)))) + +;;(alert (scan "expand" "asfdexpandasfd")) + +;; TODO empty table??? +(defbuild "GtkTable" () + (let ((n-rows (get-property self "n_rows")) + (n-columns (get-property self "n_columns")) + (row-spacing (get-property self "row_spacing")) + (column-spacing (get-property self "column_spacing")) + (homogeneous (= "True" (get-property self "homogeneous")))) + (flet ((earlier (x y) + (let ((xleft (get-packing x "left_attach")) + (xright (get-packing x "right_attach")) + (xtop (get-packing x "top_attach")) + (xbottom (get-packing x "bottom_attach")) + (yleft (get-packing y "left_attach")) + (yright (get-packing y "right_attach")) + (ytop (get-packing y "top_attach")) + (ybottom (get-packing y "bottom_attach")) + ;;(c1 (< xtop ytop)) + ;;(c2 (and (= xtop ytop) + ;;(< xleft yleft))) + #+nil(c (or c1 c2))) + #+nil(return (if c -1 1)) + (return (or (< xtop ytop) + (and (= xtop ytop) + (< xleft yleft)))))) + (getfcols (sorted) + (unless homogeneous + (let ((fcols (list)) + (sorted (copy-seq sorted)) + (child (pop sorted))) + (dotimes (row n-rows) + (dotimes (col n-columns) + (let ((left (get-packing child "left_attach")) + (right (get-packing child "right_attach")) + (top (get-packing child "top_attach")) + (bottom (get-packing child "bottom_attach")) + (x-options (get-packing child "x_options"))) + (when (and (= top row) (= left col)) + ;; missing x_options = expand|fill + (when (or (null child.packing.x_options) + (scan "expand" x-options)) + (dotimes (i (1+ (- right left))) ;; 1+? + (pushnew col fcols)) ;; appends! + #+nil(loop for c from left to right + do (pushnew col fcols))) + (setf child (pop sorted)))))) + (return fcols))))) + (let ((n-rows (get-property self "n_rows")) + (n-columns (get-property self "n_columns")) + (row-spacing (get-property self "row_spacing")) + (column-spacing (get-property self "column_spacing")) + (homogeneous (= "True" (get-property self "homogeneous"))) + (sorted (reverse (sort (copy-seq self.children) earlier))) ;; pop works reverse + (fcols (getfcols sorted)) + (w (wmake pw "xul:grid" (create :id self.id))) + (w2 (wmake w "xul:columns")) + (w3 (wmake w "xul:rows"))) + (dotimes (col n-columns) + ;; TODO homogeneous + (wmake w2 "xul:column" + (create :flex (when (or homogeneous + (member col fcols)) + 1)))) + (let ((child (pop sorted))) + (dotimes (row n-rows) + ;; TODO homogeneous/height + (let ((w4 (wmake w3 "xul:row" (create :align "center")))) + (dotimes (col n-columns) + (let ((left (get-packing child "left_attach")) + (right (get-packing child "right_attach")) + (top (get-packing child "top_attach")) + (bottom (get-packing child "bottom_attach"))) + (when (and (= top row) (= left col)) + (wbuild w4 (list child)) + (setf child (pop sorted)))))))) + (return w))))) + +(defbuild "GtkScrolledWindow" () + ;; have one child only; packing applies to the child + (let ((child self.children[0]) + (w (wbuild pw (list child)))) + ;; TODO + ;;(wsets w "overflow" "auto") + (return w))) + +(defbuild "GtkTreeView" () + (return (wmake pw "xul:tree" (create :id self.id))) + #+nil(labels ((draw-rows (rows) + (html (:treechildren + (dolist (row rows) + (let ((cells (cells row)) + (children (children row))) + (html ((:treeitem + :when (:container self.children :true) + ;;:when (:open self.children :true) + ) + (:treerow (dolist (cell cells) + (html ((:treecell :label cell))))) + (when self.children + (draw-rows self.children)))))))))) + (with-properties (model) self + ;;(format t "~s~%" model) + (let ((flex (eq (type-of (parent self)) 'GtkScrolledWindow)) + (cols (columns model)) + (scrollbar (eq (type-of (parent self)) 'GtkScrolledWindow)) + (hide-header-row (hide-header-row model))) + (html ((:tree :id (wid self) :class "GtkTreeView" + ;;:when (:style scrollbar "overflow:auto") + :when (:hidecolumnpicker (or hide-header-row + (< (length cols) 2)) :true) + :when (:flex flex 1) + ;;:enableColumnDrag :true + ;;:seltype :single :multiple + ;;:disabled :true + ;;:when (:align scrollbar :stretch) + ) + (when model + (html + (:treecols + (loop for col in cols + for n from 0 + do (destructuring-bind + (cname ctitle cflex chidden cprimary) + col + (html + ((:treecol + :id cname + :when (:primary cprimary :true) + :when (:hideheader hide-header-row :true) + ;;:ignoreincolumnpicker :true + :when (:label (and (not hide-header-row) + ctitle) + ctitle) + :when (:flex cflex cflex) + :when (:hidden chidden :true)))))))) + (draw-rows (children model))))))))) + +(defbuild "xul:iframe" () + (with-properties (string1 string2) + (return (wmake pw "xul:iframe" + (create :id self.id :src string1) + (create :load string2))))) + +(defun close-window () + ;; http://www.interwebby.com/blog/2006/02/04/3/ + (window.open "javascript:window.close();" "_self" "")) + +(defun gtk-main-quit () + (close-window))