Method: Object#console

Defined in:
lib/atome/extensions/atome.rb

#console(debug) ⇒ Object



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/atome/extensions/atome.rb', line 325

def console(debug)
  if debug
    console = box({ id: :console, width: :auto, height: 225, bottom: 0, top: :auto, left: 0, right: 0, depth: 30, color: { alpha: 0, red: 0, green: 0, blue: 0 } })
    console_back = console.box({ id: :console_back, blur: { value: 5, affect: :back }, overflow: :auto, width: :auto, height: :auto, top: 25, bottom: 0, left: 0, right: 0, depth: 30, color: { alpha: 0.5, red: 0, green: 0, blue: 0 } })
    console_top = console.box({ id: :console_top, overflow: :auto, width: :auto, height: 25, top: 0, bottom: 0, left: 0, right: 0, depth: 30, color: { alpha: 1, red: 0.3, green: 0.3, blue: 0.3 } })

    console_top.touch(:double) do
      console.height(25)
      console.bottom(0)
      console.top(:auto)
    end
    console_top.shadow({
                         id: :s1,
                         left: 0, top: 3, blur: 9,
                         invert: false,
                         red: 0, green: 0, blue: 0, alpha: 1
                       })
    console.drag(:locked) do |event|
      dy = event[:dy]
      y = console.to_px(:top) + dy.to_f
      console.top(y)
      console.height(:auto)
    end
    console_output = console_back.text({ data: '', id: :console_output, component: { size: 12 } })
    JS.eval "      (function() {\n        var oldLog = console.log;\n        var consoleDiv = document.getElementById(\"console_output\");\n        console.log = function(message) {\n          if (consoleDiv) {\n            consoleDiv.innerHTML += '<p>' + message + '</p>';\n          }\n          oldLog.apply(console, arguments);\n        };\n      }());\n    JS\n\n    console_clear = console_top.circle({ id: :console_clear, color: :red, top: 3, left: 3, width: 19, height: 19 })\n    console_clear.touch(true) do\n      console_output.data(\"\")\n    end\n    JS.global[:document].addEventListener(\"contextmenu\") do |event|\n    end\n  else\n    grab(:console_back).delete(true)\n    JS.global[:document].addEventListener(\"contextmenu\") do |native_event|\n      event = Native(native_event)\n      event.preventDefault\n    end\n  end\nend\n"