summaryrefslogtreecommitdiffstats
path: root/non-puppet/qtmetrics/ajaxrequest.js
diff options
context:
space:
mode:
authorJuha Sippola <juhasippola@ovi.com>2013-05-08 13:45:53 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-08 13:10:56 +0200
commit1d567199b095a5a7896689f9f539c6989da6ac8c (patch)
tree730b26852106e1a93490de776ab0ad84b91b8f19 /non-puppet/qtmetrics/ajaxrequest.js
parent383eb11bc0ac683d5260b8e251797e2aae39e5f9 (diff)
Add initial version of QtMetrics
Qtmetrics is a PHP / Mysql / Ajax implementation to show qt build statistics and test results on a web page. Change-Id: I5a1559b2ff0611d6d24d0bde1dd18a939fb80639 Reviewed-by: Tony SarajΓ€rvi <tony.sarajarvi@digia.com>
Diffstat (limited to 'non-puppet/qtmetrics/ajaxrequest.js')
-rw-r--r--non-puppet/qtmetrics/ajaxrequest.js116
1 files changed, 116 insertions, 0 deletions
diff --git a/non-puppet/qtmetrics/ajaxrequest.js b/non-puppet/qtmetrics/ajaxrequest.js
new file mode 100644
index 0000000..413fae5
--- /dev/null
+++ b/non-puppet/qtmetrics/ajaxrequest.js
@@ -0,0 +1,116 @@
+/****************************************************************************
+##
+## Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+## Contact: http://www.qt-project.org/legal
+##
+## This file is part of the Qt Metrics web portal.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and Digia. For licensing terms and
+## conditions see http://qt.digia.com/licensing. For further information
+## use the contact form at http://qt.digia.com/contact-us.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU Lesser
+## General Public License version 2.1 as published by the Free Software
+## Foundation and appearing in the file LICENSE.LGPL included in the
+## packaging of this file. Please review the following information to
+## ensure the GNU Lesser General Public License version 2.1 requirements
+## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+##
+## In addition, as a special exception, Digia gives you certain additional
+## rights. These rights are described in the Digia Qt LGPL Exception
+## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3.0 as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL included in the
+## packaging of this file. Please review the following information to
+## ensure the GNU General Public License version 3.0 requirements will be
+## met: http://www.gnu.org/copyleft/gpl.html.
+##
+##
+## $QT_END_LICENSE$
+##
+****************************************************************************/
+
+var metricRequest = new Array();
+var filterRequest;
+
+/* Create metric instance as required by the browser */
+function createMetricRequestObject(id)
+{
+ if (window.XMLHttpRequest)
+ metricRequest[id] = new XMLHttpRequest(); // for IE7+, Firefox, Chrome, Opera, Safari
+ else
+ metricRequest[id] = new ActiveXObject("Microsoft.XMLHTTP"); // for IE6 and IE5
+}
+
+/* Create filter instance as required by the browser */
+function createFilterRequestObject()
+{
+ if (window.XMLHttpRequest)
+ filterRequest = new XMLHttpRequest(); // for IE7+, Firefox, Chrome, Opera, Safari
+ else
+ filterRequest = new ActiveXObject("Microsoft.XMLHTTP"); // for IE6 and IE5
+}
+
+/* Request metric data (e.g. from database) */
+function getMetricData(metricId, filepath, project, conf)
+{
+ document.getElementById("metricsBox"+metricId).innerHTML = "Loading...";
+ if (project == "") {
+ document.getElementById("metricsBox"+metricId).innerHTML = "";
+ return;
+ }
+
+ createMetricRequestObject(metricId);
+ metricRequest[metricId].open("GET",filepath+"?project="+project+"&conf="+conf,true);
+ metricRequest[metricId].send();
+
+ metricRequest[metricId].onreadystatechange = function(index)
+ {
+ return function()
+ {
+ showMetricData(index);
+ };
+ } (metricId);
+}
+
+/* Show metric result in the related metrics box (div) */
+function showMetricData(metricId)
+{
+ if (metricRequest[metricId].readyState == 4 && metricRequest[metricId].status == 200) {
+ var response = metricRequest[metricId].responseText;
+ document.getElementById("metricsBox"+metricId).innerHTML = response;
+ }
+}
+
+/* Request filters (from database) */
+function getFilters(div, filepath)
+{
+ createFilterRequestObject();
+ filterRequest.open("GET",filepath,true);
+ filterRequest.send();
+ filterRequest.onreadystatechange = function(index)
+ {
+ return function()
+ {
+ showFilters(index);
+ };
+ } (div);
+}
+
+/* Show filters in the related div */
+function showFilters(div)
+{
+ if (filterRequest.readyState == 4 && filterRequest.status == 200) {
+ var response = filterRequest.responseText;
+ document.getElementById(div).innerHTML = response;
+ }
+}