Skip to content

quickredfox/quickredfox-presents

Repository files navigation

(↓ Skip to Shortcuts Menu ↓)
h1. Quickredfox Presents:

A Javascript Compendium

This précis aims to become a collection of great reusable self-contained mini-snippets in the artful language that is Javascript.

There are some conventions that I wish to impose on all items added to this collection, but if you just want to skip to a sample, edit/copy/grab the original

Comment Conventions ( draft 0.2 )

The preamble:

  /*comment
    Author: Author's Name
    Copyright: Copyright Notice (optional)
    License: License (optional)
    Source: http://athorshomepage.com/blog (optional)
    Description: 
    
        You can enter a description on a separate block
        as long as it's properly indented like here.
        
        A proper description is required!
        
    Example:
    (code)
        // In this block, you can also write lots a documentation 
        // but make sure you've read the size rules

        Stating.the("Obvious") // => "Duh!"
        
    (end)
  end*/

Containment Conventions ( draft 0.2 )

The safe-wrapper:

var Stating = (function(){ // Do whatever you want here var S = { the: function(string){ if (string.toLowerCase() == ‘obvious’) return ‘Duh!’ else return false; } } // Dont forget to return your whatever return S; })(); // important!

Size Rules and other tid-bits. ( draft 0.2 )

The size of each snippet should not be too complex and must not have dependencies such as other libraries unless they are included within the snippet somehow.

For those brief moments in life when we have no time to comment on the obivous, let us not do so but normally of course, provide proper indentation and commenting.

Why?

You may have question as to why? Why this? Why this way? Why anything? Well the answer to all of those is the obviously predictable answer of “because”. But I do admit nonethless, that imposing other people to abide by some of your rules requires a bit of an explanation…

Because:

Why do I impose a style of commenting block?

  • Because it makes me feel special, and I also parse it to generate this README
  • Because if I dont, I dont really have an edge on the disqualifying process
  • It’s semi Natural Docs compatible
  • Some of you people suck like big-time n00bs and act like you’re 5 years old

Why do I have to wrap the code this way blah blah blah…

  • That’s how this man likes his module pattern.
  • I also need it to be this way for eventual plans (to be continued…)

Why do you not include your README generator in the repository?

  • For now, it’s MY generator and no matter how half-assed the code looks, it works.
  • It’s MY generator because I want to see yours and then I’ll show you mine… that’s how it works!

Who are you speaking to?

  • No one!, I’m speaking to myself through a magical thing we call the internets, there’s 1 watcher to this project and it’s me!

What is the purpose of all this nonsense?!?!

  • To just things let us be just, like Kahlil Gibran said: “let there be no purpose in friendship save the deepening of the spirit.” s/friendship/collaboration/i

Documentation

Shortcuts


Author:

Unknown

Copyright:

Public Domain

Source:

http://www.dustindiaz.com/top-ten-javascript/

Description:

Stating the obvious here but these are common cookie getters and setters copied from Dustin Diaz’s blog and restyled for this collection.

Example:


CookieMonster.set(‘mycookie’,‘my value’)
CookieMonster.get(‘mycookie’)
CookieMonster.erase(‘mycookie’)

See this file in project @ http://github.com/quickredfox/quickredfox-presents/tree/master/browsers/cookies/commons.js

↑ shortcuts ↑


Author:

Unknown

Copyright:

Public Domain

Source:

http://github.com/quickredfox/jsgouache/tree/master

Description:

Decimal and Hexadecimal Conversions

Example:



Conversions.dec2hex(‘255’) // => ‘FF’
Conversions.hex2dec(‘ff’)  // => 255

See this file in project @ http://github.com/quickredfox/quickredfox-presents/tree/master/conversions/dec2hex_hex2dec.js

↑ shortcuts ↑


Author:

Greg Reimer (reglib version 1.0.2)

Blog:

http://blogs.sun.com/greimer

Copyright:

Copyright 2008

License:

Released under MIT license

Source:

http://code.google.com/p/reglib/

Description:

name: e.g. ‘div’, ‘div.foo’, ‘div#bar’, ‘div.foo#bar’, ‘div#bar.foo’ atts: (optional) e.g. {’href’:‘page.html’,‘target’:’_blank’} content: (optional) either a string, or an element, or an arry of strings or elements

Example:


// example 1
var myDiv = reglib.newElement(‘div’, { id:‘complex’, className:‘main’ }, “hello this is my div!” );
// example 2
var title = “Hello World”;
var description = “Lorem ipsum dolor sit amet, consectetur adipisicing elit.”
var myComplexDiv = reglib.newElement(
‘div#complex’,
{ id:‘colegram’, className:‘main parent’ },
[
reglib.newElement(‘h1.child’, {}, title ),
reglib.newElement(‘p.description’, {}, description)
]
);// end complex div

See this file in project @ http://github.com/quickredfox/quickredfox-presents/tree/master/dom/builders/reglib.newElement.js

↑ shortcuts ↑


Author:

Lee Carmichael [email protected]

Copyright:

Copyright © 2005 Lee Carmichael. All rights reserved.

License:

Artistic License

Source:

http://www.openjsan.org

Description:

File.Basename – A library that provides unix-like tools ‘dirname’ and ‘basename’ Grabbed from JSAN, modified to fit within this collection’s guidelines.

Example:


File.basename(‘/javascripts/bin.js’,2) // => bin.js
File.dirname(‘/javascripts/bin.js’,2) // => /javascripts
File.path(‘/javascripts/bin.js’,1) // => /javascripts/bin.js
File.platform(‘/javascripts/bin.js’,2) // => 2
File.platformString(‘/javascripts/bin.js’,2) // => Macintosh
File.platformString(‘/javascripts/bin.js’,1) // => Windows
File.platformString(‘/javascripts/bin.js’,2) // => Macintosh
File.platformString(‘/javascripts/bin.js’,3) // => UNIX
File.platformString(‘/javascripts/bin.js’,4) // => undefined

See this file in project @ http://github.com/quickredfox/quickredfox-presents/tree/master/file/file.basename.js

↑ shortcuts ↑


Author:

Author’s Name

Copyright:

Copyright Notice (optional)

License:

License (optional)

Source:

http://athorshomepage.com/blog (optional)

Description:

You can enter a description on a separate block as long as it’s properly indented like here. A proper description is required!

Example:


// In this block, you can also write lots a documentation
// but make sure you’ve read the size rules
Stating.the(“Obvious”) // => “Duh!”

See this file in project @ http://github.com/quickredfox/quickredfox-presents/tree/master/original/gist/original.js

↑ shortcuts ↑


Author:

Peter-Paul Koch

Blog:

http://www.quirksmode.org

Copyright:

Copyright 2008 (but free to use under no restrictions)

Source:

http://www.quirksmode.org/js/xmlhttp.html

Description:

This is the XMLHttpRequest functions originally included in the book “PPK on Javascript” by Peter-Paul Koch. They have been modified to serve along this compendium’s guidelines.

Example:


function handleRequest(req) {
var writeroot = [some element];
writeroot.innerHTML = req.responseText;
}
PPK.sendRequest(‘file.txt’,handleRequest);

See this file in project @ http://github.com/quickredfox/quickredfox-presents/tree/master/xhr/quirksmode.js

↑ shortcuts ↑


About

A Javascript Compendium

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published