<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Script Tutorials &#187; Script Tutorials | Web Developer Tutorials | HTML5 and CSS3 Tutorials</title> <atom:link href="http://www.script-tutorials.com/feed/" rel="self" type="application/rss+xml" /><link>http://www.script-tutorials.com</link> <description>Tutorials for Web Developers</description> <lastBuildDate>Wed, 16 May 2012 14:59:35 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Musical drop down menu</title><link>http://www.script-tutorials.com/musical-drop-down-menu/</link> <comments>http://www.script-tutorials.com/musical-drop-down-menu/#comments</comments> <pubDate>Wed, 16 May 2012 14:59:35 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[drop down menu]]></category> <category><![CDATA[html5 audio]]></category> <category><![CDATA[musical menu]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1612</guid> <description><![CDATA[Musical drop down menu Our new tutorial tells about developing cool musical drop down menu (html5 + css3). This menu has css3 animation effects (neat hover effect to menu elements). We also used html5 Audio element in order to add music to this menu. If you are ready, lets start. Final result Here are samples [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/flying-css3-navigation-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/260/thumb.png" alt="Flying CSS3 Navigation Menu" /></div><h3>Flying CSS3 Navigation Menu</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-css3-drop-sliding-list-menu-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/113/thumb.png" alt="Creating CSS3 Drop sliding list Menu #6" /></div><h3>Creating CSS3 Drop sliding list Menu #6</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-css3jquery-crossbrowser-dropdown-menu-with-tabs/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/119/thumb.png" alt="Creating CSS3/jQuery crossbrowser Drop-down menu with tabs" /></div><h3>Creating CSS3/jQuery crossbrowser Drop-down menu with tabs</a></h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Musical drop down menu" alt="Musical drop down menu" src="http://www.script-tutorials.com/demos/272/thumb.png" /></div><p><strong>Musical drop down menu</strong></p><p>Our new tutorial tells about developing cool musical drop down menu (html5 + css3). This menu has css3 animation effects (neat hover effect to menu elements). We also used html5 Audio element in order to add music to this menu. If you are ready, lets start.</p><p><span
id="more-1612"></span></p><hr
/><div
style="clear:both;"></div><h3>Final result</h3><p><img
title="Musical drop down menu" alt="Musical drop down menu" src="http://www.script-tutorials.com/demos/272/mus_menu.jpg" /></p><p>Here are samples and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Musical drop down menu - online demo" href="http://www.script-tutorials.com/demos/272/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Musical drop down menu - package" href="http://www.script-tutorials.com/demos/272/source.zip" target="_blank">download in package</a></strong></h5><hr
/><h3>Step 1. HTML</h3><p>As the first, we should prepare HTML layout of our menu. Each menu element (which actually is a unordered list item) has anchor, or nested level.</p><pre class="brush:html">
&lt;ul id=&quot;nav&quot;&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu element&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Submenu element&lt;/a&gt;&lt;/li&gt;
            .....
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu 4&lt;/a&gt;&lt;/li&gt;
    .....
&lt;/ul&gt;
</pre><h3>Step 2. CSS</h3><p>Here are the CSS styles of our menu:</p><pre class="brush:css">
#nav,#nav ul {
    list-style: none outside none;
    margin: 0;
    padding: 0;
}
#nav {
    font-family: &quot;Lucida Sans Unicode&quot;,Verdana,Arial,sans-serif;
    font-size: 13px;
    height: 36px;
    list-style: none outside none;
    margin: 40px auto;
    text-shadow: 0 -1px 3px #202020;
    width: 700px;

    /* border radius */
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    border-radius: 4px;

    /* box shadow */
    -moz-box-shadow: 0px 3px 3px #cecece;
    -webkit-box-shadow: 0px 3px 3px #cecece;
    box-shadow: 0 3px 4px #8b8b8b;

    /* gradient */
    background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #787878), color-stop(0.5, #5E5E5E), color-stop(0.51, #707070), color-stop(1, #838383));
    background-image: -moz-linear-gradient(center bottom, #787878 0%, #5E5E5E 50%, #707070 51%, #838383 100%);
    background-color: #5f5f5f;
}
#nav li {
    border-bottom: 1px solid #575757;
    border-left: 1px solid #929292;
    border-right: 1px solid #5d5d5d;
    border-top: 1px solid #797979;
    display: block;
    float: left;
    height: 34px;
    position: relative;
    width: 105px;
}
#nav &gt; li:first-child {
    border-left: 0 none;
    margin-left: 5px;
}
#nav ul {
    left: -9999px;
    position: absolute;
    top: -9999px;
    z-index: 2;
}
#nav ul li {
    background: none repeat scroll 0 0 #838383;
    box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
    width: 100%;
}
#nav li a {
    color: #FFFFFF;
    display: block;
    line-height: 34px;
    outline: medium none;
    text-align: center;
    text-decoration: none;

    /* gradient */
    background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #787878), color-stop(0.5, #5E5E5E), color-stop(0.51, #707070), color-stop(1, #838383));
    background-image: -moz-linear-gradient(center bottom, #787878 0%, #5E5E5E 50%, #707070 51%, #838383 100%);
    background-color: #5f5f5f;
}

/* keyframes #animation */
@-webkit-keyframes animation {
    0% {
        -webkit-transform: scale(1);
    }
    30% {
        -webkit-transform: scale(1.2);
    }
    100% {
        -webkit-transform: scale(1.1);
    }
}
@-moz-keyframes animation {
    0% {
        -moz-transform: scale(1);
    }
    30% {
        -moz-transform: scale(1.2);
    }
    100% {
        -moz-transform: scale(1.1);
    }
}
#nav li &gt; a:hover {
    /* CSS3 animation */
    -webkit-animation-name: animation;
    -webkit-animation-duration: 0.3s;
    -webkit-animation-timing-function: linear;
    -webkit-animation-iteration-count: 1;
    -webkit-animation-direction: normal;
    -webkit-animation-delay: 0;
    -webkit-animation-play-state: running;
    -webkit-animation-fill-mode: forwards;

    -moz-animation-name: animation;
    -moz-animation-duration: 0.3s;
    -moz-animation-timing-function: linear;
    -moz-animation-iteration-count: 1;
    -moz-animation-direction: normal;
    -moz-animation-delay: 0;
    -moz-animation-play-state: running;
    -moz-animation-fill-mode: forwards;
}
#nav li:hover ul {
    left: 0;
    top: 34px;
    width: 150px;
}
</pre><p>When we hover over a list item, we will animate (scale) it once to emulate beat effect.</p><h3>Step 3. HTML5 JavaScript</h3><p>Now, it is time to add music here. In the beginning, we should prepare a new empty array (to keep our Audio objects), and then, when the page is ready, initialize the music:</p><pre class="brush:js">
// variables
var aLoops = []; // sound loops

// initialization
addEvent(window, 'load', function (event) {

    // load music files
    aLoops[0] = new Audio('media/background.ogg');
    aLoops[0].volume = 0.3;
    aLoops[1] = new Audio('media/button.ogg');
    aLoops[1].volume = 1.0;
    aLoops[2] = new Audio('media/button_click.ogg');
    aLoops[2].volume = 1.0;

    aLoops[0].addEventListener('ended', function() { // loop background sound
        this.currentTime = 0;
        this.play();
    }, false);
    aLoops[0].play();
});
</pre><p>And then, we should add the handlers to different events: mouseover, mouseout and click:</p><pre class="brush:js">
// all the buttons
var aBtns = document.querySelectorAll('#nav li');

// onmouseover event handler
addEvent(aBtns, 'mouseover', function (event) {
    aLoops[1].currentTime = 0;
    aLoops[1].play(); // play click sound
});

// onmouseout event handler
addEvent(aBtns, 'mouseout', function (event) {
    aLoops[1].currentTime = 0;
    aLoops[1].pause(); // play click sound
});

// onclick event handler
addEvent(aBtns, 'click', function (event) {
    aLoops[2].currentTime = 0;
    aLoops[2].play(); // play click sound
});
</pre><p>And voila, we have finalized it.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Musical drop down menu - demo" href="http://www.script-tutorials.com/demos/272/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Musical drop down menu - package" href="http://www.script-tutorials.com/demos/272/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>Hope that you&#8217;ve enjoyed with our new menu. Good luck!</p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/flying-css3-navigation-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/260/thumb.png" alt="Flying CSS3 Navigation Menu" /></div><h3>Flying CSS3 Navigation Menu</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-css3-drop-sliding-list-menu-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/113/thumb.png" alt="Creating CSS3 Drop sliding list Menu #6" /></div><h3>Creating CSS3 Drop sliding list Menu #6</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-css3jquery-crossbrowser-dropdown-menu-with-tabs/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/119/thumb.png" alt="Creating CSS3/jQuery crossbrowser Drop-down menu with tabs" /></div><h3>Creating CSS3/jQuery crossbrowser Drop-down menu with tabs</a></h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/musical-drop-down-menu/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Bottom Menu Builder Part 2</title><link>http://www.script-tutorials.com/bottom-menu-builder-html5-2/</link> <comments>http://www.script-tutorials.com/bottom-menu-builder-html5-2/#comments</comments> <pubDate>Tue, 15 May 2012 15:48:59 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[bottom menu]]></category> <category><![CDATA[Drag and Drop]]></category> <category><![CDATA[menu builder]]></category> <category><![CDATA[preview]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1609</guid> <description><![CDATA[Bottom Menu Builder Part 2 (HTML5) Today &#8211; our final part of our &#8216;Bottom Menu Builder&#8217; which we started yesterday. We are going to implement our final features: Preview and Export (optional). So, webmaster will be able to arrange links by drag and drop, and then he can click &#8216;Preview&#8217; button in order to Preview [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/bottom-menu-builder-html5/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/270/thumb.png" alt="Bottom Menu Builder (HTML5)" /></div><h3>Bottom Menu Builder (HTML5)</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-face-builder/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/200/thumb.png" alt="HTML5 Face Builder" /></div><h3>HTML5 Face Builder</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-bottom-navigation-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/170/thumb.png" alt="Creating a Toggle CSS3 Bottom Navigation Bar" /></div><h3>Creating a Toggle CSS3 Bottom Navigation Bar</a></h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Bottom Menu Builder Part 2 (HTML5)" alt="Bottom Menu Builder Part 2 (HTML5)" src="http://www.script-tutorials.com/demos/271/thumb.png"></div><p><strong>Bottom Menu Builder Part 2 (HTML5)</strong><br
/> <br
/>Today &#8211; our final part of our &#8216;Bottom Menu Builder&#8217; which we started yesterday. We are going to implement our final features: Preview and Export (optional). So, webmaster will be able to arrange links by drag and drop, and then he can click &#8216;Preview&#8217; button in order to Preview (and export results). I moved all the links into a separate php file (and now, we can have direct access to these links from PHP). In your case it can be database as example (in case of big project). So, lets start..<br
/> <span
id="more-1609"></span></p><p>As the first, I would suggest you to download the source files and keep the demo opened in a tab for better understanding.</p><h5 style="text-align: center;"><strong><a
title="Bottom Menu Builder Part 2 (HTML5) - demo 271" href="http://www.script-tutorials.com/demos/271/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Bottom Menu Builder Part 2 (HTML5) - package" href="http://www.script-tutorials.com/demos/271/source.zip" target="_blank">download result</a></strong></h5><hr
/><p>So, lets start</p><hr
/><h3>Step 1. HTML</h3><p>Today we do not have a static html files, I moved the contents of our index.html into a new index.php file.</p><h3>Step 2. CSS</h3><p>In addition to our main.css file, I added a new css file (to stylize our preview page):</p><h4>css/bmenu.css</h4><pre class="brush:css">
/* menu builder styles */
.actions {
    border: 1px solid #CCCCCC;
    font-size: 24px;
    margin: 20px auto 5px;
    overflow: hidden;
    padding: 10px;
    width: 900px;

    /* CSS3 Box sizing property */
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -o-box-sizing: border-box;
    box-sizing: border-box;
}

.columns {
    margin: 0 auto;
    overflow: hidden;
    width: 900px;
}
.column {
    border: 1px dotted #ccc;
    float: left;
    min-height: 100px;
    padding: 10px;
    position: relative;
    width: 33.3%;

    /* CSS3 Box sizing property */
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -o-box-sizing: border-box;
    box-sizing: border-box;
}
.column a {
    cursor: pointer;
    display: block;
    font-size: 16px;
    height: 30px;
    margin-bottom: 5px;
    position: relative;
    text-align: center;
}
</pre><h3>Step 3. JS</h3><p>Please add next code to our main.js file (at the bottom, right after the call of updateHandlerDrop):</p><h4>js/main.js</h4><pre class="brush:js">
// preview button
var previewBtn = document.querySelectorAll('#preview');
addEvent(previewBtn, 'click', function (event) {
    if (event.preventDefault) event.preventDefault();

    var params = '';
    var oColumns = document.querySelectorAll('div.column');
    for (var i = 0; i &lt; oColumns.length; i++) {
        var iCol = i+1;
        var sColElems = '';
        for (var k = 0; k &lt; oColumns[i].childNodes.length; k++) {
            if (oColumns[i].childNodes[k].nodeType == document.ELEMENT_NODE &amp;&amp; oColumns[i].childNodes[k].tagName == 'A') {
                sColElems += oColumns[i].childNodes[k].id + '_';
            }
        }
        params += iCol + '=' + sColElems + '&amp;';
    }

    // open results
    var http = new XMLHttpRequest();
    http.open('POST', 'preview.php', true);
    http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    http.setRequestHeader('Content-length', params.length);
    http.setRequestHeader('Connection', 'close');
    http.onreadystatechange = function() {
        if (http.readyState == 4 &amp;&amp; http.status == 200) {
            document.open();
            document.write(http.responseText);
            return;
        }
    }
    http.send(params);
    return false;
});
</pre><p>This is Preview button code. As you can see &#8211; it prepares all necessary params in order to send to our new &#8216;preview.php&#8217;. Basically, this is some kind of serialization of our active links (in columns).</p><h3>Step 4. PHP</h3><p>Now, its time to review our server side scripting. As I told before, I moved all the links into separate php file (links.php), here it is:</p><h4>links.php</h4><pre class="brush:php">
&lt;?

$aLinks = array(
    1 =&gt; array('Link 1', '#link1'),
    2 =&gt; array('Link 2', '#link2'),
    3 =&gt; array('Link 3', '#link3'),
    4 =&gt; array('Link 4', '#link4'),
    5 =&gt; array('Link 5', '#link5'),
    6 =&gt; array('Link 6', '#link6'),
    7 =&gt; array('Link 7', '#link7'),
    8 =&gt; array('Link 8', '#link8'),
    9 =&gt; array('Link 9', '#link9'),
    10 =&gt; array('Link 10', '#link10'),
    11 =&gt; array('Link 11', '#link11'),
    12 =&gt; array('Link 12', '#link12')
);
</pre><p>Now I should generate code for our index page (with builder) with using this array:</p><h4>index.php</h4><pre class="brush:php">
&lt;?php

require_once('links.php'); // include set of all possible links

// prepare draggable elements
$sLinks = '';
foreach ($aLinks as $i =&gt; $aPair) {
    list($sText, $sUrl) = $aPair;
    $sLinks .= '&lt;a id=&quot;'.$i.'&quot; draggable=&quot;true&quot;&gt;'.$sText.'&lt;/a&gt;';
}

?&gt;
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Bottom Menu Builder (HTML5) - Step 2 (of 2) | Script Tutorials&lt;/title&gt;
        &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;header tabindex=&quot;0&quot;&gt;
            &lt;h2&gt;Bottom Menu Builder (HTML5) - Step 2 (of 2)&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/bottom-menu-builder-html5-2/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/header&gt;

        &lt;div class=&quot;actions&quot;&gt;
            Actions:
            &lt;button id=&quot;preview&quot;&gt;Preview&lt;/button&gt;
            &lt;button id=&quot;add_col&quot;&gt;Add Column&lt;/button&gt;
        &lt;/div&gt;
        &lt;div class=&quot;actions&quot;&gt;Columns (with active elements)&lt;/div&gt;
        &lt;div class=&quot;columns&quot;&gt;
            &lt;div class=&quot;column&quot; id=&quot;drop_1&quot; droppable=&quot;true&quot;&gt;&lt;img src=&quot;images/delete.png&quot; onclick=&quot;removeColumn(this)&quot; /&gt;&lt;/div&gt;
            &lt;div class=&quot;column&quot; id=&quot;drop_2&quot; droppable=&quot;true&quot;&gt;&lt;img src=&quot;images/delete.png&quot; onclick=&quot;removeColumn(this)&quot; /&gt;&lt;/div&gt;
            &lt;div class=&quot;column&quot; id=&quot;drop_3&quot; droppable=&quot;true&quot;&gt;&lt;img src=&quot;images/delete.png&quot; onclick=&quot;removeColumn(this)&quot; /&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div style=&quot;clear:both&quot;&gt;&lt;/div&gt;
        &lt;div class=&quot;actions&quot;&gt;All (inactive) elements. You can drag these elements into columns.&lt;/div&gt;
        &lt;div class=&quot;inactive&quot; droppable=&quot;true&quot;&gt;
            &lt;?= $sLinks ?&gt;
        &lt;/div&gt;
        &lt;script src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><p>And finally, our preview page:</p><h4>preview.php</h4><pre class="brush:php">
&lt;?php

require_once('links.php'); // include set of all possible links

$sColumns = '';
$iColCnt = count($_POST); // Columns count
$dWidth = round(100 / $iColCnt, 1); // Column width

foreach ($_POST as $sCol =&gt; $sColEls) { // walk through all POST params
    $iColId = (int)$sCol; // Column ID

    $sColumns .= '&lt;div class=&quot;column&quot; style=&quot;width:'.$dWidth.'%&quot;&gt;';

    $aEls = explode('_', $sColEls); // obtain elements in column
    if (is_array($aEls) &amp;&amp; count($aEls)) {
        foreach ($aEls as $iPos =&gt; $sEl) { // walk through all elements
            $iEl = (int)$sEl;
            if ($iEl) {
                list($sText, $sUrl) = $aLinks[$iEl];
                $sColumns .= '&lt;a href=&quot;'.$sUrl.'&quot;&gt;'.$sText.'&lt;/a&gt;';
            }
        }
    }
    $sColumns .= '&lt;/div&gt;';
}

// Here you can save current value of $sColumns into some cache file
//file_put_contents('cache/bottom_menu.html', $sColumns);

?&gt;

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Bottom Menu Builder (HTML5) - Step 2 (of 2) | Script Tutorials&lt;/title&gt;
        &lt;link href=&quot;css/bmenu.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;header tabindex=&quot;0&quot;&gt;
            &lt;h2&gt;Bottom Menu Builder (HTML5) - Step 2 (of 2)&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/bottom-menu-builder-html5-2/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/header&gt;

        &lt;div class=&quot;actions&quot;&gt;Result bottom menu (preview)
            &lt;a href=&quot;index.php&quot; style=&quot;float:right&quot;&gt;Start again&lt;/a&gt;
        &lt;/div&gt;
        &lt;div class=&quot;columns&quot;&gt;
            &lt;?= $sColumns /*and finally - draw our result menu*/ ?&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><p>Small code at the top &#8211; preparing of result bottom menu (with columns). As you can see, you even can uncomment &#8216;file_put_contents&#8217; in order to generate cache file of result menu.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Bottom Menu Builder Part 2 (HTML5) - demo 271" href="http://www.script-tutorials.com/demos/271/index.php" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Bottom Menu Builder Part 2 (HTML5) - package" href="http://www.script-tutorials.com/demos/271/source.zip" target="_blank" rel="nofollow">download result</a></strong></h5><hr
/><h3>Conclusion</h3><p>That&#8217;s all, I hope that we have made really user friendly script &#8211; html5 drag and drop menu builder. Hope that our tutorial has helped you. Feel free to share our tutorials with your friends. Good luck!</p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/bottom-menu-builder-html5/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/270/thumb.png" alt="Bottom Menu Builder (HTML5)" /></div><h3>Bottom Menu Builder (HTML5)</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-face-builder/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/200/thumb.png" alt="HTML5 Face Builder" /></div><h3>HTML5 Face Builder</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-bottom-navigation-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/170/thumb.png" alt="Creating a Toggle CSS3 Bottom Navigation Bar" /></div><h3>Creating a Toggle CSS3 Bottom Navigation Bar</a></h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/bottom-menu-builder-html5-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Bottom Menu Builder (HTML5)</title><link>http://www.script-tutorials.com/bottom-menu-builder-html5/</link> <comments>http://www.script-tutorials.com/bottom-menu-builder-html5/#comments</comments> <pubDate>Mon, 14 May 2012 18:15:31 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[bottom menu]]></category> <category><![CDATA[Drag and Drop]]></category> <category><![CDATA[menu builder]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1606</guid> <description><![CDATA[Bottom Menu Builder (HTML5) Bottom navigation website menu. I am sure that you have seen it many times (at different websites). As usual, this is three-four columns menu with different links. Today I would like to show you a builder, which you can use to build that bottom menu. Main purpose of this builder &#8211; [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-drag-and-drop-sorting-photos/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/255/thumb.png" alt="HTML5 Drag and Drop &#8211; sorting photos between albums" /></div><h3>HTML5 Drag and Drop &#8211; sorting photos between albums</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-face-builder/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/200/thumb.png" alt="HTML5 Face Builder" /></div><h3>HTML5 Face Builder</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-bottom-navigation-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/170/thumb.png" alt="Creating a Toggle CSS3 Bottom Navigation Bar" /></div><h3>Creating a Toggle CSS3 Bottom Navigation Bar</a></h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Bottom Menu Builder (HTML5)" alt="Bottom Menu Builder (HTML5)" src="http://www.script-tutorials.com/demos/270/thumb.png"></div><p><strong>Bottom Menu Builder (HTML5)</strong><br
/> <br
/>Bottom navigation website menu. I am sure that you have seen it many times (at different websites). As usual, this is three-four columns menu with different links. Today I would like to show you a builder, which you can use to build that bottom menu. Main purpose of this builder &#8211; prepare static HTML code (as cache file) for embedding into bottom of your website. If you like that idea, you are welcome to play with it, and I will tell you about creation of nice user friendly menu builder. This tutorial is separated into 2 parts, today I will tell you about first side: user interface with drag and drop possibility.<br
/> <span
id="more-1606"></span></p><p>As the first, I would suggest you to download the source files and keep the demo opened in a tab for better understanding.</p><h5 style="text-align: center;"><strong><a
title="Bottom Menu Builder (HTML5) - demo 270" href="http://www.script-tutorials.com/demos/270/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Bottom Menu Builder (HTML5) - package" href="http://www.script-tutorials.com/demos/270/source.zip" target="_blank">download result</a></strong></h5><hr
/><p>So, lets start</p><hr
/><h3>Step 1. HTML</h3><h4>index.html</h4><pre class="brush:html">
&lt;div class=&quot;actions&quot;&gt;
    Actions:
    &lt;button id=&quot;preview&quot; disabled&gt;Preview&lt;/button&gt;
    &lt;button id=&quot;add_col&quot;&gt;Add Column&lt;/button&gt;
&lt;/div&gt;
&lt;div class=&quot;actions&quot;&gt;Columns (with active elements)&lt;/div&gt;
&lt;div class=&quot;columns&quot;&gt;
    &lt;div class=&quot;column&quot; id=&quot;drop_1&quot; droppable=&quot;true&quot;&gt;&lt;img src=&quot;images/delete.png&quot; onclick=&quot;removeColumn(this)&quot; /&gt;&lt;/div&gt;
    &lt;div class=&quot;column&quot; id=&quot;drop_2&quot; droppable=&quot;true&quot;&gt;&lt;img src=&quot;images/delete.png&quot; onclick=&quot;removeColumn(this)&quot; /&gt;&lt;/div&gt;
    &lt;div class=&quot;column&quot; id=&quot;drop_3&quot; droppable=&quot;true&quot;&gt;&lt;img src=&quot;images/delete.png&quot; onclick=&quot;removeColumn(this)&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;clear:both&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;actions&quot;&gt;All (inactive) elements. You can drag these elements into columns.&lt;/div&gt;
&lt;div class=&quot;inactive&quot; droppable=&quot;true&quot;&gt;
    &lt;a id=&quot;1&quot; draggable=&quot;true&quot;&gt;Link 1&lt;/a&gt;
    &lt;a id=&quot;2&quot; draggable=&quot;true&quot;&gt;Link 2&lt;/a&gt;
    &lt;a id=&quot;3&quot; draggable=&quot;true&quot;&gt;Link 3&lt;/a&gt;
    &lt;a id=&quot;4&quot; draggable=&quot;true&quot;&gt;Link 4&lt;/a&gt;
    &lt;a id=&quot;5&quot; draggable=&quot;true&quot;&gt;Link 5&lt;/a&gt;
    &lt;a id=&quot;6&quot; draggable=&quot;true&quot;&gt;Link 6&lt;/a&gt;
    &lt;a id=&quot;7&quot; draggable=&quot;true&quot;&gt;Link 7&lt;/a&gt;
    &lt;a id=&quot;8&quot; draggable=&quot;true&quot;&gt;Link 8&lt;/a&gt;
    &lt;a id=&quot;9&quot; draggable=&quot;true&quot;&gt;Link 9&lt;/a&gt;
    &lt;a id=&quot;10&quot; draggable=&quot;true&quot;&gt;Link 10&lt;/a&gt;
    &lt;a id=&quot;11&quot; draggable=&quot;true&quot;&gt;Link 11&lt;/a&gt;
    &lt;a id=&quot;12&quot; draggable=&quot;true&quot;&gt;Link 12&lt;/a&gt;
&lt;/div&gt;
&lt;script src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
</pre><p>There are three main sections: block with actions, block with active columns and block with inactive elements. All the elements we can drag and drop between columns. Also we can add and remove our columns.</p><h3>Step 2. CSS</h3><p>Now, it&#8217;s time to style our menu builder page:</p><h4>css/main.css</h4><pre class="brush:css">
/* menu builder styles */
.actions {
    border: 1px solid #CCCCCC;
    font-size: 24px;
    margin: 20px auto 5px;
    overflow: hidden;
    padding: 10px;
    width: 900px;

    /* CSS3 Box sizing property */
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -o-box-sizing: border-box;
    box-sizing: border-box;
}
.actions button {
    cursor: pointer;
    font-size: 20px;
    padding: 5px;
}
.actions #add_col {
    float: right;
}
.inactive {
    border: 1px dashed #ccc;
    margin: 0 auto;
    width: 900px;
}
.inactive a {
    border-color: #FFFFFF;
    border-style: solid;
    border-width: 8px 8px 20px;
    cursor: pointer;
    display: inline-block;
    font-size: 20px;
    height: 20px;
    margin: 10px;
    opacity: 1;
    position: relative;
    text-align: center;
    width: 180px;

    -khtml-user-drag: element;

    /* CSS3 Prevent selections */
    -moz-user-select: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    user-select: none;

    /* CSS3 Box Shadow */
    -webkit-box-shadow: 2px 2px 4px #444;
    -o-box-shadow: 2px 2px 4px #444;
    box-shadow: 2px 2px 4px #444;
}
.inactive a.hidden {
    height: 0;
    margin: 0;
    opacity: 0;
    width: 0;
}
.columns {
    margin: 0 auto;
    overflow: hidden;
    width: 900px;
}
.column {
    border: 2px dashed #ccc;
    float: left;
    min-height: 100px;
    padding: 10px;
    position: relative;
    width: 33.3%;

    /* CSS3 Box sizing property */
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -o-box-sizing: border-box;
    box-sizing: border-box;
}
.column a {
    border-color: #FFFFFF;
    border-style: solid;
    border-width: 4px 4px 10px;
    cursor: pointer;
    display: block;
    font-size: 16px;
    height: 30px;
    margin-bottom: 15px;
    opacity: 1;
    position: relative;
    text-align: center;

    -khtml-user-drag: element;
    -webkit-user-drag: element;

    /* CSS3 Prevent selections */
    -moz-user-select: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    user-select: none;

    /* CSS3 Box Shadow */
    -webkit-box-shadow: 2px 2px 4px #444;
    -o-box-shadow: 2px 2px 4px #444;
    box-shadow: 2px 2px 4px #444;

    /* CSS3 Box sizing property */
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -o-box-sizing: border-box;
    box-sizing: border-box;
}
.column img {
    cursor: pointer;
    position: absolute;
    right: 2px;
    top: 2px;
    z-index: 5;
}
</pre><h3>Step 3. JS</h3><h4>js/main.js</h4><pre class="brush:js">
// add event handler realization
var addEvent = (function () {
  if (document.addEventListener) {
    return function (el, type, fn) {
      if (el &amp;&amp; el.nodeName || el === window) {
        el.addEventListener(type, fn, false);
      } else if (el &amp;&amp; el.length) {
        for (var i = 0; i &lt; el.length; i++) {
          addEvent(el[i], type, fn);
        }
      }
    };
  } else {
    return function (el, type, fn) {
      if (el &amp;&amp; el.nodeName || el === window) {
        el.attachEvent('on' + type, function () { return fn.call(el, window.event); });
      } else if (el &amp;&amp; el.length) {
        for (var i = 0; i &lt; el.length; i++) {
          addEvent(el[i], type, fn);
        }
      }
    };
  }
})();

// update handlers for draggable objects
function updateHandlerDrag() {
    var dragItems = document.querySelectorAll('[draggable=true]');
    for (var i = 0; i &lt; dragItems.length; i++) {
        // dragstart event handler
        addEvent(dragItems[i], 'dragstart', function (event) {
            event.dataTransfer.setData('obj_id', this.id);
            return false;
        });
    }
}

// update handlers for droppable objects
function updateHandlerDrop() {
    var dropAreas = document.querySelectorAll('[droppable=true]');

    // dragover event handler
    addEvent(dropAreas, 'dragover', function (event) {
        if (event.preventDefault) event.preventDefault();

        this.style.borderColor = &quot;#000&quot;;
        return false;
    });

    // dragleave event handler
    addEvent(dropAreas, 'dragleave', function (event) {
        if (event.preventDefault) event.preventDefault();

        this.style.borderColor = &quot;#ccc&quot;;
        return false;
    });

    // dragenter event handler
    addEvent(dropAreas, 'dragenter', function (event) {
        if (event.preventDefault) event.preventDefault();
        return false;
    });

    // drop event handler
    addEvent(dropAreas, 'drop', function (event) {
        if (event.preventDefault) event.preventDefault();

        // get dropped object
        var iObj = event.dataTransfer.getData('obj_id');
        var oldObj = document.getElementById(iObj);

        // get inner text
        var linkText = oldObj.innerHTML;
        oldObj.className += 'hidden';

        // remove object from DOM
        oldObj.parentNode.removeChild(oldObj);

        // add similar object in another place
        this.innerHTML += '&lt;a id=&quot;'+iObj+'&quot; draggable=&quot;true&quot;&gt;'+linkText+'&lt;/a&gt;';

        // and update event handlers
        updateHandlerDrag();

        this.style.borderColor = &quot;#ccc&quot;;
        return false;
    });
}

// add column button
var addColBtn = document.querySelectorAll('#add_col');
addEvent(addColBtn, 'click', function (event) {
    if (event.preventDefault) event.preventDefault();

    // recalculate widths for columns
    var oCols = document.querySelector('div.columns');
    var iChilds = oCols.childElementCount + 1;
    var dWidth = 100 / iChilds;

    // add single column
    oCols.innerHTML += '&lt;div class=&quot;column&quot; id=&quot;drop_'+(iChilds+1)+'&quot; droppable=&quot;true&quot;&gt;&lt;img src=&quot;images/delete.png&quot; onclick=&quot;removeColumn(this)&quot; /&gt;&lt;/div&gt;';

    // set new widths
    for (var i = 0; i &lt; iChilds; i++) {
        oCols.children[i].style.width = dWidth + '%';
    }

    // update handlers
    updateHandlerDrop();

    return false;
});

// remove columns
function removeColumn(obj) {
    var oParent = obj.parentNode;

    // move object to inactive area
    var oInactive = document.querySelector('div.inactive');
    for (var i = 0; i &lt; oParent.childNodes.length; i++) {
        if (oParent.childNodes[i].nodeType == document.ELEMENT_NODE &amp;&amp; oParent.childNodes[i].tagName == 'A') {
            oInactive.innerHTML += '&lt;a id=&quot;'+oParent.childNodes[i].id+'&quot; draggable=&quot;true&quot;&gt;'+oParent.childNodes[i].innerHTML+'&lt;/a&gt;';
        }
    }

    // remove column
    oParent.parentElement.removeChild(oParent);

    // recalculate widths for columns
    var oCols = document.querySelector('div.columns');
    var iChilds = oCols.childElementCount;
    var dWidth = 100 / iChilds;

    // set new widths
    for (var i = 0; i &lt; iChilds; i++) {
        oCols.children[i].id = 'drop_' + (i + 1);
        oCols.children[i].style.width = dWidth + '%';
    }

    // update handlers
    updateHandlerDrop();
    updateHandlerDrag();
}

// update handlers
updateHandlerDrag();
updateHandlerDrop();
</pre><p>There are a lot of event handlers (in order to make that html5 drag and drop). In the beginning, the script updates different handlers for all draggable and dropable objects. During dragging between blocks (drop areas) we should recreate objects and update handlers. In case when we need to remove column, we should move all the object of active column back to inactive area (with list of all possible elements). Tomorrow we will teach our builder to generate results.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Bottom Menu Builder (HTML5) - demo 270" href="http://www.script-tutorials.com/demos/270/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Bottom Menu Builder (HTML5) - package" href="http://www.script-tutorials.com/demos/270/source.zip" target="_blank" rel="nofollow">download result</a></strong></h5><hr
/><h3>Conclusion</h3><p>That&#8217;s all, today we have implemented first half of our bottom menu builder with native Drag and Drop functionality. Hope that our tutorial has helped you. Feel free to share our tutorials with your friends. Good luck!</p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-drag-and-drop-sorting-photos/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/255/thumb.png" alt="HTML5 Drag and Drop &#8211; sorting photos between albums" /></div><h3>HTML5 Drag and Drop &#8211; sorting photos between albums</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-face-builder/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/200/thumb.png" alt="HTML5 Face Builder" /></div><h3>HTML5 Face Builder</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-bottom-navigation-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/170/thumb.png" alt="Creating a Toggle CSS3 Bottom Navigation Bar" /></div><h3>Creating a Toggle CSS3 Bottom Navigation Bar</a></h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/bottom-menu-builder-html5/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>CSS3 Form Design &#8211; Vintage</title><link>http://www.script-tutorials.com/css3-form-design-vintage/</link> <comments>http://www.script-tutorials.com/css3-form-design-vintage/#comments</comments> <pubDate>Thu, 10 May 2012 18:39:18 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[design]]></category> <category><![CDATA[forms]]></category> <category><![CDATA[Vintage]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1603</guid> <description><![CDATA[CSS3 Form Design &#8211; Vintage Today I prepared great CSS3 styles for forms in vintage style. You can see here styles of most necessary html form elements: text field, selector, checkbox, radio, button, file, textarea and submit button. I hope that I&#8217;m not in vain spent the whole evening. It is possible that it will [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/form-validation-with-javascript-and-php/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/228/thumb.png" alt="Form Validation with Javascript and PHP" /></div><h3>Form Validation with Javascript and PHP</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-modal-popups/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/222/thumb.png" alt="CSS3 Modal Popups" /></div><h3>CSS3 Modal Popups</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/data-validation-html5/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/49.png" alt="Data Validation &#8211; How to Validate Forms using HTML5" /></div><h3>Data Validation &#8211; How to Validate Forms using HTML5</a></h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="CSS3 Form Design - Vintage" alt="CSS3 Form Design - Vintage" src="http://www.script-tutorials.com/demos/269/thumb.png"></div><p><strong>CSS3 Form Design &#8211; Vintage</strong><br
/> <br
/>Today I prepared great CSS3 styles for forms in vintage style. You can see here styles of most necessary html form elements: text field, selector, checkbox, radio, button, file, textarea and submit button. I hope that I&#8217;m not in vain spent the whole evening. It is possible that it will be whole set of styles for your website. Now, let check it.<br
/> <span
id="more-1603"></span></p><div
style="clear:both;"></div><h3>Final Result</h3><p><img
src="http://www.script-tutorials.com/demos/269/example.jpg" alt="CSS3 Form Design - Vintage" title="CSS3 Form Design - Vintage"></p><div
style="clear:both;"></div><h5 style="text-align: center;"><strong><a
title="CSS3 Form Design - Vintage - demo 269" href="http://www.script-tutorials.com/demos/269/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="CSS3 Form Design - Vintage - package" href="http://www.script-tutorials.com/demos/269/source.zip" target="_blank">download result</a></strong></h5><hr
/><p>So, lets start</p><hr
/><h3>Step 1. HTML</h3><p>Our form contains all the most of possible form elements:</p><h4>index.html</h4><pre class="brush:html">
&lt;form action=&quot;#&quot; method=&quot;post&quot;&gt;
    &lt;fieldset&gt;
        &lt;ul&gt;
            &lt;li&gt;
                &lt;label for=&quot;name&quot;&gt;Name&lt;/label&gt;
                &lt;input type=&quot;text&quot; name=&quot;name&quot;&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;label for=&quot;email&quot;&gt;Email&lt;/label&gt;
                &lt;input type=&quot;text&quot; name=&quot;email&quot;&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/fieldset&gt;
    &lt;fieldset&gt;
        &lt;ul&gt;
            &lt;li&gt;
                &lt;label for=&quot;text&quot;&gt;Text Field&lt;/label&gt;
                &lt;input type=&quot;text&quot; class=&quot;required&quot; name=&quot;text&quot;&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;label for=&quot;selector&quot;&gt;Selector&lt;/label&gt;
                &lt;div class=&quot;selector&quot;&gt;
                    &lt;span style=&quot;-moz-user-select: none;&quot;&gt;Please Select...&lt;/span&gt;
                    &lt;select class=&quot;selectors&quot; name=&quot;selector&quot;&gt;
                        &lt;option value=&quot;&quot; selected=&quot;&quot;&gt;Please Select...&lt;/option&gt;
                        &lt;option&gt;Option 1&lt;/option&gt;
                        &lt;option&gt;Option 2&lt;/option&gt;
                        &lt;option&gt;Option 3&lt;/option&gt;
                        &lt;option&gt;Option 4&lt;/option&gt;
                        &lt;option&gt;Option 5&lt;/option&gt;
                    &lt;/select&gt;
                &lt;/div&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;label for=&quot;selector&quot;&gt;Disabled&lt;/label&gt;
                &lt;div class=&quot;selector disabled&quot;&gt;
                    &lt;span&gt;&lt;/span&gt;
                    &lt;select class=&quot;selectors&quot; name=&quot;selector&quot;&gt;&lt;/select&gt;
                &lt;/div&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;label for=&quot;checkbox&quot;&gt;Checkbox active&lt;/label&gt;
                &lt;div class=&quot;checker&quot;&gt;
                    &lt;span class=&quot;&quot;&gt;&lt;/span&gt;
                    &lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot; /&gt;
                &lt;/div&gt;
                &lt;label for=&quot;checkboxc&quot;&gt;Checkbox checked&lt;/label&gt;
                &lt;div class=&quot;checker&quot;&gt;
                    &lt;span class=&quot;checked&quot;&gt;&lt;/span&gt;
                    &lt;input type=&quot;checkbox&quot; name=&quot;checkboxc&quot; /&gt;
                &lt;/div&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;label for=&quot;radio&quot;&gt;Radio checked&lt;/label&gt;
                &lt;div class=&quot;radio&quot;&gt;
                    &lt;span class=&quot;checked&quot;&gt;&lt;/span&gt;
                    &lt;input type=&quot;radio&quot; name=&quot;radio&quot; value=&quot;radio1&quot;&gt;
                &lt;/div&gt;

                &lt;label for=&quot;radio2&quot;&gt;Radio unchecked&lt;/label&gt;
                &lt;div class=&quot;radio&quot;&gt;
                    &lt;span&gt;&lt;/span&gt;
                    &lt;input type=&quot;radio&quot; name=&quot;radio2&quot; value=&quot;radio2&quot;&gt;
                &lt;/div&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;label for=&quot;button&quot;&gt;Buttons&lt;/label&gt;
                &lt;div class=&quot;button&quot;&gt;&lt;span style=&quot;-moz-user-select: none;&quot;&gt;Button 1&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;button&quot;&gt;&lt;span style=&quot;-moz-user-select: none;&quot;&gt;Button 2&lt;/span&gt;&lt;/div&gt;
                &lt;div class=&quot;button disabled&quot;&gt;&lt;span style=&quot;-moz-user-select: none;&quot;&gt;Button 3&lt;/span&gt;&lt;/div&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;label for=&quot;file&quot;&gt;File&lt;/label&gt;
                &lt;div class=&quot;uploader&quot;&gt;
                    &lt;span style=&quot;-moz-user-select: none;&quot; class=&quot;filename&quot;&gt;Please select file&lt;/span&gt;
                    &lt;span style=&quot;-moz-user-select: none;&quot; class=&quot;action&quot;&gt;Upload&lt;/span&gt;
                    &lt;input type=&quot;file&quot; name=&quot;file&quot; /&gt;
                &lt;/div&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;label for=&quot;textarea&quot;&gt;Textarea&lt;/label&gt;
                &lt;textarea name=&quot;textarea&quot;&gt;&lt;/textarea&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;input type=&quot;submit&quot; name=&quot;submit&quot;&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/fieldset&gt;
&lt;/form&gt;
</pre><h3>Step 2. CSS</h3><p>Now, its time to style our form. Don&#8217;t forget to include our CSS file in the head section of the result page.</p><h4>css/forms.css</h4><pre class="brush:css">
@font-face {
	font-family:'ClarendonRoman';
	src:url('../font/clarebtrom-webfont.ttf') format('truetype');
}
form {
	background-color:#fff;
	overflow:hidden;
	width:465px;
	margin:30px auto;
	padding:10px;
}
form label {
	font:13px &quot;ClarendonRoman&quot;, Georgia, Times, serif;
	color:#525250;
	letter-spacing:2px;
	text-transform:uppercase;
	float:left;
	position:relative;
	top:4px;
}
form ul li {
	padding-top:10px;
	clear:both;
	overflow:hidden;
}
form select,form input {
	float:right;
}
form input {
	border-bottom:1px dashed #989895;
	border-right:none;
	border-left:none;
	border-top:none;
	color:#4f4f4f;
	background:none;
	outline:none;
	position:relative;
	font:16px &quot;SeanRegular&quot;, Courier New, Courier New, Courier6, monospace;
	letter-spacing:1px;
}
form input:focus {
	border-bottom:1px dashed #000;
	-webkit-transition:border 0.3s ease-in;
	-moz-transition:border 0.3s ease-in;
	-o-transition:border 0.3s ease-in;
	transition:border 0.3s ease-in;
}
form input[type=&quot;text&quot;] {
	width:300px;
}
fieldset {
	border:0;
	border-bottom:1px solid #A7A7A4;
	margin-bottom:10px;
	padding:10px;
}
textarea {
	margin-top:4px;
	width:445px;
	height:150px;
	border:none;
	background:none;
	outline:none;
	resize:none;
	overflow:auto;
	color:#4f4f4f;
	font:16px &quot;SeanRegular&quot;, Courier New, Courier New, Courier6, monospace;
	letter-spacing:1px;
	float:left;
	display:block;
}
form input[type=&quot;submit&quot;] {
	cursor:pointer;
	background:url(../images/submit.png) no-repeat;
	width:445px;
	height:86px;
	border:none;
	text-indent:-9999px;
	position:relative;
	bottom:10px;
}
form input[type=&quot;submit&quot;]:hover {
	background-position:0 -86px;
}

div.selector,div.selector span,div.checker span,div.radio span,div.uploader,div.uploader span.action,div.button,div.button span {
	background-image:url(../images/sprite.png);
	background-repeat:no-repeat;
	-webkit-font-smoothing:antialiased;
}
.selector,.radio,.checker,.uploader,.button,.selector *,.radio *,.checker *,.uploader *,.button * {
	margin:0;
	padding:0;
}
.selector select:focus, .radio input:focus, .checker input:focus, .uploader input:focus {
	outline: 0;
}
input.text,input.password,textarea {
	font-size:12px;
	font-family:&quot;ClarendonRoman&quot;, Georgia, Times, serif;
	font-weight:400;
	color:#777;
	border-top:solid 1px #aaa;
	border-left:solid 1px #aaa;
	border-bottom:solid 1px #ccc;
	border-right:solid 1px #ccc;
	-webkit-border-radius:3px;
	-moz-border-radius:3px;
	border-radius:3px;
	outline:0;
	padding:3px;
}
input.text:focus,input.password:focus,textarea:focus {
	border-color:#999;
}
div.selector {
	background-position:-483px -130px;
	float:right;
	font:12px &quot;ClarendonRoman&quot;,Georgia,Times,serif;
	height:26px;
	left:7px;
	overflow:hidden;
	padding-left:10px;
	position:relative;
	width:300px;
}
div.selector select {
	background:none;
	border:medium none;
	font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif;
	font-size:12px;
	height:25px;
	left:0;
	opacity:0;
	position:absolute;
	top:0;
	width:300px;
}
div.selector span {
	cursor:pointer;
	background-position:right 0;
	height:26px;
	line-height:26px;
	display:block;
	float:left;
	overflow:hidden;
	text-overflow:ellipsis;
	white-space:nowrap;
	width:268px;
	text-shadow:0 1px 0 #fff;
	color:#636363;
	padding:0 25px 0 2px;
}
div.selector:active {
	background-position:-483px -156px;
}
div.selector:active span {
	background-position:right -26px;
}
div.selector:hover {
	background-position:-483px -182px;
}
div.selector:hover span {
	background-position:right -52px;
}
div.selector:hover:active {
	background-position:-483px -208px;
}
div.selector:hover:active span {
	background-position:right -78px;
}
div.selector.disabled {
	background-position:-483px -234px;
}
div.selector.disabled span {
	color:#bbb;
	background-position:right -104px;
}
div.checker {
	float:left;
	height:19px;
	margin-right:10px;
	margin-top:4px;
	position:relative;
	width:19px;
}
div.checker input {
	background:none;
	display:inline-block;
	height:19px;
	opacity:0;
	width:19px;
}
div.checker span {
	background-position:0 -260px;
	display:block;
	float:left;
	height:19px;
	text-align:center;
	width:19px;
}
div.checker:active span {
	background-position:-19px -260px;
}
div.checker:hover span {
	background-position:-38px -260px;
}
div.checker:active:hover span {
	background-position:-57px -260px;
}
div.checker span.checked {
	background-position:-76px -260px;
}
div.checker:active span.checked {
	background-position:-95px -260px;
}
div.checker:hover span.checked {
	background-position:-114px -260px;
}
div.checker:hover:active span.checked {
	background-position:-133px -260px;
}
div.radio {
	width:18px;
	height:18px;
	position:relative;
	float:left;
	margin-top:4px;
	margin-right:10px;
}
div.radio input {
	width:18px;
	height:18px;
	opacity:0;
	text-align:center;
	display:inline-block;
	background:none;
}
div.radio span {
	height:18px;
	width:18px;
	background-position:0 -279px;
	display:block;
	float:left;
	text-align:center;
}
div.radio:active span {
	background-position:-18px -279px;
}
div.radio:hover span {
	background-position:-36px -279px;
}
div.radio:active:hover span {
	background-position:-54px -279px;
}
div.radio span.checked {
	background-position:-72px -279px;
}
div.radio:active span.checked {
	background-position:-90px -279px;
}
div.radio:hover span.checked {
	background-position:-108px -279px;
}
div.radio:hover:active span.checked {
	background-position:-126px -279px;
}
div.uploader {
	background-position:0 -297px;
	height:28px;
	position:relative;
	float:right;
	overflow:hidden;
	width:303px;
	margin-bottom:20px;
	margin-left:23px;
	cursor:pointer;
}
div.uploader span.action {
	background-position:right -409px;
	height:24px;
	line-height:24px;
	float:left;
	display:inline;
	overflow:hidden;
	cursor:pointer;
	width:124px;
	text-align:center;
	text-shadow:#fff 0 1px 0;
	background-color:#f9f9f5;
	font:bold 12px/24px &quot;ClarendonRoman&quot;, Georgia, Times, serif;
	color:#636363;
	padding:2px 0;
}
div.uploader span.filename {
	height:24px;
	line-height:24px;
	float:left;
	display:block;
	overflow:hidden;
	text-overflow:ellipsis;
	white-space:nowrap;
	cursor:default;
	font-family:Georgia, &quot;Times New Roman&quot;, Times, serif;
	font-style:italic;
	color:#777;
	width:157px;
	font-size:11px;
	margin:2px 0 2px 2px;
	padding:0 10px;
}
div.uploader:hover {
	background-position:0 -353px;
}
div.uploader:hover span.action {
	background-position:right -437px;
}
div.uploader:active span.action {
	background-position:right -465px;
}
div.uploader:focus:active span.action {
	background-position:right -493px;
}
div.uploader input {
	width:303px;
	opacity:0;
	position:absolute;
	top:0;
	right:0;
	bottom:0;
	float:right;
	height:25px;
	border:none;
	cursor:default;
}
div.button button,div.button input {
	position:absolute;
}
div.button {
	background-position:0 -523px;
	cursor:pointer;
	position:relative;
	display:-moz-inline-block;
	display:inline-block;
	height:30px;
}
div.button span {
	background-position:right -643px;
	display:-moz-inline-block;
	display:inline-block;
	font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif;
	font-size:12px;
	font-weight:700;
	height:22px;
	letter-spacing:1px;
	line-height:1;
	margin-left:13px;
	padding-left:2px;
	padding-right:15px;
	padding-top:8px;
	text-align:center;
	text-transform:uppercase;
}
div.button:focus,div.button:hover {
	background-position:0 -553px;
}
div.button:focus span,div.button:hover span {
	background-position:right -673px;
}
div.button.active,div.button:active {
	background-position:0 -583px;
}
div.button.active span,div.button:active span {
	background-position:right -703px;
	color:#555;
}
div.button.disabled,div.button:disabled {
	background-position:0 -613px;
}
div.button.disabled span,div.button:disabled span {
	background-position:right -733px;
	color:#bbb;
	cursor:default;
}
</pre><p>I hope that I was able to cover all necessary styles. These styles should work well in most of popular browsers.</p><hr
/><h5 style="text-align: center;"><strong><a
title="CSS3 Form Design - Vintage - demo 269" href="http://www.script-tutorials.com/demos/269/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="CSS3 Form Design - Vintage - package" href="http://www.script-tutorials.com/demos/269/source.zip" target="_blank" rel="nofollow">download result</a></strong></h5><hr
/><h3>Conclusion</h3><p>If you like our result &#8211; don&#8217;t forget to vote up, thanks in advance. You are free to modify our result and use it at your websites. Good luck!</p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/form-validation-with-javascript-and-php/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/228/thumb.png" alt="Form Validation with Javascript and PHP" /></div><h3>Form Validation with Javascript and PHP</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-modal-popups/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/222/thumb.png" alt="CSS3 Modal Popups" /></div><h3>CSS3 Modal Popups</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/data-validation-html5/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/49.png" alt="Data Validation &#8211; How to Validate Forms using HTML5" /></div><h3>Data Validation &#8211; How to Validate Forms using HTML5</a></h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/css3-form-design-vintage/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Infographic: HTML5 and Game Development</title><link>http://www.script-tutorials.com/infographic-html5-and-game-development/</link> <comments>http://www.script-tutorials.com/infographic-html5-and-game-development/#comments</comments> <pubDate>Wed, 09 May 2012 15:43:52 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[resources]]></category> <category><![CDATA[game development]]></category> <category><![CDATA[html5]]></category> <category><![CDATA[Infographic]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1599</guid> <description><![CDATA[Infographic: HTML5 and Game Development Today I would like to show you new interesting HTML5 infographics. Both of them related with web game development. Nowadays &#8211; HTML5 is a new Web based standard with very big potential to create cross-platform applications. It has just been evolving, and even now we can create various applications with [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/infographic-html5-vs-flash-games/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/infographics/html5flash.png" alt="Infographic: HTML5 vs Flash Games" /></div><h3>Infographic: HTML5 vs Flash Games</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/infographic-html5-cheatsheat/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/infographics/html5_cheatsheet.jpg" alt="Infographic: HTML5 Cheatsheat" /></div><h3>Infographic: HTML5 Cheatsheat</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-game-development-lesson-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/214/thumb.png" alt="HTML5 Game Development &#8211; Lesson 6" /></div><h3>HTML5 Game Development &#8211; Lesson 6</a></h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="HTML5 and Game Development" src="http://www.script-tutorials.com/demos/infographics/h5g_thumb.png"></div><p><strong>Infographic: HTML5 and Game Development</strong><br
/> <br
/> Today I would like to show you new interesting HTML5 infographics. Both of them related with web game development. Nowadays &#8211; HTML5 is a new Web based standard with very big potential to create cross-platform applications. It has just been evolving, and even now we can create various applications with using html5. What about Flash? Flash is still alive. And today you can compare updated information about flash and html5. I&#8217;m not sure that this is holy war, I think that this is just different standards, but anyway &#8211; this is interesting.<br
/> <span
id="more-1599"></span><br
/> Information Graphics (known as infographics) are one of the best ways to transfer some information into a reader&#8217;s mind. It can be something new, or other useful information gathered in one place. Nowadays many people don&#8217;t have enough time to read a lot of text on multiple screens. Infographics makes the information intuitive and understandable. That&#8217;s why we would like to share the best relevant infographics from all over the web.<br
/></p><hr
/> <a
title="HTML5 and Game Development - high quality" href="http://www.script-tutorials.com/demos/infographics/infographic_html5_hype_big.jpg" target="_blank"><br
/> <img
src="http://www.script-tutorials.com/demos/infographics/infographic_html5_hype.jpg" alt="HTML5 and Game Development" /><br
/> </a></p><hr
/><h5 style="text-align: center;"><strong><a
title="HTML5 and Game Development" href="http://www.script-tutorials.com/demos/infographics/infographic_html5_hype_big.jpg" target="_blank">Download In High Quality</a></strong></h5><p><strong>Original source: <a
target="_blank" href="http://www.readwriteweb.com/mobile/2012/03/infographic-the-hype-versus-re.php" rel="nofollow">The Hype Versus Reality of HTML5 Deployment</a></strong></p><hr
/> <a
title="HTML5 and Game Development - high quality" href="http://www.script-tutorials.com/demos/infographics/html5pollresults2.jpg" target="_blank"><br
/> <img
src="http://www.script-tutorials.com/demos/infographics/html5pollresults2.jpg" alt="HTML5 and Game Development" /><br
/> </a></p><hr
/><p><strong>Original source: <a
target="_blank" href="http://www.8bitrocket.com/2012/04/09/8bitrocket-com-april-2012-html5-game-development-poll-results-infographic/" rel="nofollow">8bitrocket.com April 2012 HTML5 Game Development Poll Results Infographic</a></strong></p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/infographic-html5-vs-flash-games/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/infographics/html5flash.png" alt="Infographic: HTML5 vs Flash Games" /></div><h3>Infographic: HTML5 vs Flash Games</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/infographic-html5-cheatsheat/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/infographics/html5_cheatsheet.jpg" alt="Infographic: HTML5 Cheatsheat" /></div><h3>Infographic: HTML5 Cheatsheat</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-game-development-lesson-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/214/thumb.png" alt="HTML5 Game Development &#8211; Lesson 6" /></div><h3>HTML5 Game Development &#8211; Lesson 6</a></h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/infographic-html5-and-game-development/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Google Maps API v3 Practical Implementation</title><link>http://www.script-tutorials.com/google-maps-api-v3-practical-implementation/</link> <comments>http://www.script-tutorials.com/google-maps-api-v3-practical-implementation/#comments</comments> <pubDate>Tue, 08 May 2012 17:55:11 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Google Maps]]></category> <category><![CDATA[how-to]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1596</guid> <description><![CDATA[Google Maps API v3 Practical Implementation In our new tutorial I would like to give you one interesting example of Google Maps API (v3) implementation. Let assume, that you have website with own members. And, you need to add possibility to save map positions of your members at your website. Or, you have to store [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-own-rss-reader-using-google-feed-api/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/82/thumb.png" alt="Creating Your Own RSS Reader Using Google Feed API" /></div><h3>Creating Your Own RSS Reader Using Google Feed API</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-7/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/258/thumb.png" alt="Powerful Chat System &#8211; Lesson 7" /></div><h3>Powerful Chat System &#8211; Lesson 7</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-4/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/233/thumb.png" alt="Powerful Chat System &#8211; Lesson 4" /></div><h3>Powerful Chat System &#8211; Lesson 4</a></h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Google Maps API Practical Implementation" alt="Google Maps API Practical Implementation" src="http://www.script-tutorials.com/demos/268/thumb.png"></div><p><strong>Google Maps API v3 Practical Implementation</strong><br
/> <br
/>In our new tutorial I would like to give you one interesting example of Google Maps API (v3) implementation. Let assume, that you have website with own members. And, you need to add possibility to save map positions of your members at your website. Or, you have to store map coordinates for something else (as example &#8211; business locations). I think that this is one of usual tasks in webdevelopment. For our practical realization I took the base of our <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-8/" target="_blank">chat system</a> (I removed everything unnecessary except registration). Now, I will add here next features: index page block with map of 20 recent locations of members, profile page map (with single marker), and page to set coordinates at map.<br
/> <span
id="more-1596"></span></p><h5 style="text-align: center;"><strong><a
title="Google Maps API Practical Implementation - demo 268" href="http://www.script-tutorials.com/demos/268/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Google Maps API Practical Implementation - package" href="http://www.script-tutorials.com/demos/268/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Now &#8211; download the source files and lets start coding !</p><hr
/><h3>Step 1. SQL</h3><p>If you have already had `cs_profiles` table in your database (due of tests), you don&#8217;t need remove previous version, keep it, and add second one new table `latlng268`:</p><pre class="brush:sql">
CREATE TABLE `cs_profiles` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  `first_name` varchar(255) NOT NULL default '',
  `last_name` varchar(255) NOT NULL default '',
  `email` varchar(255) NOT NULL default '',
  `password` varchar(40) NOT NULL default '',
  `salt` varchar(10) NOT NULL default '',
  `status` enum('active','passive') NOT NULL default 'active',
  `role` tinyint(4) unsigned NOT NULL default '1',
  `about` varchar(255) NOT NULL,
  `date_reg` datetime NOT NULL default '0000-00-00 00:00:00',
  `date_nav` datetime NOT NULL default '0000-00-00 00:00:00',
  `color` varchar(6) NOT NULL,
  `rate` float NOT NULL,
  `rate_count` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `latlng268` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `profile` int(11) unsigned NOT NULL,
  `name` varchar(255) NOT NULL default '',
  `lat` double NOT NULL,
  `lng` double NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
</pre><h3>Step 2. HTML</h3><p>This is Login / Join form template:</p><h4>templates/login_form.html</h4><pre class="brush:html">
&lt;div class=&quot;column&quot;&gt;
    &lt;h3&gt;Google Maps API v3 Practical Implementation&lt;/h3&gt;
    &lt;p&gt;Our demonstration contains next features: member registration, and possibility to add own custom marker at google map.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;column&quot;&gt;

    &lt;div class=&quot;tabs_container&quot;&gt;
        &lt;ul class=&quot;tabs&quot;&gt;
            &lt;li class=&quot;active&quot;&gt;&lt;h3&gt;Log In&lt;/h3&gt;&lt;/li&gt;
            &lt;li&gt;&lt;h3&gt;Join&lt;/h3&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/div&gt;

    &lt;div class=&quot;nav_container&quot;&gt;
        &lt;form class=&quot;login_form&quot; action=&quot;index.php&quot; method=&quot;post&quot; id=&quot;1&quot;&gt;
            &lt;label&gt;Username:&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;username&quot;&gt;
            &lt;label&gt;Password:&lt;/label&gt;&lt;input type=&quot;password&quot; name=&quot;password&quot;&gt;
            &lt;input type=&quot;submit&quot; name=&quot;Login&quot; value=&quot;Login&quot;&gt;
        &lt;/form&gt;
        &lt;form class=&quot;join_form&quot; action=&quot;index.php&quot; method=&quot;post&quot; id=&quot;2&quot; style=&quot;display: none;&quot;&gt;

            &lt;label&gt;Full name:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;username&quot; name=&quot;username&quot; placeholder=&quot;Your name&quot; maxlength=&quot;128&quot; title=&quot;Your name&quot; required&gt;

            &lt;label&gt;First name:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;firstname&quot; name=&quot;firstname&quot; placeholder=&quot;Your first name&quot; maxlength=&quot;128&quot; title=&quot;Your first name&quot;&gt;

            &lt;label&gt;Last name:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;lastname&quot; name=&quot;lastname&quot; placeholder=&quot;Your last name&quot; maxlength=&quot;128&quot; title=&quot;Your last name&quot;&gt;

            &lt;label&gt;Email:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;email&quot; name=&quot;email&quot; placeholder=&quot;Your email&quot; maxlength=&quot;128&quot; title=&quot;Format: *@gmail.com&quot; pattern=&quot;.*@gmail\.com&quot; required&gt;

            &lt;label&gt;Password:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;password&quot; name=&quot;password&quot; maxlength=&quot;128&quot; title=&quot;Password&quot; required&gt;

            &lt;label&gt;Repeat Password:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;password&quot; name=&quot;password&quot; maxlength=&quot;128&quot; title=&quot;Repeat password&quot; required oninput=&quot;checkpass(this)&quot;&gt;

            &lt;input type=&quot;submit&quot; name=&quot;Join&quot; value=&quot;Join&quot;&gt;
        &lt;/form&gt;
    &lt;/div&gt;

    &lt;div&gt;Powered by &lt;a href=&quot;http://www.script-tutorials.com/&quot; target=&quot;_blank&quot; title=&quot;Script Tutorials&quot;&gt;Script Tutorials&lt;/a&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
$(document).ready(function(){
    $('.tabs li h3').click(function () {
      $('.tabs li').removeClass('active');
      $(this).parent().addClass('active');

      $('.nav_container form').hide();
      var index = $('.tabs li h3').index(this);
      $('.nav_container form').eq(index).show();
      return false;
    });
});

function checkpass(input) {
    if (input.value != document.getElementById('password').value) {
        input.setCustomValidity('Password must match.');
    } else {
        input.setCustomValidity('');
    }
}
&lt;/script&gt;
</pre><p>Very easy form, isn&#8217;t it? Next template &#8211; small logout template (with link to page to set position):</p><h4>templates/logout_form.html</h4><pre class="brush:html">
&lt;div class=&quot;column&quot;&gt;
    &lt;span style=&quot;float:right&quot;&gt;&lt;a href=&quot;index.php?logout&quot;&gt;Log Out&lt;/a&gt;&lt;/span&gt;
    &lt;h3&gt;Hello {name}&lt;/h3&gt;
    &lt;h3&gt;Your status:&lt;/h3&gt;
    &lt;div&gt;{status}&lt;/div&gt;
    &lt;h3&gt;&lt;a href=&quot;setpos.php&quot;&gt;Set my position&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;
</pre><p>Again &#8211; very easy template. Next template &#8211; index (main) page template:</p><h4>templates/main_page.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
&lt;head&gt;
    &lt;title&gt;Google Maps API v3 Practical Implementation&lt;/title&gt;
    &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://maps.googleapis.com/maps/api/js?sensor=false&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;js/update.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;header&gt;
        &lt;h2&gt;Google Maps API v3 Practical Implementation&lt;/h2&gt;
        &lt;a href=&quot;http://www.script-tutorials.com/google-maps-api-v3-practical-implementation/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
    &lt;/header&gt;
    &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;container&quot; id=&quot;con1&quot;&gt;
        {form}
    &lt;/div&gt;
    &lt;div class=&quot;container&quot; id=&quot;con2&quot;&gt;
        &lt;h2&gt;Main Map&lt;/h2&gt;
        &lt;div class=&quot;gmap&quot;&gt;
            &lt;div id='gmap_canvas' style=&quot;position:relative; width:100%; height:550px;&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class=&quot;sidebar&quot;&gt;
        &lt;div&gt;
            &lt;h2&gt;Online Members Block&lt;/h2&gt;
            {online_members}
        &lt;/div&gt;
        &lt;div&gt;
            &lt;h2&gt;Last Members&lt;/h2&gt;
            {profiles}
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;script type=&quot;text/javascript&quot;&gt;
        var map;
        function initialize() {

            var iCoordX = 40;
            var iCoordY = -75;
            var myLatlng = new google.maps.LatLng(iCoordX, iCoordY);

            var myOptions = {
                zoom: 6,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            map = new google.maps.Map(document.getElementById('gmap_canvas'), myOptions);

            var aMarkers = new Array();
            var aMarkerInfos = new Array();

            {add_markers}
        }

        google.maps.event.addDomListener(window, 'load', initialize);
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre><p>Here you can see google maps initialization &#8211; this is very easy JS script, where we need prepare map options and initialize map object, and then &#8211; we need to add 20 (optonal) recent positions. Next template &#8211; profile page template:</p><h4>templates/profile_page.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
&lt;head&gt;
    &lt;title&gt;Google Maps API v3 Practical Implementation&lt;/title&gt;
    &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;js/update.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;header&gt;
        &lt;h2&gt;Google Maps API v3 Practical Implementation&lt;/h2&gt;
        &lt;a href=&quot;http://www.script-tutorials.com/google-maps-api-v3-practical-implementation/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
    &lt;/header&gt;
    &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;container&quot;&gt;
        &lt;div class=&quot;column&quot;&gt;
            &lt;h3&gt;Name: {name}&lt;/h3&gt;
            &lt;h3&gt;First name: {fname}&lt;/h3&gt;
            &lt;h3&gt;Last name: {lname}&lt;/h3&gt;
            &lt;h3&gt;About: {about}&lt;/h3&gt;
            &lt;h3&gt;Date Reg: {datereg}&lt;/h3&gt;
        &lt;/div&gt;
        &lt;div class=&quot;column&quot;&gt;
            &lt;p&gt;&lt;a href=&quot;index.php&quot;&gt;Back to main page&lt;/a&gt;&lt;/p&gt;
        &lt;/div&gt;
    &lt;/div&gt;

    {map}

    &lt;div class=&quot;sidebar&quot;&gt;
        &lt;div&gt;
            &lt;h2&gt;Online Members Block&lt;/h2&gt;
            {online_members}
        &lt;/div&gt;
        &lt;div&gt;
            &lt;h2&gt;Last Members&lt;/h2&gt;
            {profiles}
        &lt;/div&gt;
    &lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre><p>At this page, we will see single profile view page, and, if he (that member) has set his coordinates, we will see google map at his page. Next template &#8211; html template of that profile&#8217;s map:</p><h4>templates/profile_map.html</h4><pre class="brush:html">
&lt;script src=&quot;https://maps.googleapis.com/maps/api/js?sensor=false&quot;&gt;&lt;/script&gt;

&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;container&quot;&gt;
    &lt;div id='gmap_canvas' style=&quot;position:relative; width:100%; height:400px;&quot;&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
    var map;
    var marker;

    function initialize() {

        // set profile coordinates
        var myLatlng = new google.maps.LatLng({lat}, {lng});

        var myOptions = {
            zoom: 6,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById('gmap_canvas'), myOptions);

        // prepare info window
        var infowindow = new google.maps.InfoWindow({
            content: &quot;{name}&quot;
        });

        // prepare new marker
        marker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            title: &quot;{name}&quot;,
            animation: google.maps.Animation.DROP
        });
        google.maps.event.addListener(marker, 'click', function() {
            infowindow.open(map,marker);
        });
    }

    // initialization
    google.maps.event.addDomListener(window, 'load', initialize);
&lt;/script&gt;
</pre><p>You can see here new google map initialization in certain coordinates with marker, and we add event listener (when we click at marker) to display popup info (InfoWindow). And finally, we should prepare last one template file &#8211; for page where member can setup own coordinates:</p><h4>templates/setpos_page.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
&lt;head&gt;
    &lt;title&gt;Google Maps API v3 Practical Implementation&lt;/title&gt;
    &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;https://maps.googleapis.com/maps/api/js?sensor=false&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;header&gt;
        &lt;h2&gt;Google Maps API v3 Practical Implementation&lt;/h2&gt;
        &lt;a href=&quot;http://www.script-tutorials.com/google-maps-api-v3-practical-implementation/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
    &lt;/header&gt;
    &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;container&quot;&gt;
        &lt;h3&gt;&lt;a href=&quot;index.php&quot;&gt;Back to main page&lt;/a&gt;&lt;/h3&gt;

        &lt;div style=&quot;margin:10px;&quot;&gt;Type full street address into field and click on FIND to center map on location.&lt;/div&gt;
        &lt;div style=&quot;margin:10px;&quot;&gt;&lt;input id=&quot;gmap_where&quot; type=&quot;text&quot; name=&quot;gmap_where&quot; /&gt;&lt;input id=&quot;find&quot; type=&quot;button&quot; value=&quot;Find&quot; name=&quot;find&quot; onclick=&quot;findAddress(); return false;&quot; /&gt;&lt;/div&gt;
        &lt;div id='gmap_canvas' style=&quot;position:relative; width:100%; height:400px;margin-bottom:25px;&quot;&gt;&lt;/div&gt;

        &lt;hr /&gt;
        &lt;h3&gt;Please confirm your position&lt;/h3&gt;
        &lt;form class=&quot;login_form&quot; action=&quot;setpos.php&quot; method=&quot;post&quot; name=&quot;setpos_form&quot;&gt;
            &lt;input type=&quot;text&quot; name=&quot;lat&quot; value=&quot;{lat}&quot; /&gt;
            &lt;input type=&quot;text&quot; name=&quot;lng&quot; value=&quot;{lng}&quot; /&gt;
            &lt;input type=&quot;submit&quot; name=&quot;Confirm&quot; value=&quot;Confirm positions&quot; /&gt;
        &lt;/form&gt;
    &lt;/div&gt;

    &lt;script type=&quot;text/javascript&quot;&gt;
        var geocoder;
        var map;
        var marker;

        function initialize() {
            geocoder = new google.maps.Geocoder();

            // set initial coordinates
            var myLatlng = new google.maps.LatLng({lat}, {lng});

            var myOptions = {
                zoom: 6,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            map = new google.maps.Map(document.getElementById('gmap_canvas'), myOptions);

            // prepare info window
            var infowindow = new google.maps.InfoWindow({
                content: 'My position'
            });

            // prepare new marker
            marker = new google.maps.Marker({
                position: myLatlng,
                map: map,
                title: 'My position',
                draggable:true,
                animation: google.maps.Animation.DROP
            });
            google.maps.event.addListener(marker, 'click', function() {
                infowindow.open(map,marker);
            });

            google.maps.event.addListener(marker, 'dragstart', function() {
                infowindow.close();
            });
            google.maps.event.addListener(marker, 'dragend', function(obj) {
                map.setCenter(obj.latLng);
                $('form[name=setpos_form] input[name=lat]').val( obj.latLng.$a );
                $('form[name=setpos_form] input[name=lng]').val( obj.latLng.ab );
            });
        }

        // initialization
        google.maps.event.addDomListener(window, 'load', initialize);

        // find custom address function
        function findAddress() {
            var address = document.getElementById(&quot;gmap_where&quot;).value;
            geocoder.geocode( { 'address': address}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                marker.position = results[0].geometry.location;

                $('form[name=setpos_form] input[name=lat]').val( results[0].geometry.location.$a );
                $('form[name=setpos_form] input[name=lng]').val( results[0].geometry.location.ab );
            } else {
                alert(&quot;Geocode was not successful for the following reason: &quot; + status);
            }
            });
        }
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre><p>This Javascript is more complicated, I added here possibility to drag marker, and also I added search panel, so now we can search by exact names.</p><h3>Step 3. CSS</h3><p>Now, it&#8217;s time to apply styles:</p><h4>css/main.css</h4><pre class="brush:css">
/* page layout */
*{
    margin:0;
    padding:0;
}
body {
    background-color:#eee;
    color:#fff;
    font:14px/1.3 Arial,sans-serif;
}
header {
    background-color:#212121;
    box-shadow: 0 -1px 2px #111111;
    display:block;
    height:70px;
    position:relative;
    width:100%;
    z-index:100;
}
header h2{
    float: left;
    font-size:22px;
    font-weight:normal;
    margin-left:10px;
    margin-right:20px;
    padding:22px 0;
}
header a.stuts,a.stuts:visited{
    float: left;
    text-decoration:none;
    color:#fcfcfc;
    font-size:14px;
    height:70px;
    line-height:70px;
}
header .stuts span {
    font-size:22px;
    font-weight:bold;
    margin-left:5px;
}

/* main styles */
a {
    color: #333;
    outline: none;
    text-decoration: none;
}
a:hover,a:active {
    outline: 0;
    text-decoration: none;
}
.container {
    background-color: #F2F4F8;
    border: 1px solid rgba(0, 0, 0, 0.4);
    box-shadow: 2px 0 2px -2px #B2B9C9 inset;
    color: #333333;
    margin: 20px;
    overflow: hidden;
    padding: 20px;
    position: relative;
    width: 70%;
    float:left;
}
#con1.container {
    width: 300px;
}
#con2.container {
    width: 500px;
}
.container h2 {
    margin-bottom: 10px;
}
.column {
}
.column:first-child {
}
.column &gt; * {
    margin-bottom: 10px;
}
.clear {
    clear: both;
    font-size: 1px;
}
.sidebar {
    background-color: #F2F4F8;
    border-left: 1px solid rgba(0, 0, 0, 0.4);
    box-shadow: 2px 0 2px -2px #B2B9C9 inset;
    color: #333333;
    display: block;
    height: 100%;
    padding: 10px;
    position: fixed;
    right: 0;
    top: 0;
    width: 250px;
    z-index: 101;
}
.sidebar &gt; div {
    margin-bottom: 30px;
}

/* tabs section */
.tabs_container {
    margin: 0;
}
.tabs {
    overflow: hidden;
}
.tabs li {
    float: left;
    list-style: none;
}
.tabs li h3:first-child {
    margin-left: 10px
}
.tabs li h3 {
    border: 1px solid #ddd;
    border-bottom-width: 0;
    display: block;
    margin: 0 2px 0 0;
    padding: 6px 10px 4px
}
.tabs li.active h3 {
    background-color: #ccc;
    border: 1px solid #ddd;
    border-bottom-width: 0;

    -moz-border-radius: 4px 4px 0 0;
    -ms-border-radius: 4px 4px 0 0;
    -o-border-radius: 4px 4px 0 0;
    -webkit-border-radius: 4px 4px 0 0;
    border-radius: 4px 4px 0 0;
}
.tabs li h3:hover {
    background-color: #bbb;
    cursor: pointer;
}
.tabs li.active h3:hover {
    background-color: #ccc;
    cursor: normal;
}
.nav_container form {
    background-color: #ccc;
    display: block;
    padding: 15px;
}
.login_form input,.login_form label,
.join_form input,.join_form label {
    display: block;
    margin-bottom: 10px;
}
input[type=text], input[type=password], input[type=submit] {
    -moz-border-radius: 5px;
    -ms-border-radius: 5px;
    -o-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    border-style: groove;
}
input[type=text], input[type=password] {
    border-style: groove;
    font-size: 16px;
    height: 25px;
    margin-right: 10px;
    width: 200px;
}
input[type=submit],
input[type=file]{
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    height: 35px;
    padding: 5px;
}

/* profiles */
.profiles {
    overflow: hidden;
}
.profiles a {
    display: block;
}
.profiles div {
    overflow: hidden;
}
.profiles div a {
    color: #333333;
    display: block;
    padding: 2px 22px 2px 10px;
    position: relative;
}
.profiles div a:hover {
    background-color: #E0E4EE;
    box-shadow: 2px 0 2px -2px #B2B9C9 inset;
}

.profiles div img {
    border: 0;
    float: left;
    height: 48px;
    margin-right: 8px;
    width: 48px;
}
.profiles div p {
    display: block;
    line-height: 28px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profiles div img.status_img {
    border: 0;
    display: block;
    height: 7px;
    margin-top: -6px;
    position: absolute;
    right: 5px;
    top: 50%;
    width: 7px;
}
</pre><h3>Step 4. PHP</h3><p>Our PHP files are separated into two types: action files and classes. I think that you have already saw sources of most of classes of chat project. So, first two files are same:</p><h4>classes/CLogin.php</h4><h4>classes/CMySQL.php</h4><p>We don&#8217;t need to re-publish sources of both files again. Both are available in our package. But I updated Profiles class file (I removed all unnecessary here, now it contains only registration and few other functions):</p><h4>classes/CProfiles.php</h4><pre class="brush:php">
&lt;?php

define('PROFILE_TIMEOUT', 5); // 5 mins

// Profiles class
class CProfiles {

    // constructor
    function CProfiles() {}

    // profile registration
    function registerProfile() {
        $sUsername = $GLOBALS['MySQL']-&gt;escape($_POST['username']);
        $sFirstname = $GLOBALS['MySQL']-&gt;escape($_POST['firstname']);
        $sLastname = $GLOBALS['MySQL']-&gt;escape($_POST['lastname']);
        $sEmail = $GLOBALS['MySQL']-&gt;escape($_POST['email']);
        $sPassword = $GLOBALS['MySQL']-&gt;escape($_POST['password']);

        if ($sUsername &amp;&amp; $sEmail &amp;&amp; $sPassword) {
            // check if already exist
            $aProfile = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `cs_profiles` WHERE `email`='{$sEmail}'&quot;);
            if ($aProfile['id'] &gt; 0) {
                $sErrors = '&lt;h2&gt;Another profile with same email already exist&lt;/h2&gt;';
            } else {
                // generate Salt and Cached password
                $sSalt = $this-&gt;getRandCode();
                $sPass = sha1(md5($sPassword) . $sSalt);

                // add new member into database
                $sSQL = &quot;
                    INSERT INTO `cs_profiles` SET
                    `name` = '{$sUsername}',
                    `first_name` = '{$sFirstname}',
                    `last_name` = '{$sLastname}',
                    `email` = '{$sEmail}',
                    `password` = '{$sPass}',
                    `salt` = '{$sSalt}',
                    `status` = 'active',
                    `role` = '1',
                    `date_reg` = NOW();
                &quot;;
                $GLOBALS['MySQL']-&gt;res($sSQL);

                // autologin
                $GLOBALS['CLogin']-&gt;performLogin($sUsername, $sPassword);
            }
        }
    }

    // get random code (for salt)
    function getRandCode($iLen = <img src='http://www.script-tutorials.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> {
        $sRes = '';

        $sChars = &quot;23456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ&quot;;
        for ($i = 0; $i &lt; $iLen; $i++) {
            $z = rand(0, strlen($sChars) -1);
            $sRes .= $sChars[$z];
        }
        return $sRes;
    }

    // get profiles block
    function getProfilesBlock($iLim = 20, $bOnlineOnly = false) {
        $iPLimit = PROFILE_TIMEOUT;
        $sOnlineSQL = ($bOnlineOnly) ? 'AND (`date_nav` &gt; SUBDATE(NOW(), INTERVAL ' . $iPLimit . ' MINUTE))' : '';
        $sSQL = &quot;
            SELECT `cs_profiles`.*,
            if (`date_nav` &gt; SUBDATE(NOW(), INTERVAL {$iPLimit} MINUTE ), 1, 0) AS `is_online`
            FROM `cs_profiles`
            WHERE `status` = 'active'
            {$sOnlineSQL}
            ORDER BY `date_reg` DESC
            LIMIT {$iLim}
        &quot;;
        $aProfiles = $GLOBALS['MySQL']-&gt;getAll($sSQL);

        // create list of messages
        $sCode = '';
        foreach ($aProfiles as $i =&gt; $aProfile) {
            $sName = $aProfile['name'];
            $iPid = $aProfile['id'];
            $sOnline = ($aProfile['is_online'] == 1) ? '&lt;img alt=&quot;&quot; src=&quot;images/online.png&quot; class=&quot;status_img&quot; /&gt;' : '';
            $sCode .= '&lt;div id=&quot;'.$iPid.'&quot; title=&quot;'.$sName.'&quot;&gt;&lt;a href=&quot;profile.php?id='.$iPid.'&quot;&gt;&lt;p&gt;'.$sName.'&lt;/p&gt;'.$sOnline.'&lt;/a&gt;&lt;/div&gt;';
        }

        $sClass = ($bOnlineOnly) ? 'profiles online_profiles' : 'profiles';
        return '&lt;div class=&quot;'.$sClass.'&quot;&gt;' . $sCode . '&lt;/div&gt;';
    }

    // get profile info
    function getProfileInfo($i) {
        $sSQL = &quot;
            SELECT *
            FROM `cs_profiles`
            WHERE `id` = '{$i}'
        &quot;;
        $aInfos = $GLOBALS['MySQL']-&gt;getAll($sSQL);
        return $aInfos[0];
    }
}

$GLOBALS['CProfiles'] = new CProfiles();
</pre><p>Now lets review our main files:</p><h4>index.php</h4><pre class="brush:php">
&lt;?php

// set error reporting level
if (version_compare(phpversion(), '5.3.0', '&gt;=') == 1)
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED);
else
  error_reporting(E_ALL &amp; ~E_NOTICE);

require_once('classes/CMySQL.php'); // service class to work with database
require_once('classes/CLogin.php'); // service class to work with login processing
require_once('classes/CProfiles.php'); // service class to work with profiles

// join processing
if (! isset($_SESSION['member_id']) &amp;&amp; $_POST['Join'] == 'Join') {
    $GLOBALS['CProfiles']-&gt;registerProfile();
}

// login system init and generation code
$sLoginForm = $GLOBALS['CLogin']-&gt;getLoginBox();

if ($_SESSION['member_id'] &amp;&amp; $_SESSION['member_status'] == 'active') {
    if ($_GET['action'] == 'update_last_nav') { // update last navigate time
        $iPid = (int)$_SESSION['member_id'];
        if ($iPid) {
            $GLOBALS['MySQL']-&gt;res(&quot;UPDATE `cs_profiles` SET `date_nav` = NOW() WHERE `id` = '{$iPid}'&quot;);
        }
        exit;
    }
}

// get profiles lists
$sProfiles = $GLOBALS['CProfiles']-&gt;getProfilesBlock();
$sOnlineMembers = $GLOBALS['CProfiles']-&gt;getProfilesBlock(10, true);

// prepare set of markers for global map
$sMarkers = '';
$aRecentMarkers = $GLOBALS['MySQL']-&gt;getAll(&quot;SELECT * FROM `latlng268` ORDER BY `id` DESC LIMIT 20&quot;);
foreach ($aRecentMarkers as $i =&gt; $sMInfo) {
    if ($sMInfo['lat'] != 0 &amp;&amp; $sMInfo['lng'] != 0) {
        $sUnitLocation = str_replace('&quot;', '', $sMInfo['name']);

        $sMarkers .= &lt;&lt;&lt;EOF
aMarkerInfos[{$sMInfo['id']}] = new google.maps.InfoWindow({content: &quot;{$sUnitLocation}&quot;});
aMarkers[{$sMInfo['id']}] = new google.maps.Marker({position: new google.maps.LatLng({$sMInfo['lat']}, {$sMInfo['lng']}), map: map, title: &quot;{$sUnitLocation}&quot;});

google.maps.event.addListener(aMarkers[{$sMInfo['id']}], 'click', function() {
    aMarkerInfos[{$sMInfo['id']}].open(map,aMarkers[{$sMInfo['id']}]);
});

EOF;
    }
}

// draw common page
$aKeys = array(
    '{form}' =&gt; $sLoginForm,
    '{profiles}' =&gt; $sProfiles,
    '{online_members}' =&gt; $sOnlineMembers,
    '{add_markers}' =&gt; $sMarkers
);
echo strtr(file_get_contents('templates/main_page.html'), $aKeys);
</pre><p>Pay attention to code where we add markers for map. By default, there are only 20 last markers. You always can play with that limit. Our next file &#8211; profile page:</p><h4>profile.php</h4><pre class="brush:php">
&lt;?php

// set error reporting level
if (version_compare(phpversion(), '5.3.0', '&gt;=') == 1)
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED);
else
  error_reporting(E_ALL &amp; ~E_NOTICE);

require_once('classes/CMySQL.php'); // service class to work with database
require_once('classes/CLogin.php'); // service class to work with login processing
require_once('classes/CProfiles.php'); // service class to work with profiles

// get basic info about profile
$iPid = (int)$_GET['id'];
$aInfo = $GLOBALS['CProfiles']-&gt;getProfileInfo($iPid);
$sName = $aInfo['name'];
$sFName = $aInfo['first_name'];
$sLName = $aInfo['last_name'];
$sAbout = $aInfo['about'];
$sDate = $aInfo['date_reg'];

// get map block
$sMap = '';
$aPosInfo = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `latlng268` WHERE `profile` = '{$iPid}'&quot;);
if ($aPosInfo['id']) {
    $aPosKeys = array(
        '{lat}' =&gt; $aPosInfo['lat'],
        '{lng}' =&gt; $aPosInfo['lng'],
        '{name}' =&gt; str_replace('&quot;', '', $sName)
    );
    $sMap = strtr(file_get_contents('templates/profile_map.html'), $aPosKeys);
}

// get profiles listings
$sProfiles = $GLOBALS['CProfiles']-&gt;getProfilesBlock();
$sOnlineMembers = $GLOBALS['CProfiles']-&gt;getProfilesBlock(10, true);

// draw common page
$aKeys = array(
    '{id}' =&gt; $iPid,
    '{name}' =&gt; $sName,
    '{fname}' =&gt; $sFName,
    '{lname}' =&gt; $sLName,
    '{about}' =&gt; $sAbout,
    '{datereg}' =&gt; $sDate,
    '{profiles}' =&gt; $sProfiles,
    '{online_members}' =&gt; $sOnlineMembers,
    '{map}' =&gt; $sMap
);
echo strtr(file_get_contents('templates/profile_page.html'), $aKeys);
</pre><p>As you can see &#8211; most of the code are already commented. So I hope that this code are pretty understandable. And, in the long run &#8211; our new file which we use to set our coordinates:</p><h4>setpos.php</h4><pre class="brush:php">
&lt;?php

// set error reporting level
if (version_compare(phpversion(), '5.3.0', '&gt;=') == 1)
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED);
else
  error_reporting(E_ALL &amp; ~E_NOTICE);

require_once('classes/CMySQL.php'); // service class to work with database
require_once('classes/CLogin.php'); // service class to work with login processing
require_once('classes/CProfiles.php'); // service class to work with profiles

$iPid = (int)$_SESSION['member_id'];

// save coordinates
if ($_POST &amp;&amp; $_POST['Confirm']) {
    $dLat = (double)$_POST['lat'];
    $dLng = (double)$_POST['lng'];

    if ($iPid &amp;&amp; $dLat &amp;&amp; $dLng) {

        $aInfo = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `latlng268` WHERE `profile` = '{$iPid}'&quot;);
        if ($aInfo['id']) {
            $GLOBALS['MySQL']-&gt;res(&quot;UPDATE `latlng268` SET `lat` = '{$dLat}', `lng` = '{$dLng}' WHERE `profile` = '{$iPid}'&quot;);
        } else {
            $aPInfo = $GLOBALS['CProfiles']-&gt;getProfileInfo($iPid);
            $sName = $GLOBALS['MySQL']-&gt;escape($aPInfo['name']);
            $GLOBALS['MySQL']-&gt;res(&quot;INSERT INTO `latlng268` SET `lat` = '{$dLat}', `lng` = '{$dLng}', `profile` = '{$iPid}', `name` = '{$sName}'&quot;);
        }
        header('Location: profile.php?id=' . $iPid);
    }
}

// find profile coordinates
$aPosInfo = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `latlng268` WHERE `profile` = '{$iPid}'&quot;);
$dLat = 40;
$dLng = -75;
if ($aPosInfo['id']) {
    $dLat = $aPosInfo['lat'];
    $dLng = $aPosInfo['lng'];
}

// draw page
$aKeys = array(
    '{lat}' =&gt; $dLat,
    '{lng}' =&gt; $dLng
);
echo strtr(file_get_contents('templates/setpos_page.html'), $aKeys);
</pre><h3>Step 5. Javascript</h3><p>I added that simple script in order to update (periodically) time of our last navigation (simulation of online status)</p><h4>js/update.js</h4><pre class="brush:js">
$(function() {
    // Update last navigation time feature
    updateLastNav = function() {
        $.getJSON('index.php?action=update_last_nav', function() {

            // refresh last nav time
            setTimeout(function(){
               updateLastNav();
            }, 180000); // 3 mins
        });
    }
    updateLastNav();
});
</pre><hr
/><h5 style="text-align: center;"><strong><a
title="Google Maps API Practical Implementation - demo 268" href="http://www.script-tutorials.com/demos/268/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Google Maps API Practical Implementation - package" href="http://www.script-tutorials.com/demos/268/source.zip" target="_blank" rel="nofollow">download in archive</a></strong></h5><hr
/><h3>Conclusion</h3><p>I hope that our new tutorial was very useful and interesting for you. If you want to share your ideas, or you noticed any weakness &#8211; don&#8217;t hesitate to contact us. Good luck and welcome back!</p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-own-rss-reader-using-google-feed-api/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/82/thumb.png" alt="Creating Your Own RSS Reader Using Google Feed API" /></div><h3>Creating Your Own RSS Reader Using Google Feed API</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-7/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/258/thumb.png" alt="Powerful Chat System &#8211; Lesson 7" /></div><h3>Powerful Chat System &#8211; Lesson 7</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-4/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/233/thumb.png" alt="Powerful Chat System &#8211; Lesson 4" /></div><h3>Powerful Chat System &#8211; Lesson 4</a></h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/google-maps-api-v3-practical-implementation/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Powerful Chat System &#8211; Lesson 8</title><link>http://www.script-tutorials.com/powerful-chat-system-lesson-8/</link> <comments>http://www.script-tutorials.com/powerful-chat-system-lesson-8/#comments</comments> <pubDate>Mon, 07 May 2012 13:33:59 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[blocking system]]></category> <category><![CDATA[chat system]]></category> <category><![CDATA[rate system]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1592</guid> <description><![CDATA[Powerful Chat System &#8211; Lesson 8 Today we continue a series of articles on the creation of powerful chat system. In our eighth lesson I added several features: I gave right to block (and unblock) members for admins and moderators (now, they can perform normal moderation &#8211; they can ban members), and I added rates [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-7/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/258/thumb.png" alt="Powerful Chat System &#8211; Lesson 7" /></div><h3>Powerful Chat System &#8211; Lesson 7</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/250/thumb.png" alt="Powerful Chat System &#8211; Lesson 6" /></div><h3>Powerful Chat System &#8211; Lesson 6</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-5/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/240/thumb.png" alt="Powerful Chat System &#8211; Lesson 5" /></div><h3>Powerful Chat System &#8211; Lesson 5</a></h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Powerful Chat System" alt="Powerful Chat System" src="http://www.script-tutorials.com/demos/267/thumb.png"></div><p><strong>Powerful Chat System &#8211; Lesson 8</strong><br
/> <br
/>Today we continue a series of articles on the creation of powerful chat system. In our eighth lesson I added several features: I gave right to block (and unblock) members for admins and moderators (now, they can perform normal moderation &#8211; they can ban members), and I added rates to our members. Now, every active member can put his vote for another members.<br
/> <span
id="more-1592"></span></p><p>Today I will publish updated sources of our growing project. All project is well structured: system classes is in &#8216;classes&#8217; folder, all javascript files in &#8216;js&#8217; folder, stylesheets in &#8216;css&#8217; folder, all custom avatars in &#8216;data&#8217; folder, images in &#8216;images&#8217; folder, template files in &#8216;templates&#8217; folder.</p><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - demo 267" href="http://www.script-tutorials.com/demos/267/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - package" href="http://www.script-tutorials.com/demos/267/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Now &#8211; download the source files and lets start coding !</p><hr
/><h3>Step 1. SQL</h3><p>I added one new table into database &#8216;cs_profiles_vote_track&#8217;. This table keeps records voting (track). Please execute next SQL:</p><pre class="brush:sql">
CREATE TABLE `cs_profiles_vote_track` (
  `pid` int(11) unsigned NOT NULL default '0',
  `ip` varchar(20) default NULL,
  `date` datetime default NULL,
  KEY `uip` (`ip`,`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
</pre><h3>Step 2. HTML</h3><p>I updated template of our profile page. Now it contains extra button (block feature) and rate block:</p><h4>templates/profile_page.html</h4><pre class="brush:html">
<!DOCTYPE html>
&lt;html lang=&quot;en&quot; &gt;
&lt;head&gt;
    &lt;title&gt;Powerful Chat System - Lesson 8&lt;/title&gt;
    &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;js/customizer.js&quot;&gt;&lt;/script&gt;

    &lt;style&gt;
        .container {
            {custom_styles}
        }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;header&gt;
        &lt;h2&gt;Powerful Chat System - Lesson 8&lt;/h2&gt;
        &lt;a href=&quot;http://www.script-tutorials.com/powerful-chat-system-lesson-8/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
    &lt;/header&gt;
    &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;container&quot;&gt;
        &lt;div class=&quot;column&quot;&gt;
            &lt;h3&gt;Name: {name}&lt;/h3&gt;
            &lt;h3&gt;First name: {fname}&lt;/h3&gt;
            &lt;h3&gt;Last name: {lname}&lt;/h3&gt;
            &lt;h3&gt;About: {about}&lt;/h3&gt;
            &lt;h3&gt;Date Reg: {datereg}&lt;/h3&gt;
            &lt;h3&gt;Role: {role}&lt;/h3&gt;
            &lt;h3&gt;Avatar: &lt;img src=&quot;{avatar}&quot; style=&quot;vertical-align:middle&quot; /&gt;&lt;/h3&gt;
        &lt;/div&gt;
        &lt;div class=&quot;column&quot;&gt;
            &lt;p&gt;&lt;a href=&quot;index.php&quot;&gt;Back to chat&lt;/a&gt;
                {actions}
            &lt;/p&gt;

        &lt;/div&gt;
    &lt;/div&gt;
    {rate}
    &lt;div class=&quot;container&quot; {cust_visible}&gt;
        &lt;h2&gt;You can customize your profile page&lt;/h2&gt;
        &lt;div class=&quot;column&quot;&gt;
            &lt;canvas id=&quot;color_canvas&quot; width=&quot;370&quot; height=&quot;60&quot;&gt;&lt;/canvas&gt;
        &lt;/div&gt;
        &lt;div class=&quot;column&quot;&gt;
            &lt;div class=&quot;customizer_buttons&quot;&gt;
                &lt;div id=&quot;preview&quot;&gt;&lt;/div&gt;
            &lt;/div&gt;

            &lt;form action=&quot;profile.php&quot; method=&quot;GET&quot; target=&quot;change_color_result&quot;&gt;
                &lt;input type=&quot;hidden&quot; value=&quot;{id}&quot; name=&quot;id&quot;&gt;
                &lt;input type=&quot;hidden&quot; value=&quot;color&quot; name=&quot;color&quot; id=&quot;color&quot;&gt;
                &lt;input type=&quot;hidden&quot; value=&quot;change_color&quot; name=&quot;action&quot;&gt;
                &lt;input id=&quot;submit&quot; type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Apply&quot;&gt;
            &lt;/form&gt;
            &lt;iframe class=&quot;avatar_iframe&quot; name=&quot;change_color_result&quot;&gt;&lt;/iframe&gt;
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class=&quot;sidebar&quot;&gt;
        &lt;div&gt;
            &lt;h2&gt;Online Members Block&lt;/h2&gt;
            {online_members}
        &lt;/div&gt;
        &lt;div&gt;
            &lt;h2&gt;Last Members&lt;/h2&gt;
            {profiles}
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class=&quot;priv_dock_wrap&quot;&gt;&lt;/div&gt;
    {priv_js}

&lt;/body&gt;
&lt;/html&gt;
</pre><p>And, we have one new template for rate block:</p><h4>templates/vote.html</h4><pre class="brush:html">
&lt;link href=&quot;css/vote.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;script src=&quot;js/vote.js&quot;&gt;&lt;/script&gt;

&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;container&quot;&gt;
    &lt;div class=&quot;column&quot;&gt;
        &lt;div class=&quot;votes_main&quot;&gt;
            &lt;div class=&quot;votes_gray&quot; style=&quot;width:{width}px;&quot;&gt;
                &lt;div class=&quot;votes_buttons&quot; id=&quot;{pid}&quot; cnt=&quot;{rate_cnt}&quot; val=&quot;{rate_avg}&quot;&gt;
                    {votes}
                &lt;/div&gt;
                &lt;div class=&quot;votes_active&quot; style=&quot;width:{act_width}px;&quot;&gt;&lt;/div&gt;
            &lt;/div&gt;
            &lt;span&gt;&lt;b&gt;{rate_cnt}&lt;/b&gt; votes&lt;/span&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre><h3>Step 3. CSS</h3><p>I added new css file to keep styles of our vote element:</p><h4>css/vote.css</h4><pre class="brush:html">
.votes_main {
    margin: 10px auto;
    overflow: hidden;
    width: 450px;
}
.votes_gray {
    background-image: url(&quot;../images/star_gray.png&quot;);
    float: left;
    height: 64px;
    position: relative;
}
.votes_active {
    background-image: url(&quot;../images/star.png&quot;);
    height: 64px;
    left: 0;
    position: absolute;
    top: 0;
    z-index: 1;
}
.votes_buttons {
    left: 0;
    position: absolute;
    top: 0;
    z-index: 2;
}
.votes_button {
    border: medium none;
    height: 64px;
    margin: 0;
    padding: 0;
    width: 64px;
}
.votes_main span {
    color: #333333;
    display: block;
    float: left;
    font-weight: bold;
    font-size: 18px;
    line-height: 64px;
    margin-left: 10px;
}
</pre><h3>Step 4. PHP</h3><p>Profile page file was updated, I added only few lines at the bottom (into array), it isn&#8217;t necessary to publish whole file, but I will give you updated array:</p><h4>profile.php</h4><pre class="brush:php">
// draw common page
$aKeys = array(
    '{id}' =&gt; $iPid,
    '{name}' =&gt; $sName,
    '{fname}' =&gt; $sFName,
    '{lname}' =&gt; $sLName,
    '{about}' =&gt; $sAbout,
    '{datereg}' =&gt; $sDate,
    '{role}' =&gt; $sRole,
    '{avatar}' =&gt; $sAvatar,
    '{custom_styles}' =&gt; $sCustomBG,
    '{cust_visible}' =&gt; ($_SESSION['member_id'] == $iPid) ? '' : 'style=&quot;display:none&quot;',
    '{profiles}' =&gt; $sProfiles,
    '{online_members}' =&gt; $sOnlineMembers,
    '{priv_js}' =&gt; $sPrivChatJs,
    '{actions}' =&gt; $GLOBALS['CProfiles']-&gt;getBlockMemberAction($iPid),
    '{rate}' =&gt; $GLOBALS['CProfiles']-&gt;getBlockRate($iPid),
);
</pre><p>This is our next updated file. There are three new functions (you can add them at the bottom of our class:</p><h4>classes/CProfiles.php</h4><pre class="brush:php">
// get block member action button
function getBlockMemberAction($iPid) {
    if ($_SESSION['member_id'] != $iPid &amp;&amp; $_SESSION['member_status'] == 'active' &amp;&amp; in_array($_SESSION['member_role'], array(4, 5))) {
        $aMyInfo = $this-&gt;getProfileInfo($_SESSION['member_id']);
        $aInfo = $this-&gt;getProfileInfo($iPid);

        if ($aMyInfo['role'] &gt; $aInfo['role']) {
            $sStatus = $aInfo['status'];
            $sDescDesc = ($sStatus == 'active') ? 'Block this member' : 'Unblock this member';

            return '&lt;font style=&quot;float:right&quot;&gt;&lt;button id=&quot;block&quot; pid=&quot;'.$iPid.'&quot;&gt;'.$sDescDesc.'&lt;/button&gt;&lt;/font&gt;&lt;script src=&quot;js/admin_utils.js&quot;&gt;&lt;/script&gt;';
        }
    }
}

// block member
function blockMember($iPid) {
    if ($iPid) {
        $aInfo = $this-&gt;getProfileInfo($iPid);
        $sStatus = $aInfo['status'];
        $sUpStatus = ($sStatus == 'active') ? 'passive' : 'active';
        $sSQL = &quot;
            UPDATE `cs_profiles` SET
            `status` = '{$sUpStatus}'
            WHERE `id` = '{$iPid}'
        &quot;;
        $GLOBALS['MySQL']-&gt;res($sSQL);
        return ($sStatus == 'active') ? 2 : 1;
    }
    return;
}

// get block member action button
function getBlockRate($iPid) {
    if ($_SESSION['member_id'] != $iPid &amp;&amp; $_SESSION['member_status'] == 'active') {
        // $aMyInfo = $this-&gt;getProfileInfo($_SESSION['member_id']);
        $aInfo = $this-&gt;getProfileInfo($iPid);

        // vote element
        $iIconSize = 64;
        $iMax = 5;
        $iRate = $aInfo['rate'];
        $iRateCnt = $aInfo['rate_count'];
        $fRateAvg = ($iRate &amp;&amp; $iRateCnt) ? $iRate / $iRateCnt : 0;
        $iWidth = $iIconSize*$iMax;
        $iActiveWidth = round($fRateAvg*($iMax ? $iWidth/$iMax : 0));

        $sVot = '';
        for ($i=1 ; $i&lt;=$iMax ; $i++) {
            $sVot .= '&lt;a href=&quot;#&quot; id=&quot;'.$i.'&quot;&gt;&lt;img class=&quot;votes_button&quot; src=&quot;images/empty.gif&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;';
        }

        $aKeys = array(
            '{pid}' =&gt; $iPid,
            '{width}' =&gt; $iWidth,
            '{rate_cnt}' =&gt; $iRateCnt,
            '{rate_avg}' =&gt; $fRateAvg,
            '{votes}' =&gt; $sVot,
            '{act_width}' =&gt; $iActiveWidth,
        );
        return strtr(file_get_contents('templates/vote.html'), $aKeys);
    }
}
</pre><p>First one function getBlockMemberAction returns one little button for profile page. Clicking at this page will force block / unblock members. This function available only for moderators and admins. And, moderator can&#8217;t block admin, only admin can block moderator. Second one function blockMember updates profile status (block). And, last one &#8211; getBlockRate returns block with rate object (stars), where we can vote for members.</p><p>In order to perform different actions, I added one new PHP file:</p><h4>actions.php</h4><pre class="brush:php">
&lt;?php

// set error reporting level
if (version_compare(phpversion(), '5.3.0', '&gt;=') == 1)
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED);
else
  error_reporting(E_ALL &amp; ~E_NOTICE);

require_once('classes/CMySQL.php');
require_once('classes/CLogin.php');
require_once('classes/CProfiles.php');

// for logged-in members only
if ($_SESSION['member_id'] &amp;&amp; $_SESSION['member_status'] == 'active') {
    if (in_array($_SESSION['member_role'], array(4, 5))) { // for moderators and admins only
        if ($_POST['action'] == 'block') { // Block action
            $iRes = $GLOBALS['CProfiles']-&gt;blockMember((int)$_POST['pid']);
            header('Content-Type: text/html; charset=utf-8');
            echo $iRes;
            exit;
        }
    }

    if ($_POST['action'] == 'put_vote') { // Put vote action
        $iPid = (int)$_POST['id'];
        $iVote = (int)$_POST['vote'];
        $sIp = getVisitorIP();

        // we can vote once per week (protection)
        $iOldId = $GLOBALS['MySQL']-&gt;getOne(&quot;SELECT `pid` FROM `cs_profiles_vote_track` WHERE `pid` = '{$iPid}' AND `ip` = '{$sIp}' AND (`date` &gt;= NOW() - INTERVAL 7 DAY) LIMIT 1&quot;);
        if (! $iOldId) {
            $GLOBALS['MySQL']-&gt;res(&quot;INSERT INTO `cs_profiles_vote_track` SET `pid` = '{$iPid}', `ip` = '{$sIp}', `date` = NOW()&quot;);
            $GLOBALS['MySQL']-&gt;res(&quot;UPDATE `cs_profiles` SET `rate` = `rate` + {$iVote}, `rate_count` = `rate_count` + 1 WHERE `id` = '{$iPid}'&quot;);
            header('Content-Type: text/html; charset=utf-8');
            echo 1;
            exit;
        }
    }
}

function getVisitorIP() {
    $ip = &quot;0.0.0.0&quot;;
    if( ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) &amp;&amp; ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } elseif( ( isset( $_SERVER['HTTP_CLIENT_IP'])) &amp;&amp; (!empty($_SERVER['HTTP_CLIENT_IP'] ) ) ) {
        $ip = explode(&quot;.&quot;,$_SERVER['HTTP_CLIENT_IP']);
        $ip = $ip[3].&quot;.&quot;.$ip[2].&quot;.&quot;.$ip[1].&quot;.&quot;.$ip[0];
    } elseif((!isset( $_SERVER['HTTP_X_FORWARDED_FOR'])) || (empty($_SERVER['HTTP_X_FORWARDED_FOR']))) {
        if ((!isset( $_SERVER['HTTP_CLIENT_IP'])) &amp;&amp; (empty($_SERVER['HTTP_CLIENT_IP']))) {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
    }
    return $ip;
}
</pre><p>Since today, I will use this file to perform different hidden actions. Now, I use this file to perform member blocking and to accept votes for members.</p><h3>Step 5. Javascript</h3><p>I added new JS file which will perform different admin&#8217;s service methods. First of them is blocking of members</p><h4>js/admin_utils.js</h4><pre class="brush:js">
$(function() {

    // block member
    $('#block').click(function(event) {
        var oBtn = $(this);
        $.post('actions.php', { pid: oBtn.attr('pid'), action: 'block' },
            function(data){
                if (data != undefined) {
                    oBtn[0].innerHTML = (data == 2) ? 'Unblock this member' : 'Block this member';
                }
            }
        );
    });
});
</pre><p>Another one JS file to work with rate object</p><h4>js/vote.js</h4><pre class="brush:js">
$(function(){
    var width = 0;

    $('.votes_buttons a').hover(
        function () {
            width = $(this).attr('id') * 64;
            $('.votes_active').width(width + 'px');
        },
        function () {
            width = $(this).parent().attr('val') * 64;
            $('.votes_active').width(width + 'px');
        }
    );

    $('.votes_buttons a').click(function () {
        var idVal = $(this).parent().attr('id');
        var iCnt = $(this).parent().attr('cnt');
        var voteVal = $(this).attr('id');
        var iSelWidth = voteVal * 64;

        $.post('actions.php', { id: idVal, vote: voteVal, action: 'put_vote' },
            function(data){
                if (data == 1) {
                    width = iSelWidth;
                    $('.votes_active').width(iSelWidth + 'px');
                    iCnt = parseInt(iCnt) + 1;
                    $('.votes_main span b').text(iCnt);
                    $('.votes_buttons').attr('val', voteVal);
                }
            }
        );
    });
});
</pre><hr
/><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - demo 267" href="http://www.script-tutorials.com/demos/267/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - package" href="http://www.script-tutorials.com/demos/267/source.zip" target="_blank" rel="nofollow">download in archive</a></strong></h5><hr
/><h3>Conclusion</h3><p>I hope that our new series of articles of chat system creation is very useful and interesting for you. If you want to share your ideas, or you noticed any weakness &#8211; don&#8217;t hesitate to contact us. Good luck and welcome back!</p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-7/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/258/thumb.png" alt="Powerful Chat System &#8211; Lesson 7" /></div><h3>Powerful Chat System &#8211; Lesson 7</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/250/thumb.png" alt="Powerful Chat System &#8211; Lesson 6" /></div><h3>Powerful Chat System &#8211; Lesson 6</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-5/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/240/thumb.png" alt="Powerful Chat System &#8211; Lesson 5" /></div><h3>Powerful Chat System &#8211; Lesson 5</a></h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/powerful-chat-system-lesson-8/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Office Style CSS3 Multilevel Menu</title><link>http://www.script-tutorials.com/office-style-css3-multilevel-menu/</link> <comments>http://www.script-tutorials.com/office-style-css3-multilevel-menu/#comments</comments> <pubDate>Fri, 04 May 2012 04:39:13 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[click action]]></category> <category><![CDATA[css3 menu]]></category> <category><![CDATA[dropdown]]></category> <category><![CDATA[office style]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1589</guid> <description><![CDATA[Office Style CSS3 Multilevel Menu In our new tutorial I will give you another one brilliant crossbrowser css3 navigation menu. This is click action drop down menu with strict office styles (like MS Office styles). Also, you can also use different icons in this menu. This solution is ideal for business websites. If you are [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-green-marble-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/179/thumb.png" alt="Creating a Marble Style CSS3 Navigation Menu" /></div><h3>Creating a Marble Style CSS3 Navigation Menu</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-multilevel-menu-with-transition-and-animation/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/211/thumb.png" alt="CSS3 multilevel menu with transition and animation" /></div><h3>CSS3 multilevel menu with transition and animation</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-multilevel-menu-using-xslt/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/53/thumb.png" alt="Creating a Multilevel Menu using XSLT" /></div><h3>Creating a Multilevel Menu using XSLT</a></h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Office Style CSS3 Multilevel Menu" alt="Office Style CSS3 Multilevel Menu" src="http://www.script-tutorials.com/demos/266/thumb.png" /></div><p><strong>Office Style CSS3 Multilevel Menu</strong></p><p>In our new tutorial I will give you another one brilliant crossbrowser css3 navigation menu. This is click action drop down menu with strict office styles (like MS Office styles). Also, you can also use different icons in this menu. This solution is ideal for business websites. If you are ready, lets start.</p><p><span
id="more-1589"></span></p><hr
/><div
style="clear:both;"></div><p>This is our final result:</p><p><img
title="Office Style CSS3 Multilevel Menu" alt="Office Style CSS3 Multilevel Menu" src="http://www.script-tutorials.com/demos/266/result.png" /></p><p>Here are samples and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Office Style CSS3 Multilevel Menu - demo 266" href="http://www.script-tutorials.com/demos/266/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Office Style CSS3 Multilevel Menu - package" href="http://www.script-tutorials.com/demos/266/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, download the sources and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>Please point your attention to prepared HTML layout of our multilevel menu. This is usual UL-LI based multilevel navigation menu. Of course, the most interesting thing is CSS styles.</p><h4>index.html</h4><pre class="brush:html">
&lt;div id=&quot;nav&quot;&gt;
    &lt;ul&gt;
        &lt;li&gt;&lt;span tabindex=&quot;1&quot;&gt;File&lt;/span&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon1.gif&quot; alt=&quot;&quot; /&gt;New&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon2.gif&quot; alt=&quot;&quot; /&gt;Open&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon3.gif&quot; alt=&quot;&quot; /&gt;Close&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;span tabindex=&quot;1&quot;&gt;&lt;img src=&quot;images/icon4.gif&quot; alt=&quot;&quot; /&gt;Save&lt;/span&gt;
                    &lt;ul&gt;
                        &lt;li&gt;&lt;span tabindex=&quot;1&quot;&gt;&lt;img src=&quot;images/icon4.gif&quot; alt=&quot;&quot; /&gt;Option 1&lt;/span&gt;
                            &lt;ul&gt;
                                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon1.gif&quot; alt=&quot;&quot; /&gt;Option A&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon2.gif&quot; alt=&quot;&quot; /&gt;Option B&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon3.gif&quot; alt=&quot;&quot; /&gt;Option C&lt;/a&gt;&lt;/li&gt;
                            &lt;/ul&gt;
                        &lt;/li&gt;
                        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon2.gif&quot; alt=&quot;&quot; /&gt;Option 2&lt;/a&gt;&lt;/li&gt;
                        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon3.gif&quot; alt=&quot;&quot; /&gt;Option 3&lt;/a&gt;&lt;/li&gt;
                    &lt;/ul&gt;
                &lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon5.gif&quot; alt=&quot;&quot; /&gt;Save As&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon1.gif&quot; alt=&quot;&quot; /&gt;Print&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon2.gif&quot; alt=&quot;&quot; /&gt;Exit&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;span tabindex=&quot;1&quot;&gt;Edit&lt;/span&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon1.gif&quot; alt=&quot;&quot; /&gt;Cut&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon2.gif&quot; alt=&quot;&quot; /&gt;Copy&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon3.gif&quot; alt=&quot;&quot; /&gt;Paste&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;span tabindex=&quot;1&quot;&gt;View&lt;/span&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon1.gif&quot; alt=&quot;&quot; /&gt;Normal&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon2.gif&quot; alt=&quot;&quot; /&gt;Web Layout&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;images/icon3.gif&quot; alt=&quot;&quot; /&gt;Print Layout&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Insert&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Format&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Tools&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Table&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Window&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;http://www.script-tutorials.com/&quot;&gt;Help&lt;/a&gt;&lt;/li&gt;
        &lt;img class=&quot;close&quot; src=&quot;images/spacer.gif&quot; alt=&quot;&quot; /&gt;
    &lt;/ul&gt;
&lt;/div&gt;
</pre><h3>Step 2. CSS</h3><p>Here are the CSS styles of our click action dropdown menu.</p><h4>css/menu.css</h4><pre class="brush:css">
#nav {
    position:relative;
    z-index:2;
}
#nav ul {
    background-color:#B8D1F8;
    border:1px solid #000C80;
    height:24px;
    list-style:none outside none;
    margin:0;
    padding:1px;
}
#nav ul ul {
    background-color:#FFFFFF;
    border:1px solid #8A867A;
    display:none;
    height:auto;
    left:0;
    padding:0;
    position:absolute;
    top:25px;
    width:168px;

    background-image:-webkit-gradient(left center , #F8FAFF 0%, #B8D1F8 15%, #FFFFFF 15%, #FFFFFF 100%);
    background-image:-moz-linear-gradient(left center , #F8FAFF 0%, #B8D1F8 15%, #FFFFFF 15%, #FFFFFF 100%);
}
#nav ul ul ul {
    display:none;
    left:168px;
    position:absolute;
    top:-1px;
    width:168px;
}
#nav ul li {
    float:left;
    margin-right:1px;
    position:relative;
}
#nav ul li a {
    border:1px solid #B8D1F8;
    color:#000;
    cursor:default;
    display:block;
    font:11px Tahoma,Arial;
    padding:3px 3px 4px;
    text-decoration:none;
}
#nav ul li span {
    background:url(&quot;../images/u.gif&quot;) no-repeat scroll 90% center transparent;
    border:1px solid #B8D1F8;
    color:#000;
    cursor:default;
    display:block;
    font:11px Tahoma,Arial;
    padding:3px 14px 4px 3px;
    position:relative;
}
#nav ul ul li span {
    background:url(&quot;../images/s.gif&quot;) no-repeat scroll 97% center transparent;
}
#nav ul ul li {
    float:none;
    margin-right:0;
    padding:1px;
    text-indent:10px;
}
#nav ul ul li a,#nav ul ul li span {
    border:1px solid transparent;
    padding:3px 3px 5px 2px;
}
#nav ul ul li a img,#nav ul ul li span img {
    border-width:0;
    float:left;
    margin-right:5px;
    vertical-align:middle;
}
#nav ul li:hover &gt; a,#nav ul li:hover &gt; span {
    background-color:#FFF2C8;
    border:1px solid #000C80;
    color:#000;
}
#nav img.close {
    display:none;
    height:100%;
    left:0;
    position:fixed;
    top:0;
    width:100%;
    z-index:-1;
}
#nav ul li span:focus + ul,#nav ul li ul:hover,#nav ul:hover + img.close {
    display:block;
}
</pre><p>Less than 100 lines of code, it&#8217;s great, isn&#8217;t it?</p><hr
/><h5 style="text-align: center;"><strong><a
title="Office Style CSS3 Multilevel Menu - demo 266" href="http://www.script-tutorials.com/demos/266/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Office Style CSS3 Multilevel Menu - package" href="http://www.script-tutorials.com/demos/266/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>Hope you enjoyed with our new CSS3 menu, don&#8217;t forget to tell thanks and leave a comment <img
src='http://www.script-tutorials.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Good luck!</p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-green-marble-menu/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/179/thumb.png" alt="Creating a Marble Style CSS3 Navigation Menu" /></div><h3>Creating a Marble Style CSS3 Navigation Menu</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/css3-multilevel-menu-with-transition-and-animation/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/211/thumb.png" alt="CSS3 multilevel menu with transition and animation" /></div><h3>CSS3 multilevel menu with transition and animation</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-multilevel-menu-using-xslt/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/53/thumb.png" alt="Creating a Multilevel Menu using XSLT" /></div><h3>Creating a Multilevel Menu using XSLT</a></h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/office-style-css3-multilevel-menu/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>HTML5 Canvas Twirl Sphere</title><link>http://www.script-tutorials.com/html5-canvas-twirl-sphere/</link> <comments>http://www.script-tutorials.com/html5-canvas-twirl-sphere/#comments</comments> <pubDate>Wed, 02 May 2012 12:38:41 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML5]]></category> <category><![CDATA[canvas]]></category> <category><![CDATA[html5]]></category> <category><![CDATA[Twirl Sphere]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1586</guid> <description><![CDATA[HTML5 Canvas Twirl Sphere Today, I would like to tell about creation of animated Twirl Sphere (I modified our previous 3D sphere, and, I used same way of accessing pixels of canvas). Our sphere goes around the canvas continuously. This example is cross browser solution (because of html5). In the result, you should to get [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-canvas-3d-sphere/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/261/thumb.png" alt="HTML5 Canvas 3D Sphere" /></div><h3>HTML5 Canvas 3D Sphere</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-an-html5-canvas-image-color-picker/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/158/thumb.png" alt="Creating an HTML5 Canvas Image Color Picker" /></div><h3>Creating an HTML5 Canvas Image Color Picker</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-canvas-creating-your-own-paint-program/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/173/thumb.png" alt="HTML5 canvas &#8211; Creating Your Own Paint Program" /></div><h3>HTML5 canvas &#8211; Creating Your Own Paint Program</a></h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="HTML5 Canvas Twirl Sphere" alt="HTML5 Canvas Twirl Sphere" src="http://www.script-tutorials.com/demos/265/thumb.png"></div><p><strong>HTML5 Canvas Twirl Sphere</strong><br
/> <br
/>Today, I would like to tell about creation of animated Twirl Sphere (I modified our previous 3D sphere, and, I used same way of accessing pixels of canvas). Our sphere goes around the canvas continuously. This example is cross browser solution (because of html5).<br
/> <span
id="more-1586"></span></p><div
style="clear:both;"></div><p></p><p>In the result, you should to get something like this:</p><p><img
src="http://www.script-tutorials.com/demos/265/result.jpg" alt="HTML5 Canvas Twirl Sphere" /></p><p>Here are our demo and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="HTML5 Canvas Twirl Sphere - demo 265" href="http://www.script-tutorials.com/demos/265/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="HTML5 Canvas Twirl Sphere - package" href="http://www.script-tutorials.com/demos/265/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, please download our source files and let&#8217;s start coding !</p><hr
/><h3>Step 1. HTML</h3><p>This is markup of our result page. Here it is:</p><h4>index.html</h4><pre class="brush:html">
&lt;div class=&quot;container&quot;&gt;
    &lt;canvas id=&quot;slideshow&quot; width=&quot;1024&quot; height=&quot;630&quot;&gt;&lt;/canvas&gt;
    &lt;canvas id=&quot;obj&quot; width=&quot;256&quot; height=&quot;256&quot;&gt;&lt;/canvas&gt;
&lt;/div&gt;
</pre><p>I prepared two canvas objects: first one for resource image, and second one &#8211; for our Twirl sphere.</p><h3>Step 2. CSS</h3><h4>css/main.css</h4><pre class="brush:css">
.container {
    height: 630px;
    margin: 50px auto;
    position: relative;
    width: 1024px;
    z-index: 1;
}
#obj {
    position: absolute;
    z-index: 2;
}
</pre><p>We should keep our Sphere object above our main canvas.</p><h3>Step 3. JS</h3><p>And now, our main js script file. Here it is:</p><h4>js/script.js</h4><pre class="brush:js">
var canvas, ctx;
var canvasObj, ctxObj;
var iDstW = 256;
var iDstH = 256;
var iXSpeed = 4;
var iYSpeed = 3;
var iLastX = iDstW / 2;
var iLastY = iDstH / 2;
var oImage;
var aMap = [];
var aMapT = [];
var aBitmap;

var mathTwirl = function(px,py) {
    var x = px - iDstW / 2;
    var y = py - iDstH / 2;
    var r = Math.sqrt(x * x + y * y);
    var maxR = iDstW / 2;
    if (r &gt; maxR) return {'x':px, 'y':py, 't': 1};

    var a = Math.atan2(y, x);
    a -= 1 - r / maxR;

    var dx = Math.cos(a) * r;
    var dy = Math.sin(a) * r;

    return {'x': dx+iDstW/2, 'y': dy+iDstH/2, 't': 1.5}
}

window.onload = function(){

    // load background
    oImage = new Image();
    oImage.src = 'images/bg.jpg';
    oImage.onload = function () {

        // creating canvas and context objects
        canvas = document.getElementById('slideshow');
        ctx = canvas.getContext('2d');
        canvasObj = document.getElementById('obj');
        ctxObj = canvasObj.getContext('2d');

        // clear context
        ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);

        // and draw source image
        ctx.drawImage(oImage, 0, 0);

        aBitmap = ctx.getImageData(0, 0, iDstW, iDstH);
        for (var y = 0; y &lt; iDstH; y++) {
            for (var x = 0; x &lt; iDstW; x++) {
                var t = mathTwirl(x, y);
                aMap[(x + y * iDstH) * 2 + 0] = Math.max(Math.min(t.x, iDstW - 1), 0);
                aMap[(x + y * iDstH) * 2 + 1] = Math.max(Math.min(t.y, iDstH - 1), 0);
                aMapT[(x + y * iDstH)] = t.t;
            }
        }

        // begin updating scene
        updateScene();
    };

    function updateScene() {

        // update last coordinates
        iLastX = iLastX + iXSpeed;
        iLastY = iLastY + iYSpeed;

        // reverse speed
        if (iLastX + 1 &gt; ctx.canvas.width - iDstW/2) {
            iXSpeed = -4;
        }
        if (iLastX - 1 &lt; iDstW/2) {
            iXSpeed = 4;
        }
        if (iLastY + 1 &gt; ctx.canvas.height - iDstH/2) {
            iYSpeed = -3;
        }
        if (iLastY - 1 &lt; iDstH/2) {
            iYSpeed = 3;
        }

        // shifting of the second object
        canvasObj.style.left = iLastX - Math.floor(iDstW / 2) + 'px';
        canvasObj.style.top = iLastY - (Math.floor(iDstH / 2)) + 'px';

        // draw result Twirl sphere
        var aData = ctx.getImageData(iLastX - Math.ceil(iDstW / 2), iLastY - Math.ceil(iDstH / 2), iDstW, iDstH + 1);
        for (var j = 0; j &lt; iDstH; j++) {
            for (var i = 0; i &lt; iDstW; i++) {
                var u = aMap[(i + j * iDstH) * 2];
                var v = aMap[(i + j * iDstH) * 2 + 1];
                var t = aMapT[(i + j * iDstH)];
                var x = Math.floor(u);
                var y = Math.floor(v);
                var kx = u - x;
                var ky = v - y;
                for (var c = 0; c &lt; 3; c++) {
                    aBitmap.data[(i + j * iDstH) * 4 + c] =
                      (aData.data[(x + y * iDstH) * 4 + c] * (1 - kx) + aData.data[((x + 1) + y * iDstH) * 4 + c] * kx) * (1-ky) * t +
                      (aData.data[(x + (y + 1) * iDstH) * 4 + c] * (1 - kx) + aData.data[((x + 1) + (y + 1) * iDstH) * 4 + c] * kx) * (ky) * t;
                }
            }
        }
        ctxObj.putImageData(aBitmap,0,0);

        // update timer
        setTimeout(updateScene, 16);
    }
};
</pre><p>During initialization, the script is preparing two canvas objects and two contexts. After, it loads background image, and draw it at our first context. After it prepares hash table of sphere transformations: aMap (with using of new mathTwirl function). And, in the end &#8211; it starts timer which updates the main scene. This function (updateScene) updates coordinates of our Sphere object, and draws updated sphere at our second context.</p><hr
/><h5 style="text-align: center;"><strong><a
title="HTML5 Canvas Twirl Sphere - demo 265" href="http://www.script-tutorials.com/demos/265/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="HTML5 Canvas Twirl Sphere - package" href="http://www.script-tutorials.com/demos/265/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>I hope that today&#8217;s Twirl HTML5 Sphere lesson has been interesting for you. We have done another one nice html5 example. I will be glad to see your thanks and comments. Good luck!</p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-canvas-3d-sphere/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/261/thumb.png" alt="HTML5 Canvas 3D Sphere" /></div><h3>HTML5 Canvas 3D Sphere</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/creating-an-html5-canvas-image-color-picker/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/158/thumb.png" alt="Creating an HTML5 Canvas Image Color Picker" /></div><h3>Creating an HTML5 Canvas Image Color Picker</a></h3></div><div
class="post"><div> <a
href="http://www.script-tutorials.com/html5-canvas-creating-your-own-paint-program/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/173/thumb.png" alt="HTML5 canvas &#8211; Creating Your Own Paint Program" /></div><h3>HTML5 canvas &#8211; Creating Your Own Paint Program</a></h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/html5-canvas-twirl-sphere/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>10 Creative Website Designs</title><link>http://www.script-tutorials.com/10-creative-website-designs/</link> <comments>http://www.script-tutorials.com/10-creative-website-designs/#comments</comments> <pubDate>Tue, 01 May 2012 14:20:34 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[resources]]></category> <category><![CDATA[creative layouts]]></category> <category><![CDATA[Web Design]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1583</guid> <description><![CDATA[10 Creative Website Designs Sorry for that 10 days period without fresh articles. I have been abroad for all this time. Had to solve some things. But, since today, we continue our tutorials. Today I would like to introduce you with new collection of websites with impressive design. I think that it should give you [...]<div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><h3>No related posts.</h3></div></div></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="10 Creative Contact Form Designs" src="http://www.script-tutorials.com/demos/264/thumb.png"></div><p><strong>10 Creative Website Designs</strong><br
/> <br
/>Sorry for that 10 days period without fresh articles. I have been abroad for all this time. Had to solve some things. But, since today, we continue our tutorials. Today I would like to introduce you with new collection of websites with impressive design. I think that it should give you some new ideas for you and your projects.<br
/> <span
id="more-1583"></span></p><hr
/><h3><a
rel="nofollow" target="_blank" href="http://2012.beercamp.com/">1. Beercamp 2012</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img1.jpg" alt="Beercamp 2012" /></p><h3><a
rel="nofollow" target="_blank" href="http://naturevalleytrailview.com/">2. Nature Valley Trail View</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img2.jpg" alt="Nature Valley Trail View" /></p><h3><a
rel="nofollow" target="_blank" href="http://glamour.biz/?lang=en">3. Glamour.biz &#8211; design and branding</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img3.jpg" alt="Glamour.biz - design and branding" /></p><h3><a
rel="nofollow" target="_blank" href="http://www.nossa.pt/trabalho/">4. Home &#8211; NOSSA</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img4.jpg" alt="Home - NOSSA" /></p><h3><a
rel="nofollow" target="_blank" href="http://www.torpedo-lefilm.com/">5. Torpedo &#8211; Un film de Matthieu Donck</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img5.jpg" alt="Torpedo - Un film de Matthieu Donck" /></p><h3><a
rel="nofollow" target="_blank" href="http://luxahoy.com/">6. Lux Ahoy &#8211; HTML5 Game</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img6.jpg" alt="Lux Ahoy - HTML5 Game" /></p><h3><a
rel="nofollow" target="_blank" href="http://www.putzengel.at/">7. Putzengel &#8211; Reinigung Wien, Transport, Handwerker</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img7.jpg" alt="Putzengel" /></p><h3><a
rel="nofollow" target="_blank" href="http://www.myownbike.de/">8. myownbike</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img8.jpg" alt="myownbike" /></p><h3><a
rel="nofollow" target="_blank" href="http://cheesepleasegame.com/">9. Cheese Please</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img9.jpg" alt="Cheese Please" /></p><h3><a
rel="nofollow" target="_blank" href="http://www.ghosthorses.co.uk/">10. Ghost Horses</a></h3><p><img
src="http://www.script-tutorials.com/demos/264/img10.jpg" alt="Ghost Horses" /></p><hr
/><h3>Conclusion</h3><p>Hope that our new collection of new contact form designs has been interesting to you. Good luck!</p><div
id="main-related"><h3>Related Articles</h3><div
class="related_articles"><div
class="post"><h3>No related posts.</h3></div></div></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/10-creative-website-designs/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic (User agent is rejected)
Database Caching using disk: basic

Served from: www.script-tutorials.com @ 2012-05-17 10:27:57 -->
