Skip to content
Jonathan Carter edited this page May 29, 2013 · 6 revisions

![](images/app structure - homepage.jpg)

The application homepage is created with the function

SearchWindow.js :: displaySearchForce()

- closes the filter view
- creates a window with a top of 40px (so that is does not cover the topbar)
- creates the display and adds these to the window
- opens the window (which actually appears as a layer above the search screen)

When the search is performed it calls an internal function

SearchWindow.js :: displaySearchForce() :: perform_search()

- saves the value of the search string in a local storage variable called 'search-string'
- resets the other search criteris in their respectie local storage variables :

	require("/helpers/LocalStorage").setString("search-string",xsearch.value);
	require("/helpers/LocalStorage").setString("yr-string","");
	require("/helpers/LocalStorage").setString("place-string","");
	require("/helpers/LocalStorage").setString("page","0");
	require("/helpers/LocalStorage").setString("type-string","");
	require("/helpers/LocalStorage").setString("query-string","");

- calls search2();

	search2.call(this);

search2 is the global function that calls the api url

SearchWindow.js :: search2()

- calls the url, in the case of europeana is is "http://europeanaapp.glimworm.com/europeana/eu.php?action=json-srch&query="+query+"&page="+pg+"&srch="+srch+"&type="+Ti.Network.encodeURIComponent(type),
- on success saves the returned json strings into a local storage variables as follows.  See the page on the data format for an explanation of the code

	require("/helpers/LocalStorage").setObject("search",e.data.items);
	require("/helpers/LocalStorage").setObject("types",e.data.types);
	require("/helpers/LocalStorage").setString("totalResults",e.data.totalResults);
	require("/helpers/LocalStorage").setString("perpage",e.data.perpage);
	require("/helpers/LocalStorage").setString("search-message",e.data.status_msg);

- calls the function to redisplay the search screen using this data.  See the App search screen documentation for details of this function

	Titanium.App.fireEvent("redisplay-search",{xfrom : 'search2'});

[App search screen page](App searchscreen)