<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta charset="UTF-8">
<title>Rule Editor Convertor by Jens Niemeyer</title>
<script id="sap-ui-bootstrap"
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-preload="async"
data-sap-ui-compatVersion="edge"
data-sap-ui-frameOptions='allow'>
</script>
<script id="startpage" type="ui5/xmlview">
<mvc:View
controllerName="${UI5_Namespace}.controller.${NAME}"
displayBlock="true"
xmlns="sap.m"
xmlns:l="sap.ui.layout"
xmlns:core="sap.ui.core"
xmlns:c="sap.ui.codeeditor"
xmlns:mvc="sap.ui.core.mvc">
<Page title="C4 Rule Converter">
<headerContent>
<Button press="pressBtn" icon="sap-icon://paste" text="Copy to clipboard" />
</headerContent>
<content>
<c:CodeEditor type="javascript"
height="80%" id="txt"
liveChange="onUpdate">
</c:CodeEditor>
<TextArea width="100%" enabled="false" id="newText"
height="10%"></TextArea>
</content>
</Page>
</mvc:View>
</script>
<script>
sap.ui.getCore().attachInit(function () {
"use strict";
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
return Controller.extend("${UI5_Namespace}.controller.${NAME}", {
pressBtn: function (oEvent) {
//debugger;
let textToCopy =this.getView().byId("newText").getValue();
async function copyToClipboard() {
try {
await navigator.clipboard.writeText(textToCopy);
sap.m.MessageToast.show("Copied to clipboard");
// 2) Catch errors
} catch (err) {
console.error('Failed to copy: ', err);
sap.m.MessageToast.show("Failed to copy");
}
}
copyToClipboard();
},
onUpdate: function (oEvent) {
var txt = this.getView().byId("txt").getCurrentValue();
var newText = txt.replaceAll("\t", " ");
newText = newText.replaceAll("\n", " ");
newText = newText.replaceAll("\r", " ");
newText = newText.replaceAll(" ", " ");
newText = newText.replaceAll(" ", "");
this.getView().byId("newText").setValue(newText);
},
});
});
sap.ui.require([
"jquery.sap.global"
], function (jQuery) {
sap.ui.xmlview({
viewContent: jQuery("#startpage").html()
}).placeAt('root');
});
});
</script>
</head>
<body class="sapUiBody" id="root"/>
</html>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |