Star webPRNT User's Manual

StarWebPrintTrader.js

Sends Star webPRNT Request Element and checks status from received Star webPRNT Request Element.

Constructor

NameDescription
StarWebPrintTraderCreates StarWebPrintTrader object.

Method

NameDescription
sendMessagesendMessage Sends Star webPRNT Request Element.
isCoverOpenCover open is checked.
isOffLineOffline/Online is checked.
isCompulsionSwitchCloseCompulsion switch is checked.
isEtbCommandExecuteETB command execute is checked.
isHighTemperatureStopHigh temperature stop is checked.
isNonRecoverableErrorNon recoverable error is checked.
isAutoCutterErrorAuto cutter error is checked.
isBlackMarkErrorBlack mark error is checked.
isPaperEndPaper end is checked.
isPaperNearEndPaper near end is checked.
extractionEtbCounterETB counter is extracted.

Property

NameDescription
onReceiveCommunication success event
onErrorCommunication error event.

Star Printer Compatibility Chart

POS Printer
NameFVP10TSP650IITSP700IITSP800IImPOPmC-Print2mC-Print3
sendMessage*1
isCoverOpen
isOffLine
isCompulsionSwitchClose
isEtbCommandExecute
isHighTemperatureStop
isNonRecoverableError
isAutoCutterError
isBlackMarkError----
isPaperEnd
isPaperNearEnd--
extractionEtbCounter

*1 Waiting for completion of printing is fixed to valid for Bluetooth printers.
The named argument ’checkedblock' does not work.

Mobile Printer (ESC/POS)
NameSM-S220i
(Excluding Jp model)
SM-S230iSM-T300iSM-T400i
sendMessage*1 *2
isCoverOpen
isOffLine
isCompulsionSwitchClose----
isEtbCommandExecute----
isHighTemperatureStop----
isNonRecoverableError----
isAutoCutterError----
isBlackMarkError----
isPaperEnd
isPaperNearEnd----
extractionEtbCounter----

*1 Waiting for completion of printing is fixed to valid for Bluetooth printers.
The named argument ’checkedblock' does not work.

*2 The named argument 'papertype' does not work.

Mobile Printer (StarPRNT)
NameSM-S220i
(Excluding Jp model)
SM-S230iSM-T300iSM-T400iSM-L200SM-L300
sendMessage*1 *2
isCoverOpen
isOffLine
isCompulsionSwitchClose------
isEtbCommandExecute
isHighTemperatureStop
isNonRecoverableError------
isAutoCutterError------
isBlackMarkError
isPaperEnd
isPaperNearEnd------
extractionEtbCounter

*1 Waiting for completion of printing is fixed to valid for Bluetooth printers.
The named argument ’checkedblock' does not work.

*2 The named argument 'papertype' does not work.

StarWebPrintTrader

Creates StarWebPrintTrader object.

syntax

StarWebPrintTrader(args);

Parameter

NameDescriptionObject typeOmission
urlSpecifies Star webPRNT endpoint URL
Note: When a url is omitted, it should be specified by sendMessage method.
String-
checkedblockSpecifies waiting for the completion of printing
  • true … Wait for the completion of printing
  • false … Not wait for the completion of printing
Booleantrue
papertypePaper type
  • normal … Nomal paper
  • black_mark … Black mark paper
  • black_mark_and_detect_at_power_on … Black mark paper (Detect at power on)
String-

Return value

DescriptionObject type
StarWebPrintTrader objectStarWebPrintTrader
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

    trader.sendMessage({request:request});
}
// -->
</script>

sendMessage

Sends Star webPRNT Request Element and checks status from received Star webPRNT Request Element.

syntax

sendMessage(args);

Parameter

NameDescriptionObject typeOmission
urlSpecifies Star webPRNT endpoint URL
Note: When a url is omitted, it should be specified by StarWebPrintTrader constructor.
String-
checkedblock Specifies waiting for the completion of printing
  • true … Wait for the completion of printing
  • false … Not wait for the completion of printing

Note: When a checkedblock is omitted, the value specified by StarWebPrintTrader constructor should be used.
Boolean-
requestList of Star webPRNT Request ElementStringCan't be omitted
papertypePaper type
  • normal … Nomal paper
  • black_mark … Black mark paper
  • black_mark_and_detect_at_power_on … Black mark paper (Detect at power on)

Note: When a papertype is omitted, the value specified by StarWebPrintTrader constructor should be used. If not specified by StarWebPrintTrader constructor either, it is an unset status.
String-

Return value

DescriptionObject type
--
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

    trader.sendMessage({request:request});
}
// -->
</script>

isCoverOpen

Cover open is checked.

syntax

isCoverOpen(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Cover status
  • true … Open
  • false … Close
Boolean
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
        if (trader.isCoverOpen({traderStatus:response.traderStatus})) {
            alert('CoverOpen');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

isOffLine

Offline/Online is checked.

syntax

isOffLine(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Offline/Online status
  • true … Offline
  • false … Online
Boolean
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      if (trader.isOffLine({traderStatus:response.traderStatus})) {
      alert('OffLine');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

isCompulsionSwitchClose

Compulsion switch close is checked.

syntax

isCompulsionSwitchClose(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Compulsion switch
  • true … Close
  • false … open
Boolean
Example
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      if (trader.isCompulsionSwitchClose({traderStatus:response.traderStatus})) {
      alert('CompulsionSwitchClose');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

isEtbCommandExecute

ETB command execute is checked.

syntax

isEtbCommandExecute(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
ETB command
  • true … Executed
  • false … Not executed
Boolean
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      if (trader.isEtbCommandExecute({traderStatus:response.traderStatus})) {
      alert('EtbCommandExecute');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

isHighTemperatureStop

High temperature stop is checked.

syntax

isHighTemperatureStop(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Stopped by high head temperature
  • true … Yes
  • false … No
Boolean
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      if (trader.isHighTemperatureStop({traderStatus:response.traderStatus})) {
      alert('HighTemperatureStop');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

isNonRecoverableError

Non recoverable error is checked.

syntax

isNonRecoverableError(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Non recoverable error
  • true … Yes
  • false … No
Boolean
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      if (trader.isNonRecoverableError({traderStatus:response.traderStatus})) {
      alert('NonRecoverableError');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

isAutoCutterError

Auto cutter error is checked.

syntax

isAutoCutterError(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Auto cutter error
  • true … Yes
  • false … No
Boolean
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      if (trader.isAutoCutterError({traderStatus:response.traderStatus})) {
      alert('AutoCutterError');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

isBlackMarkError

Black mark error is checked.

syntax

isBlackMarkError(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Black mark error
  • true … Yes
  • false … No
Boolean
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      if (trader.isBlackMarkError({traderStatus:response.traderStatus})) {
      alert('BlackMarkError');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

isPaperEnd

Paper end is checked.

syntax

isPaperEnd(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Paper end
  • true … Yes
  • false … No
Boolean
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      if (trader.isPaperEnd({traderStatus:response.traderStatus})) {
      alert('PaperEnd');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

isPaperNearEnd

Paper near end is checked.

syntax

isPaperNearEnd(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
Paper near end
  • true … Yes
  • false … No
Boolean
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      if (trader.isPaperNearEnd({traderStatus:response.traderStatus})) {
            alert('PaperNearEnd');
    }
  }

    trader.sendMessage({request:request});
}
// -->
</script>

extractionEtbCounter

ETB counter is extracted.

syntax

extractionEtbCounter(args);

Parameter

NameDescriptionObject typeOmission
traderStatustraderStatus property of response passed to the onReceive eventStringCan't be omitted

Return value

DescriptionObject type
ETB counterNumber
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
      alert('EtbCounter = ' + trader.extractionEtbCounter({traderStatus:response.traderStatus}).toString();
  }

    trader.sendMessage({request:request});
}
// -->
</script>

onReceive

Communication success event.

syntax

function(response);

Parameter

NameDescriptionObject type
traderSuccessSuccess code
  • true … Printing succeeded
  • false … Printing failed
Boolean
traderCodeResult code
  • 0 … Success
  • 1100 … Printer off line(On error)
  • 2001 … Printer busy(In use with another device: Need to resend data)
Number
traderStatusStar Automatic Status
Note. Refer to the command specifications.
String
statusStatus property of XMLHttpRequest
Note. Refer to the XMLHttpRequest specifications.
Number
responseTextResponseText property of XMLHttpRequest
Note. Refer to the XMLHttpRequest specifications.
String
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
        var msg = '- onReceive -\n\n';

        msg += 'TraderSuccess:' + response.traderSuccess + '\n';

       msg += 'TraderCode:' + response.traderCode + '\n';

        msg += 'TraderStatus:' + response.traderStatus + '\n';

        msg += 'Status:' + response.status + '\n';

       msg += 'ResponseText:' + response.responseText;

        alert(msg);
  }

    trader.onError = function (response) {
        var msg = '- onError -\n\n';

        msg += '\tStatus:' + response.status + '\n';

        msg += '\tResponseText:' + response.responseText;

        alert(msg);
    }

    trader.sendMessage({request:request});
}
// -->
</script>

onError

Communication error event.

syntax

function(response);

Parameter

NameDescriptionObject type
statusStatus property of XMLHttpRequest
Note. Refer to the XMLHttpRequest specifications.
Number
responseTextResponseText property of XMLHttpRequest
Note. Refer to the XMLHttpRequest specifications.
String
Example
// -->
<script type='text/javascript' src='js/StarWebPrintTrader.js'></script>
<script type='text/javascript'>
<!--
function onSend(url, request) {
  var trader = new StarWebPrintTrader({url:url});

  trader.onReceive = function (response) {
        var msg = '- onReceive -\n\n';

        msg += 'TraderSuccess:' + response.traderSuccess + '\n';

       msg += 'TraderCode:' + response.traderCode + '\n';

        msg += 'TraderStatus:' + response.traderStatus + '\n';

        msg += 'Status:' + response.status + '\n';

       msg += 'ResponseText:' + response.responseText;

        alert(msg);
  }

    trader.onError = function (response) {
        var msg = '- onError -\n\n';

        msg += '\tStatus:' + response.status + '\n';

        msg += '\tResponseText:' + response.responseText;

        alert(msg);
    }

    trader.sendMessage({request:request});
}
// -->
</script>