Skip to content

Instantly share code, notes, and snippets.

@zaydek-old
Last active March 5, 2017 17:15
Show Gist options
  • Save zaydek-old/6e1539e6a0db7b673ae3a9445f318188 to your computer and use it in GitHub Desktop.
Save zaydek-old/6e1539e6a0db7b673ae3a9445f318188 to your computer and use it in GitHub Desktop.
'use strict'
var $0 = 'html', $1 = 'body'
function title()
{
if (!arguments.length)
{
$('html').prepend('\n\t').append('\n')
$('head, body').empty()
}
else if (arguments.length == 1)
{
title()
layer('head').write(
'<meta charset="utf-8">',
'<title>' + arguments[0] + '</title>',
'<meta name="viewport" content="width=device-width, initial-scale=1">',
'<style></style>')()
}
}
function layer()
{
if (!arguments.length)
layer('body')
else if (arguments.length == 1)
$0 = $1, $1 = arguments[0]
return (layer)
}
function _()
{
if (!arguments.length)
return ('\t'.repeat($($1).parents().length))
}
function x()
{
if (!arguments.length)
$($1).html( $($1).html().slice(0, -_().length) )
}
layer.write = function()
{
if (!arguments.length)
{
if ($($1).html())
x()
$($1).append('\n' + _())
}
else if (arguments.length)
{
if (!$($1).html())
$($1).append('\n' + _())
for (var i = 0; arguments[i]; ++i)
$($1).append('\t' + arguments[i] + '\n' + _())
}
return (layer)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment