WPC Developers Documentation

Project
	The project is completly written in ActionScript3 using FlashDevelop, a free software for creating flash applications based on eclipse. All software used is free/OpenSource to allow
	further development. The only part of the project which is specific to the search engine is the "statloader" object. There should be no need to change the other classes.
	The installer is created with NSIS, which can be retrived from sourceforge.net.
	
Classes
	Preloader.as
		A standard preloader. No loading bar added as the size of WPC is still very small.
	Main.as
		The main class for processing and control.
		- main creates a "form" object and adds it to the stage
		- main adds an event listener to the "GO" button of the form to start the processing.
		- if "GO" is clicked, main creates a table containing the contents of the form, dropping all empty fields
			main creates a second table which contains one statloader object for each query derived from table one
			all statloaders are added to a queue wich allows to influence the timing of their start
		- if all statloaders have finished loading, the statloaders inside the table are replaced by their result values
			a "show_table" object is created to show the results of the querys, it takes the two tables as input.
			an event listener is added to the tables "copy to csv" button, when activated the tables csv string is copied to the clipboard
	
	form.as
		Creates a form out of input textfields and adds description and borders. it also containes a "GO" button. The input textfields
		are stored as arrays for easy access.
		
	show_table.as
		Takes a desctiption and a value array as inputs, creates an output table from it which consists of selectable text fields.
		To copy the table to other applications, the table is also constructed as csv which can be copied to the clipboard via button.
		
	finished_event.as
		This is a custom event used by the statloader to indicate that loading is finished.
		
	statloader.as
		This is the class where the search engine specific processing happens.
		- Takes 3 arrays (of strings) as input:
			-"common" holds the common search phrase for all domains.
			-"phrase" holds the search phrase for the query
			-"domain" holds the search domain
		- An url is created out of the 3 input arrays, specific to the search engine
		- A "textloader" object is created to load the result webpage from the search engine
		- if the loading is finished, the number of results is extracted from the webpage and cast to number for processing, a finished event is dipatched
		
		To create a new statloader for other search engines or repair a statloader after changes to the search engine:
		- Create/repair  the "constructurl" function
			-use the search engines web form to derive the correct syntax. after submitting the form, an url shows in the browsers adress field. it should contain all search parameters
			 and some additional information. first cut all additional information from the url and test the output to reduce the length and complexity of the url.
			 There are some parts that must be identified:
			 - The starting string: consists of the search engines adress and an indicator for the query. For google this is "http://www.google.com/search?num=100&q="
			 - the syntax for multiple search words, this is used to concatinate the common and phrase parts of the url. For google it is "+"
			 - the syntax for searching whole phrases, this is used to encapsule the phrase part of the url. For google it is "\"word1+word2+...+wordX\"". Note that " must be escaped to be used in a string.
			 - the syntax for searching a single domain only. Note: there can be multiple variations for normals search form, advanced search form... Note: there can be an encoding of special characters
			   making creating multipe characters out of one special character. Use the variation which is the easiest to adapt.
			 - Having all those information, it should be no problem to create/repair the constructurl function. To test it, all constructed urls can be seen in FlashDevelop.
		
		- Create/repair the "textLoadComplete" function
			- use the webform of the search engine to get a webpage which contains a number of results. Copy this number to the clipboard.
			- use mozillas "show source" function to view the html code of the result page
			- search for the number inside the html
			- the number should be encapsuled by a html-tag, identify the whole tag. For google this is "<div id=resultStats>Ungefähr 59.900.000 Ergebnisse<nobr>"
			- use the comments inside the function to find the parts you need to change and replace them. The idea is to eliminate everything from the string that isn't a number, then cast the rest to number.
		 Note that the resulting webpage can differ depending on the environment. A standalone flashplayer loads english pages, from inside a browser german pages are loaded.

Security Issues
	For the standalone version, the statloader queries the search engine directly. To do so, it has to be in a folder wich allowes unrestricted internet access to the security sandbox.
	To set the permission, use "http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html", the adobe security settings manager.
	
	For a web based version, only the own domain can be used for the queries. The query has to be changed to a local target provided by a proxy. A proxy must be set up to import the
	search engine into the local domain. 