Author: prasad
Date: Thu Jan 17 00:32:05 2008
New Revision: 12389
Log:
Fixed MASHUP-519:The 'Mashup Code' tab of the new editor UI need to be adjusted
to stay in the same line with the editor's top boarder.
Modified:
trunk/mashup/java/modules/www/css/styles.css
trunk/mashup/java/modules/www/editor.jsp
Modified: trunk/mashup/java/modules/www/css/styles.css
==============================================================================
--- trunk/mashup/java/modules/www/css/styles.css (original)
+++ trunk/mashup/java/modules/www/css/styles.css Thu Jan 17 00:32:05 2008
@@ -532,3 +532,36 @@
}.login-error {
color: #FF0000;
}
+
+div#editor ul.user {
+ text-align: left;
+ margin: 4px 0px 0px 0px;
+}
+
+div#editor span.beta {
+ color: white;
+ font-weight: bold;
+ font-size: 120%;
+ font-style: italic;
+ position: relative;
+ top: 6px;
+}
+
+div#editor li.tab {
+ display: inline;
+ background-image: url( ../images/gradient-tab.gif );
+ height: 15px;
+ padding: 4px 2px 2px 8px;
+ font-size: 10px;
+ margin-left: 0px;
+}
+
+div#editor li.tab-right {
+ display: inline;
+ background-image: url( ../images/gradient-tab-right.gif );
+ background-repeat: no-repeat;
+ height: 20px;
+ padding: 4px 2px 2px 0px;
+ font-size: 10px;
+}
+
Modified: trunk/mashup/java/modules/www/editor.jsp
==============================================================================
--- trunk/mashup/java/modules/www/editor.jsp (original)
+++ trunk/mashup/java/modules/www/editor.jsp Thu Jan 17 00:32:05 2008
@@ -1,461 +1,440 @@
-<%--
- * Copyright 2006,2007 WSO2, Inc. http://www.wso2.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
---%>
-<%@ page isErrorPage="true" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ page import="org.wso2.mashup.utils.MashupUtils" %>
-<%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils" %>
-<%@ page import="org.wso2.registry.Registry" %>
-<%@ page import="java.net.URLDecoder" %>
-<%@ page import="java.util.Enumeration" %>
-
-<!--Required to keep a user logged in if 'Remember Me' option is selected-->
-<%@ include file="validate_login.jsp" %>
-
-<%
- //Disabling browser caching
- response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
- response.setHeader("Pragma", "no-cache"); //HTTP 1.0
- response.setDateHeader("Expires", 0); //prevents caching at the proxy
server
-
- String bounceback = request.getParameter("bounceback");
-
- if (bounceback == null) {
- bounceback = "index.jsp";
- } else {
- bounceback = URLDecoder.decode(bounceback, "UTF-8");
- }
-
- // Set bounceback location
- String queryString = request.getQueryString();
- String thisPage = URLEncoder
- .encode("editor.jsp" + (queryString == null ? "" : "?" +
queryString), "UTF-8");
-
- //The query for this page will contain two parameters. The 'action'
parameter, which will
- // notify whether a new service is being created or an existing one is to
be edited and an
- // optional 'mashup' parameter, which will identify the mashup to be
edited in such an instance.
-
- String action = request.getParameter("action");
- String mashup = request.getParameter("mashup");
- String mashupName = mashup;
- String author = "";
- String currentUser = RegistryUtils.getCurrentUser(registry);
-
- //Sanity check. Immediately terminate further processing if this fails.
- if (action == null) {
- throw new Exception("Sorry. An action was not specified in the
request.");
- } else if ((action.equalsIgnoreCase("edit")) && (mashup == null)) {
- throw new Exception(
- "Sorry. An edit request was made without a valid mashup being
named for editing.");
- } else if ((action.equalsIgnoreCase("edit")) && (mashup != null)) {
- String[] pathContents = mashup.split("/");
-
- //Restricting mashup editing for particular referer pages
- String[] validReferers = { "mashup.jsp" };
- boolean validReferer = false;
-
- if (pathContents.length < 4) {
- throw new Exception("Sorry. The path specified for the mashup is
invalid.");
- } else {
- author = pathContents[2];
- mashupName = pathContents[3];
- }
-
- if (!((author.equalsIgnoreCase(currentUser) ||
RegistryUtils.isAdminRole(registry)))) {
- throw new Exception(
- "Sorry. You are not authorized to perform this
operation.");
- }
- } else if ((action.equalsIgnoreCase("new")) && (mashup == null)) {
- throw new Exception(
- "Sorry. A request was made to create a mashup without
providing a valid name.");
- } else if ((action.equalsIgnoreCase("new")) && (mashup != null)) {
- author = currentUser;
- String serviceValidationResult =
- MashupUtils.isPossibleToCreateService("/mashups/" + author +
"/" + mashup);
- if (!(serviceValidationResult.equalsIgnoreCase("ok"))) {
- throw new Exception(serviceValidationResult);
- }
- }
-%>
-<html>
-<head>
-<!--Do not cache -->
-<meta http-equiv="PRAGMA" content="NO-CACHE">
-<meta http-equiv="expires" content=<%= new java.util.Date() %>>
-
-<title>WSO2 Mashup Server - Editing <%=mashupName%> by <%=RegistryUtils
- .getFullName(request, author)%></title>
-<!-- Required CSS -->
-<link href="css/styles.css" rel="stylesheet" type="text/css"/>
-<style type="text/css">
- #tabs {
- display: block;
- float: left;
- width: 100%;
- }
-
- a.tab {
- border-collapse: collapse;
- border-style: solid solid none solid;
- border-color: black;
- border-width: 1px 1px 0px 1px;
- background-color: silver;
- padding: 4px 0.5em 0px 0.5em;
- margin-top: 4px;
- margin-right: 2px;
- text-decoration: none;
- width: 11%;
- text-align: center;
- float: left;
- }
-
- a.tab:hover {
- border-color: black;
- background-color: white;
- }
-
- .panel {
- /*border: solid 1px black;*/
- background-color: white; /* padding: 5px;*/
- height: 95%;
- overflow: auto;
- clear: left;
- }
-</style>
-
-<!-- Required Javascript -->
-<script language="javascript" src="js/common.js"
type="text/javascript"></script>
-<script type="text/javascript" src="../wsasadmin/global_params.js"></script>
-<script type="text/javascript" src="../wsasadmin/js/main.js"></script>
-<script type="text/javascript" src="js/mashup-main.js"></script>
-<script language="javascript" src="js/wso2/WSRequest.js"
type="text/javascript"></script>
-<script language="javascript" src="js/services.js"
type="text/javascript"></script>
-<script language="javascript"
- type="text/javascript">userLoggedOn =
<%=RegistryUtils.isLoggedIn(registry) %>;</script>
-
-<script language="JavaScript" type="text/javascript">
-var panels = new Array('mashup_code', 'ui_code');
-var selectedTab = null;
-function showPanel(tab, name)
-{
- if (selectedTab)
- {
- selectedTab.style.backgroundColor = '';
- selectedTab.style.paddingTop = '';
- selectedTab.style.marginTop = '4px';
- }
- selectedTab = tab;
- selectedTab.style.backgroundColor = 'white';
- selectedTab.style.paddingTop = '6px';
- selectedTab.style.marginTop = '0px';
- for (var i = 0; i < panels.length; i++)
- {
- document.getElementById(panels[i]).style.display =
- (name == panels[i]) ? 'block' : 'none';
- }
- return false;
-}
-
-function init() {
- try {
- showPanel(document.getElementById('tab1'), 'mashup_code');
- } catch(e) {
- }
-}
-
-function saveSourceCallback() {
-
- var lblInfo = document.getElementById(this.params);
-
- var saveSuccess;
-
- var browser = WSRequest.util._getBrowser();
- if (browser == "ie" || browser == "ie7") {
- saveSuccess =
-
this.req.responseXML.getElementsByTagName("ns:return")[0].firstChild.nodeValue;
- } else {
- saveSuccess =
-
this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue;
- }
-
-
- var currentTime = new Date();
- var hours = currentTime.getHours();
- var minutes = currentTime.getMinutes();
- var month = currentTime.getMonth() + 1;
- var day = currentTime.getDate();
- var year = currentTime.getFullYear();
-
- if (minutes < 10)
- minutes = "0" + minutes;
-
- var timeStamp = "at " + hours + ":" + minutes;
-
- if (hours > 11) {
- timeStamp = timeStamp + " PM";
- } else {
- timeStamp = timeStamp + " AM";
- }
-
- timeStamp = timeStamp + " on " + month + "/" + day + "/" + year;
-
- if (saveSuccess == "true") {
- lblInfo.innerHTML = "";
- lblInfo.innerHTML =
- "<font color=green>Your source edits were successfully updated " +
timeStamp +
- "</font>";
- } else {
- lblInfo.innerHTML = "";
- lblInfo.innerHTML =
- "<font color=red>Failed to update source edits " + timeStamp +
"</font>";
- }
-
-}
-
-function saveServiceSource(newSource) {
-<%
-if(action.equalsIgnoreCase("edit")){
-%>
- wso2.mashup.services.saveServiceSource('<%=mashup%>', newSource,
saveSourceCallback, "source_save_status");
-<%
-}else if(action.equalsIgnoreCase("new")){
-%>
- wso2.mashup.services.saveServiceSource('<%="/mashups/" + currentUser + "/"
+ mashup%>', newSource, saveSourceCallback, "source_save_status");
-<%
-}
-%>
-}
-
-function saveUiSource(newSource) {
-<%
- if(action.equalsIgnoreCase("edit")){
-%>
- wso2.mashup.services.saveUiSource('<%=mashup%>', newSource,
saveSourceCallback, "ui_save_status");
-<%
-}else if(action.equalsIgnoreCase("new")){
-%>
- wso2.mashup.services.saveUiSource('<%="/mashups/" + currentUser + "/" +
mashup%>', newSource, saveSourceCallback, "ui_save_status");
-<%
-}
-%>
-}
-
-</script>
-</head>
-<body onload="init();">
-<div id="page">
-<%@ include file="header.jsp" %>
-<div id="search"></div>
-<div id="welcome">Editing the mashup <b><%=mashupName%>
-</b> authored by <i><%=RegistryUtils.getFullName(request, author)%>
-</i>.
-</div>
-<div id="content">
-<%
- //Only signed in users can perform editing in the first place
- if (!RegistryUtils.isLoggedIn(registry)) {
-%>
-<p>You need to <a href="signin.jsp?bounceback=<%=thisPage%>">sign in</a> to
edit Mashups. If
- you came here by accident, <a href="<%=bounceback%>">go back</a>.
-</p>
-<%
-} else {
- //We have an authorized user. Spawning an editor.
-%>
-
-<div id="mashup_editor" style="height: 80%;">
-<div id="tabs">
- <a href="" class="tab"
- onmousedown="return event.returnValue = showPanel(this, 'mashup_code');"
- id="tab1"
- onclick="return false;">Mashup Code</a>
- <a href="" class="tab"
- onmousedown="return event.returnValue = showPanel(this, 'ui_code');"
- onclick="return false;">Custom UI Code</a>
-</div>
-<div class="panel" id="mashup_code" style="display: block">
- <%
- String serviceSource = "";
- if (action.equalsIgnoreCase("new")) {
- //Inserting the initial mashup skeleton
- serviceSource = "/*\n" +
- "* Copyright 2005-2007 WSO2, Inc. http://www.wso2.org\n" +
- "*\n" +
- "* Licensed under the Apache License, Version 2.0 (the
\"License\");\n" +
- "* you may not use this file except in compliance with the
License.\n" +
- "* You may obtain a copy of the License at\n" +
- "*\n" +
- "* http://www.apache.org/licenses/LICENSE-2.0\n" +
- "*\n" +
- "* Unless required by applicable law or agreed to in
writing, software\n" +
- "* distributed under the License is distributed on an \"AS
IS\" BASIS,\n" +
- "* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied.\n" +
- "* See the License for the specific language governing
permissions and\n" +
- "* limitations under the License.\n" +
- "*/\n" +
- "this.serviceName = \"" + mashup + "\";\n" +
- "this.documentation = \"TODO: Add service level
documentation here\" ;\n" +
- "\n" +
- "toString.documentation = \"TODO: Add operation level
documentation here\" ;\n" +
- "toString.inputTypes = { /* TODO: Add input types of this
operation */ };\n" +
- "toString.outputType = \"String\"; /* TODO: Add output
type here */ \n" +
- "function toString()\n" +
- "{\n" +
- " //TODO: Add function code here\n" +
- " return \"Hi, my name is " + mashup + "\";\n" +
- "}\n";
-
-
- } else if (action.equalsIgnoreCase("edit")) {
- serviceSource = MashupUtils.readServiceSource(mashup);
- }
- %>
- <textarea id="mashup_code_text" rows="" cols="" class="codepress
javascript"
- style="width: 100%; height: 95%;">
- <%=serviceSource%>
- </textarea>
- <br>
-
- <div style="padding-top: 10px;"><label id="source_save_status"
style="float: left;">Tip: You can
- use the button on
- the right to save changes.</label> <input type="button"
- value="Save mashup code"
-
onclick="saveServiceSource(mashup_code_text.getCode());"
- style="float: right;"/>
- </div>
-</div>
-<div class="panel" id="ui_code" style="display: block">
-<%
- String uiSource = "";
- if (action.equalsIgnoreCase("new")) {
- uiSource =
- "<!--\n" +
- " ~ Copyright 2005-2007 WSO2, Inc.
http://www.wso2.org\n" +
- " ~\n" +
- " ~ Licensed under the Apache License, Version 2.0
(the \"License\");\n" +
- " ~ you may not use this file except in compliance
with the License.\n" +
- " ~ You may obtain a copy of the License at\n" +
- " ~\n" +
- " ~ http://www.apache.org/licenses/LICENSE-2.0\n" +
- " ~\n" +
- " ~ Unless required by applicable law or agreed to in
writing, software\n" +
- " ~ distributed under the License is distributed on
an \"AS IS\" BASIS,\n" +
- " ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied.\n" +
- " ~ See the License for the specific language
governing permissions and\n" +
- " ~ limitations under the License.\n" +
- " -->\n" +
- "\n" +
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">\n" +
- "<html>\n" +
- "<head>\n" +
- "\n" +
- " <meta content=\"text/html; charset=ISO-8859-1\"
http-equiv=\"content-type\">\n" +
- " <title>Welcome to " + mashup + "</title>\n" +
- " \n" +
- " <style type=\"text/css\">\n" +
- " body {font: 75%/1.5 \"Lucida Grande\",\"Lucida
Sans\",\"Microsoft Sans Serif\", \"Lucida Sans
Unicode\",verdana,sans-serif,\"trebuchet ms\"; color: #111; }\n" +
- " img {margin-bottom: 0.5em}\n" +
- " span {font-weight: bold}\n" +
- " .template {margin-left:1em; margin-bottom:1em;
font-size:125%}\n" +
- " #console {color:red; font-weight:bold}\n" +
- " </style>\n" +
- " <script type=\"text/javascript\"
src=\"/js/wso2/WSRequest.js\"></script>\n" +
- " <script type=\"text/javascript\" src=\"../" +
mashup +
- "?stub\"></script>\n" +
- " \n" +
- " <script type=\"text/javascript\"
language=\"javascript\">\n" +
- "\n" +
- "\t\t //Calls the toString operation of the '" +
mashup +
- "' Mashup \n" +
- " function callMashup() { \n" +
- "\n" +
- " " + mashup + ".setAddress(" +
- mashup + ".endpoint, \"services/" + mashup +
- "\");\n" +
- " " + mashup +
- ".toString.onError = handleError;\n" +
- " " + mashup +
- ".toString.callback = function (response) {\n" +
- " fillData(response);\n" +
- " }\n" +
- " " + mashup + ".toString();\n" +
- " }\n" +
- " \n" +
- " //Handles and error by displaying the reason
in a dialog\n" +
- " function handleError(error) {\n" +
- " var console =
document.getElementById(\"error-console\");" +
- " log (console, \"Fault: \" + error.reason
+ \"\\n\\n\" + error.detail);\n" +
- " }\n" +
- "\n" +
- "\t\t //Writes the received response to the DIV\n" +
- " function fillData(response)\n" +
- " { \n" +
- " var responseDiv =
document.getElementById(\"reponse-text\");\n" +
- " responseDiv.innerHTML = '<p>' + response
+ '</p>'; \n" +
- " } \n" +
- " \n" +
- " function log(console, data) {\n" +
- " var browser =
WSRequest.util._getBrowser();\n" +
- " if (browser == \"ie\" || browser ==
\"ie7\")\n" +
- " console.innerText = data;\n" +
- " else\n" +
- " console.textContent = data;\n" +
- " }" +
- " \n" +
- " </script>\n" +
- " \n" +
- "</head>\n" +
- "\n" +
- "<body onload='callMashup();'>\n" +
- "<img alt=\"WSO2 Mashup Server logo\"
src=\"/images/wso2_mashup_logo.gif\"/>" +
- "\n" +
- "\t<div id=\"reponse-text\"> \n" +
- "\t<!-- This div will contain the text returned as
response to the service call -->\n" +
- "\t</div>\n" +
- "<div>Access all the operations of the " + mashup +
- " service through the <a href=\"../" + mashup +
- "?tryit\">Try-it page</a>.</div>" +
- "\n" +
- "<div id=\"error-console\"></div>" +
- " \n" +
- "</body>\n" +
- "</html>";
- } else if (action.equalsIgnoreCase("edit")) {
- uiSource = MashupUtils.readServiceUiSource(mashup);
- }
-%>
-<textarea id="ui_code_text" rows="" cols="" class="codepress html"
- style="width: 100%; height: 95%;"><%=uiSource%>
-</textarea>
-<br>
-
-<div style="padding-top: 10px;"><label id="ui_save_status" style="float:
left;">Tip: You can
- use the button on
- the right to save changes.</label> <input type="button"
- value="Save custom ui code"
-
onclick="saveUiSource(ui_code_text.getCode());"
- style="float: right;"/>
-</div>
-</div>
-</div>
-<%
- }
-%>
-</div>
-<%@ include file="footer.jsp" %>
-</div>
-<script language="javascript" src="js/codepress/codepress.js"
type="text/javascript"></script>
-</body>
+<%--
+ * Copyright 2006,2007 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+--%>
+<%@ page isErrorPage="true" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ page import="org.wso2.mashup.utils.MashupUtils" %>
+<%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils" %>
+<%@ page import="org.wso2.registry.Registry" %>
+<%@ page import="java.net.URLDecoder" %>
+<%@ page import="java.util.Enumeration" %>
+
+<!--Required to keep a user logged in if 'Remember Me' option is selected-->
+<%@ include file="validate_login.jsp" %>
+
+<%
+ //Disabling browser caching
+ response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
+ response.setHeader("Pragma", "no-cache"); //HTTP 1.0
+ response.setDateHeader("Expires", 0); //prevents caching at the proxy
server
+
+ String bounceback = request.getParameter("bounceback");
+
+ if (bounceback == null) {
+ bounceback = "index.jsp";
+ } else {
+ bounceback = URLDecoder.decode(bounceback, "UTF-8");
+ }
+
+ // Set bounceback location
+ String queryString = request.getQueryString();
+ String thisPage = URLEncoder
+ .encode("editor.jsp" + (queryString == null ? "" : "?" +
queryString), "UTF-8");
+
+ //The query for this page will contain two parameters. The 'action'
parameter, which will
+ // notify whether a new service is being created or an existing one is to
be edited and an
+ // optional 'mashup' parameter, which will identify the mashup to be
edited in such an instance.
+
+ String action = request.getParameter("action");
+ String mashup = request.getParameter("mashup");
+ String mashupName = mashup;
+ String author = "";
+ String currentUser = RegistryUtils.getCurrentUser(registry);
+
+ //Sanity check. Immediately terminate further processing if this fails.
+ if (action == null) {
+ throw new Exception("Sorry. An action was not specified in the
request.");
+ } else if ((action.equalsIgnoreCase("edit")) && (mashup == null)) {
+ throw new Exception(
+ "Sorry. An edit request was made without a valid mashup being
named for editing.");
+ } else if ((action.equalsIgnoreCase("edit")) && (mashup != null)) {
+ String[] pathContents = mashup.split("/");
+
+ //Restricting mashup editing for particular referer pages
+ String[] validReferers = { "mashup.jsp" };
+ boolean validReferer = false;
+
+ if (pathContents.length < 4) {
+ throw new Exception("Sorry. The path specified for the mashup is
invalid.");
+ } else {
+ author = pathContents[2];
+ mashupName = pathContents[3];
+ }
+
+ if (!((author.equalsIgnoreCase(currentUser) ||
RegistryUtils.isAdminRole(registry)))) {
+ throw new Exception(
+ "Sorry. You are not authorized to perform this
operation.");
+ }
+ } else if ((action.equalsIgnoreCase("new")) && (mashup == null)) {
+ throw new Exception(
+ "Sorry. A request was made to create a mashup without
providing a valid name.");
+ } else if ((action.equalsIgnoreCase("new")) && (mashup != null)) {
+ author = currentUser;
+ String serviceValidationResult =
+ MashupUtils.isPossibleToCreateService("/mashups/" + author +
"/" + mashup);
+ if (!(serviceValidationResult.equalsIgnoreCase("ok"))) {
+ throw new Exception(serviceValidationResult);
+ }
+ }
+%>
+<html>
+<head>
+<!--Do not cache -->
+<meta http-equiv="PRAGMA" content="NO-CACHE">
+<meta http-equiv="expires" content=<%= new java.util.Date() %>>
+
+<title>WSO2 Mashup Server - Editing <%=mashupName%> by <%=RegistryUtils
+ .getFullName(request, author)%></title>
+<!-- Required CSS -->
+<link href="css/styles.css" rel="stylesheet" type="text/css"/>
+<style type="text/css">
+
+ .panel {
+ /*border: solid 1px black;*/
+ background-color: white; /* padding: 5px;*/
+ height: 95%;
+ overflow: auto;
+ clear: left;
+ border-top:3px solid #CEE171;
+ }
+</style>
+
+<!-- Required Javascript -->
+<script language="javascript" src="js/common.js"
type="text/javascript"></script>
+<script type="text/javascript" src="../wsasadmin/global_params.js"></script>
+<script type="text/javascript" src="../wsasadmin/js/main.js"></script>
+<script type="text/javascript" src="js/mashup-main.js"></script>
+<script language="javascript" src="js/wso2/WSRequest.js"
type="text/javascript"></script>
+<script language="javascript" src="js/services.js"
type="text/javascript"></script>
+<script language="javascript"
+ type="text/javascript">userLoggedOn =
<%=RegistryUtils.isLoggedIn(registry) %>;</script>
+
+<script language="JavaScript" type="text/javascript">
+var panels = new Array('mashup_code', 'ui_code');
+var selectedTab = null;
+function showPanel(tab, name)
+{
+ if (selectedTab)
+ {
+ selectedTab.style.color = '';
+ //selectedTab.style.fontWeight = '';
+ selectedTab.style.textDecoration = '';
+
+ }
+ selectedTab = tab;
+ selectedTab.style.color = 'black';
+ // selectedTab.style.fontWeight = 'bold';
+ selectedTab.style.textDecoration = 'none';
+
+ for (var i = 0; i < panels.length; i++)
+ {
+ document.getElementById(panels[i]).style.display =
+ (name == panels[i]) ? 'block' : 'none';
+ }
+ return false;
+}
+
+function init() {
+ try {
+ showPanel(document.getElementById('tab1'), 'mashup_code');
+ } catch(e) {
+ }
+}
+
+function saveSourceCallback() {
+
+ var lblInfo = document.getElementById(this.params);
+
+ var saveSuccess;
+
+ var browser = WSRequest.util._getBrowser();
+ if (browser == "ie" || browser == "ie7") {
+ saveSuccess =
+
this.req.responseXML.getElementsByTagName("ns:return")[0].firstChild.nodeValue;
+ } else {
+ saveSuccess =
+
this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue;
+ }
+
+
+ var currentTime = new Date();
+ var hours = currentTime.getHours();
+ var minutes = currentTime.getMinutes();
+ var month = currentTime.getMonth() + 1;
+ var day = currentTime.getDate();
+ var year = currentTime.getFullYear();
+
+ if (minutes < 10)
+ minutes = "0" + minutes;
+
+ var timeStamp = "at " + hours + ":" + minutes;
+
+ if (hours > 11) {
+ timeStamp = timeStamp + " PM";
+ } else {
+ timeStamp = timeStamp + " AM";
+ }
+
+ timeStamp = timeStamp + " on " + month + "/" + day + "/" + year;
+
+ if (saveSuccess == "true") {
+ lblInfo.innerHTML = "";
+ lblInfo.innerHTML =
+ "<font color=green>Your source edits were successfully updated " +
timeStamp +
+ "</font>";
+ } else {
+ lblInfo.innerHTML = "";
+ lblInfo.innerHTML =
+ "<font color=red>Failed to update source edits " + timeStamp +
"</font>";
+ }
+
+}
+
+function saveServiceSource(newSource) {
+<%
+if(action.equalsIgnoreCase("edit")){
+%>
+ wso2.mashup.services.saveServiceSource('<%=mashup%>', newSource,
saveSourceCallback, "source_save_status");
+<%
+}else if(action.equalsIgnoreCase("new")){
+%>
+ wso2.mashup.services.saveServiceSource('<%="/mashups/" + currentUser + "/"
+ mashup%>', newSource, saveSourceCallback, "source_save_status");
+<%
+}
+%>
+}
+
+function saveUiSource(newSource) {
+<%
+ if(action.equalsIgnoreCase("edit")){
+%>
+ wso2.mashup.services.saveUiSource('<%=mashup%>', newSource,
saveSourceCallback, "ui_save_status");
+<%
+}else if(action.equalsIgnoreCase("new")){
+%>
+ wso2.mashup.services.saveUiSource('<%="/mashups/" + currentUser + "/" +
mashup%>', newSource, saveSourceCallback, "ui_save_status");
+<%
+}
+%>
+}
+
+</script>
+</head>
+<body onload="init();">
+<div id="page">
+<%@ include file="header.jsp" %>
+<div id="search"></div>
+<div id="welcome">Editing the mashup <b><%=mashupName%>
+</b> authored by <i><%=RegistryUtils.getFullName(request, author)%>
+</i>.
+</div>
+<div id="content">
+<%
+ //Only signed in users can perform editing in the first place
+ if (!RegistryUtils.isLoggedIn(registry)) {
+%>
+<p>You need to <a href="signin.jsp?bounceback=<%=thisPage%>">sign in</a> to
edit Mashups. If
+ you came here by accident, <a href="<%=bounceback%>">go back</a>.
+</p>
+<%
+} else {
+ //We have an authorized user. Spawning an editor.
+%>
+
+<div id="mashup_editor" style="height: 80%;">
+<div id="editor" >
+<ul class="user">
+ <li class="tab"><a href="" onmousedown="return
event.returnValue = showPanel(this, 'mashup_code');"
+ id="tab1"
+ onclick="return false;">Mashup Code</a></li><li class="tab-right"><img
src="images/blank.gif" width="8"/></li>
+ <li class="tab"><a href=""
onmousedown="return event.returnValue = showPanel(this, 'ui_code');"
+ onclick="return false;">Custom UI Code</a></li><li
class="tab-right"><img src="images/blank.gif" width="8"/></li>
+ </ul>
+
+</div>
+<div class="panel" id="mashup_code" style="display: block">
+ <%
+ String serviceSource = "";
+ if (action.equalsIgnoreCase("new")) {
+ //Inserting the initial mashup skeleton
+ serviceSource = "/*\n" +
+ "* Copyright 2005-2007 WSO2, Inc. http://www.wso2.org\n" +
+ "*\n" +
+ "* Licensed under the Apache License, Version 2.0 (the
\"License\");\n" +
+ "* you may not use this file except in compliance with the
License.\n" +
+ "* You may obtain a copy of the License at\n" +
+ "*\n" +
+ "* http://www.apache.org/licenses/LICENSE-2.0\n" +
+ "*\n" +
+ "* Unless required by applicable law or agreed to in
writing, software\n" +
+ "* distributed under the License is distributed on an \"AS
IS\" BASIS,\n" +
+ "* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied.\n" +
+ "* See the License for the specific language governing
permissions and\n" +
+ "* limitations under the License.\n" +
+ "*/\n" +
+ "this.serviceName = \"" + mashup + "\";\n" +
+ "this.documentation = \"TODO: Add service level
documentation here\" ;\n" +
+ "\n" +
+ "toString.documentation = \"TODO: Add operation level
documentation here\" ;\n" +
+ "toString.inputTypes = { /* TODO: Add input types of this
operation */ };\n" +
+ "toString.outputType = \"String\"; /* TODO: Add output
type here */ \n" +
+ "function toString()\n" +
+ "{\n" +
+ " //TODO: Add function code here\n" +
+ " return \"Hi, my name is " + mashup + "\";\n" +
+ "}\n";
+
+
+ } else if (action.equalsIgnoreCase("edit")) {
+ serviceSource = MashupUtils.readServiceSource(mashup);
+ }
+ %>
+ <textarea id="mashup_code_text" rows="" cols="" class="codepress
javascript"
+ style="width: 100%; height: 94%;">
+ <%=serviceSource%>
+ </textarea>
+ <br>
+
+ <div style="padding-top: 10px;"><label id="source_save_status"
style="float: left;">Tip: You can
+ use the button on
+ the right to save changes.</label> <input type="button"
+ value="Save mashup code"
+
onclick="saveServiceSource(mashup_code_text.getCode());"
+ style="float: right;"/>
+ </div>
+</div>
+<div class="panel" id="ui_code" style="display: block">
+<%
+ String uiSource = "";
+ if (action.equalsIgnoreCase("new")) {
+ uiSource =
+ "<!--\n" +
+ " ~ Copyright 2005-2007 WSO2, Inc.
http://www.wso2.org\n" +
+ " ~\n" +
+ " ~ Licensed under the Apache License, Version 2.0
(the \"License\");\n" +
+ " ~ you may not use this file except in compliance
with the License.\n" +
+ " ~ You may obtain a copy of the License at\n" +
+ " ~\n" +
+ " ~ http://www.apache.org/licenses/LICENSE-2.0\n" +
+ " ~\n" +
+ " ~ Unless required by applicable law or agreed to in
writing, software\n" +
+ " ~ distributed under the License is distributed on
an \"AS IS\" BASIS,\n" +
+ " ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied.\n" +
+ " ~ See the License for the specific language
governing permissions and\n" +
+ " ~ limitations under the License.\n" +
+ " -->\n" +
+ "\n" +
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">\n" +
+ "<html>\n" +
+ "<head>\n" +
+ "\n" +
+ " <meta content=\"text/html; charset=ISO-8859-1\"
http-equiv=\"content-type\">\n" +
+ " <title>Welcome to " + mashup + "</title>\n" +
+ " \n" +
+ " <style type=\"text/css\">\n" +
+ " body {font: 75%/1.5 \"Lucida Grande\",\"Lucida
Sans\",\"Microsoft Sans Serif\", \"Lucida Sans
Unicode\",verdana,sans-serif,\"trebuchet ms\"; color: #111; }\n" +
+ " img {margin-bottom: 0.5em}\n" +
+ " span {font-weight: bold}\n" +
+ " .template {margin-left:1em; margin-bottom:1em;
font-size:125%}\n" +
+ " #console {color:red; font-weight:bold}\n" +
+ " </style>\n" +
+ " <script type=\"text/javascript\"
src=\"/js/wso2/WSRequest.js\"></script>\n" +
+ " <script type=\"text/javascript\" src=\"../" +
mashup +
+ "?stub\"></script>\n" +
+ " \n" +
+ " <script type=\"text/javascript\"
language=\"javascript\">\n" +
+ "\n" +
+ "\t\t //Calls the toString operation of the '" +
mashup +
+ "' Mashup \n" +
+ " function callMashup() { \n" +
+ "\n" +
+ " " + mashup + ".setAddress(" +
+ mashup + ".endpoint, \"services/" + mashup +
+ "\");\n" +
+ " " + mashup +
+ ".toString.onError = handleError;\n" +
+ " " + mashup +
+ ".toString.callback = function (response) {\n" +
+ " fillData(response);\n" +
+ " }\n" +
+ " " + mashup + ".toString();\n" +
+ " }\n" +
+ " \n" +
+ " //Handles and error by displaying the reason
in a dialog\n" +
+ " function handleError(error) {\n" +
+ " var console =
document.getElementById(\"error-console\");" +
+ " log (console, \"Fault: \" + error.reason
+ \"\\n\\n\" + error.detail);\n" +
+ " }\n" +
+ "\n" +
+ "\t\t //Writes the received response to the DIV\n" +
+ " function fillData(response)\n" +
+ " { \n" +
+ " var responseDiv =
document.getElementById(\"reponse-text\");\n" +
+ " responseDiv.innerHTML = '<p>' + response
+ '</p>'; \n" +
+ " } \n" +
+ " \n" +
+ " function log(console, data) {\n" +
+ " var browser =
WSRequest.util._getBrowser();\n" +
+ " if (browser == \"ie\" || browser ==
\"ie7\")\n" +
+ " console.innerText = data;\n" +
+ " else\n" +
+ " console.textContent = data;\n" +
+ " }" +
+ " \n" +
+ " </script>\n" +
+ " \n" +
+ "</head>\n" +
+ "\n" +
+ "<body onload='callMashup();'>\n" +
+ "<img alt=\"WSO2 Mashup Server logo\"
src=\"/images/wso2_mashup_logo.gif\"/>" +
+ "\n" +
+ "\t<div id=\"reponse-text\"> \n" +
+ "\t<!-- This div will contain the text returned as
response to the service call -->\n" +
+ "\t</div>\n" +
+ "<div>Access all the operations of the " + mashup +
+ " service through the <a href=\"../" + mashup +
+ "?tryit\">Try-it page</a>.</div>" +
+ "\n" +
+ "<div id=\"error-console\"></div>" +
+ " \n" +
+ "</body>\n" +
+ "</html>";
+ } else if (action.equalsIgnoreCase("edit")) {
+ uiSource = MashupUtils.readServiceUiSource(mashup);
+ }
+%>
+<textarea id="ui_code_text" rows="" cols="" class="codepress html"
+ style="width: 100%; height: 94%;"><%=uiSource%>
+</textarea>
+<br>
+
+<div style="padding-top: 10px;"><label id="ui_save_status" style="float:
left;">Tip: You can
+ use the button on
+ the right to save changes.</label> <input type="button"
+ value="Save custom ui code"
+
onclick="saveUiSource(ui_code_text.getCode());"
+ style="float: right;"/>
+</div>
+</div>
+</div>
+<%
+ }
+%>
+</div>
+<%@ include file="footer.jsp" %>
+</div>
+<script language="javascript" src="js/codepress/codepress.js"
type="text/javascript"></script>
+</body>
</html>
\ No newline at end of file
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev