Giter VIP home page Giter VIP logo

pplugins's Introduction

pPlugins

A few plugins, helpers and tools for jQuery

Plugin List:

  • Style Getter
  • String Mapper
  • Pattern Replacer
  • CamelCase String
  • Hex Encode/Decode
  • LZW Packer/Unpacker
  • Fuzzy Time
  • PubSub Hooks

Style Getter

Returns an object with style information from the Style element (not computed style). This will only return Legal style attributes, no data stored or non-supported browser vendor styles.

	// .myCoolColor { color: #BADA55; }
	$.cssStyle(".myCoolColor").color --> "rgb(186, 218, 85)"

Depends on the String Mapper

String Mapper

Creates an Object based on parsing the supplied string. Uses the stings ";" as default KeyVal-pair divider and ":" as key-value divider.

	var myObj = $.map.str("the: string; you:supply will be; parsed: and turned in:to; some-object: like this");
	JSON.stringify(myObj) --> '{"the":"string","you":"supply will be","parsed":"and turned in:to","someObject":"like this"}'
	
	// Lets say the document location is: http://localhost/?hello=world&and=space%20to
	var myOtherObj = $.map.str(document.location.search.substr(1));
	JSON.stringify(myOtherObj) --> '{"hello":"world","and":"space%20to"}'

Depends on the CamelCase-plugin ( or the native jQuery $.camelCase ).

CamelCase String

Code ripped from the jQuery core, since it seem to come and go.

	$.camelCase("my-odd-key") --> "myOddKey"

Pattern Replacer

Replaces named containers with values corresponding with matching keys.

	var myString = "my {color} {fruit}";
	var myValues = { color: "red", fruit: "apple" }
	$.prep(myString, myValues) --> "my red apple"
	
	//as String prototype
	"my {color} {fruit}".prep({ color: "red", fruit: "apple" }) --> "my red apple"

Hex Encode/Decode

Encodes strings as Hex (and decodes).

	($.hex("my String") === "6d7920537472696e67") && ($.HEX("6d7920537472696e67") === "my String") --> true

LZW Packer/Unpacker

Packing strings with LZW. Algorithm from rosettacode.org

	("!!!!!!!!!!".lzw() === "!ĀāĂ") && ("!ĀāĂ".LZW() === "!!!!!!!!!!") --> true

Fuzzy Time

A little verbose time teller.

	// At 14:58
	$.fuzz() --> "it's about three o'clock"
	
	// With string ( see Date.parse() )
	$.fuzz("march 8, 2011 15:50:30") --> "it's right after a quarter to four"
	
	var someDate = new Date(2000, 01, 01, 23, 18, 00);
	$.fuzz(someDate) --> "it's right after a quarter past eleven"

PubSub Hooks

Add hooks to your pub/sub architecture

	// For <a href="some/action" class="myAction">Do The Action</a>
	$(".myAction").pubsub() 
	
	// For <a href="#" class="myAction" pub="some/action">Do The Action</a>
	$(".myAction").pubsub() 
	
	// For <a href="#" class="myAction">Do The Action</a>
	$(".myAction").pubsub("some/action") 
	
	--> click will fire a pub to "some/action", with the event and target, $(this) as arguments		

pplugins's People

Contributors

pjotor avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.