Skip to content

Commit

Permalink
release 0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
phivk committed Feb 6, 2022
1 parent 9c46618 commit 6a19b4f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/Twine1/Trialogue/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ <h5 class="modal-title content-container" id="exitModalLabel"></h5>
"use strict";function render(e){var r=_.template(e)({s:window.story.state,$:readyFunc});r=r.replace(/\/\*.*\*\//g,""),r=r.replace(/^\/\/.*(\r\n?|\n)/g,"");for(var n=/\[([\r\n+])([^\]]*?)([\r\n+])\]\{(.*?)\}/g,s=function(e,r,n,s,t){return renderEl("div",r+n+s,t)};n.test(r);)r=r.replace(n,s);for(var t=/\[(.*?)\]\{(.*?)\}/g,a=function(e,r,n){return renderEl("span",r,n)};t.test(r);)r=r.replace(t,a);return r=r.replace(/\[\[(.*?)\]\]/g,function(e,r){var n=r,s=r.indexOf("|");if(s!=-1)n=r.substr(0,s),r=r.substr(s+1);else{var t=r.indexOf("->");if(t!=-1)n=r.substr(0,t),r=r.substr(t+2);else{var a=r.indexOf("<-");a!=-1&&(n=r.substr(a+2),r=r.substr(0,a))}}return/^\w+:\/\/\/?\w/i.test(r)?'<a href="'+r+'">'+n+"</a>":(passage.links.push({display:n,target:r}),"")}),marked(r)}function renderEl(e,r,n){var s="<"+e;if(n){"-"==n[0]&&(s+=' style="display:none"');for(var t=[],a=null,u=/([#\.])([^#\.]+)/g,i=u.exec(n);null!==i;){switch(i[1]){case"#":a=i[2];break;case".":t.push(i[2]);break;default:throw new Error("Don't know how to apply selector "+i[0])}i=u.exec(n)}null!==a&&(s+=' id="'+a+'"'),t.length>0&&(s+=' class="'+t.join(" ")+'"')}return s+=">",null!==r&&(s+=render(r)),s+"</"+e+">"}function readyFunc(){return 1==arguments.length&&"function"==typeof arguments[0]?jQuery(window).one("showpassage:after",_.bind(arguments[0],jQuery("#passage"))):jQuery.apply(window,arguments)}var _=require("underscore"),marked=require("marked"),jQuery=require("jquery"),Passage=function(e,r,n,s){this.id=e,this.name=r,this.tags=n,this.source=_.unescape(s),this.links=[]};Passage.render=render,_.extend(Passage.prototype,{render:function(){return render(_.unescape(this.source))}}),module.exports=Passage;

},{"jquery":1,"marked":3,"underscore":4}],7:[function(require,module,exports){
"use strict";var $=require("jquery"),_=require("underscore"),LZString=require("lz-string"),Story=function(){var t,s,e,a,i,r;$("tw-storydata").length>0?(t=$("tw-storydata"),s=2,e="tw-passagedata[name=StoryAuthor]",a='*[type="text/twine-css"]',i='*[type="text/twine-javascript"]',r="tw-passagedata[name=StorySubtitle]"):(t=$("#storeArea"),s=1,e="div[tiddler=StoryAuthor]",a='*[tags*="stylesheet"]',i='*[tags*="script"]',r="div[tiddler=StorySubtitle]"),this.el=t,this.name=2==s?t.attr("name"):t.find("div[tiddler=StoryTitle]").text(),this.subtitle=t.find(r).html(),this.author=t.find(e).text(),this.startPassage=2==s?parseInt(t.attr("startnode")):$("[tiddler=Start]").index(),this.creator=t.attr("creator"),this.creatorVersion=t.attr("creator-version"),this.history=[],this.history_dom=[],this.recent_dom=[],this.recent=[],this.state={},this.undoHistory=[],this.ignoreErrors=!1,this.errorMessage="⚠ %s",this.passages=[],this.delayedTypingEvent=null,this.delayedPassageEvent=null;var n=this.passages;2==s?t.children("tw-passagedata").each(function(t){var s=$(this),e=parseInt(s.attr("pid")),a=s.attr("tags");n[e]=new Passage(e,s.attr("name"),""!==a&&void 0!==a?a.split(" "):[],s.html())}):(t.children("*[tiddler]").each(function(t,s){var e=$(s),a=t,i=$.trim(e.attr("tags"));n[a]=new Passage(a,e.attr("tiddler"),""!==i&&void 0!==i?i.split(" "):[],e.html().replace(/\\n/g,"\n"))}),$("title").html(this.name),$("#ptitle").html(this.name)),this.userScripts=_.map(t.children(i),function(t){return $(t).html()}),this.userStyles=_.map(t.children(a),function(t){return $(t).html()})};_.extend(Story.prototype,{start:function(){$("#psubtitle").html(this.subtitle),this.author&&$("#pauthor").html(" by "+this.author),$("#nav-link-undo").on("click",function(t){var s=this.undoHistory.pop();s&&(this.state=s.state,this.history_dom=s.history_dom,this.history=s.history,this.clearUserResponses(),null!==this.delayedTypingEvent&&(clearTimeout(this.delayedTypingEvent),this.delayedTypingEvent=null),this.hideTyping(),null!==this.delayedPassageEvent&&(clearTimeout(this.delayedPassageEvent),this.delayedPassageEvent=null),$("#phistory").children().not(this.history_dom).remove(),$("#passage").children().not(this.history_dom).remove(),$("#phistory").children().last().remove(),this.show(this.history[this.history.length-1]),0==this.undoHistory.length&&$("#nav-link-undo").css({visibility:"hidden"}))}.bind(this)),$("body").on("click","a[data-passage]",function(t){if(0==$(t.target).closest("#phistory").length){this.movePassageToHistory(),this.clearUserResponses(),this.showUserPassage($(t.target).text());var s=$(t.target).closest("[data-passage]").attr("data-passage");this.getPassageDelay(s);this.showDelayed(s,!1,!0)}}.bind(this)),$(window).on("hashchange",function(){this.restore(window.location.hash.replace("#",""))}.bind(this)),window.onerror=function(t,s,e){this.errorMessage&&"string"==typeof this.errorMessage||(this.errorMessage=Story.prototype.errorMessage),this.ignoreErrors||(s&&(t+=" ("+s,e&&(t+=": "+e),t+=")"),$("#passage").html(this.errorMessage.replace("%s",t)))}.bind(this),_.each(this.userStyles,function(t){$("body").append("<style>"+t+"</style>")}),_.each(this.userScripts,function(script){eval(script)}),$.event.trigger("startstory",{story:this}),""!==window.location.hash&&this.restore(window.location.hash.replace("#",""))||this.show(this.startPassage)},passage:function(t){return _.isNumber(t)?this.passages[t]:_.isString(t)?_.findWhere(this.passages,{name:t}):void 0},show:function(t,s,e){var a=this.passage(t);if(!a)throw new Error('There is no passage with the ID or name "'+t+'"');$.event.trigger("hidepassage",{passage:window.passage}),$.event.trigger("showpassage",{passage:a}),e||this.movePassageToHistory(),window.passage=a;var i,r=this.getPassageSpeaker(a);i=$("undefined"==r?'<div class="meta-passage">'+a.render()+"</div>":'<div data-speaker="'+r+'" class="chat-passage-wrapper '+a.tags.join(" ")+'"><div data-speaker="'+r+'" class="chat-passage">'+a.render()+"</div></div>"),s||(this.recent.push(a.id),this.recent_dom.push(i[0])),$("#passage").append(i).fadeIn("slow"),this.showUserResponses(),this.scrollChatIntoView(),this.pcolophon(),$.event.trigger("showpassage:after",{passage:a})},movePassageToHistory:function(){this.emptyPassageLinks(),this.pcopy()},showUserResponses:function(){_.each(passage.links,function(t){$("#user-response-panel").append('<a href="javascript:void(0)"class="user-response"data-passage="'+_.escape(t.target)+'">'+t.display+"</a>").fadeIn("slow")})},clearUserResponses:function(){$("#user-response-panel").empty()},showUserPassage:function(t){this.history=this.history.concat(this.recent),this.history_dom=this.history_dom.concat(this.recent_dom),this.recent=[],this.recent_dom=[],this.undoHistory.push({state:this.state,history_dom:this.history_dom,history:this.history}),$("#nav-link-undo").css({visibility:"visible"});var s=$('<div class="chat-passage-wrapper" data-speaker="you"><div class="chat-passage phistory" data-speaker="you" data-upassage="'+window.passage.id+'">'+t+"</div></div>");$("#phistory").append(s),this.recent_dom.push(s[0]),this.scrollChatIntoView()},scrollChatIntoView:function(){var t=document.documentElement,s=t.scrollTop+window.innerHeight,e=t.offsetHeight;s!==e&&$("html, body").animate({scrollTop:$(".chat-panel").height()},1e3)},pcolophon:function(){$.inArray("End",window.passage.tags)>-1&&null!=this.passage("StoryColophon")&&$(this.passage("StoryColophon").render()).hide().appendTo("#passage").fadeIn("slow")},pcopy:function(){if(parseInt(window.passage.id,10)){var t=$("#passage").children().remove();$("#phistory").append(t)}},emptyPassageLinks:function(){passage.links=[]},getPassageSpeaker:function(t){String.prototype.startsWith||(String.prototype.startsWith=function(t,s){return this.substr(!s||s<0?0:+s,t.length)===t});var s=_.find(t.tags,function(t){return t.startsWith("speaker-")});return"undefined"==typeof s?"undefined":s.substring(8)},render:function(t){var s=this.passage(t);if(!s)throw new Error("There is no passage with the ID or name "+t);return s.render()},showDelayed:function(t,s,e){var a=.3,i=this.getPassageDelay(t),r=this.getPassageSpeaker(this.passage(t));"undefined"!=r?this.delayedTypingEvent=_.delay(function(){story.showTyping(t)},i*a):i=1e3,this.delayedPassageEvent=_.delay(function(){story.hideTyping(),story.show(t,s,e)},i)},getPassageDelay:function(t){var s=this.passage(t),e=$("<div></div>").html(s.source).text().length,a=_.reduce(s.links,function(t,s){return t+s.display.length+4},0),i=e-a,r=20,n=i*r;return n},showTyping:function(t){var s=this.getPassageSpeaker(this.passage(t));$("#animation-container .chat-passage-wrapper").attr("data-speaker",s),$("#animation-container .chat-passage-wrapper .chat-passage").attr("data-speaker",s),$("#animation-container").fadeIn("slow"),this.scrollChatIntoView()},hideTyping:function(t){$("#animation-container").hide()},saveHash:function(){return LZString.compressToBase64(JSON.stringify({state:this.state,history:this.history}))},save:function(){$.event.trigger("save"),window.location.hash=this.saveHash()},restore:function(t){$.event.trigger("restore");try{var s=JSON.parse(LZString.decompressFromBase64(t));this.state=s.state,this.history=s.history,this.show(this.history[this.history.length-1],!0)}catch(t){return $.event.trigger("restorefailed",{error:t}),!1}return $.event.trigger("restore:after"),!0}}),module.exports=Story;
"use strict";var $=require("jquery"),_=require("underscore"),LZString=require("lz-string"),Story=function(){var t,s,e,a,i,r;$("tw-storydata").length>0?(t=$("tw-storydata"),s=2,e="tw-passagedata[name=StoryAuthor]",a='*[type="text/twine-css"]',i='*[type="text/twine-javascript"]',r="tw-passagedata[name=StorySubtitle]"):(t=$("#storeArea"),s=1,e="div[tiddler=StoryAuthor]",a='*[tags*="stylesheet"]',i='*[tags*="script"]',r="div[tiddler=StorySubtitle]"),this.el=t,this.name=2==s?t.attr("name"):t.find("div[tiddler=StoryTitle]").text(),this.subtitle=t.find(r).html(),this.author=t.find(e).text(),this.startPassage=2==s?parseInt(t.attr("startnode")):$("[tiddler=Start]").index(),this.creator=t.attr("creator"),this.creatorVersion=t.attr("creator-version"),this.history=[],this.history_dom=[],this.recent_dom=[],this.recent=[],this.state={},this.undoHistory=[],this.ignoreErrors=!1,this.errorMessage="⚠ %s",this.passages=[],this.delayedTypingEvent=null,this.delayedPassageEvent=null,this.maxPassageDelay=1e4;var n=this.passages;2==s?t.children("tw-passagedata").each(function(t){var s=$(this),e=parseInt(s.attr("pid")),a=s.attr("tags");n[e]=new Passage(e,s.attr("name"),""!==a&&void 0!==a?a.split(" "):[],s.html())}):(t.children("*[tiddler]").each(function(t,s){var e=$(s),a=t,i=$.trim(e.attr("tags"));n[a]=new Passage(a,e.attr("tiddler"),""!==i&&void 0!==i?i.split(" "):[],e.html().replace(/\\n/g,"\n"))}),$("title").html(this.name),$("#ptitle").html(this.name)),this.userScripts=_.map(t.children(i),function(t){return $(t).html()}),this.userStyles=_.map(t.children(a),function(t){return $(t).html()})};_.extend(Story.prototype,{start:function(){$("#psubtitle").html(this.subtitle),this.author&&$("#pauthor").html(" by "+this.author),$("#nav-link-undo").on("click",function(t){var s=this.undoHistory.pop();s&&(this.state=s.state,this.history_dom=s.history_dom,this.history=s.history,this.clearUserResponses(),null!==this.delayedTypingEvent&&(clearTimeout(this.delayedTypingEvent),this.delayedTypingEvent=null),this.hideTyping(),null!==this.delayedPassageEvent&&(clearTimeout(this.delayedPassageEvent),this.delayedPassageEvent=null),$("#phistory").children().not(this.history_dom).remove(),$("#passage").children().not(this.history_dom).remove(),$("#phistory").children().last().remove(),this.show(this.history[this.history.length-1]),0==this.undoHistory.length&&$("#nav-link-undo").css({visibility:"hidden"}))}.bind(this)),$("body").on("click","a[data-passage]",function(t){if(0==$(t.target).closest("#phistory").length){this.movePassageToHistory(),this.clearUserResponses(),this.showUserPassage($(t.target).text());var s=$(t.target).closest("[data-passage]").attr("data-passage");this.getPassageDelay(s);this.showDelayed(s,!1,!0)}}.bind(this)),$(window).on("hashchange",function(){this.restore(window.location.hash.replace("#",""))}.bind(this)),window.onerror=function(t,s,e){this.errorMessage&&"string"==typeof this.errorMessage||(this.errorMessage=Story.prototype.errorMessage),this.ignoreErrors||(s&&(t+=" ("+s,e&&(t+=": "+e),t+=")"),$("#passage").html(this.errorMessage.replace("%s",t)))}.bind(this),_.each(this.userStyles,function(t){$("body").append("<style>"+t+"</style>")}),_.each(this.userScripts,function(script){eval(script)}),$.event.trigger("startstory",{story:this}),""!==window.location.hash&&this.restore(window.location.hash.replace("#",""))||this.show(this.startPassage)},passage:function(t){return _.isNumber(t)?this.passages[t]:_.isString(t)?_.findWhere(this.passages,{name:t}):void 0},show:function(t,s,e){var a=this.passage(t);if(!a)throw new Error('There is no passage with the ID or name "'+t+'"');$.event.trigger("hidepassage",{passage:window.passage}),$.event.trigger("showpassage",{passage:a}),e||this.movePassageToHistory(),window.passage=a;var i,r=this.getPassageSpeaker(a);i=$("undefined"==r?'<div class="meta-passage">'+a.render()+"</div>":'<div data-speaker="'+r+'" class="chat-passage-wrapper '+a.tags.join(" ")+'"><div data-speaker="'+r+'" class="chat-passage">'+a.render()+"</div></div>"),s||(this.recent.push(a.id),this.recent_dom.push(i[0])),$("#passage").append(i).fadeIn("slow"),this.showUserResponses(),this.scrollChatIntoView(),this.pcolophon(),$.event.trigger("showpassage:after",{passage:a})},movePassageToHistory:function(){this.emptyPassageLinks(),this.pcopy()},showUserResponses:function(){_.each(passage.links,function(t){$("#user-response-panel").append('<a href="javascript:void(0)"class="user-response"data-passage="'+_.escape(t.target)+'">'+t.display+"</a>").fadeIn("slow")})},clearUserResponses:function(){$("#user-response-panel").empty()},showUserPassage:function(t){this.history=this.history.concat(this.recent),this.history_dom=this.history_dom.concat(this.recent_dom),this.recent=[],this.recent_dom=[],this.undoHistory.push({state:this.state,history_dom:this.history_dom,history:this.history}),$("#nav-link-undo").css({visibility:"visible"});var s=$('<div class="chat-passage-wrapper" data-speaker="you"><div class="chat-passage phistory" data-speaker="you" data-upassage="'+window.passage.id+'">'+t+"</div></div>");$("#phistory").append(s),this.recent_dom.push(s[0]),this.scrollChatIntoView()},scrollChatIntoView:function(){var t=document.documentElement,s=t.scrollTop+window.innerHeight,e=t.offsetHeight;s!==e&&$("html, body").animate({scrollTop:$(".chat-panel").height()},1e3)},pcolophon:function(){$.inArray("End",window.passage.tags)>-1&&null!=this.passage("StoryColophon")&&$(this.passage("StoryColophon").render()).hide().appendTo("#passage").fadeIn("slow")},pcopy:function(){if(parseInt(window.passage.id,10)){var t=$("#passage").children().remove();$("#phistory").append(t)}},emptyPassageLinks:function(){passage.links=[]},getPassageSpeaker:function(t){String.prototype.startsWith||(String.prototype.startsWith=function(t,s){return this.substr(!s||s<0?0:+s,t.length)===t});var s=_.find(t.tags,function(t){return t.startsWith("speaker-")});return"undefined"==typeof s?"undefined":s.substring(8)},render:function(t){var s=this.passage(t);if(!s)throw new Error("There is no passage with the ID or name "+t);return s.render()},showDelayed:function(t,s,e){var a=.3,i=this.getPassageDelay(t),r=this.getPassageSpeaker(this.passage(t));"undefined"!=r?this.delayedTypingEvent=_.delay(function(){story.showTyping(t)},i*a):i=1e3,this.delayedPassageEvent=_.delay(function(){story.hideTyping(),story.show(t,s,e)},i)},getPassageDelay:function(t){var s=this.passage(t),e=$("<div></div>").html(s.source).text().length,a=_.reduce(s.links,function(t,s){return t+s.display.length+4},0),i=e-a,r=20,n=i*r,o=Math.min(n,this.maxPassageDelay);return o},showTyping:function(t){var s=this.getPassageSpeaker(this.passage(t));$("#animation-container .chat-passage-wrapper").attr("data-speaker",s),$("#animation-container .chat-passage-wrapper .chat-passage").attr("data-speaker",s),$("#animation-container").fadeIn("slow"),this.scrollChatIntoView()},hideTyping:function(t){$("#animation-container").hide()},saveHash:function(){return LZString.compressToBase64(JSON.stringify({state:this.state,history:this.history}))},save:function(){$.event.trigger("save"),window.location.hash=this.saveHash()},restore:function(t){$.event.trigger("restore");try{var s=JSON.parse(LZString.decompressFromBase64(t));this.state=s.state,this.history=s.history,this.show(this.history[this.history.length-1],!0)}catch(t){return $.event.trigger("restorefailed",{error:t}),!1}return $.event.trigger("restore:after"),!0}}),module.exports=Story;

},{"jquery":1,"lz-string":2,"underscore":4}]},{},[5]);
</script>
Expand Down
2 changes: 1 addition & 1 deletion dist/Twine2/Trialogue/format.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Trialogue",
"version": "0.0.8",
"version": "0.0.9",
"description": "A chat style story format based on Paloma",
"author": "Philo van Kemenade",
"license": "MIT",
Expand Down

0 comments on commit 6a19b4f

Please sign in to comment.