Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I cleaned up your code for you! #1

Merged
merged 1 commit into from
Dec 21, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,50 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Numerous always-ignore extensions
###################
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~

*.sass-cache
# Folders to ignore
###################
.hg
.svn
.CVS
# OS or Editor folders
###################
.DS_Store
Icon?
Thumbs.db
ehthumbs.db
nbproject
.cache
.project
.settings
.tmproj
*.esproj
*.sublime-project
*.sublime-workspace
# Dreamweaver added files
###################
_notes
dwsync.xml
# Komodo
###################
*.komodoproject
.komodotools
12 changes: 6 additions & 6 deletions Blocky.coffee
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
window.Blocky = class Blocky window.Blocky = class Blocky
constructor: (text = null ,container=null, config={}) -> constructor: (text = null ,container=null, config={}) ->
if container if container
@container=window.document.getElementById(container) @container=window.document.getElementById(container)
Expand All @@ -12,10 +12,10 @@ window.Blocky = class Blocky
@black = config.black or "rgb(0,0,0)" @black = config.black or "rgb(0,0,0)"
@white = config.white or "rgb(255,255,255)" @white = config.white or "rgb(255,255,255)"
#type and error level control how much information we can encode. #type and error level control how much information we can encode.
@type_number = config.typenumber or 10 @type_number = config.typenumber or 10
@error_level = config.error_level or 'M' @error_level = config.error_level or 'M'
#in case they put something stupid #in case they put something stupid
@error_level.charAt(0).toUpperCase in ['M', 'H', 'Q' ,'L'] or 'M' @error_level.charAt(0).toUpperCase in ['M', 'H', 'Q' ,'L'] or 'M'
#some fun preset colors! :D #some fun preset colors! :D
if config.scheme in ['watermelon' , 'wedding' , 'arctic' , 'spicy'] if config.scheme in ['watermelon' , 'wedding' , 'arctic' , 'spicy']
switch config.scheme switch config.scheme
Expand All @@ -34,7 +34,7 @@ window.Blocky = class Blocky
return return


@context = canvas.getContext '2d' @context = canvas.getContext '2d'

@das_code = new qrcode @type_number ,'L' @das_code = new qrcode @type_number ,'L'
@das_code.addData text @das_code.addData text
@das_code.make() @das_code.make()
Expand All @@ -44,7 +44,7 @@ window.Blocky = class Blocky
canvas.setAttribute 'height' , canvas_size canvas.setAttribute 'height' , canvas_size
@container.appendChild canvas @container.appendChild canvas


#big main loops to build the QR code #big main loops to build the QR code
limit= @das_code.getModuleCount() limit= @das_code.getModuleCount()


if canvas.getContext if canvas.getContext
Expand All @@ -56,6 +56,6 @@ window.Blocky = class Blocky
else else
@context.fillStyle = @white @context.fillStyle = @white
@context.fillRect c*@cell_size , r*@cell_size , @cell_size, @cell_size @context.fillRect c*@cell_size , r*@cell_size , @cell_size, @cell_size

else else
console.log "no getContext.., cannot proceed." console.log "no getContext.., cannot proceed."
2 changes: 1 addition & 1 deletion README
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Dependencies:
The JS library after the 11/5/2011 update is included within this project. The JS library after the 11/5/2011 update is included within this project.


Installation: Installation:
The compiled javascript is included from the associated .coffee file. The compiled javascript is included from the associated .coffee file.
Include this in your page after qrcode.js (Kazuhiko's library) Include this in your page after qrcode.js (Kazuhiko's library)


Usage: Usage:
Expand Down
4 changes: 2 additions & 2 deletions sample.html
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
<html> <html>
<head> <head>

<script type="text/javascript" src="qrcode.js"></script> <script type="text/javascript" src="qrcode.js"></script>
<script type="text/javascript" src="Blocky.js"></script> <script type="text/javascript" src="Blocky.js"></script>
</head> </head>
Expand All @@ -12,5 +12,5 @@
new Blocky('http://hackazach.net' ,'funfun', {cell_size:11, scheme:'watermelon'}) new Blocky('http://hackazach.net' ,'funfun', {cell_size:11, scheme:'watermelon'})
</script> </script>



</html> </html>