Wednesday, November 7, 2012

custom_generator(arg_generator, firstline):



def main():
    def custom_generator(arg_generator, firstline):
        """This"""
        yield firstline
        for x in arg_generator:
            yield x

    the_data = [1,2,3,4,5]
    firstline = ["BOM"]

    x = custom_generator(the_data, firstline)
    print x

##    for x in custom_generator(the_data, firstline):
##        print x

if __name__ == '__main__':
    main()












Sunday, November 4, 2012

web tool format html - htmltidy

web tool format html

http://infohound.net/tidy/tidy.pl

HTML5 Tables

html5 table

Absolute Basic Table markup:
http://perishablepress.com/html5-table-template/#html5table


Absolute Basic Table Template

Because, sometimes it’s all you need. Thanks to Helen for the idea.
<table>
 <tr>
  <td>Name</td>
  <td>Side</td>
  <td>Role</td>
 </tr>
 <tr>
  <td>Obi Wan Kenobi</td>
  <td>Light</td>
  <td>Jedi</td>
 </tr>
 <tr>
  <td>Greedo</td>
  <td>South</td>
  <td>Scumbag</td>
 </tr>
</table>
Thanks to the amazing powers of CSS3, even the most basic table can be transformed into brilliant works of art, displaying data as clearly and succinctly as possible. Nice :)






html table
http://www.w3schools.com/tags/tag_table.asp
alignleft
center
right
Not supported in HTML5. Deprecated in HTML 4.01.Specifies the alignment of a table according to surrounding text
bgcolorrgb(x,x,x)
#xxxxxx
colorname
Not supported in HTML5. Deprecated in HTML 4.01.Spec


http://www.w3schools.com/html/html_tables.asp




CSS > Selector

w3Schools

CSS Selector Reference

http://www.w3schools.com/cssref/css_selectors.asp

element>elementdiv>pSelects all <p> elements where the parent is a <div> element2
element+elementdiv+pSelects all <p> elements that are placed immediately after <div> elements

[attribute][target]Selects all elements with a target attribute2
[attribute=value][target=_blank]Selects all elements with target="_blank"2
[attribute~=value][title~=flower]Selects all elements with a title attribute containing the word "flower"2
[attribute|=value][lang|=en]Selects all elements with a lang attribute value starting with "en"2
:linka:linkSelects all unvisited links1
:visiteda:visitedSelects all visited links1
:activea:activeSelects the active link1
:hovera:hoverSelects links on mouse over1
:focusinput:focusSelects the input element which has focus

jquery mobile forms validation

jquery mobile forms validation
http://stackoverflow.com/questions/5636856/jqm-jquerymobile-html5-form-validation
http://stackoverflow.com/questions/8997252/jquery-form-validation-in-jquery-mobile
http://www.elijahmanor.com/2011/02/jquery-mobile-form-validation.html





JQM (jQueryMobile) HTML5 Form Validation



Need to add form validation for each form and wanted to take advantage of the html5 syntax, that's why I liked the h5validate plugin but everything I try nothing happens, ugh...
I've also looked at the jQuery Validation plugin but the additional syntax and markup is something I'm trying to avoid. And I've looked at HTML5FORM but it is using jQuery 1.4.2 and I'm using 1.5.x
Wanted to know if anyone else had any luck with html5 and multi form validation submission?




A.

I have had success with multi forms with the validationEngine.js plugin from here http://www.position-relative.net/creation/formValidator/
Example here: http://coww.ws/jqmtest/
Hope this helps?

A2.
ValidVal is what I'm going with, it has all the simple syntax and takes advantage of the html5 attributes for validation



I'm trying to use form validation that is working in this example with my jQuery Mobile project:
This example works but uses an older version of jQuery Mobile js and css files. I'm working with the 1.0 release version which appears to have broken this form validation. You can see my updated version at:
You'll notice when you click the Login button you get the alert messages but they are not in red and are in the wrong location compared to the original version.
Can anyone locate what broke the original version and how to restore functionality to new version using jQuery Mobile 1.0?


Try this:




alternative to href="#" : to prevent href="#" link from jumping to top of page: function() { ...everything... return false; }

1
alternative to href="#" : to prevent href="#" link from jumping to top of page: function() { ...everything... return false; }

alternative to href="#"

Regarding "sending the user to the top of the page"; you should just return false from your the function you have hooked up as a click() handler;
$('a').click(function() {
    // Do your stuff.
    // The below line prevents the 'href' on the anchor to be followed.
    return false;
});




2
jquery getting the text of an element
http://api.jquery.com/text/



3


Simulating a click in jQuery/JavaScript on a link



$( 'selector for your link' ).click ();

http://stackoverflow.com/questions/1839363/simulating-a-click-in-jquery-javascript-on-a-link
http://api.jquery.com/click/




4

jquery prevent default on anchor

jQuery anchor preventDefault


http://stackoverflow.com/questions/3786898/jquery-anchor-preventdefault

jQuery('#demoLink').bind('click',function(e){
      e.preventDefault();
      document.location.href="someUrl.php?text="+ jQuery('#demoQuery').val();     
});




jquery.data(key, value)


jquery.data(key, value)

$('#something').data('foo', 52);        
alert($('#something').data('foo')); 


http://answers.oreilly.com/topic/1634-how-to-attach-objects-and-data-to-dom-with-jquery-data-to-avoid-memory-leak-issues/

How to attach objects and data to DOM with jQuery.data to avoid memory leak issues


Properties added to an object or DOM node at runtime (called expandos) exhibit a number of issues because of flawed garbage collection implementations in some web browsers. This excerpt from jQuery Cookbook shows you how to avoid memory leak issues by using .data().