Printing a Transcript (Part 2)

K.V.

This is the best method for transcripts I've pieced together as of yet, I believe.

Yeah... I sort of think it's the best way to go.

It should work the same on the web player as it does on the desktop player, too.

(Somebody poke some holes in it, please.)


This depends on this modified clearScreen() function:

var clearedOnce = false;
clearScreen = function () {
    $('#divOutput').append('<hr class=\"clearedAbove\" />');
    if (!clearedOnce) {
        addText('<style>#divOutput > .clearedScreen { display: none; }</style>');
    }
    clearedOnce = true;
    $('#divOutput').children().addClass('clearedScreen');
    $('#divOutput').css('min-height', 0);
    createNewDiv('left');
    beginningOfCurrentTurnScrollPosition = 0;
    setTimeout(function () {
        $('html,body').scrollTop(0);
    }, 100);
}

The transcript stuff:

var transcriptVar = "";
function addTranscriptEntry(text) {
    transcriptVar += text;
};


function showTranscript() {
    var transcriptDivString = "";
    transcriptDivString += "<div ";
    transcriptDivString += "id='transcript-dialog' ";
    transcriptDivString += "style='display:none;'>";
    transcriptDivString += "<div id='transcriptdata'></div></div>";
    addText(transcriptDivString);
    var transcriptDialog = $("#transcript-dialog").dialog({
        autoOpen: false,
        width: 600,
        height: 500,
        title: "Transcript",
        buttons: {
            Ok: function () {
                $(this).dialog("close");
                $(this).remove();
            },
            Print: function () {
                printTranscriptDiv();
            },
        },
        show: { effect: "fadeIn", duration: 500 },
        modal: true,
    });
    $('#transcriptdata').html($('#divOutput').html()); $("#transcriptdata *").attr('style', '').attr('color', '');
    transcriptDialog.dialog("open");

};



function printTranscriptDiv() {
    var iframe = document.createElement('iframe');
    document.body.appendChild(iframe);
    iframe.contentWindow.document.write($("#transcriptdata").html());
    iframe.contentWindow.print();
    document.body.removeChild(iframe);
    $("#transcript-dialog").dialog("close");
    $("#transcript-dialog").remove();
};

The Quest command:

  <command name="view_transcript_cmd">
    <pattern>transcript;script;view script;view transcript;display transcript;view the transcript;display the transcript</pattern>
    <script>
      game.notarealturn = true
      JS.showTranscript ()
    </script>
  </command> 

NOTE:

I'm just piecing different bits of code together until things behave like I want them to.

If this works, thank mrangel and Pixie. They provided the good bits of code.

If it doesn't work, blame me.

CAN I PRINT THIS NOW???


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums