aboutsummaryrefslogtreecommitdiffstats
path: root/winery/org.eclipse.winery.repository/src/main/webapp/js
diff options
context:
space:
mode:
authorHuabingZhao <zhao.huabing@zte.com.cn>2016-09-20 13:59:27 +0800
committerHuabingZhao <zhao.huabing@zte.com.cn>2016-09-20 14:08:41 +0800
commit01bfe0bd23f92625e4b52710c1460f64f3a270b6 (patch)
tree66e5c95c3e4bc1e89b5026772d20bbb305e56959 /winery/org.eclipse.winery.repository/src/main/webapp/js
parentfcac34d12ac374fb63926f354d19172eff430e40 (diff)
Now we have pulled the winery source codes from github and publish the winery binary to OPEN-O third party Nexus repository. So we don't use winery code in the OPEN-O git repo anymore.
Issue id: OCS-55 Change-Id: I76fdfb17b1c90377a44c2d47f81b5698d5a220d3 Signed-off-by: HuabingZhao <zhao.huabing@zte.com.cn>
Diffstat (limited to 'winery/org.eclipse.winery.repository/src/main/webapp/js')
-rw-r--r--winery/org.eclipse.winery.repository/src/main/webapp/js/.gitignore3
-rw-r--r--winery/org.eclipse.winery.repository/src/main/webapp/js/boundaryDefinitionsXSelection.js96
-rw-r--r--winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-audio.js12
-rw-r--r--winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-image.js12
-rw-r--r--winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-validate.js12
-rw-r--r--winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-video.js12
-rw-r--r--winery/org.eclipse.winery.repository/src/main/webapp/js/nextselect.js144
-rw-r--r--winery/org.eclipse.winery.repository/src/main/webapp/js/winery-support-non-AMD.js223
-rw-r--r--winery/org.eclipse.winery.repository/src/main/webapp/js/winery-support.js112
9 files changed, 0 insertions, 626 deletions
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/js/.gitignore b/winery/org.eclipse.winery.repository/src/main/webapp/js/.gitignore
deleted file mode 100644
index 23c1477..0000000
--- a/winery/org.eclipse.winery.repository/src/main/webapp/js/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# copied from topology modeler at mvn generate-sources
-winery-common-topologyrendering.js
-winery-support-common.js \ No newline at end of file
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/js/boundaryDefinitionsXSelection.js b/winery/org.eclipse.winery.repository/src/main/webapp/js/boundaryDefinitionsXSelection.js
deleted file mode 100644
index afefc8c..0000000
--- a/winery/org.eclipse.winery.repository/src/main/webapp/js/boundaryDefinitionsXSelection.js
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 University of Stuttgart.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * Oliver Kopp - initial API and implementation
- * Tobias Binz - communication with the parent window
- *******************************************************************************/
-
- /**
- * Called from the renderer as soon as the whole topology is loaded
- */
- function wineryViewExternalScriptOnLoad() {
-
- function getIdOfNodeTemplateShape(element) {
- var nodeTemplate = element.closest("div.NodeTemplateShape");
- var id = nodeTemplate.children("div.headerContainer").children("div.id").text();
- return id;
- }
-
- jsPlumb.bind("ready", function() {
- jsPlumb.bind("click", function(conn, originalEvent) {
- var id = winery.connections[conn.id].id;
- var message = {
- targetRelationshipTemplateRef: id
- }
- sendMessage(message);
- });
- });
-
-
- $("div.NodeTemplateShape").on("click", function(e) {
- var id = getIdOfNodeTemplateShape($(e.target));
- // send id and empty property as no property has been clicked
- var message = {
- targetObjectRef: id,
- targetPropertyRef: ""
- };
- sendMessage(message);
-
- return false;
- });
-
- $("tr.KVProperty").on("click", function(e) {
- var trKVProperty = $(e.target).closest("tr.KVProperty");
- var key = trKVProperty.children("td").children("span.KVPropertyKey").text();
-
- var content = trKVProperty.closest("div.content");
- var elementName = content.children("span.elementName").text();
-
- // form namespace-unaware XPath
- var xpath = "/*[local-name()='" + elementName + "']/*[local-name()='" + key + "']";
-
- var message = {
- targetPropertyRef: xpath,
- targetObjectRef: getIdOfNodeTemplateShape(trKVProperty)
- };
- sendMessage(message);
-
- // do not trigger click on NodeTemplateShape -> we included both values in the message
- return false;
- });
-
- $("div.requirements").on("click", function(e) {
- var reqorcap = $(e.target).closest("div.requirements");
- var id = reqorcap.children("div.id").text();
-
- var message = {
- reqRef: id
- };
- sendMessage(message);
-
- return false;
- });
-
- $("div.capabilities").on("click", function(e) {
- var reqorcap = $(e.target).closest("div.capabilities");
- var id = reqorcap.children("div.id").text();
-
- var message = {
- capRef: id
- };
- sendMessage(message);
-
- return false;
- });
-
- }
-
-function sendMessage(message) {
- window.parent.postMessage(message, "*");
-}
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-audio.js b/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-audio.js
deleted file mode 100644
index 9b68349..0000000
--- a/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-audio.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012-2013 University of Stuttgart.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * Oliver Kopp - initial API and implementation and/or initial documentation
- *******************************************************************************/
-// dummy as we don't need the functionality, but jquery.fileupload-ui.js requires it \ No newline at end of file
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-image.js b/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-image.js
deleted file mode 100644
index 9b68349..0000000
--- a/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-image.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012-2013 University of Stuttgart.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * Oliver Kopp - initial API and implementation and/or initial documentation
- *******************************************************************************/
-// dummy as we don't need the functionality, but jquery.fileupload-ui.js requires it \ No newline at end of file
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-validate.js b/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-validate.js
deleted file mode 100644
index 9b68349..0000000
--- a/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-validate.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012-2013 University of Stuttgart.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * Oliver Kopp - initial API and implementation and/or initial documentation
- *******************************************************************************/
-// dummy as we don't need the functionality, but jquery.fileupload-ui.js requires it \ No newline at end of file
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-video.js b/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-video.js
deleted file mode 100644
index 9b68349..0000000
--- a/winery/org.eclipse.winery.repository/src/main/webapp/js/jquery.fileupload-video.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012-2013 University of Stuttgart.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * Oliver Kopp - initial API and implementation and/or initial documentation
- *******************************************************************************/
-// dummy as we don't need the functionality, but jquery.fileupload-ui.js requires it \ No newline at end of file
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/js/nextselect.js b/winery/org.eclipse.winery.repository/src/main/webapp/js/nextselect.js
deleted file mode 100644
index 050fcb1..0000000
--- a/winery/org.eclipse.winery.repository/src/main/webapp/js/nextselect.js
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012-2013 University of Stuttgart.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * Oliver Kopp - initial API and implementation and/or initial documentation
- *******************************************************************************/
-/*
-
-Script for dependent selection boxes.
-
-One object for stating a map from value to content. The value is globally unique.
-
-Verbose example:
-<script>
-
-var WSDLoperationsData = {
- "ns1" : {
- "options" : ["ns1:pt11", "ns1:pt12"],
- },
-
- "ns2" : {
- "options" : ["ns2:pt21"],
- },
-
- "ns3" : {
- "options" : ["ns3:pt31"],
- },
-
- "ns1:pt11" : {
- "label" : "PortType 1.1",
- "options" : ["ns1:pt11:op111", "ns1:pt11:op112"]
- },
-
- "ns1:pt12" : {
- "label" : "PortType 1.2",
- "options" : ["ns1:pt12:op113", "ns1:pt11:op114"]
- },
-
-
- "ns2:pt21" : {
- "label" : "PortType 2.1",
- "options" : ["ns2:pt21:op211", "ns2:pt21:op212"]
- },
-
-
- "ns3:pt31" : {
- "label" : "PortType 3.1",
- "options" : ["ns3:pt31:op311", "ns3:pt31:op312"]
- },
-
-
- "ns1:pt11:op111" : {
- "label" : "operation 1.1.1",
- },
-
- "ns1:pt11:op112" : {
- "label" : "operation 1.1.2",
- },
-
- "ns1:pt12:op113" : {
- "label" : "operation 1.1.3",
- },
-
- "ns1:pt12:op114" : {
- "label" : "operation 1.1.4",
- },
-
- "ns2:pt21:op211" : {
- "label" : "operation 2.1.1",
- },
-
- "ns2:pt21:op212" : {
- "label" : "operation 2.1.2",
- },
-
- "ns3:pt31:op311" : {
- "label" : "operation 3.1.1",
- },
-
- "ns3:pt31:op312" : {
- "label" : "operation 3.1.2",
- }
-}
-
-var WSDLdependendSelects = {
- "#portTypes" : "#operations"
-}
-</script>
-
-<select size="15" onchange="updateListContent(this.value, '#portTypes', WSDLdependendSelects, WSDLoperationsData);" >
- <option value="ns1" selected="true" >Namespace1</option>
- <option value="ns2" >Namespace2</option>
- <option value="ns3" >Namespace3</option>
-</select>
-
-<select id="portTypes" size="15" onchange="updateListContent(this.value, '#operations', WSDLdependendSelects, WSDLoperationsData);">
- <option value="ns1:pt11" selected="true">PortType1.1</option>
- <option value="ns1:pt11">PortType1.2</option>
-</select>
-
-<select id="operations" size="15">
- <option value="ns1:pt11:op111" selected="true">op1.1.2</option>
- <option value="ns1:pt12:op112">op1.1.2</option>
- <option value="ns1:pt13:op113">op1.1.2</option>
-</select>
-
- */
-
-/**
- *
- * @param value the current selected value
- * @param targetElement the select to update
- * @param dependendSelects the data structure for subsequently dependent select elements
- * @param completeData the data structure with the complete data
- */
-function updateListContent(value, targetElement, dependendSelects, completeData) {
- jQuery(targetElement).empty();
- var listData = completeData[value];
- if (listData !== undefined) {
- for (var i=0; i < listData.options.length; i++) {
- var optionName = listData.options[i];
- var label = completeData[optionName].label;
- var selected;
- if (i == 0) {
- selected = ' selected="selected"';
- } else {
- selected = '';
- }
- var toAppend = '<option value="' + optionName + '"' + selected + '>' + label + '</option>';
- jQuery(targetElement).append(toAppend);
- }
- nextSelect = dependendSelects[targetElement];
- if (nextSelect !== undefined) {
- // We assume listData is not empty
- updateListContent(listData.options[0], nextSelect, dependendSelects, completeData);
- }
- }
- jQuery(targetElement).trigger("change");
-}
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/js/winery-support-non-AMD.js b/winery/org.eclipse.winery.repository/src/main/webapp/js/winery-support-non-AMD.js
deleted file mode 100644
index f1f1cfa..0000000
--- a/winery/org.eclipse.winery.repository/src/main/webapp/js/winery-support-non-AMD.js
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012-2013 University of Stuttgart.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * Oliver Kopp - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-function addResourceInstance() {
- if (highlightRequiredFields()) {
- vShowError("Please fill in all required fields");
- return;
- }
-
- var dataToSend = $('#createResourceForm').serialize();
- var cr = $('#createResource');
- $.ajax({
- type: "POST",
- async: false,
- "data": dataToSend,
- "url": cr.data("url"),
- dataType: "text",
- error: function(jqXHR, textStatus, errorThrown) {
- vShowAJAXError("Could not create resource", jqXHR, errorThrown);
- cr.modal("hide");
- },
- success: function(resData, textStatus, jqXHR) {
- cr.data("onSuccess")($('#createResourceForm').serializeArray(), resData, textStatus, jqXHR);
- cr.modal('hide');
- }
- });
-}
-
-/**
- * This function creates a dialog, where the user can add key/value pairs.
- * These pairs are then sent to the given URL via POST.
- *
- * REQUIRES <script id="template-createresource" type="text/x-tmpl">
- * Currently placed in header.jsp
- *
- * @param nameOfResource the name of the resource to add
- * @param fields array of label/name/type/hint/checked values to use for the field and to pass in the AJAX call. (optional) type is in "text"/"checkbox"/... -- the values allowed for "type" attributes of <input> fields. Currently, all fields are required.
- * @param url the URL to use. The URL is uses as unique ID. If a dialog is requested to be open with a URL and the previous dialog had the same URL, the previous dialog is opened
- * @param onSuccess: function(serializedArray, data, textStatus, jqXHR) to call if adding has been successful. "serializedArray" contains the value of $('#formid').serializeArray()
- */
-function createResource(nameOfResource, fields, url, onSuccess) {
- var cr = $('#createResource');
- if (cr.length == 1) {
- if (cr.data("url") == url) {
- // the same dialog has been created before. Reuse it
- cr.modal("show");
- return;
- } else {
- // remove the dialog and thus enable the creation of a new one
- cr.remove();
- }
- }
-
- var data = {
- nameOfResource: nameOfResource,
- fields: fields
- };
- require(["tmpl"], function(tmpl) {
- var div = tmpl("template-createresource", data);
-
- $("body").append(div);
- cr = $('#createResource');
- cr.on("shown.bs.modal", function() {
- $("#createResourceForm > fieldset > div:first-child > input").focus();
- });
-
- cr.modal('show');
- cr.data("url", url);
- cr.data("onSuccess", onSuccess);
- });
-}
-
-/**
- *
- * @param selection jQuery selection object (<selection>)
- * @param value the value of the text to add
- * @param text the text to add
- */
-function addSortedSelectionItem(selection, value, text) {
- var option = selection.children("option:first-child");
- while ((option.length == 1) && (option.text() < text)) {
- option = option.next();
- }
- var toAppend = '<option value="' + value + '" selected="selected">' + text + '</option>';
- if (option.length == 0) {
- selection.append(toAppend);
- } else {
- option.before(toAppend);
- }
-}
-
-/**** begin: for datatable ****/
-
-/**
- * Uses selected row as information for deleting on server (and on success deleting in table)
- *
- * the id of the thing to delete is read from the first column of the table
- *
- * @param tableInfo: info object about table
- * @param nameOfThingToDelete: used at messages
- * @param baseURL: used to form URL by baseURL+<name of thing>
- * @param idColumn: (optional) column to look for the id. If not provided, look in the first column
- * @param nameColumn: (optional) column to look for a name. If not provided, the id is used
- * @param namespaceColumn: (optional) column to look for a namespace. If not provided, do not use any nameespace information
- * @param withoutConfirmation (optional) if given, the resource is deleted without any confirmation
-*/
-function deleteOnServerAndInTable(tableInfo, nameOfThingToDelete, baseURL, idColumn, nameColumn, namespaceColumn, withoutConfirmation) {
- if (tableInfo.selectedRow == null) {
- vShowError("No row selected.");
- } else {
- idColumn = idColumn || 0; // default: first column indicates identifier
- var id = tableInfo.table.fnGetData(tableInfo.selectedRow, idColumn);
- var name;
- if (typeof nameColumn === "undefined") {
- name = id;
- } else {
- name = tableInfo.table.fnGetData(tableInfo.selectedRow, nameColumn);
- }
-
- var url = baseURL;
- if (typeof namespaceColumn !== "undefined") {
- var namespace = tableInfo.table.fnGetData(tableInfo.selectedRow, namespaceColumn);
- namespace = encodeID(namespace);
- url = url + namespace + '/';
- }
- // append the id
- // we could add a "/" to be compatible with Jersey's URL rewriting
- // However, that prevents deleting a thing being a leaf in the URL (e.g. a namespace)
- url = url + encodeID(id);
-
- // defined in winery-common.js
- deleteResource(nameOfThingToDelete + " " + name, url,
- function(data, textSTatus, jqXHR) {
- tableInfo.table.fnDeleteRow(tableInfo.selectedRow);
- tableInfo.selectedRow = null;
- tableInfo.selectedTr = null;
- }, false, false, withoutConfirmation
- );
- }
-}
-
-/**** end: for datatable ****/
-
-/**
- * Uploads the content of given form to given url
- *
- * @param form specifies the form to read data from
- * @param url specifies the URL to send the data to
- * @param onSuccess: function(XMLHttpRequest) to handle result
- */
-function uploadFile(form, url, onSuccess) {
- var xhr = new XMLHttpRequest();
- var fd = new FormData(form);
- xhr.onreadystatechange = function(e) {
- if (this.readyState == 4) {
- if ((xhr.status != 200) && (xhr.status != 201)) {
- alert("Upload error occurred: " + xhr.status);
- } else {
- onSuccess(xhr);
- }
- }
- };
- xhr.open('post', url, true);
- xhr.send(fd);
-}
-
-/**
- * PUTs given value to the server in the BODY
- *
- * @param thing the thing to send. used as URL and in the error messages
- */
-function updateValue(thing, value) {
- $.ajax({
- type: "PUT",
- async: false,
- url: thing,
- "data": value,
- dataType: "text",
- processData: false, // leads to a send in the body
- error: function(jqXHR, textStatus, errorThrown) {
- vShowAJAXError("Could not set " + thing, jqXHR, errorThrown);
- },
- success: function() {
- vShowSuccess("Successfully updated " + thing);
- }
- });
-}
-
-/**
- * Puts the color to visualappearance/{id}
- *
- * Required by visualappearance.jsp (node type and relation ship type)
- *
- * @param id
- */
-function putColor(id, hex) {
- var dataToSend = {
- "color" : hex
- };
- $.ajax({
- type : "PUT",
- async : false,
- url : "visualappearance/" + id,
- "data" : dataToSend,
- dataType : "text",
- error : function(jqXHR, textStatus, errorThrown) {
- vShowError("Could not set color " + errorThrown);
- },
- success: function(data, textStatus, jqXHR) {
- vShowSuccess("Successfully updated color");
- }
- });
-}
-
diff --git a/winery/org.eclipse.winery.repository/src/main/webapp/js/winery-support.js b/winery/org.eclipse.winery.repository/src/main/webapp/js/winery-support.js
deleted file mode 100644
index 0459235..0000000
--- a/winery/org.eclipse.winery.repository/src/main/webapp/js/winery-support.js
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012-2013 University of Stuttgart.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * Oliver Kopp - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-/* no name given as RequireJS' documentatio says that makes modules less portable */
-define(["datatables"], function() {
- /*
- * Valid chars: See
- * <ul>
- * <li>http://www.w3.org/TR/REC-xml-names/#NT-NCName</li>
- * <li>http://www.w3.org/TR/REC-xml/#NT-Name</li>
- * </ul>
- */
- // NameCharRange \u10000-\ueffff is not supported by Java
- var NCNameStartChar_RegExp = "[A-Z_a-z\u00c0-\u00d6\u00d8\u00f6\u00f8\u02ff\u0370\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]";
- var NCNameChar_RegExp = NCNameStartChar_RegExp + "|[-\\.0-9\u00B7\u0300-\u036F\u203F-\u2040]";
- var NCName_RegExp = NCNameStartChar_RegExp + "(" + NCNameChar_RegExp + ")*";
- var QName_RegExp = "(" + NCName_RegExp + ":)?(" + NCName_RegExp + ")";
-
- var NCNameStartChar_Pattern = new RegExp(NCNameStartChar_RegExp);
- var NCNameChar_Pattern = new RegExp(NCNameChar_RegExp);
-
- /**
- * Initializes a table (and updates tableInfo)
- * * adds selection capability
- *
- * @param info.id: id of the table (with #)
- * @param paramsForDataTable: additional parameters for dataTable()
- * @param afterInit function to be called after dataTables object initalization happened
- *
- * @returns initialized info object
- * * info.table is updated with a pointer to the data table
- * * info.selectedTr is set to null
- */
- function initTable(info, paramsForDataTable, afterInit) {
- paramsForDataTable = paramsForDataTable || {};
-
- $(info.id).click(function(event) {
- if (info.selectedTr != null) {
- info.selectedTr.removeClass('row_selected');
- }
- var row = $(event.target.parentNode);
- if ((info.selectedTr != null) && (info.selectedTr[0] == row[0])) {
- // row is deselected if selected again
- info.selectedRow = null;
- info.selectedTr = null;
- } else {
- info.selectedTr = row;
- info.selectedTr.addClass('row_selected');
- info.selectedRow = event.target.parentNode;
- }
- });
- info.selectedTr = null;
- info.table = $(info.id).dataTable(paramsForDataTable);
- if (afterInit) afterInit();
- }
-
- /**
- * Function to determine whether a data table described with the tableInfo object is empty
- *
- * @param tableInfo the table info object describing the table
- * @returns true if the table is empty, false otherwise
- */
- function isEmptyTable(tableInfo) {
- return tableInfo.table.children("tbody").children("tr").first().children("td").hasClass("dataTables_empty");
- }
-
- /**
- * JavaScript implementation of org.eclipse.winery.common.Util.makeNCName(String)
- */
- function makeNCName(text) {
- if (!text || text == "") {
- return text;
- }
-
- var res = "";
-
- var start = text.substr(0, 1);
- if (NCNameStartChar_Pattern.test(start)) {
- res += start;
- } else {
- res += "_";
- }
-
- for (var i=1; i<text.length; i++) {
- var c = (text.substr(i, 1));
- if (NCNameChar_Pattern.test(c)) {
- res += c;
- } else {
- res += "_";
- }
- }
- return res;
- }
-
- var module = {
- initTable: initTable,
- isEmptyTable: isEmptyTable,
- makeNCName: makeNCName,
- QName_RegExp: QName_RegExp
- };
- return module;
- }
-);