From 438cb7ed2415e223c3006c40fe87cf55c48f15d8 Mon Sep 17 00:00:00 2001 From: deathcap Date: Sun, 19 Jan 2014 22:38:03 -0800 Subject: [PATCH] Existence check document for non-browser --- index.coffee | 14 +++++++------- index.js | 13 +++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/index.coffee b/index.coffee index d7eca58..90d97ff 100644 --- a/index.coffee +++ b/index.coffee @@ -57,15 +57,15 @@ class ChestDialog extends ModalDialog @chestIW.linkedInventory = @playerInventory @playerIW.linkedInventory = @chestInventory - chestCont = @chestIW.createContainer() + if document? + chestCont = @chestIW.createContainer() - contents = [] - contents.push chestCont - contents.push document.createElement('br') # TODO: better positioning - # player inventory at bottom - contents.push @playerIW.createContainer() + contents = [] + contents.push chestCont + contents.push document.createElement('br') # TODO: better positioning + # player inventory at bottom + contents.push @playerIW.createContainer() - console.log 'ChestDialog, super=',super super game, {contents: contents} loadBlockdata: (x, y, z) -> diff --git a/index.js b/index.js index b594189..1897460 100644 --- a/index.js +++ b/index.js @@ -95,12 +95,13 @@ }); this.chestIW.linkedInventory = this.playerInventory; this.playerIW.linkedInventory = this.chestInventory; - chestCont = this.chestIW.createContainer(); - contents = []; - contents.push(chestCont); - contents.push(document.createElement('br')); - contents.push(this.playerIW.createContainer()); - console.log('ChestDialog, super=', ChestDialog.__super__.constructor.apply(this, arguments)); + if (typeof document !== "undefined" && document !== null) { + chestCont = this.chestIW.createContainer(); + contents = []; + contents.push(chestCont); + contents.push(document.createElement('br')); + contents.push(this.playerIW.createContainer()); + } ChestDialog.__super__.constructor.call(this, game, { contents: contents });