summaryrefslogtreecommitdiffstats
path: root/doc/src/template/scripts/functions.js
blob: 09b7de391cb436591fa659ce6a31f210018c7162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* START non link areas where cursor should change to pointing hand */
$('.t_button').mouseover(function() {
    $('.t_button').css('cursor','pointer');
		/*document.getElementById(this.id).style.cursor='pointer';*/
});
/* END non link areas  */
$('#smallA').click(function() {
		$('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','smaller');
		$('.t_button').removeClass('active')
		$(this).addClass('active')
});

$('#medA').click(function() {
		$('.content .heading').css('font','600 16px/1 Arial');
		$('.content h1').css('font','600 18px/1.2 Arial');
		$('.content h2').css('font','600 16px/1.2 Arial');
		$('.content h3').css('font','600 14px/1.2 Arial');
		$('.content p').css('font','13px/20px Verdana');
		$('.content li').css('font','400 13px/1 Verdana');
		$('.content li').css('line-height','14px');
		$('.content .toc li').css('font', 'normal 10px/1.2 Verdana');
		$('.content table').css('font','13px/1.2 Verdana');
		$('.content .heading').css('font','600 16px/1 Arial');
		$('.content .indexboxcont li').css('font','600 13px/1 Verdana');
		$('.t_button').removeClass('active')
		$(this).addClass('active')
});

$('#bigA').click(function() {
		$('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('font-size','large');
		$('.content .heading,.content h1, .content h2, .content h3, .content p, .content li, .content table').css('line-height','25px');
		$('.t_button').removeClass('active')
		$(this).addClass('active')
});


var lookupCount = 0;
var articleCount = 0;
var exampleCount = 0;
var qturl = ""; // change from "http://doc.qt.nokia.com/4.6/" to 0 so we can have relative links

function processNokiaData(response){
	// debug $('.content').prepend('<li>handling search results</li>'); // debuging
	var propertyTags = response.getElementsByTagName('page');
	
 	for (var i=0; i< propertyTags.length; i++) {
		var linkStart   = "<li class=\"liveResult\"><a href='"+qturl+"";
		var linkEnd  = "</a></li>";
		
		if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'APIPage'){
			lookupCount++;
			//$('.live001').css('display','block');

			
			for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){
				full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue;
				full_li_element = full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd;
					
				$('#ul001').append(full_li_element);
			$('#ul001 .defaultLink').css('display','none');

		   		}
			}
	 
		if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Article'){
			articleCount++;
	 		//$('.live002').css('display','block');

				 
			for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){
			    full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue;
				full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ;
					
				$('#ul002').append(full_li_element);
			$('#ul002 .defaultLink').css('display','none');

	   		}
		}
		if(propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Example'){
			exampleCount++;
	 		//$('.live003').css('display','block');


			for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++){
			    full_li_element = linkStart + propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue;
				full_li_element =full_li_element + "'>" + propertyTags[i].getElementsByTagName('pageTitle')[0].firstChild.nodeValue + linkEnd ;
					
				$('#ul003').append(full_li_element);
			$('#ul003 .defaultLink').css('display','none');

	   		}
		} 
	}	
	 
	if(lookupCount == 0){$('#ul001').prepend('<li class=\"liveResult noMatch\">Found no result</li>');$('#ul001 li').css('display','block');}
    if(articleCount == 0){$('#ul002').prepend('<li class=\"liveResult noMatch\">Found no result</li>');$('#ul002 li').css('display','block');}
	if(exampleCount == 0){$('#ul003').prepend('<li class=\"liveResult noMatch\">Found no result</li>');$('#ul003 li').css('display','block');}
	// reset count variables;
	 lookupCount=0;
	 articleCount = 0;
     exampleCount = 0;
	
}

//build regular expression object to find empty string or any number of blank
var blankRE=/^\s*$/;
function CheckEmptyAndLoadList()
{
	$('.liveResult').remove();
	var value = document.getElementById('pageType').value; 
	if((blankRE.test(value)) || (value.length < 3))
	{
	//empty inputbox
		// load default li elements into the ul if empty
	//	loadAllList(); // replaced
	 $('.defaultLink').css('display','block');
	// $('.liveResult').css('display','none');
	}else{
	 $('.defaultLink').css('display','none');
	}
}


// Loads on doc ready
	$(document).ready(function () {
	var pageTitle = $('title').html();
		$('#feedform').append('<input id="page" name="pageVal" value="'+pageTitle+'" style="display:none;">');
          var currentString = $('#pageType').val() ;
		  if(currentString.length < 1){
			$('.defaultLink').css('display','block');
      	   		CheckEmptyAndLoadList();			
		  }

        $('#pageType').keyup(function () {
          var searchString = $('#pageType').val() ;
          if ((searchString == null) || (searchString.length < 3)) {
				 $('.liveResult').remove(); // replaces removeResults();
      	   		CheckEmptyAndLoadList();
				$('.report').remove();
				// debug$('.content').prepend('<li>too short or blank</li>'); // debug
				return;
		   }
            if (this.timer) clearTimeout(this.timer);
            this.timer = setTimeout(function () {
				// debug$('.content').prepend('<li>new search started </li>');// debug
				// debug$('.content').prepend('<p class=\"report\">Search string ' +searchString +'</p>'); // debug

               $.ajax({
                contentType: "application/x-www-form-urlencoded",
                url: 'http://' + location.host + '/nokiasearch/GetDataServlet',
                data: 'searchString='+searchString,
                dataType:'xml',
				type: 'post',	 
                success: function (response, textStatus) {

				$('.liveResult').remove(); // replaces removeResults();
                processNokiaData(response);

 }     
              });
            }, 500);
        });
      });