1 /* create basic elements */
3 var widget = document.getElementById(id);
4 var linkLogo = document.createElement('a');
5 var logo = document.createElement('img');
6 var form = document.createElement('form');
7 var inputText = document.createElement('input');
8 var inputSubmit = document.createElement('input');
9 var body = document.getElementsByTagName('body')
10 var stylesheet = document.createElement('link');
11 var stylesheetJQUI = document.createElement('linl');
13 var host = 'localhost:8000'; //'www.wolnelektury.pl';
15 /* set attributes of created elements */
16 stylesheet.setAttribute('type', 'text/css');
17 stylesheet.setAttribute('rel', 'stylesheet');
18 stylesheet.setAttribute('href', 'http://'+host+'/static/css/widget.css');
19 stylesheetJQUI.setAttribute('type', 'text/css');
20 stylesheetJQUI.setAttribute('rel', 'stylesheet');
21 stylesheetJQUI.setAttribute('href', 'http://'+host+'/static/css/ui-lightness/jquery-ui-1.8.16.custom.css');
22 linkLogo.setAttribute('href', 'http://'+host);
23 logo.setAttribute('src', 'http://'+host+'/static/img/logo-bez.png');
24 form.setAttribute('action', 'http://'+host+'/szukaj/');
25 form.setAttribute('method', 'get');
26 form.setAttribute('accept-charset', 'utf-8');
27 form.setAttribute('id', 'wl-form');
28 inputText.setAttribute('type', 'text');
29 inputText.setAttribute('title', 'tytul, autor, motyw/temat, epoka, rodzaj, gatunek');
30 inputText.setAttribute('value', '');
31 inputText.setAttribute('name', 'q');
32 inputText.setAttribute('id', 'id_qq');
33 inputText.setAttribute('data-source', 'http://'+host+'/szukaj/hint');
34 /*inputText.setAttribute('size', '13');*/
35 inputSubmit.setAttribute('type', 'image');
36 inputSubmit.setAttribute('src', 'http://'+host+'/static/img/search.png');
37 /* inputSubmit.setAttribute('style', 'position:relative; top:5px; margin-left:5px');*/
39 /* import jquery and autocomplete */
40 var scriptJ = document.createElement('script');
41 scriptJ.setAttribute('type', 'text/javascript');
42 scriptJ.setAttribute('src', 'http://'+host+'/static/js/jquery.js');
44 var scriptUI = document.createElement('script');
45 scriptUI.setAttribute('type', 'text/javascript');
46 scriptUI.setAttribute('src', 'http://'+host+'/static/js/jquery-ui-1.8.2.custom.min.js');
47 scriptUI.setAttribute('id', 'wl-jquery-ui-script')
49 var scriptSearch = document.createElement('script');
50 scriptSearch.setAttribute('type', 'text/javascript');
51 scriptSearch.setAttribute('src', 'http://'+host+'/static/js/search.js');
52 scriptSearch.setAttribute('id', 'wl-search-script')
55 body[0].appendChild(scriptJ);
56 body[0].appendChild(scriptUI);
57 body[0].appendChild(scriptSearch);
59 /* append elements to widget */
60 widget.appendChild(stylesheet);
61 //widget.appendChild(stylesheetJQUI);
62 widget.appendChild(linkLogo);
63 linkLogo.appendChild(logo);
64 widget.appendChild(form);
65 form.appendChild(inputText);
66 form.appendChild(inputSubmit);
68 /* ...and a little make-up */
70 widget.style.borderColor = "#84BF2A";
71 widget.style.borderWidth = "2px";
72 widget.style.borderStyle = "solid";
73 widget.style.width = "160px";
74 widget.style.padding = "10px";
75 widget.style.fontSize = "12px";
76 form.style.paddingTop = "10px";
79 /* resize - if needed */
80 if(widget.getAttribute('width') == '140'){
81 logo.setAttribute('width', '140');
82 inputText.setAttribute('size', '10');
83 widget.style.width = "140px";
86 var wl_loaded_scripts = {};
88 function wl_initialize_after_load(just_loaded) {
89 wl_loaded_scripts[just_loaded] = true;
90 if (wl_loaded_scripts.jquery
91 && wl_loaded_scripts.ui
92 && wl_loaded_scripts.search) {
94 s.search({source: s.attr('data-source')});
98 scriptJ.onload = function() { wl_initialize_after_load('jquery'); };
99 scriptUI.onload = function() { wl_initialize_after_load('ui'); };
100 scriptSearch.onload = function() { wl_initialize_after_load('search'); };