CodePen

HTML

            
              body
  h1 Automatically Directed Drama with Async2.js
  h2 A.K.A. Soap Opera/Reality TV Series Episode Generator

            
          
!

↑ Insert the most common viewport meta tag

CSS

            
              body
  background: #ccc
  color: #333
  padding: 1em
  font: normal 16px/1.3em Monaco, monospace
h1
  font-weight: bold
  font-size: 1.5em
  text-decoration: underline
  margin: .5em 0
h2
  font-size: 1.2em
  margin: .5em 0 1em 0
p
  color: #999
  font-weight: bold
span
  color: #333
  font-weight: normal
strong
  font-weight: bold
  color: #000
  &:hover
i
  font-style: italic
  color: #000
  text-decoration: underline
            
          
!
? ?
? ?
Must be a valid URL.
+ add another resource
via CSS Lint

JS

            
              # lights and stage props
start=new Date; log=(s)->
  rx1=/\*(.+?)\*/g
  rx2=/_(.+?)_/g
  jQuery('<p>').text("[#{(new Date-start)/1000}s] ").append('<span>').find('span').html(s.replace('<','&lt;').replace('>','&gt;').replace(rx1,'<strong>$1</strong>').replace(rx2,'<i>$1</i>')).end().appendTo('body')
reply_to_subject=(s,r)->rx=`/^.*_(.+?)_.*\*(.+?)\*.*$/i`;[s.replace(rx,r)].concat(s.match(rx).slice(1))
    
# dramatic helpers
push=(room, action)->
  log "<*Boss* heads toward the #{room} room to see who is in there.>"
  async.push room, action
asynchronous_blocking_process=(name,ms,script)->(request,next)->
  log "*Boss*: \"*#{name}*, #{request}\""
  [reply, action, subject] = reply_to_subject request, script
  log "<*#{name}* invoked.> *#{name}*: \"#{reply} BRB +#{ms}ms.\""
  async.delay ms, ->
    log "<*#{name}* appears.> *#{name}*: \"back with your #{subject}. need me to #{action} any more?\""
    next() if next
  log "<*#{name}* turns to exit.>"
Wade=asynchronous_blocking_process 'Wade', 8000, "Ok. Hmm. Well I guess I'll put everything on hold and go $1 your $2 now."
Mark=asynchronous_blocking_process 'Mark', 10000, "Well, ok. You want me to $1 $2? Sure."
Jim=asynchronous_blocking_process 'Jim', 5000, "Oh, I almost forgot to $1 the $2."

jQuery ->
  log '<curtains go up.>'
  log '<async2.js is on stage.>'
  
  # ACTION!

  push 'Accounting', -> Wade "If you're not busy can you please _prepare_ me an updated *P&L report*?", @
  push 'Marketing',  -> Jim "How are we doing on sales? Did you _mail_ those *flyers* yet?", @
  push 'Accounting', -> Wade "I know you're just dicking around. How about you _call_ up *Papa John's* and order us some pizza for lunch?", @
  push 'Accounting', -> Wade "And don't forget to _order_ *the sauce* this time.", @
  push 'Marketing', ->
    Jim "I want you to _follow-up on_ some *reports from Dr. Smith*. Find out if he's cheating us.";
    Jim "While you're doing that, also _call_ *Dr. Johnson*. Tell him he owes us for last week.";
    @()
  push 'Legal', -> Mark "A former employee's site is ranking higher on Google than our own. Can't we _threaten_ *legal action*?", @
  
            
          
!
Must be a valid URL.
+ add another resource
via JS Hint
Loading ..................