Friday, October 15, 2010

html img with span brand or patent logo simple

<html>
<style>
img, span, div, a { padding:0px; margin:0px; }
</style>
<body style="margin:10px;">

<div style="height:100px;background:red;">a</div>

<div style="clear:both;background-color:#FFFF00;">

<a style="display:inline-block;height:100px;width:120px; padding:2px;background-color:white;">

<span style="display:block;height:100px;width:120px;background-color:blue;"><img style="height:100px;width:120px;position:absolute; " src="images/default.jpg">
<span style="height:100px;width:120px;position:absolute; color:red;text-align:right;margin-top:80px;">boroo</span>
</span>

</a>

</div>

<div style="height:100px;background:green;">b</div>

</body>
</html>

Monday, October 11, 2010

Javascript hex decimal rgb simple converter

<html>
<style>
body,ul,li{padding:0px;margin:0px;}
div {display:block;}
ul {list-style: none;background-color:red;height:60px;line-height:50px;}
li {float:left;background-color:green;height:50px;line-height:40px;}
a {font-family:arial,sans-serif;color:red;
background-color:yellow;padding:10px;height:20px;line-height:20px;}
</style>
<body>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var c = $("a").css("color");
var s = JCOLOR2HTML(c);
alert(HTML2RGB(s,"red"));
});

//0070FF=rgb(0, 70, 255);
function JCOLOR2HTML(color)
{
    var rgbString = color.toString();
    var parts = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
    // parts now should be ["rgb(0, 70, 255", "0", "70", "255"]
    delete (parts[0]);
    for (var i = 1; i <= 3; ++i) {
    parts[i] = parseInt(parts[i]).toString(16);
    if (parts[i].length == 1) parts[i] = '0' + parts[i];
    }
    var hexString = parts.join('');
    return hexString;
}
//FFFFFF=RGB2HTML(255, 255, 255);
function RGB2HTML(red, green, blue)
{
    var decColor = red + 256 * green + 65536 * blue;
    return decColor.toString(16);
}
//FF=RGB2HEX(255);
function RGB2HEX(rgb) {
var char = "0123456789ABCDEF";
return String(char.charAt(Math.floor(rgb / 16))) + String(char.charAt(rgb - (Math.floor(rgb / 16) * 16)));
}
//255=HEX2RGB("FF0000", "red");
function HEX2RGB(hex, name)
{
    hex = hex.replace('#', '');   
    if(name == null) name="red";
    if(name == 0) name='red';
    if(name == 1) name='green';
    if(name == 2) name='blue';   
    var s = (""+name).toLowerCase();
    if( s == 'red' ) return HTML2DEC(hex.substr(0,2));
    if( s == 'green' ) return HTML2DEC(hex.substr(2,2));
    if( s == 'blue' ) return HTML2DEC(hex.substr(4,2));
    else return HTML2DEC(hex);
}
//FFFFFF=DEC2HTML(16777215);
function DEC2HEX(d) {return d.toString(16);}
//255=HTML2DEC("FF");
function DEC2HEX(h) {return parseInt(h,16);}

</script>
<div><ul><li><a href="#">Product Search.</a></li></ul></div>
</body>
</html>

JQuery html css tabcontrol example

css file

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
    margin:0;
    padding:0;
}
table {
    border-collapse:collapse;
    border-spacing:0;
}
fieldset,img {
    border:0;
}
address,caption,cite,code,dfn,em,strong,th,var {
    font-style:normal;
    font-weight:normal;
}
ol,ul {
    list-style:none;
}
caption,th {
    text-align:left;
}
h1,h2,h3,h4,h5,h6 {
    font-size:100%;
    font-weight:normal;
}
q:before,q:after {
    content:'';
}
abbr,acronym { border:0;
}
html, body {
    background-color: #fff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 18px;
    color: #52697E;
}
body {
    text-align: center;
    overflow: auto;
}
h1 {
    font-size: 21px;
    height: 47px;
    line-height: 47px;
    text-transform: uppercase;
}
.TabControl {
    width: 700px;
    margin: 0 auto;
    text-align: left;
}
.TabNavigationControl {
    height: 23px;
    line-height: 23px;
    border-bottom: 1px solid #ccc;
}
.TabNavigationControl li {
    float: left;
    height: 23px;
    line-height: 23px;
    padding-right: 3px;
}
.TabNavigationControl li a{
    float: left;
    dispaly: block;
    height: 23px;
    line-height: 23px;
    padding: 0 10px;
    overflow: hidden;
    color: #52697E;
    background-color: #eee;
    position: relative;
    text-decoration: none;
}
.TabNavigationControl li a:hover {
    background-color: #f0f0f0;
}
.TabNavigationControl li a.active {
    background-color: #fff;
    border: 1px solid #ccc;
    border-bottom: 0px solid;
}
.TabContentControl {
    border: 1px solid #ccc;
    border-top: 0px solid;
    width: 698px;
    overflow: hidden;
}
.TabPageControl {
    padding: 16px;
    display: none;
}
.TabPageControl h2 {
    font-weight: bold;
    font-size: 16px;
}


 html file

<html>
<head>
<link rel="stylesheet" type="text/css" href="layout.css" />
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
</head>
<body>
    <h1>TabControl - boroo plugin</h1>
    <div class="TabControl1">   
        <ul class="TabNavigationControl">
            <li><a href="#about" rel="about">About</a></li>
            <li><a href="#download" rel="download">Download</a></li>
            <li><a href="#implement" rel="implement">Implement</a></li>
        </ul>
        <div class="TabContentControl">
            <div class="TabPageControl">
                <h2>About</h2>
            </div>
            <div class="TabPageControl">
                <h2>Download</h2>
            </div>
            <div class="TabPageControl">
                <h2>Implement</h2>
            </div>
        </div>
    </div>

    <div class="TabControl2">   
        <ul class="TabNavigationControl">
            <li><a href="#about1" rel="about">About</a></li>
            <li><a href="#download" rel="download">Download</a></li>
            <li><a href="#implement" rel="implement">Implement</a></li>
        </ul>
        <div class="TabContentControl">
            <div class="TabPageControl">
                <h2>About #</h2>
            </div>
            <div class="TabPageControl">
                <h2>Download</h2>
            </div>
            <div class="TabPageControl">
                <h2>Implement</h2>
            </div>
        </div>
    </div>

<script type="text/javascript">
//jQuery.fn._init = jQuery.fn.init;
//jQuery.fn.init = function( selector, context ) {
//    if(typeof selector === 'string') {
//        return jQuery.fn._init(selector, context).data('selector', selector);
//    }
//    return jQuery.fn._init( selector, context );
//};
//jQuery.fn.getSelector = function() {
//        return jQuery(this).data('selector');
//};
(function($){
    $.fn.tabControls = new Array();
    $.fn.initTab = function(ts, cs) {
        var selStr = $(this).selector;
        $.fn.tabControls[selStr] = {tabs:ts, contents:cs};       
        ts.each(function(i){ $(this).data("___tabs___", $.fn.tabControls[selStr]); $(this).bind('click',_changeTab); });
        _changeHash();
    };
    $.fn.showTab = function(i){       
        var selStr = $(this).selector;       
        window.location.hash = "#" + $.fn.tabControls[selStr].tabs.eq(i).attr("rel");
        $.fn.tabControls[selStr].tabs.removeClass('active');
        $.fn.tabControls[selStr].tabs.eq(i).addClass('active').blur();
        $.fn.tabControls[selStr].contents.hide().eq(i).show();
    };
    var _changeHash = function() {
        var hash = window.location.hash.replace('#', '');
        var currentTab = $('a[rel='+hash+']');
        if (currentTab.size() > 0) {
            currentTab.click();
        }
    };
    var _changeTab = function() {
        var hash = window.location.hash.replace('#', '');
        var t = $(this).data("___tabs___");
        var currentTab = $(this);//t.tabs.filter('[rel=' + hash + ']');
        if (currentTab.size() > 0) {
            t.tabs.removeClass('active');   
            var tabIndex = t.tabs.index(currentTab);       
            $(this).addClass('active').blur();
            t.contents.hide().eq(tabIndex).show();           
        }
    };   
})(jQuery);

$(document).ready(function(){
$(".TabControl1").initTab($(".TabControl1").find(".TabNavigationControl li a")
    , $(".TabControl1").find(".TabContentControl .TabPageControl"));
//$(".TabControl1").showTab(0);
$(".TabControl2").initTab($(".TabControl2").find(".TabNavigationControl li a")
    , $(".TabControl2").find(".TabContentControl .TabPageControl"));
//$(".TabControl2").showTab(1);
});
</script>

</body>
</html>

Friday, October 8, 2010

Activity, sequence, usercase, class diagram

Хараад ойлгохоор зарим нэг зургууд

мөнгөний атм машины үйлдлийг их хялбар харуулсан байна. Ихэвчлэн хэрэглэгддэг
Activity Diagram

Борлуулалтын жишээ диаграм. Activity Diagram

UML Diagram ийн бүрдэл хэсгүүд
эдгээр тэмдэглэгээнүүдийг хэрхэн зурах нь чухал биш зурсан тэмдэглэгээ нь үүргээ гүйцэтгэж ойлгогдох нь чухал

Collaboration Diagram

 Package Diagram
 Sequence Diagram
 Department
 Deployment Diagram
 Multiple User Case
 Class Diagram
 Object Diagram
 User Case Diagram

Javascript using simple IsNumeric method

it's simple work fine

firefox дээр e.preventDefault internet explorer дээр e.returnValue event -ийн үйлдэлийг хорих эсэхийг шийддэг.

<html>
<body>

<script type="text/javascript">
function __IsNumeric(e) {
var obj = e.srcElement ? e.srcElement : e.target;
var key = e.keyCode ? e.keyCode : e.which;
if ( key == 8 || key == '8' || key == 9 || key == '9') return true;

if ( key == 189 || key == '189' || key == 109 || key == '109') {
    if(obj.value.indexOf('-') > -1 || obj.value.indexOf('-') > -1)
    { if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; }
    else {return true}
}
if ( key == 190 || key == '190' || key == 110 || key == '110') {
    if(obj.value.indexOf('.') > -1 || obj.value.indexOf('.') > -1)
    { if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; }
    else {return true}
}
if (!( 48 <= key && key <= 57 || 96 <= key && key <= 105 ))
{ if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; }
return true;
}
</script>

<input type="text" onkeydown="__IsNumeric(event);">
</body>
</html>

Java application XPath ( xml document ) expression example

Expression Meaning
XXX XXX нэртэй бүх тагуудыг ялган авна
* Бүх тагуудыг болон элементийг авна.
../TITLE Эцэг элементийн TITLE тагийг авна.
XXX[@AAA] XXX тагууд дотроос attribute нь AAA гэсэн нэртэй байх тагуудыг авна.
*[last()] Сонгосон элементийн сүүлчийн хүү элементийг авна.
*/ZZZ ZZZ элементүүдийн хамгийн дээд талд байгааг сонгон авна.
XXX[ZZZ] XXX элемент нь ZZZ гэсэн хүү элементтэй бол авна.
XXX[@WIDTH and not(@WIDTH="20")] XXX элемент нь WIDTH гэсэн attribute -тай ба утга нь "20" -с ялгаатай бол авна.
/* document -ийн хамгийн захын ( гадна талд байгаа ) элементийг авна.
//TITLE document -ийн TITLE нэртэй тагуудыг авна.
./@* Сонгосон элементийн ( current element ) бүх attributes -г авна.

Өгүүлбэрийн төгсгөлд "авна" гэж бичсэн байгаа нь утга буцаана гэсэн утгыг илэрхийлнэ.
Доорхи жишээг харна уу!

Ямар нэгэн XML файл:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<XDataTable name="Table1" rowcount="1">
<Columns>
<XDataColumn name="id" size="9" type="Long"/>
<XDataColumn name="name" size="150" type="String"/>
<XDataColumn name="image" size="4" type="ByteArray"/>
</Columns>
<Rows>
<XDataRow index="0"><id>1</id><name>b.boldbaatar</name><image>df56382d63412d</image></XDataRow>
</Rows>
</XDataTable>

Хандаж ажиллаж байгаа жишээ class элдэв функыг нь хасаад:

тод хараар тэмдэглэсэн хэсгийг сайн ажиглаарай.
мэдээж энэхүү классыг ашиглахын өмнө Document үүсгэн XML -г
унших ёстой.


package xdata;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import xdata.Interface.IDataColumn;
import xdata.Interface.IDataRow;
import xdata.Interface.IDataTable;
import AIObjectManager.AIXMLBuilder; // Xml -тэй ажилладаг зарим код
import java.io.Serializable;
import java.util.ArrayList;
import javax.xml.xpath.XPathConstants;
import org.w3c.dom.*;
import org.w3c.dom.Element;

/**
 *
 * @author boroo
 */
public class XDataTable implements IDataTable, Serializable {

    private Document xdoc;
    private ActionListener tranEvent;

    public XDataTable() {
        //xdoc = new com.sun.org.apache.xerces.internal.dom.DocumentImpl();
        this("");
    }

    public XDataTable(Document doc) {
        this.xdoc = doc;
    }

    public void addColumn(IDataColumn column) {

        String exp = "//XDataColumn[@name='" + column.getName() + "']@name";
        if(XdbEngine.get(this.xdoc.getOwnerDocument(), exp, XPathConstants.NODE) != null) {
            throw new RuntimeException("Column name is already exists in table !");
        }

        NodeList nodes = this.xdoc.getElementsByTagName("Columns");
        Node node = nodes.item(0);

        Element newCol = this.xdoc.createElement("XDataColumn");
        newCol.setAttribute("name", column.getName());
        newCol.setAttribute("type", column.getType().name());
        newCol.setAttribute("auto", "" + column.getAuto());
        newCol.setAttribute("empty", "" + column.getEmpty());

        node.appendChild(newCol);
    }

    public List<IDataRow> getRows() {
        //String exp = "/XDataTable/Rows/node()";
        //NodeList rows = (NodeList) XdbEngine.get(this.xdoc, exp, XPathConstants.NODESET);
        NodeList rows = this.xdoc.getElementsByTagName("XDataRow");

        int l = rows.getLength();
        ArrayList<IDataRow> list = new ArrayList<IDataRow>();

        for (int i = 0; i < l; i++) {
            Element item = (Element) rows.item(i);
            XDataRow row = new XDataRow();
            row.FillFrom(item);
            list.add(row);
        }
        return list;
    }

    public int getRowCount() {
        String exp = "//XDataTable[@rowcount]/@rowcount";
        Node curr = (Node) XdbEngine.get(this.xdoc, exp, XPathConstants.NODE);

        return Integer.parseInt(curr.getNodeValue());
    }

    private void setRowCount(int rowcount) {
        String exp = "//XDataTable[@rowcount]/@rowcount";
        Node curr = (Node) XdbEngine.get(this.xdoc, exp, XPathConstants.NODE);

        curr.setNodeValue("" + rowcount);
    }

    public void Commit() {
        String exp = "//XDataRow[@handle != '1']/@handle";
        NodeList curr = (NodeList) XdbEngine.get(this.xdoc, exp, XPathConstants.NODESET);

        for(int i = 0; i < curr.getLength(); i++){
            Node nod = curr.item(i);
            nod.setNodeValue("1");
        }
        if(this.tranEvent != null)
            this.tranEvent.actionPerformed(
                    new ActionEvent(this, 0, "Commit"));
    }


    public void setDocument(Document doc) {
        this.xdoc = doc;
    }

    public Document getDocument() {
        return this.xdoc;
    }
}

Миний Cанаа - Intention of my blog

Сайн байна уу? Миний блогт тавтай морил. Програм хангамж хөгжүүлэгчиддээ зориулан өөрийн цуглуулсан та бүхэнд хэрэгтэй байж болох мэдээллийг нэгтгэн сүлжээнд хэвлэж байгаадаа таатай байна. Би энэхүү блогтоо шууд ажилладаг код болон жишээг оруулахыг зорисон бөгөөд ихэндээ би өөрөө тест хийж баталгаажуулсан мөн миний хийсэн програм хангамжид алдаагүй ашиглагдаж байгаа кодуудыг тависан. Хэрэв програм хөгжүүлэхэд элдэв асуудал гарж байгаа бол хамдтаа судлахадаа дуртай байх болноо. Саналаа явуулаарай!!! <a href="mailto:boroog@gmail.com">boroog@gmail.com</a>

Javascript prototype ajax and xml tools

it's menual code. work fine


tools.js file


///////////////////////////////////////////////////////////////////////////////
var WebTools = function() {
    var doc;

    this.constructor = null;

    this.valueOf = function(unknown) {
        return null;
    };

    this.toString = function(unknown) {
        return "";
    }

    this.toLocaleString = function(unknown) {
        return "";
    }

    this.setDocument = function(hdoc) {
        doc = hdoc;
    }

    this.getDocument = function() {
        return doc;
    }

    this.XmlTool = new function() {
        this.getXmlDocument = function(text) {
            var xmlDoc = null;
            try //Internet Explorer
            {
                xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.async = "false";
                xmlDoc.loadXML(text);
            }
            catch (e) {
                try //Firefox, Mozilla, Opera, etc.
                {
                    parser = new DOMParser();
                    xmlDoc = parser.parseFromString(text, "text/xml");
                }
                catch (e) {
                    return null;
                }
            }
            return xmlDoc;
        };

        this.getXMLString = function(xmlDoc) {
            var serialized;
            try {
                // XMLSerializer exists in current Mozilla browsers
                serializer = new XMLSerializer();
                serialized = serializer.serializeToString(xmlDoc);
            }
            catch (e) {
                // Internet Explorer has a different approach to serializing XML
                serialized = xmlDoc.xml;
            }
            return serialized;
        };

        this.createXmlDocument = function() {
            var xmlDoc = null;
            // code for IE   
            if (window.ActiveXObject) {
                xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.async = false;
            }
            // code for Mozilla, Firefox, Opera, etc.
            else if (document.implementation.createDocument) {
                xmlDoc = document.implementation.createDocument("", "", null);
            }
            return xmlDoc;
        };

        this.openXmlDocument = function(xmlFile) {
            if (window.ActiveXObject) { //Internet Explorer
                xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            } else if (document.implementation && document.implementation.createDocument) {
                xmlDoc = document.implementation.createDocument("", "", null);
            }
            try {
                xmlDoc.async = false;
                xmlDoc.load(xmlFile);
            }
            catch (e) { alert(e.message); }
        };
    };

    this.Converter = new function() {
        this.Win1251ToUtf8 = function(str) {
            var strlen = str.length;
            var utf8_str = "";

            for (i = 0; i < strlen; i++) {
                var codestr = str.charCodeAt(i);
                switch (codestr) {
                    case 184: codestr = 1105; break; //eo
                    case 168: codestr = 1025; break; // capital EO

                    case 175: codestr = 1198; break; //capital UE
                    case 191: codestr = 1199; break; //ue

                    case 170: codestr = 1256; break; // capital OE
                    case 186: codestr = 1257; break; //oe
                }
                if (256 > codestr && codestr > 191) codestr = codestr + 848;
                switch (codestr) {
                    case 1111: codestr = 1199; break;   //u
                    case 1031: codestr = 1198; break; //capital U

                    case 1108: codestr = 1257; break; //ou
                    case 1028: codestr = 1256; break; //capital OU
                }

                utf8_str = utf8_str + String.fromCharCode(codestr);
            }
            return utf8_str;
        };
    };

    this.Sender = new function() {
        var postFrameIndex = 0;
        this.getPostID = function(nam) {
            postFrameIndex++;
            return (nam + postFrameIndex);
        };

        this.dynamicPostSend = function(formid, hfunc) {
            var postid = this.getPostID("post");
            iframeId = document.createElement("FRAME");
            iframeId.src = "";
            iframeId.id = postid;
            iframeId.name = postid;
            callBackEvent = function(fra, func) {
                if (fra.contentDocument) {
                    content = fra.contentDocument.body.innerHTML;
                } else if (fra.contentWindow) {
                    content = fra.contentWindow.document.body.innerHTML;
                } else if (fra.document) {
                    content = fra.document.body.innerHTML;
                }
                if (content != null && content != "")
                    func(fra, content);
                try {
                    //fra.parentNode.removeChild(fra);
                } catch (e) {
                }
            };
            document.body.appendChild(iframeId);
            iframe = document.getElementById(postid);
            callBack = function() {
                callBackEvent(iframe, hfunc);
                /*
                if (iframeId.document != null && iframeId.document + "" != "undefined") {
                iframeId.onreadystatechange = function() {
                if (iframeId.readyState + "" == "complete") {
                callBackEvent(iframeId, hfunc);
                }
                };
                } else {
                iframeId.onload = function() {
                callBackEvent(iframeId, hfunc);
                };
                }*/
            };
            iframe.onload = callBack;
            hform = document.getElementById(formid);
            hform.target = postid;
            /*
            var str = "<iframe id='" + postid + "' name='" + postid
            + "' src='' onload='callBack(this)' style='display:none; height:0px; width:0xp;'></iframe>";
            var formid = "";
            if (typeof (form) + "" == "string")
            formid = form;
            else
            formid = form.id;
            hform = document.getElementById(formid);
            parNode = hform.parentNode;
            var innert = parNode.innerHTML;
            parNode.innerHTML = innert + str;
            hform = document.getElementById(formid);
            */
            //form.setAttribute("enctype", "application/x-www-form-urlencoded");
            //form.setAttribute("encoding", "multipart/form-data");           
            hform.submit();
        };
    };

    this.AjaxTool = new function() {
        this.createAjaxRequest = function() {
            var http_request;
            if (window.XMLHttpRequest) {
                http_request = new XMLHttpRequest();
                //if (http_request.overrideMimeType) {
                //    http_request.overrideMimeType("text/xml");
                //http_request.overrideMimeType("text/html");
                //}
            } else {
                var msxmlhttp = new Array("Msxml2.XMLHTTP.4.0",
                "Msxml2.XMLHTTP.3.0",
                "Msxml2.XMLHTTP",
                "Microsoft.XMLHTTP");
                for (var i = 0; i < msxmlhttp.length; i++) {
                    try {
                        http_request = new ActiveXObject(msxmlhttp[i]);
                        if (http_request != null) return http_request;
                    } catch (e) {
                        http_request = null;
                    }
                }
            }
            return http_request;
        };

        this.quickSet = function(url, hfunc) {
            var xmlHttp = null;
            xmlHttp = this.createAjaxRequest();
            if (xmlHttp != null) {
                xmlHttp.open("get", url, true);
                xmlHttp.onreadystatechange = function() {
                    try {
                        if (xmlHttp.readyState == 4) {
                            //Request OK
                            if (xmlHttp.status == 200) {
                                hfunc(xmlHttp);
                            }
                        }
                    } catch (e) {
                        alert("XmlHTTP-д ажиллахад асуудал гарлаа!");
                    }
                }
                xmlHttp.send(null);
            } else {
                alert("Таны веб хөтөч XmlHTTP-г дэмжихгүй байна!");
            }
        };

        this.quickGet = function(url, args, hfunc) {
            var xmlHttp = null;
            xmlHttp = createAjaxRequest();
            if (xmlHttp != null) {
                xmlHttp.open("get", url + args, true);
                xmlHttp.setrequestHeader("Content-Type", "application/x-www-form-urlencoded");
                xmlHttp.onreadystatechange = function() {
                    try {
                        if (xmlHttp.readyState == 4) {
                            //Request OK
                            if (xmlHttp.status == 200) {
                                hfunc(xmlHttp);
                            }
                        }
                    } catch (e) {
                        alert("XmlHTTP-д ажиллахад асуудал гарлаа!");
                    }
                }
                xmlHttp.send(null);
            } else {
                alert("Таны веб хөтөч XmlHTTP-г дэмжихгүй байна!");
            }
        };

        this.AjaxMessage = function(msg) {
            alert(msg);
        };

        this.postSend = function(url, parameters, hfunc) {
            http_request = this.createAjaxRequest();
            if (http_request != null) {
                http_request.open("POST", url, true);
                //http_request.setRequestHeader("Content-Type", "text/xml");
                http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                //http_request.setRequestHeader("Content-Length", parameters.length);
                //http_request.setRequestHeader("Connection", "close");
                http_request.onreadystatechange = function() {
                    if (http_request.readyState == 4) {
                        if (http_request.status == 200) {
                            result = http_request.responseText;
                            hfunc(result);
                        } else {
                            alert("XmlHTTP-д ажиллахад асуудал гарлаа!");
                        }
                    }
                }
                http_request.send(parameters);
            } else hfunc("error");
        };

        this.encodeInput = function(form) {
            inputs = form.getElementsByTagName("input");
            var retParams = "";
            for (var i = 0; i < inputs.length; i++) {
                inputNode = inputs[i];
                var inputName = inputNode.name;
                var inputvalue = inputNode.value;
                retParams = retParams + inputName + "=" + ((inputvalue != null) ? inputvalue : "");
                if ((i + 1) < inputs.length)
                    retParams = retParams + "&";
            }
            return retParams;
        };

        this.postParameters = function(obj) {
            var getstr = "";
            for (i = 0; i < obj.getElementsByTagName("input").length; i++) {
                if (obj.getElementsByTagName("input")[i].type == "text") {
                    getstr += obj.getElementsByTagName("input")[i].name + "=" +
                   obj.getElementsByTagName("input")[i].value + "&";
                }
                if (obj.getElementsByTagName("input")[i].type == "checkbox") {
                    if (obj.getElementsByTagName("input")[i].checked) {
                        getstr += obj.getElementsByTagName("input")[i].name + "=" +
                   obj.getElementsByTagName("input")[i].value + "&";
                    } else {
                        getstr += obj.getElementsByTagName("input")[i].name + "=&";
                    }
                }
                if (obj.getElementsByTagName("input")[i].type == "radio") {
                    if (obj.getElementsByTagName("input")[i].checked) {
                        getstr += obj.getElementsByTagName("input")[i].name + "=" +
                   obj.getElementsByTagName("input")[i].value + "&";
                    }
                }
                if (obj.getElementsByTagName("input")[i].tagName == "SELECT") {
                    var sel = obj.getElementsByTagName("input")[i];
                    getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
                }
            }
            return getstr;
        };

        this.getParameters = function(obj) {
            var getstr = "?";
            for (i = 0; i < obj.childNodes.length; i++) {
                if (obj.childNodes[i].tagName == "INPUT") {
                    if (obj.childNodes[i].type == "text") {
                        getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
                    }
                    if (obj.childNodes[i].type == "checkbox") {
                        if (obj.childNodes[i].checked) {
                            getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
                        } else {
                            getstr += obj.childNodes[i].name + "=&";
                        }
                    }
                    if (obj.childNodes[i].type == "radio") {
                        if (obj.childNodes[i].checked) {
                            getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
                        }
                    }
                }
                if (obj.childNodes[i].tagName == "SELECT") {
                    var sel = obj.childNodes[i];
                    getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
                }
            }
            return getstr;
        }
    };
};

var webTools = new WebTools();

USAGE:

simple.js file ( book search on js of asp.net )

var oldSearchType;

function SelectSearchType(stype) {   
    if (oldSearchType == null)
        oldSearchType = document.getElementById("SearchType_Title");
    if (oldSearchType != null) {
        if(stype != null)
            oldSearchType.className = "";
    }
    if (stype != null) {
        stype.className = "SelectedSearchType";
        oldSearchType = stype;
    }
}

function ToogleNextSearch() {
    snext = document.getElementById("NextSearchCheck");
    if (snext.checked)
        snext.checked = false;
    else
        snext.checked = true;
}

function SearchBook() {
    SearchBookNext();
    return false;
}

function SearchBookNext() {   
    SelectSearchType(null);
    var searchTypeid = oldSearchType.id;
    var ind = searchTypeid.indexOf('_');
    document.getElementById("ctlSearchType").value = searchTypeid.substring(ind + 1);   
    document.getElementById("ctlPageStart").value = 0;
    document.getElementById("ctlPageLen").value = 10;
    snext = document.getElementById("NextSearchCheck");
    document.getElementById("ctlNextSearch").value = ((snext.checked) ? "1" : "0");   
    form = document.getElementById("frmSearchBook");   
    var params = webTools.AjaxTool.encodeInput(form);

    retfunc = function(content) {
        try {           
            xml = webTools.XmlTool.getXmlDocument(content);
            //alert(xml.firstChild.nodeName);
            //alert(webTools.XmlTool.getXMLString(xml));
            var root = xml.firstChild;
            if (root != null && root.childNodes.length > 0) {               
                //alert(root.getElementsByTagName("info").length);
                //alert(root.getElementsByTagName("book").length);
                var vars = root.getElementsByTagName("info")[0];
                var rlength = parseInt(vars.childNodes[0].firstChild.nodeValue);
                var rstart = parseInt(vars.childNodes[1].firstChild.nodeValue);
                var rlimit = parseInt(vars.childNodes[2].firstChild.nodeValue);
                if (rlength < rstart && rlength < rlimit) rlimit = Math.abs(rlength - rlimit);
                var books = root.getElementsByTagName("book");
                if (books.length > 0) {
                    var alll = "<li><div>Хайлтын үр дүн: <span>(" + rlength + " -c " + (rstart + rlimit) + ")</span></div></li>";
                    for (var i = 0; i < books.length; i++) {
                        var book = books[i].childNodes;
                        var BookTitle = ((book[0].firstChild != null) ? book[0].firstChild.nodeValue : "");
                        var Author = ((book[1].firstChild != null) ? book[1].firstChild.nodeValue : "");
                        var Synopsis = ((book[2].firstChild != null) ? "<b>Агуулга: </b>" + book[2].firstChild.nodeValue : "");
                        var Keywords = ((book[3].firstChild != null) ? " << " + book[3].firstChild.nodeValue : "");
                        var Typename = ((book[4].firstChild != null) ? book[4].firstChild.nodeValue : "");
                        var Genres = ((book[5].firstChild != null) ? book[5].firstChild.nodeValue : "");
                        var Publisher = ((book[6].firstChild != null) ? book[6].firstChild.nodeValue : "");
                        var Bookid = ((book[7].firstChild != null) ? book[7].firstChild.nodeValue : "");

                        var ihtml = "<li><div><A href='javascript:void(0);' onclick='javascriopt:SelectBookInfo();' id='" + Bookid + "'>"
+ BookTitle + "</A> <A>- " + Author + "</A></div><div><p>" + Synopsis + "<span>"
+ Keywords + "</span></p></div><div><font><B>Төрөл:</B> " + Typename + " <B>, Жанар:</B> "
+ Genres + " </font></div><div><pre>" + Publisher + "</pre></div></li>";

                        alll = alll + ihtml;
                    }
                    document.getElementById("SearchResultUL").innerHTML = alll;
                }
            }
            else {
                alert("Search Failed: " + book);
            }
        } catch (e) {
            document.getElementById("SearchResultUL").innerHTML = "<li>Алдаа илэрсэн. Та дахин хайна уу!</li><li>" + e + "</li>";
        }
    };
    try {
        webTools.AjaxTool.postSend("../cinc/cserve.aspx", params, retfunc);
    } catch (e) { }   
}

function CallAccountSetting() {
    alert("callAccountSetting()");
}

function LoadSearchBody() {
}

Thursday, October 7, 2010

How to run ( call ) java application ( jar ) using linux command shell

Open terminal on linux

> vi file.sh

export JAVA_HOME=$JAVA_HOME:/opt/jdk1.6.0_24
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

echo $CLASSPATH

java -Xmx128m -jar DandaaMessenger.jar

click ESC close editor
click ZZ for save

>file.sh for run jar

How to install android on netbeans

on cmd

D:\\android-sdk-windows\\tools\\android.bat list targets
// -t targets
//-n emulator name
D:\\android-sdk-windows\\tools\\android create avd -n android_1-5 -t 1

on netbeans
1. Plugins->Add button
NAME: nbandroid
URL: http://kenai.com/downloads/nbandroid/updates.xml

2.next
Available Plugin Install of Android

3.next
Add android on java platform

4.Create project now

Create html with data using JQuery templete

I wish it. JQuery is great.
({data model} is json syntax) + (<script>html template</script>) => html page and more



<html>
<body>
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="jquery.tmpl.js" type="text/javascript"></script>

<div id="pager">sain baina uu?</div>

<script>

(function($) {

    $.fn.msgbox = function(options) {

        var opts = $.extend({}, $.fn.msgbox.defaults, options);
        //alert(this.get(0));
        return this.each(function() {           
            alert($(this).text());
        });
    };
   
    $.fn.msgbox.defaults = {
        pagenumber: 1,
        pagecount: 1
    };
   
})(jQuery);

//$("#pager").msgbox({options: "fix"});

</script>

<script id="tmplPeople" type="text/x-jquery-tmpl">
<tr class="${alternate($data, people)}"><td colspan="2"><a href="${url}">${getName()}</a></td></tr>
{{each cities}}
<tr class="cityseparator"><td colspan="2"></td></tr>
<tr class="${alternate($data, people)}"><td colspan="2"><b><i>City ${index($value, cities)}:</i></b></td></tr>
<tr class="${alternate($data, people)}"><td><b>${name}</b></td><td>${state}</td></tr>
{{/each}}
<tr class="separator"><td colspan="2">{{if cities}} {{/if}}</td></tr>
</script>

<script type="text/javascript">

var dataObject = {
    firstName: "John",
    lastName: "Resig",
    url: "http://ejohn.org/",
    cities: ["Boston, MA", "San Francisco, CA"]
};

var people = [
{firstName: "John", lastName: "Resig", url: "http://ejohn.org/",
    cities: [
        { name: "Boston", state: "MA" },
        { name: "San Francisco", state: "CA" }
    ]},
{firstName: "Dave",lastName: "Reed",url: "http://dave.org/",
    cities: [
        { name: "Seattle", state: "WA" },
        { name: "Los Angeles", state: "CA" },
        { name: "New York", state: "NY" }
    ]},
{firstName: "Boris",lastName: "Moore",url: "http://boris.org/",
    cities: [
        { name: "Redmond", state: "WA" }
    ]}
];

function cityJoin( separator ) {
    return this.data.cities.join( separator || ", " );
}

function getName() {
    return this.data.firstName + " " + this.data.lastName;
}

function index( item, array ) {
    return $.inArray( item, array ) + 1;
}

function alternate( item, array ) {
    return ($.inArray( item, array ) % 2) ? "personAlt" : "person";
}

jQuery(function(){
    // A template string
    var tmpl = '<li><a href="${url}">${cityJoin()}</a>';
    tmpl += ' {{if $item.showCities}} (${cityJoin()}) {{/if}} </li>';

    $.tmpl( tmpl, dataObject ).appendTo( "ul" );
});


$(function(){
    $("#tmplPeople").tmpl( people ).appendTo(".peopleTable");
});


</script>

<ul></ul>

<table class="peopleTable"><tbody>
<tr class="separator"><td colspan="2"></td></tr>
</tbody></table>

</body>
</html>

Monday, October 4, 2010

Activity Diagram Standard (simple algorithm graph)

Element and its description Symbol
Initial Activity: Үйл ажиллагааны эхлэлийг тод хар дугуйгаар тэмдэглэж өгнө.
Activity:Үйл ажиллагааны явагдах процессийг тэмдэглэхэд зуйван дотор тухайн ажиллагааны тайлбарыг бичиж дүрслэнэ. (Methods or module)
Decisions:Энэ нь нөхцөл шалгах үйлдэл ба нөхцөл үнэн эсвэл худал тохиолдолд 2 өөр шийдвэрт хүрч ондоо ажиллагаа явагдана. (if true then op1 else op2)
Signal: Үйл ажиллагааны явцад өөр төлөвлөгдсөн хэсгээс мэдээлэл ирэх процессийг дээд талд байгаа дүрсээр тэмдэглэнэ. Үүнтэй ижлээр гадагш мэдээлэл илгээх процессийг доод талд байгаа дүрсээр тэмдэглэнэ. (1-Listeners, 2-Events)
Concurrent Activities: Зарим үйл ажиллагаа нь хэд хэдэн үйлдэл зэрэг хийж нэг үр дүнгээр дараачийн процессруу шилжих тохиолдол гардаг. Иймэрхүү үйл ажиллагааны онцлогийг зузаан хөндлөн шугамаар зурж тодорхи үйлдлүүдийг нь дараах байдлаар тэмдэглэж өгнө. (Threads, Invokers, Double process in method)
Time event action: Тодорхой хугацааны нөхцөлд хэрэгжих үйлдлийг 2 гурвалжингийн оройг дээр доороос нь уулзуулан зурж тэмдэглэнэ.
Final Activity: Үйл ажиллагааны төгсгөлийг тойрог доторхи дугуй дүрсээр тэмдэглэнэ.

Creating an Activity Diagram

Let us consider the example of attending a course lecture, at 8 am.

JQuery methods example & turorial

Javascript JQuery syntax, methods. try now


<html>
<body>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>

<div id="boroo" style="background-color:green;"><a>menu</a>
<span style="opacity:0;background-color:blue;width:200px;position:relative;">popup menu</span>
</div>

<script type="text/javascript">
$("#boroo").mousedown(function(event) {
    if(event.button == 2){
        $("#boroo span").animate({opacity:1},"slow");
    }
    else $("#boroo span").animate({opacity:0},"slow");
});

$(document).ready(function(){       
        $(document).bind("contextmenu",function(e){
            return false;
        });

    $("#boroo span").focusout(function(){
        $(this).css("display","none");
    }).css("left",-2*$($("#boroo").contents().get(0)).width()).css("top",$("#boroo").css("height"));
});
</script>
//~=hooson zaitai
//!=tentsuu bish
//^=ehlel ni tentsuu
//$=togsgol ni tentsuu
//*=aguulagdaj baival
//|=ehlel-zuraas orson

<div id="abc" style="height:40px; background-color:blue;">
<a href="#">baldskf lakdj;falkdsj;lfka jd;klja;dlks jal;d </a>
</div>

<form name="form1">
  <input id="target" type="text" value="Field 1" />
  <input type="text" value="Field 2" />
  <input type="checkbox" name="isactive" id="isactive"/>
</form>

<div id="other">
  Trigger the handler
</div>

<select name="sweets" multiple="multiple">
    <option>Chocolate</option>
    <option selected="selected">Candy</option>
    <option>Taffy</option>
    <option selected="selected">Caramel</option>
    <option>Fudge</option>
    <option>Cookie</option>
  </select>

<script type="text/javascript">

$(document).ready(function() {
    try{
        $("div#abc a").css("color","white");
        $("div#abc a").attr("href","?name=boroo");
        $("div").click(function(){ $(this).children().focus(); });
        $("div").focusout(function() { alert($(this).get(0).tagName); });
    }catch(ex){
        alert(ex);
    }
    //alert("ready");
});
//$(window).load( function () { alert("Hello now!"); } );
//$(window).unload( function () { alert("Bye now!"); } );

//appendTo(document.body);
$("div#other").append("<p> my name is boroo </p>");

//alert($("input:checkbox[name='isactive']").get(0).id);
//alert($("input:checkbox").filter(":not(:checked)").get(0).id);

//alert($("input:checkbox").is(":checked"));

 $("select").change(function () {
    var str = "";
              $("select option:selected").each(function (index) {   
                    str += $(this).text() + " ";
                  });
    $(document).data("str",str);//("#abc")
        }).change();

$(document.body).delegate("div#abc a", "mouseover", function(){
    $(this).fadeOut("slow");
    alert($(document).data("str"));
});

jQuery.each(jQuery.browser, function(i) {
   if($.browser.msie){
      //alert("Internet explore");
   }else{
      //alert("Others"+jQuery.browser.version);
   }
 });

function listX() {
        var xtn = "id";
        var xt =  "id="+1;
        $.ajax({
            url:'${pageContext.request.contextPath}/admin/core/xdata/ListXdatarow/',
            type:'post',
            data:xt,
            //beforeSend:,
            dataType:'html',
            success:function(data){
                $("#listShowTarget").html(data);
            }
        });
    }
</script>

<table id="table1">
<tr><td>TD #00</td><td>TD #01</td><td>TD #02</td></tr>
</table>
<table id="table2">
<tr><td>
<input type="text" maxlength="30" value="sadfasdf asdfasd" size="100" style="width:8px;"></td><td>TD #1</td><td>TD #2</td></tr>
<tr><td>TD #3</td><td>TD #4</td><td>TD #5</td></tr>
<tr><td>TD #6</td><td>TD #7</td><td>TD #8</td></tr>
</table>
<script>
//$('#table2 tr:eq(1) td').slice(0,1).css("background-color","red");
//var td = $("table[id='table2'] tr td:eq(8)");
//alert($("#table2 tr td").index(td));
//$("tr:eq(1)").css("color", "red");
//$("td:gt(7)").css("color", "red");
//:eq(), :lt(), :gt(), tr:even, tr:odd
</script>

<div class="container">
  <h2>Greetings</h2>
  <div class="inner">Hello</div>
  <div class="inner">Goodbye</div>
</div>
<script>
//$('.inner').after('<p>Test</p>').after('<p>Test</p>');
</script>

<div id="boroo" style="background-color:green;">menu<span style="display:none;background-color:blue;width:200px;position:relative;">popup menu</span></div>
<script>
$("#boroo").mousedown(function(event) {
//  alert("Current mouse position: " + event.pageX + ", " + event.pageY + " : " + event.button);
});
$(document).ready(function(){
    $(document).bind("contextmenu",function(e){
        return false;
    });
});
</script>
               
//zovhon songoson elements iin childuud children() tai tostei command 
<ul class="topnav">
    <li>Item 1</li>
    <li>Item 2 
        <ul><li>Nested item 1</li><li>Nested item 2</li><li>Nested item 3</li></ul>
       </li>
    <li>Item 3</li>
</ul>
<script>$("ul.topnav > li").css("border", "3px double red");</script>

</body>
</html>