<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="eventHandle.aspx.cs" Inherits="view.flow.eventHandle" %>

<html><head>
  <meta http-equiv="X-UA-Compatible"content="IE=EmulateIE7"/>
  <meta http-equiv="Content-Type" content='text/html; charset=utf-8' />
  <title>workflow events</title>
  <link href='../skin/view.css' type='text/css' rel='stylesheet'>
  <script language=javascript>document.write("<script type='text/javaScript' src='../common/view"+location.search.substring(1)+".js'><\/script>");</script>
  <script type='text/javascript' src='../common/view.js'></script>
</head>

<body scroll=no>
<div style='margin:0px 10px;'>
<div>function onLoad()</div><textarea style='width:460px;height:115px;line-height:1.5;' id=oOnLoad onkeypress='if(event.keyCode==34) return false;'></textarea><br />
<div>function onActionBefore(nActionId,sName)</div><textarea style='width:460px;height:115px;line-height:1.5;' id=oOnActionBefore onkeypress='if(event.keyCode==34) return false;'></textarea><br />
<div>function onActionAfter(nActionId,sName)</div><textarea style='width:460px;height:115px;line-height:1.5;' id=oOnActionAfter onkeypress='if(event.keyCode==34) return false;'></textarea>
</div>
<script language=javaScript>
    workflowActionsShow('okCancel');
    var sSource = dialogArguments.value.replace(new RegExp('<br>', 'g'), '\r\n');
    var sSeperator = ';\r\n/*//*/\r\n';
    var aSource = sSource.split(sSeperator);
    if (aSource.length == 7) {
        document.getElementById('oOnLoad').value = aSource[1];
        document.getElementById('oOnActionBefore').value = aSource[3];
        document.getElementById('oOnActionAfter').value = aSource[5];
    }
    function onActionBefore(nActionId, sName, bPostForm) {
        if (nActionId > 0) {
            var sOnLoad = document.getElementById('oOnLoad').value.replace(/(^\s*)|(\s*$)/g, "");
            var sOnActionBefore = document.getElementById('oOnActionBefore').value.replace(/(^\s*)|(\s*$)/g, "");
            var sOnActionAfter = document.getElementById('oOnActionAfter').value.replace(/(^\s*)|(\s*$)/g, "");
            if(sOnLoad.length == 0 && sOnActionBefore.length == 0 && sOnActionAfter.length == 0)
            {
                dialogArguments.value= "";
            }
            else
            {
                var s = "try{" + sSeperator + sOnLoad + sSeperator + "}catch(e){alert('[ '+translate['eventHandle']+' ] '+(typeof e=='object'?e.message:e));}function onActionBefore(nActionId,sName,bPostForm){try{" + sSeperator + sOnActionBefore + sSeperator + "return 1;}catch(e){alert('[ '+translate['eventHandle']+' ] '+(typeof e=='object'?e.message:e));return 0;}}function onActionAfter(nActionId,sName,bPostForm){try{" + sSeperator + sOnActionAfter + sSeperator + "return 1;}catch(e){alert('[ '+translate['eventHandle']+' ] '+(typeof e=='object'?e.message:e));return 0;}}";
                dialogArguments.value = s.replace(new RegExp('\r\n', 'g'), '<br>');
            }
        }
        self.close();
        return 0; //prevent from submitting
    }
</script>
</body>
</html>