~ubuntu-branches/ubuntu/utopic/qtsystems-opensource-src/utopic-proposed

« back to all changes in this revision

Viewing changes to doc/config/publishsubscribe/scripts/functions.js

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-06-14 10:32:13 UTC
  • Revision ID: package-import@ubuntu.com-20130614103213-yao8gdav28kntvvj
Tags: upstream-5.0~git20130614
ImportĀ upstreamĀ versionĀ 5.0~git20130614

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Removing search results
 
2
function hideSearchResults() {
 
3
/* hiding search results as the user clicks on the different categories */
 
4
  $('#resultdialog').removeClass('active');
 
5
    $("#resultlist").removeClass().addClass('all');
 
6
    $("#resultlinks").removeClass().addClass('all');
 
7
    $("#searchcount").removeClass().addClass('all');
 
8
}
 
9
/* closing the searhc result dialog */
 
10
$('#resultclose').click(function(e) {
 
11
  e.preventDefault();
 
12
  hideSearchResults();
 
13
});
 
14
 
 
15
$(document.body).click(function() {
 
16
});
 
17
 
 
18
/* START non link areas where cursor should change to pointing hand */
 
19
$('.t_button').mouseover(function() {
 
20
    $('.t_button').css('cursor','pointer');
 
21
});
 
22
/* END non link areas  */
 
23
/* Changing font size to smaller */
 
24
$('#smallA').click(function() {
 
25
        $('.mainContent .heading,.mainContent h1, .mainContent h2, .mainContent h3, .mainContent p, .mainContent li, .mainContent table').css('font-size','smaller');
 
26
        $('.t_button').removeClass('active')
 
27
        $(this).addClass('active')
 
28
});
 
29
 
 
30
/* Reset font size */
 
31
$('#medA').click(function() {
 
32
        $('.mainContent .heading').css('font','600 16px/1 Arial');
 
33
        $('.mainContent h1').css('font','600 18px/1.2 Arial');
 
34
        $('.mainContent h2').css('font','600 16px/1.2 Arial');
 
35
        $('.mainContent h3').css('font','600 14px/1.2 Arial');
 
36
        $('.mainContent p').css('font','13px/20px Verdana');
 
37
        $('.mainContent li').css('font','400 13px/1 Verdana');
 
38
        $('.mainContent li').css('line-height','14px');
 
39
        $('.mainContent .toc li').css('font', 'normal 10px/1.2 Verdana');
 
40
        $('.mainContent table').css('font','13px/1.2 Verdana');
 
41
        $('.mainContent .heading').css('font','600 16px/1 Arial');
 
42
        $('.mainContent .indexboxcont li').css('font','600 13px/1 Verdana');
 
43
        $('.t_button').removeClass('active')
 
44
        $(this).addClass('active')
 
45
});
 
46
/* Changing font size to bigger */
 
47
$('#bigA').click(function() {
 
48
        $('.mainContent .heading,.mainContent h1, .mainContent h2, .mainContent h3, .mainContent p, .mainContent li, .mainContent table').css('font-size','large');
 
49
        $('.mainContent .heading,.mainContent h1, .mainContent h2, .mainContent h3, .mainContent p, .mainContent li, .mainContent table').css('line-height','25px');
 
50
        $('.t_button').removeClass('active')
 
51
        $(this).addClass('active')
 
52
});
 
53
 
 
54
/* Show page content after closing feedback box */
 
55
$('.feedclose').click(function() {
 
56
    $('.bd').show();
 
57
    $('.hd').show();
 
58
    $('.footer').show();
 
59
    $('#feedbackBox').hide();
 
60
    $('#blurpage').hide();
 
61
});
 
62
 
 
63
/* Hide page content and show feedback box */
 
64
$('.feedback').click(function() {
 
65
    $('.bd').hide();
 
66
    $('.hd').hide();
 
67
    $('.footer').hide();
 
68
    $('#feedbackBox').show();
 
69
    $('#blurpage').show();
 
70
});
 
71
/* Default search URL */
 
72
var qturl = "";
 
73
 
 
74
/* The next function handles the response data (in xml) returned by the search engine */
 
75
 
 
76
// Process data sent back from the server. The data is structured as a XML.
 
77
/*
 
78
XML structure handled by function processNokiaData()
 
79
<page> - container for each page returned
 
80
<pageWords/> - contains keywords
 
81
<pageTitle/> - contains page title/header content
 
82
<pageUrl/> - contains page URL - URL relative to root
 
83
<pageType> - contains page type - APIPage/Article/Example
 
84
</page>
 
85
*/
 
86
 
 
87
 
 
88
function processNokiaData(response){
 
89
/* fetch the responce from the server using page as the root element */
 
90
    var propertyTags = response.getElementsByTagName('page');
 
91
    /* reset counters */
 
92
    var apiCount = 0;
 
93
    var articleCount = 0;
 
94
    var exampleCount = 0;
 
95
    var full_li_element;
 
96
 
 
97
/* remove any old results */
 
98
    $('#resultlist li').remove();
 
99
 
 
100
 
 
101
    /* running through the elements in the xml structure */
 
102
    for (var i=0; i<propertyTags.length; i++) {
 
103
        /* for every element named pageWords*/
 
104
        for (var j=0; j< propertyTags[i].getElementsByTagName('pageWords').length; j++) {
 
105
            /* start a new list element */
 
106
            full_li_element = '<li';
 
107
                    /* if the pageType element reads APIPage, add class name api */
 
108
      if (propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'APIPage') {
 
109
          full_li_element += ' class="api"';
 
110
          apiCount++;
 
111
      }
 
112
                    /* if the pageType element reads Article, add class name article */
 
113
      else if (propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Article') {
 
114
          full_li_element += ' class="article"';
 
115
          articleCount++;
 
116
      }
 
117
                    /* if the pageType element reads Example, add class name example */
 
118
      else if (propertyTags[i].getElementsByTagName('pageType')[0].firstChild.nodeValue == 'Example') {
 
119
          full_li_element += ' class="example"';
 
120
          exampleCount++;
 
121
      }
 
122
            /* adding the link element*/
 
123
            full_li_element += '><a href="'+qturl;
 
124
            /* adding the URL attribute*/
 
125
            full_li_element += propertyTags[i].getElementsByTagName('pageUrl')[j].firstChild.nodeValue;
 
126
              /* adding the link title and closing the link and list elements */
 
127
            full_li_element += '">' + propertyTags[i].getElementsByTagName('pageWords')[0].firstChild.nodeValue + '</a></li>';
 
128
            /* appending the list element to the #resultlist div*/
 
129
            $('#resultlist').append(full_li_element);
 
130
        }
 
131
    }
 
132
 
 
133
    /* if the result is not empty */
 
134
    if (propertyTags.length > 0) {
 
135
    /* add class name active to show the dialog */
 
136
      $('#resultdialog').addClass('active');
 
137
      /* setting number of hits*/
 
138
      $('#resultcount').html(propertyTags.length);
 
139
      $('#apicount').html(apiCount);
 
140
      $('#articlecount').html(articleCount);
 
141
      $('#examplecount').html(exampleCount);
 
142
 
 
143
    }
 
144
    else {
 
145
      $('#pageType').addClass('red');
 
146
      }
 
147
 
 
148
 
 
149
 
 
150
  // Filtering results in display
 
151
    $('p#resultlinks a').click(function(e) {
 
152
      e.preventDefault();
 
153
    // Displays API ref pages
 
154
        if (this.id == "showapiresults") {
 
155
            $("#resultlist").removeClass().addClass('api');
 
156
            $("#resultlinks").removeClass().addClass('api');
 
157
            $("#searchcount").removeClass().addClass('api');
 
158
        }
 
159
    // Displays Articles
 
160
        else if (this.id == "showarticleresults") {
 
161
            $("#resultlist").removeClass().addClass('article');
 
162
            $("#resultlinks").removeClass().addClass('article');
 
163
            $("#searchcount").removeClass().addClass('article');
 
164
        }
 
165
    // Displays Examples
 
166
        if (this.id == "showexampleresults") {
 
167
            $("#resultlist").removeClass().addClass('example');
 
168
            $("#resultlinks").removeClass().addClass('example');
 
169
            $("#searchcount").removeClass().addClass('example');
 
170
        }
 
171
    // Displays All
 
172
        if (this.id == "showallresults") {
 
173
            $("#resultlist").removeClass().addClass('all');
 
174
            $("#resultlinks").removeClass().addClass('all');
 
175
            $("#searchcount").removeClass().addClass('all');
 
176
        }
 
177
    });
 
178
}
 
179
 
 
180
//build regular expression object to find empty string or any number of blank
 
181
var blankRE=/^\s*$/;
 
182
 
 
183
 
 
184
function CheckEmptyAndLoadList()
 
185
{
 
186
    /* Start Extracting information for feedback and adding this to the feedback form */
 
187
    var pageUrl = window.location.href;
 
188
    var pageVal = $('title').html();
 
189
    $('#pageType').removeClass('red');
 
190
    $('#feedUrl').remove();
 
191
    $('#pageVal').remove();
 
192
    $('.menuAlert').remove();
 
193
    $('#feedform').append('<input id="feedUrl" name="feedUrl" value="'+pageUrl+'" style="display:none;">');
 
194
    $('#feedform').append('<input id="pageVal" name="pageVal" value="'+pageVal+'" style="display:none;">');
 
195
    /* End Extracting information for feedback and adding this to the feedback form */
 
196
 
 
197
    /* extracts search query */
 
198
    var value = document.getElementById('pageType').value;
 
199
    /* if the search is less than three chars long remove class names and remove elements from old search*/
 
200
    if ((blankRE.test(value)) || (value.length < 3))
 
201
    {
 
202
    $('#resultdialog').removeClass('active');
 
203
    $('#resultlist li').remove();
 
204
    }
 
205
}
 
206
 
 
207
// Loads on doc ready - prepares search
 
208
    $(document).ready(function () {
 
209
    /* fetch page title*/
 
210
    var pageTitle = $('title').html();
 
211
    /* getting content from search box */
 
212
          var currentString = $('#pageType').val() ;
 
213
      /* if the search box is not empty run CheckEmptyAndLoadList*/
 
214
        if (currentString.length < 1){
 
215
            CheckEmptyAndLoadList();
 
216
        }
 
217
 
 
218
        /* on key-up in the search box execute the following */
 
219
        $('#pageType').keyup(function () {
 
220
        /* extract the search box content */
 
221
          var searchString = $('#pageType').val() ;
 
222
      /* if the string is less than three characters */
 
223
          if ((searchString == null) || (searchString.length < 3)) {
 
224
            /* remove classes and elements*/
 
225
                $('#pageType').removeClass('loading');
 
226
                 $('.searching').remove();
 
227
            /*  run CheckEmptyAndLoadList */
 
228
                     CheckEmptyAndLoadList();
 
229
 
 
230
                $('.report').remove();
 
231
                return;
 
232
           }
 
233
       /* if timer checks out */
 
234
            if (this.timer) clearTimeout(this.timer);
 
235
            this.timer = setTimeout(function () {
 
236
            /* add loading image by adding loading class */
 
237
                $('#pageType').addClass('loading');
 
238
                $('.searching').remove();
 
239
 
 
240
            /* run the actual search */
 
241
               $.ajax({
 
242
                contentType: "application/x-www-form-urlencoded",
 
243
                url: 'http://' + location.host + '/nokiasearch/GetDataServlet',
 
244
                data: 'searchString='+searchString,
 
245
                dataType:'xml',
 
246
                type: 'post',
 
247
                success: function (response, textStatus) {
 
248
                /* on success remove loading img */
 
249
                $('.searching').remove();
 
250
                $('#pageType').removeClass('loading');
 
251
 
 
252
                processNokiaData(response);
 
253
 
 
254
 }
 
255
              });
 
256
            }, 500); /* timer set to 500 ms */
 
257
        });
 
258
      });
 
 
b'\\ No newline at end of file'