Skip to content

Commit

Permalink
Build 0.0.33 - Updating copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
draeton committed Feb 21, 2013
1 parent 0bb9040 commit 7676181
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 76 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011, Matthew Cobbs
Copyright (c) 2013, Matthew Cobbs

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
## Lockdown

[Lockdown](http://draeton.github.com/lockdown/) obfuscates code snippets by writing them to the canvas.
The current version is `0.0.32`. Documentation is available
The current version is `0.0.33`. Documentation is available
[here](http://draeton.github.com/lockdown/lockdown/docs/lockdown.html).

## Implementation

Place jQuery, the Lockdown script and the Lockdown stylesheet on the page:

<link rel="stylesheet" href="css/lockdown-0.0.32-min.css">
<link rel="stylesheet" href="css/lockdown-0.0.33-min.css">
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/modernizr-2.0.6.min.js"></script>
<script src="js/lockdown-0.0.32-min.js"></script>
<script src="js/lockdown-0.0.33-min.js"></script>

Once that's in place, you may replace code blocks using the `Lockdown.lock` method:

Modernizr.load([
"js/lockdown-0.0.32-min.js",
"js/lockdown-0.0.33-min.js",
{
test: Modernizr.canvas,
nope: "js/flashcanvas/flashcanvas.js",
complete: function () {
$(function () {

var $elements = $("pre.code");
var options = {
jsdir: "lockdown/build/js",
Expand All @@ -31,7 +31,7 @@ Once that's in place, you may replace code blocks using the `Lockdown.lock` meth
};
Lockdown.init( options );
Lockdown.lock( $elements );

});
}
}
Expand All @@ -45,7 +45,7 @@ jQuery 1.7+, Modernizr; *Flashcanvas for older browser support*

(The MIT License)

Copyright (c) 2011, <[Matthew Cobbs](mailto:draeton@gmail.com)>
Copyright (c) 2013, <[Matthew Cobbs](mailto:draeton@gmail.com)>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
6 changes: 3 additions & 3 deletions _templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Once that's in place, you may replace code blocks using the `Lockdown.lock` meth
nope: "js/flashcanvas/flashcanvas.js",
complete: function () {
$(function () {

var $elements = $("pre.code");
var options = {
jsdir: "lockdown/build/js",
Expand All @@ -31,7 +31,7 @@ Once that's in place, you may replace code blocks using the `Lockdown.lock` meth
};
Lockdown.init( options );
Lockdown.lock( $elements );

});
}
}
Expand All @@ -45,7 +45,7 @@ jQuery 1.7+, Modernizr; *Flashcanvas for older browser support*

(The MIT License)

Copyright (c) 2011, <[Matthew Cobbs](mailto:draeton@gmail.com)>
Copyright (c) 2013, <[Matthew Cobbs](mailto:draeton@gmail.com)>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
4 changes: 2 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Thu, 21 Feb 2013 04:03:56 -0500
#Thu, 21 Feb 2013 04:05:55 -0500
build.major=0
build.minor=0
build.number=32
build.number=33
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
* Obfuscates code snippets by writing them to the canvas
* http://draeton.github.com/lockdown
*
* Copyright 2011, Matthew Cobbs
* Copyright 2013, Matthew Cobbs
* Licensed under the MIT license.
*/canvas.lockdown{outline:1px dotted black;display:block;clear:both;margin-bottom:18px}canvas.lockdown:hover{outline:1px dotted #aaa}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Obfuscates code snippets by writing them to the canvas
* http://draeton.github.com/lockdown
*
* Copyright 2011, Matthew Cobbs
* Copyright 2013, Matthew Cobbs
* Licensed under the MIT license.
*/
canvas.lockdown {
Expand Down
File renamed without changes.
48 changes: 24 additions & 24 deletions build/js/lockdown-0.0.32.js → build/js/lockdown-0.0.33.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// ## Lockdown
//
//
// Obfuscates code snippets by writing them to the canvas
// [http://draeton.github.com/lockdown](http://draeton.github.com/lockdown)
//
// Copyright 2011, Matthew Cobbs
// Copyright 2013, Matthew Cobbs
// Licensed under the MIT license.
//
/*global jQuery, FlashCanvas*/
Expand All @@ -21,20 +21,20 @@
font : "12px Courier",
baseline : "top",
yoffset : (24 - 12) / 2 - 2,

/* font colors */
linecolor : "blue",
codecolor : "black",
rowcolor : "LightCyan",

/* text start position */
top : 10,
left : 15,
indent : 8,

/* canvas width */
width : 600,

/* lines to remove from code before drawing */
filterexp : null
}
Expand All @@ -53,34 +53,34 @@
// ## Lockdown prototype
Lockdown.prototype = {
// ### init
//
//
// Update the settings object, perhaps when styling
// a new section of code blocks
init: function (options) {
this.settings = $.extend({}, defaults, options);
},

// ### lock
//
//
// Loop through each element to replace the code
// blocks with canvas elements
//
// @param {jQuery} $elements Set of nodes to lock down
// @return {jQuery} The locked down canvas nodes
lock: function ($elements) {
var self = this;

if ($elements) {
$elements = $elements.map(function (i, element) {
return self._replaceCodeBlock(element);
});
}

return $elements;
},

// ### *_getCode*
//
//
// Decode the base64 encoded code,
// get the code text as an array of lines,
// filter out the garbage lines
Expand All @@ -98,20 +98,20 @@

/* remove whitespace and split on new lines */
var code = $.trim(innerText).split("\n");

/* if there is a filterexp regexp, filter lines */
if (s.filterexp) {
code = $.grep(code, function (line, i) {
return !s.filterexp.test(line);
});
}

/* return the array of code lines */
return code;
},

// ### *_getCanvas*
//
//
// Create the canvas element with height for the # of lines;
// FlashCanvas for IE support
//
Expand All @@ -134,9 +134,9 @@
},

// ### *_writeText*
//
//
// Write a piece of text to the canvas
//
//
// @param {CanvasRenderingContext2D} context
// @param {String} text Text to write to context
// @param {Number} x X-position
Expand All @@ -154,17 +154,17 @@
},

// ### *_writeTextRight*
//
//
// Curry `_writeText` to align text to the right
_writeTextRight: function (context, text, x, y, color) {
this._writeText(context, text, x, y, color, "right");
},

// ### *_writeLine*
//
//
// Write the line number;
// write the code
//
//
// @param {CanvasRenderingContext2D} context
// @param {Number} i Line number
// @param {String} line Line text
Expand All @@ -186,11 +186,11 @@
},

// ### *_replaceCodeBlock*
//
//
// Parse the code from the pre element;
// place and get the canvas;
// get the drawing context
//
//
// @param {HTMLElement} element
// @return {jQuery} Wrapped canvas node
_replaceCodeBlock: function (element) {
Expand All @@ -209,13 +209,13 @@

/* replace the element */
$(element).replaceWith(canvas);

/* get the drawing context and starting drawing lines */
var context = canvas.getContext("2d");
$.each(code, function (i, line) {
self._writeLine(context, i, line);
});

/* return the canvas with the code added to DOM data and a class of `lockdown` */
$canvas.data("code", code.join("\n")).addClass("lockdown");
return $canvas;
Expand Down
Binary file added dist/lockdown-0.0.33.zip
Binary file not shown.
24 changes: 12 additions & 12 deletions docs/lockdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>Obfuscates code snippets by writing them to the canvas
<a href="http://draeton.github.com/lockdown">http://draeton.github.com/lockdown</a></p>

<p>Copyright 2011, Matthew Cobbs <br />
<p>Copyright 2013, Matthew Cobbs
Licensed under the MIT license.</p> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*global jQuery, FlashCanvas*/</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="nx">$</span><span class="p">)</span> <span class="p">{</span>

Expand All @@ -19,20 +19,20 @@
<span class="nx">font</span> <span class="o">:</span> <span class="s2">&quot;12px Courier&quot;</span><span class="p">,</span>
<span class="nx">baseline</span> <span class="o">:</span> <span class="s2">&quot;top&quot;</span><span class="p">,</span>
<span class="nx">yoffset</span> <span class="o">:</span> <span class="p">(</span><span class="mi">24</span> <span class="o">-</span> <span class="mi">12</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span>

<span class="cm">/* font colors */</span>
<span class="nx">linecolor</span> <span class="o">:</span> <span class="s2">&quot;blue&quot;</span><span class="p">,</span>
<span class="nx">codecolor</span> <span class="o">:</span> <span class="s2">&quot;black&quot;</span><span class="p">,</span>
<span class="nx">rowcolor</span> <span class="o">:</span> <span class="s2">&quot;LightCyan&quot;</span><span class="p">,</span>

<span class="cm">/* text start position */</span>
<span class="nx">top</span> <span class="o">:</span> <span class="mi">10</span><span class="p">,</span>
<span class="nx">left</span> <span class="o">:</span> <span class="mi">15</span><span class="p">,</span>
<span class="nx">indent</span> <span class="o">:</span> <span class="mi">8</span><span class="p">,</span>

<span class="cm">/* canvas width */</span>
<span class="nx">width</span> <span class="o">:</span> <span class="mi">600</span><span class="p">,</span>

<span class="cm">/* lines to remove from code before drawing */</span>
<span class="nx">filterexp</span> <span class="o">:</span> <span class="kc">null</span>
<span class="p">}</span>
Expand All @@ -58,7 +58,7 @@
<span class="nx">init</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">settings</span> <span class="o">=</span> <span class="nx">$</span><span class="p">.</span><span class="nx">extend</span><span class="p">({},</span> <span class="nx">defaults</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
<span class="p">},</span>

</pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h3>lock</h3>

<p>Loop through each element to replace the code
Expand All @@ -69,13 +69,13 @@
</code></pre> </td> <td class="code"> <div class="highlight"><pre>
<span class="nx">lock</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">$elements</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>

<span class="k">if</span> <span class="p">(</span><span class="nx">$elements</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$elements</span> <span class="o">=</span> <span class="nx">$elements</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="nx">element</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_replaceCodeBlock</span><span class="p">(</span><span class="nx">element</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">}</span>

<span class="k">return</span> <span class="nx">$elements</span><span class="p">;</span>
<span class="p">},</span>

Expand All @@ -99,14 +99,14 @@

<span class="cm">/* remove whitespace and split on new lines */</span>
<span class="kd">var</span> <span class="nx">code</span> <span class="o">=</span> <span class="nx">$</span><span class="p">.</span><span class="nx">trim</span><span class="p">(</span><span class="nx">innerText</span><span class="p">).</span><span class="nx">split</span><span class="p">(</span><span class="s2">&quot;\n&quot;</span><span class="p">);</span>

<span class="cm">/* if there is a filterexp regexp, filter lines */</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">filterexp</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">code</span> <span class="o">=</span> <span class="nx">$</span><span class="p">.</span><span class="nx">grep</span><span class="p">(</span><span class="nx">code</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">,</span> <span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="o">!</span><span class="nx">s</span><span class="p">.</span><span class="nx">filterexp</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">}</span>

<span class="cm">/* return the array of code lines */</span>
<span class="k">return</span> <span class="nx">code</span><span class="p">;</span>
<span class="p">},</span>
Expand Down Expand Up @@ -214,13 +214,13 @@

<span class="cm">/* replace the element */</span>
<span class="nx">$</span><span class="p">(</span><span class="nx">element</span><span class="p">).</span><span class="nx">replaceWith</span><span class="p">(</span><span class="nx">canvas</span><span class="p">);</span>

<span class="cm">/* get the drawing context and starting drawing lines */</span>
<span class="kd">var</span> <span class="nx">context</span> <span class="o">=</span> <span class="nx">canvas</span><span class="p">.</span><span class="nx">getContext</span><span class="p">(</span><span class="s2">&quot;2d&quot;</span><span class="p">);</span>
<span class="nx">$</span><span class="p">.</span><span class="nx">each</span><span class="p">(</span><span class="nx">code</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">self</span><span class="p">.</span><span class="nx">_writeLine</span><span class="p">(</span><span class="nx">context</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">line</span><span class="p">);</span>
<span class="p">});</span>

<span class="cm">/* return the canvas with the code added to DOM data and a class of `lockdown` */</span>
<span class="nx">$canvas</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="s2">&quot;code&quot;</span><span class="p">,</span> <span class="nx">code</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s2">&quot;\n&quot;</span><span class="p">)).</span><span class="nx">addClass</span><span class="p">(</span><span class="s2">&quot;lockdown&quot;</span><span class="p">);</span>
<span class="k">return</span> <span class="nx">$canvas</span><span class="p">;</span>
Expand Down
2 changes: 1 addition & 1 deletion src/lockdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Obfuscates code snippets by writing them to the canvas
* http://draeton.github.com/lockdown
*
* Copyright 2011, Matthew Cobbs
* Copyright 2013, Matthew Cobbs
* Licensed under the MIT license.
*/
canvas.lockdown {
Expand Down
Loading

0 comments on commit 7676181

Please sign in to comment.