vendredi 29 mars 2019

Rewriting a HTML file to exclude ActiveX objects

I am rewriting an application that is using alot of ActiveX objects throughout the code, and my goal is to rewrite the application to get rid of all ActiveX objects, and make the project client/server architecture using Java Spring.

I am basically stuck on how to delete the code using ActiveX objects in this file, and writing it in java instead.

<!DOCTYPE html>
<html>
<head>
<title>Velkommen</title>

<script type="text/javascript">

var message="Højreklik er ikke tilladt her."; 
function clickIE() {if (document.all) {(message);return false;}} 
function clickNS(e) {
    if(document.layers||(document.getElementById&&!document.all)) { 
        if (e.which==2||e.which==3) {(message);return false;}
    }
} 

if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
}else{
    document.onmouseup=clickNS;document.oncontextmenu=clickIE;
} 
document.oncontextmenu=new Function("return false") 

//var strConn_ORA_SCDRIFT = 'Provider=OraOLEDB.Oracle;Data Source=CTIRP;User Id=SC_DRIFT;Password=DRIFTSC;';    
var today=new Date()
var sql_today=""
var notification=""

function getBirthdays(){

    sql_today= today.toString("ddMM")//""+dd+""+dm

    var rs = new ActiveXObject("ADODB.Recordset");
    conn.Open(strConn_ORA_SCDRIFT);

    var SQL="SELECT SAF1.INITIALER , SAF1.MED_STEDKODE_ID , SAF1.FORNAVN , SAF1.EFTERNAVN , SAF.FUNKTIONSNAVN FROM SC_DRIFT.SAFE_SYS_MED_ANS_FUNKTION SAF, SC_DRIFT.SAFE_DATA_MEDARBEJDER SAF1 WHERE SAF.ANS_FUNKTIONS_ID=SAF1.FUNKTION AND SAF1.MED_STEDKODE_ID = '"+loggedInUser.Stedkode+"' AND SAF1.STATUS = 1 AND SUBSTR(SAF1.BIRTHDAY,1,4) = '"+sql_today+"' ORDER BY SAF.FUNKTIONSNAVN"

    rs.Open(SQL, conn);

    if(rs.eof == true){
        notification="Ingen nyheder i dag"
    }else{
        notification = "<ul>"
        while (rs.eof != true)
        {
            notification = notification +"<br>"+" <li>"+rs("FUNKTIONSNAVN")+" "+rs("FORNAVN")+" "+rs("EFTERNAVN")+" ("+rs("INITIALER")+") fra dit team har f&oslash;dseldag.<br>"
            rs.moveNext();
            notification = notification +"<br>"
            document.getElementById('info').innerHTML=notification
        }
        notification += "</ul>"
    }
    conn.Close();

}

function getMissingInfo() {

    var targetDiv = document.getElementById('info');

    var SQL = "Select * from SC_DRIFT.SAFE_DATA_MEDARBEJDER where INITIALER= '"+loggedInUser.Init+"'"

    var rs = new ActiveXObject("ADODB.Recordset");
    conn.Open(strConn_ORA_SCDRIFT);
    rs.Open(SQL, conn);
    while (rs.eof != true)
    {
        var birthDay = ""+rs("BIRTHDAY");
        var mobil = ""+rs("MOBILTELEFON");
        var adresse = ""+rs("ADRESSE");
        var mail = ""+rs("MAILADRESSE");
        var uddId = ""+rs("UDDANNELSERID");
        var uddStart = ""+rs("UDD_START");
        var uddSlut = ""+rs("UDD_SLUT");
        var madvalg = ""+rs("MADVALG");

        rs.moveNext();  
    }
    conn.Close();
    missingInfo = [];

    if(birthDay == "0000000000" || birthDay == 'null'){
        missingInfo.push("Fødselsdag")
    }
    if(mobil == 'null'){
        missingInfo.push("Mobiltelefon")
    }
    substring = "Ukendt";
    if(adresse == 'null' || adresse.indexOf(substring) > -1){
        missingInfo.push("Adresse")
    }
    if(mail == 'null'){
        missingInfo.push("Email")
    }
    if(uddId == 1 || uddId == 100 || uddId == 0){
        missingInfo.push("Uddannelse")
    }
    if(uddStart == 'null'){
        missingInfo.push("Uddannelse Start")
    }
    if(uddSlut == 'null'){
        missingInfo.push("Uddannelse Slut")
    }
    if(madvalg == 'null'){
        missingInfo.push("Madvalg")
    }
    if(missingInfo.length > 0){

        if(targetDiv.innerHTML == "Ingen info pt."){
            targetDiv.innerHTML = "";
        }
        var missingInfoLabel = document.createElement("div");
        missingInfoLabel.innerHTML = "<br />De f&oslash;lgende info mangler at blive indtastet"
        targetDiv.appendChild(missingInfoLabel);

        var missingInfoTable = document.createElement("div");
        var ul = document.createElement("ul");
        for(i = 0; i < missingInfo.length; i++){
            var li = document.createElement("li");
            li.innerHTML = missingInfo[i];
            li.className = "missingInfoLi";
            li.addEventListener("click", function (){document.getElementById("87_subPageId").click();}); 
            ul.appendChild(li);
        }
        missingInfoTable.appendChild(ul);
        targetDiv.appendChild(missingInfoTable);
    }

}

function getLeaderVacationNotify() {


    var targetDiv = document.getElementById('leaderVacationInfo');

    var SQL = "select distinct INITIALER, min(VAGT_DATO) FRA_DATO,max(VAGT_DATO) TIL_DATO from( Select * from SC_DRIFT.SAFE_DATA_VAGTPLAN where VACATION_ID in(2,3) and AKTIVITET_ID not in(54,15) and STEDKODE_ID="+loggedInUser.Stedkode+" and VAGT_DATO between  trunc(sysdate) and sysdate+90 and DELETED=0) group by INITIALER" //godkendt, men ikke accepteret samt anmodet ferie
    var rs = new ActiveXObject("ADODB.Recordset");
    conn.Open(strConn_ORA_SCDRIFT);
    rs.Open(SQL, conn);
    var vacationInit = [];
    var vacationDates = [];
    while (rs.eof != true)
    {
        var init = ""+rs("INITIALER");
        var dates = new Date(""+rs("FRA_DATO")).toString('dd-MM-yyyy')+ " til "+ new Date(""+rs("TIL_DATO")).toString('dd-MM-yyyy')
        vacationInit.push(init)
        vacationDates.push(dates)
        rs.moveNext();  
    }
    conn.Close();

    if(vacationInit.length > 0){

        if(targetDiv.innerHTML == "Ingen info pt."){
            targetDiv.innerHTML = "";
        }
        var vacationInfoLabel = document.createElement("div");
        vacationInfoLabel.innerHTML = "<br />De f&oslash;lgende initialer har udestående ferieønsker:"
        targetDiv.appendChild(vacationInfoLabel);

        var vacationInfoTable = document.createElement("div");
        var ul = document.createElement("ul");
        for(i = 0; i < vacationInit.length; i++){
            var li = document.createElement("li");
            li.innerHTML = vacationInit[i]+ " ("+vacationDates[i]+")";
            ul.appendChild(li);
        }
        vacationInfoTable.appendChild(ul);
        targetDiv.appendChild(vacationInfoTable);
    }
    //alert("done vaca")
}


</script>
</head>

<body>
    <div id="welcomePage">
        <p><img alt="Safe 4.0" src="pics/logo3.jpg"></p>
        <br />
        <br />
        <div class="overskrift_info" id="husk">Info:</div>
        <div class="tekst" id="info">Ingen info pt.</div>
        <br><div class="tekst" id="leaderVacationInfo"></div>
    </div>
<script>


</script>
</body>
</html>




Aucun commentaire:

Enregistrer un commentaire