MongoDB: The Definitive Guide

MongoDB: The Definitive Guide
Authors
Kristina Chodorow, Michael Dirolf
ISBN
1449381561
Published
17 Sep 2010
Purchase online
amazon.com

How does MongoDB help you manage a huMONGOus amount of data collected through your web application? With this authoritative introduction, you'll learn the many advantages of using document-oriented databases, and discover why MongoDB is a reliable, high-performance system that allows for almost infinite horizontal scalability.

Editorial Reviews

Quietly extract JSON metadata contained within DOM elements.


Basic Usage

1. Include the scripts required:

<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yahoo/yahoo-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/dom/dom-min.js"></script>
<script type="text/javascript" src="metadata-min.js"></script>

2. Store the data in DOM elements

<p id="one" class="someclass {itemid: 1, itemlabel: 'Label 1'}">This is p1</p>
<p id="two" class="someclass" data="{itemid: 2, itemlabel: 'Label 2'}">This is p2</p>
<p id="three" class="someclass"><script type= "text/javascript">{itemid: 3, item_label: 'Label 3'}</script>This is p3</p>

3. Retrieve using metadata

var dom = YAHOO.util.Dom;
var metadata = YAHOO.plugin.Metadata;

metadata.setType("class"); document.write( metadata.get( dom.get("one") ).itemid + ", " + metadata.get( dom.get("one") ).itemlabel + "<br />");

metadata.setType("attr", "data"); document.write( metadata.get( dom.get("two") ).itemid + ", " + metadata.get( dom.get("two") ).itemlabel + "<br />");

metadata.setType("elem", "script"); document.write( metadata.get( dom.get("three") ).itemid + ", " + metadata.get( dom.get("three") ).itemlabel + "<br />");


Using YUI Loader

<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yuiloader/yuiloader-min.js"></script>
<script type="text/javascript">

var loader = new YAHOO.util.YUILoader({

    onSuccess: function() {

        var dom = YAHOO.util.Dom;
        var metadata = YAHOO.plugin.Metadata;

        // do something with metadata
     }
});

loader.addModule({
    name: "metadata",
    type: "js",
    fullpath: "http://yui-metadata.googlecode.com/svn/trunk/yui-metadata/metadata-min.js",
    varName: "YAHOO.plugin.Metadata",
    requires: ['yahoo', 'dom']
});

loader.require("metadata");
loader.insert();

</script>


Documentions and demo

Please view the source code of this link: http://labs.xddnet.com/yui-metadata/example/example.html


Contact

Feedback and suggestions are always welcome, you can reach me at tszming at gmail dot com.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - Rick Osborne