Wednesday, November 13, 2013

comparator sort and order java

comparesortandorder.java
 1 /*
 2  * To change this template, choose Tools | Templates
 3  * and open the template in the editor.
 4  */
 5 package checkex;
 6 
 7 import java.text.DateFormat;
 8 import java.text.ParseException;
 9 import java.text.SimpleDateFormat;
10 import java.util.ArrayList;
11 import java.util.Collections;
12 import java.util.Comparator;
13 import java.util.Date;
14 import java.util.List;
15 import java.util.logging.Level;
16 import java.util.logging.Logger;
17 
18 /**
19  *
20  * @author 
21  */
22 public class comparesortandorder {
23     public static void main(String[] args) {
24         List<Person> persons = new java.util.ArrayList<Person>();
25         persons.add(new Person("a", "def5", -10, "10/10/12"));
26         persons.add(new Person("a", "def3", 70, "01/01/13"));
27         persons.add(new Person("b", "def22", 32, "01/01/2013"));
28         persons.add(new Person("b", "def1", 65, "01/01/13"));
29         persons.add(new Person("a", "def4", -10, "10/10/12"));
30         persons.add(new Person("a", "def4", -10, "10/10/19"));
31         persons.add(new Person("c", "def22", 10, "01/01/2013"));
32         persons.add(new Person("c", "def21", 10, "01/01/2013"));
33         
34         System.out.println(persons);
35         Collections.sort(persons, new Comparator<Person>() {
36 
37             @Override
38             public int compare(Person t, Person t1) {
39                 //return t.getAge() - t1.getAge();
40                         if(0 == t.getAge() || 0== t1.getAge() ){
41             throw new NullPointerException();
42         }else{
43             int nameComparisonResult = t.getAge()-(t1.getAge());
44             if(0 == nameComparisonResult){
45                 return t.getLname().compareTo(t1.getLname());
46             }else{
47                 return nameComparisonResult;
48             }
49         }
50             }
51         });
52         System.out.println(persons);
53         
54         
55         List<Person> a1 = new ArrayList<Person>();
56         for (int i = 0; i < persons.size(); i++) {
57                         if((persons.get(i).getFname() == "a") || (persons.get(i).getFname() == "d") ){
58                             a1.add(new Person(persons.get(i).getFname(), persons.get(i).getLname(),persons.get(i).getAge(), persons.get(i).getDateval()));
59                         }
60                 }
61         System.out.println(a1);
62         
63         Collections.sort(a1, new Comparator<Person>() {
64 
65             @Override
66             public int compare(Person o1, Person o2) {
67                  //To change body of generated methods, choose Tools | Templates.
68 
69            if (o1.getDateval() == null || o2.getDateval() == null)
70         return 0;
71                 try {
72                     return converttodate(o1.getDateval()).compareTo(converttodate(o2.getDateval()));
73                 } catch (ParseException ex) {
74                     Logger.getLogger(comparesortandorder.class.getName()).log(Level.SEVERE, null, ex);
75                 }
76                 return 0;
77             }
78         
79         });
80         System.out.println(a1);
81         
82 
83     }
84     public static Date converttodate(String dateval) throws ParseException {
85        
86 DateFormat formatter ; 
87 Date date ; 
88    formatter = new SimpleDateFormat("MM/dd/yy");
89    date = formatter.parse(dateval);
90         return date;
91         
92         
93     }
94 }
95 




Person.java
 1 /*
 2  * To change this template, choose Tools | Templates
 3  * and open the template in the editor.
 4  */
 5 package checkex;
 6 
 7 /**
 8  *
 9  * @author 
10  */
11 public class Person {
12     String fname;
13     String lname;
14     String dateval;
15     int age;
16 
17     public Person() {
18     }
19 
20     public int getAge() {
21         return age;
22     }
23 
24     public void setAge(int age) {
25         this.age = age;
26     }
27     public String getDateval() {
28         return dateval;
29     }
30 
31     public void setDateval(String dateval) {
32         this.dateval = dateval;
33     }
34 
35     public String getFname() {
36         return fname;
37     }
38 
39     public void setFname(String fname) {
40         this.fname = fname;
41     }
42 
43     public String getLname() {
44         return lname;
45     }
46 
47     public void setLname(String lname) {
48         this.lname = lname;
49     }
50 
51     public Person(String fname, String lname, int age, String dateval) {
52         this.fname = fname;
53         this.lname = lname;
54         this.age = age;
55         this.dateval = dateval;
56     }
57 
58     @Override
59     public String toString() {
60         return fname + "," + lname + "," + age+","+dateval;
61     }
62 }
63 

Monday, November 4, 2013

fixed headers

C:\vivek\jquerymobile\netbeansEx\vivekmras\web\fixedheadermultiple.html
  1 <html> 
  2 <head> 
  3         <title>vivekmras.webhostingbuilders.com</title> 
  4         <meta name="viewport" content="width=device-width,user-scalable=no">
  5         <script src="viscpt.js"></script>
  6         <style>
  7             #fixhed{
  8                 
  9 position: fixed;
 10 width: 100%;
 11 height: 40px;
 12 top: 0px;
 13 -webkit-margin-before: 0em;
 14 display: block;
 15             }
 16             
 17         #fixhed td{  
 18             width: 10%;
 19             height: 40px;
 20         }
 21         .ui-content .ui-listview, .ui-panel-inner>.ui-listview {
 22             margin: 0px;
 23         }
 24         .maincont {
 25             position: relative;
 26         }
 27         .secHead{
 28             position: absolute;
 29         }
 30         .subHead{
 31             height: 20px;
 32         }
 33         
 34         .headerpersist {
 35             position: fixed !important;
 36             margin: auto;
 37             z-index:1000;
 38             top: 0px;
 39         }
 40             </style>
 41  </head> 
 42 <body> 
 43 
 44         <div style="text-align: center;"><div style="position:relative; top:0; margin-right:auto;margin-left:auto; z-index:99999"></div></div>
 45     <div data-role="content">
 46         <ul data-role="listview"  data-divider-theme="d">
 47             <li data-role="list-divider" id="fhm1" class="maincont"><div class="subHead"><div id="secondary1" class="secHead">Mail</div></div></li>
 48     <li><a href="#">Inbox</a></li>
 49     <li><a href="#">Outbox</a></li>
 50     <li data-role="list-divider" id="fhm2" class="maincont"><div class="subHead"><div id="secondary2" class="secHead">Contacts</div></div></li>
 51     <li><a href="#">Friends</a></li>
 52     <li><a href="#">Work</a></li>
 53 </ul>
 54 
 55         <p>
 56             Adding Back buttons
 57 
 58 jQuery Mobile has a feature to automatically create and append "back" buttons to any header, though it is disabled by default. This is primarily useful in chromeless installed applications, such as those running in a native app webview. The framework automatically generates a "back" button on a header when the page plugin's addBackBtn option is true. This can also be set via markup if the page div has a data-add-back-btn="true" attribute.
 59 
 60 If you use the attribute data-rel="back" on an anchor, any clicks on that anchor will mimic the back button, going back one history entry and ignoring the anchor's default href. This is particularly useful when linking back to a named page, such as a link that says "home", or when generating "back" buttons with JavaScript, such as a button to close a dialog. When using this feature in your source markup, be sure to provide a meaningful href that actually points to the URL of the referring page. This will allow the feature to work for users in C-Grade browsers.
 61 
 62 If you just want a reverse transition without actually going back in history, you should use the data-direction="reverse" attribute.
 63 </p>
 64 
 65         </div><!-- /content -->
 66    <script>
 67        var x4=0;
 68        if(x4==0){
 69            var lastY;
 70     document.addEventListener('touchmove', function(event) {
 71        
 72         event.preventDefault();
 73         var currentY = event.touches[0].clientY;
 74         if(currentY > lastY){
 75            // window.scrollBy(0,-4);
 76             x4= x4+1;
 77         }else{
 78            // window.scrollBy(0,4);
 79             x4= x4+1;
 80         }
 81         console.log("x2="+x4);
 82         lastY = currentY;
 83     });
 84        }else{
 85            event.preventDefault();
 86        }
 87     $( window ).on( "orientationchange", function( event ) {
 88         
 89     });
 90     window.onresize = resize;
 91     function resize()
 92     {
 93         console.log("resize");
 94       $.mobile.silentScroll(0);
 95       var x3=0;
 96        if(x3==0){
 97            var lastY;
 98     document.addEventListener('touchmove', function(event) {
 99        
100         event.preventDefault();
101         var currentY = event.touches[0].clientY;
102         if(currentY > lastY){
103             window.scrollBy(0,-6);
104             x3= x3+1;
105         }else{
106             window.scrollBy(0,6);
107             x3= x3+1;
108         }
109         console.log("x2="+x3);
110         lastY = currentY;
111     });
112        }else{
113            event.preventDefault();
114        }
115     }
116     
117         function addclass(add, idname, classtoadd){
118                 if(add){
119                         if((document.getElementById(idname).className).indexOf(classtoadd) == '-1'){
120                         document.getElementById(idname).className +=' '+ classtoadd;
121                         }
122                 }
123         }
124 
125         function removeclass(remove, idname, classtoremove){
126                 if(remove){
127                         //document.getElementById(idname).className = classtoremove;
128                         document.getElementById(idname).className = document.getElementById(idname).className.replace(new RegExp('\\b' + classtoremove + '\\b'),'');
129                 }
130         }
131 
132         document.addEventListener('scroll', function (event) {
133             event.preventDefault();
134                 var ele = document.getElementById("fhm1");
135                 var x = 0;
136                 while(ele){
137                    x += ele.offsetTop;
138                    ele = ele.offsetParent;
139                 }
140                 console.log("x="+x);
141                 if(document.body.scrollTop  > (x+3)){
142                         addclass(true, 'secondary1','headerpersist');
143                 
144                 }
145                 if(document.body.scrollTop  < (x+3)){
146                         removeclass(true, 'secondary1','headerpersist');
147                 }
148                 
149                 var ele1 = document.getElementById("fhm2");
150                 var x1 = 0;
151                 while(ele1){
152                    x1 += ele1.offsetTop;
153                    ele1 = ele1.offsetParent;
154                 }
155                 console.log("x1="+x1);
156                 if(document.body.scrollTop  > (x1-30)){
157                     removeclass(true, 'secondary1','headerpersist');
158                 }
159                 if(document.body.scrollTop  > (x1+3)){
160                         addclass(true, 'secondary2','headerpersist');
161                 
162                 }
163                 if(document.body.scrollTop  < (x1+3)){
164                         removeclass(true, 'secondary2','headerpersist');
165                 }
166                 
167         });
168   
169         </script> 
170 </body>
171 
172 </html>
173 
174  

Thursday, October 31, 2013

C:\vivek\jquerymobile\netbeansEx\vivekmras\web\fixedheadermultiple.html
 1 <html> 
 2 <head> 
 3         <title>vivekmras.webhostingbuilders.com</title> 
 4         <meta name="viewport" content="width=device-width,user-scalable=no">
 5         <script src="viscpt.js"></script>
 6         <style>
 7             #fixhed{
 8                 
 9 position: fixed;
10 width: 100%;
11 height: 40px;
12 top: 0px;
13 -webkit-margin-before: 0em;
14             }
15             
16         #fixhed td{  
17             width: 10%;
18             height: 40px;
19         }
20         .ui-content {
21             padding: 0px;
22         }
23         .ui-bar-a {
24             border:0px;
25             background: transparent;
26         }
27             </style>
28  </head> 
29 <body> 
30     <div data-role="header" data-position="fixed">
31         <h1></h1>
32 </div>
33     <div data-role="content">
34             <div id="fixhed"><table border="1" style="width: 100%;">
35                 <tr>
36                     <td></td>
37                     <td style="width: 80%;background:red;"></td>
38                     <td></td>
39                 </tr>
40             </table>
41             </div>
42             Adding Back buttons
43 
44 jQuery Mobile has a feature to automatically create and append "back" buttons to any header, though it is disabled by default. This is primarily useful in chromeless installed applications, such as those running in a native app webview. The framework automatically generates a "back" button on a header when the page plugin's addBackBtn option is true. This can also be set via markup if the page div has a data-add-back-btn="true" attribute.
45 
46 If you use the attribute data-rel="back" on an anchor, any clicks on that anchor will mimic the back button, going back one history entry and ignoring the anchor's default href. This is particularly useful when linking back to a named page, such as a link that says "home", or when generating "back" buttons with JavaScript, such as a button to close a dialog. When using this feature in your source markup, be sure to provide a meaningful href that actually points to the URL of the referring page. This will allow the feature to work for users in C-Grade browsers.
47 
48 If you just want a reverse transition without actually going back in history, you should use the data-direction="reverse" attribute.
49         </div><!-- /content -->
50     
51 </body>
52 </html>

Thursday, October 24, 2013

scroll position mobile



<head> 

<title>vivekmras.webhostingbuilders.com</title> 

        <meta name="viewport" content="width=device-width,user-scalable=no">

        <script src="viscpt.js"></script>

</head> 

<body> 

  

<!-- Start of first page: #one -->

<div data-role="page" id="one">

<div data-role="content" >

<h2>One</h2>

                <div id="div1"></div>

<label for="text-1">Text input:</label>

     <input type="text" name="text-1" id="text-1" value="">

     

     

     <div data-role="collapsible" data-collapsed="false" data-theme="b" data-content-theme="d">

    <h4>Heading</h4>

    <ul data-role="listview">

        <li><a href="#">List item 1</a></li>

        <li><a href="#">List item 2</a></li>

        <li><a href="#">List item 3</a></li>

    </ul>

</div>

     

     

</div><!-- /content -->

<div data-role="footer" data-theme="d">

<h4>Page Footer</h4>

</div><!-- /footer -->

</div><!-- /page one -->

<script>

    window.onload = function() {

         var d = document.getElementById("div1");

var topPos = d.offsetTop;

/

    console.log("onload--  document.body.scrollTop="+document.body.scrollTop);

    console.log("onload-- window.innerHeight="+window.innerHeight);

    console.log("onload-- document.body.scrollHeight="+document.body.scrollHeight);

};

window.onresize=function(){

         var d = document.getElementById("div1");

var topPos = d.offsetTop;

    console.log("onresize--  document.body.scrollTop="+document.body.scrollTop);

    console.log("onresize-- window.innerHeight="+window.innerHeight);

    console.log("onresize-- document.body.scrollHeight="+document.body.scrollHeight);

};

document.addEventListener('scroll', function (event) {

    console.log("document.body.scrollTop="+document.body.scrollTop);

    console.log("window.innerHeight="+window.innerHeight);

    console.log("document.body.scrollHeight="+document.body.scrollHeight);

    if (document.body.scrollHeight == 

        document.body.scrollTop +        

        window.innerHeight) {

        

    }

             var d = document.getElementById("div1");

var topPos = d.offsetTop;

console.log("topPos="+topPos);

});

    </script>

    

</body>


vivekmras.webhostingbuilders.com

One

Page Footer

Wednesday, October 23, 2013

jquery mobile ios 5 > issue on zoom

https://github.com/jquery/jquery-mobile/issues/3690

http://zsprawl.com/iOS/2012/05/completely-disabling-zoom-in-jquery-mobile-1-1-0/


$(document).bind("mobileinit", function(){
//$.mobile.ignoreContentEnabled="true";
//$.mobile.zoom.enable( false );
//$.extend($.mobile.zoom, {locked:true,enabled:false})
});

<!DOCTYPE html>
<html>
<head>
<title>vivekmras.webhostingbuilders.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="viewport" content="width=device-width,user-scalable=no">
        <script src="viscpt.js"></script>
</head>
<body>
    <style>
        .ui-mobile [data-role=page], .ui-mobile [data-role=dialog], .ui-page {
            position: relative;
        }
    </style>
<p><a id="name1" href="#two" >Show page "two"</a></p>
<p><a id="name2" href="#one" >Show page "one"</a></p>  
<div id="para">
<p>Hiya</p>
<p>Such interesting text, eh?</p>
</div>
<div id="para2">
<p>Hi vivek</p>
<p>Such interesting text, eh?</p>
</div>
<script>
$( '#name1' ).click(function() {
 // $( '#para' ).hide( "slow" );
//  $( '#para1' ).show( "slow" );
  $.mobile.changePage( "#two", {
    transition: "flip",
    reverse: true
});
 
});
$( '#name2' ).click(function() {
 // $( '#para1' ).hide( "slow" );
 // $( '#para' ).show( "slow" );
    $.mobile.changePage( "#one", {
    transition: "flip",
    reverse: true
});
});
</script>
<!-- Start of first page: #one -->
<div data-role="page" id="one">



<div data-role="content" >
<h2>One</h2>
<label for="text-1">Text input:</label>
     <input type="text" name="text-1" id="text-1" value="">
</div><!-- /content -->

<div data-role="footer" data-theme="d">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page one -->


<!-- Start of second page: #two -->
<div data-role="page" id="two">



<div data-role="content" >
<h2>two</h2>

</div><!-- /content -->

<div data-role="footer" data-theme="d">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page two -->
   
</body>



</html>

Wednesday, October 9, 2013

useragent and input switch

<!DOCTYPE html>
<html>
<head>
<title>vivekmras.webhostingbuilders.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
 
</head>
<body>

<div  id="login">



    <label for="name">Login value:</label>
    <input type="text" name="name" id="name" value=""  />
   

           

    <label for="password">Password:</label>
    <input type="password" name="password" id="password" value="" />
   
   

   

           
 <button type="submit" data-theme="e" >Submit</button>

</div><!-- /content -->
        <script>
            function isNumberKey(evt, y){
                var next=y.tabIndex;
                console.log('next='+next);
                document.getElementById("passwrdnew").focus();
               
                var charCode = (evt.which) ? evt.which : event.keyCode;
    alert("charCode="+charCode);
    var userAgent = navigator.userAgent.toLowerCase();
    if ((userAgent.search("android") > -1) && (userAgent.search("mobile") > -1) && (userAgent.search("chrome") > -1)){
        alert("android mobile chrome");
    }
                       
                var mytextvalue = document.getElementById("passwrd").value;
               // alert("mytextvalue="+mytextvalue);
               //var str="myfile.doc";
               //alert(mytextvalue);
               if(mytextvalue.toString().indexOf('-') !== -1){
                   alert("value avialable");
               }
                var value =  evt.target.value;
               // alert("value="+value);
                if(mytextvalue==="1-"){
                    //alert("value="+mytextvalue);
                }
               
    var charCode = (evt.which) ? evt.which : event.keyCode;
    //alert("charCode="+charCode);
     if(charCode === 45 || charCode === 46 ){
       // alert("1");
       //var string = "Hello";
        var str = mytextvalue.substring(0, mytextvalue.length);
        //alert(str);
      document.getElementById("passwrd").value=str;
      //alert("value="+value);
        return false;
     }
    if (charCode > 31 && (charCode < 48 || charCode > 57) && !(charCode === 45 || charCode === 46 )){
        //alert("charCode="+charCode);
        //evt.preventdefault();
        return false;
        //setTimeout(function(){},1);
    }else{
        return true;
       // evt.preventdefault();
    }

    }
   
   document.getElementById("passwrdnew").keydown(function(event){
        alert(event.keyCode);
    });
        </script>
       
       
        <div  id="login1">
    <label for="password">Password:</label>
    <input type="number" id="passwrd" tabindex="1" pattern="[0-9]*" onkeydown="return isNumberKey(event, this);"/>
   
    <label for="login">login:</label>
    <input type="text" id="passwrdnew"  onkeydown="return isNumberKey(event);"/>  
        </div>

</body>


</html>

Sunday, October 6, 2013

numeric input no dots or no hyphen android and iphone

<!DOCTYPE html>
<html>
<head>
<title>vivekmras.webhostingbuilders.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
 
</head>
<body>

<div  id="login">



    <label for="name">Login value:</label>
    <input type="text" name="name" id="name" value=""  />
   

           

    <label for="password">Password:</label>
    <input type="password" name="password" id="password" value="" />
   
   

   

           
 <button type="submit" data-theme="e" >Submit</button>

</div><!-- /content -->
        <script>
            function isNumberKey(evt){
                var mytextvalue = document.getElementById("passwrd").value;
               // alert("mytextvalue="+mytextvalue);
               //var str="myfile.doc";
               //alert(mytextvalue);
               if(mytextvalue.toString().indexOf('-') !== -1){
                   alert("value avialable");
               }
                var value =  evt.target.value;
               // alert("value="+value);
                if(mytextvalue==="1-"){
                    //alert("value="+mytextvalue);
                }
               
    var charCode = (evt.which) ? evt.which : event.keyCode;
     if(charCode === 45 || charCode === 46 ){
       // alert("1");
       //var string = "Hello";
        var str = mytextvalue.substring(0, mytextvalue.length);
        //alert(str);
      document.getElementById("passwrd").value=str;
      //alert("value="+value);
        return false;
     }
    if (charCode > 31 && (charCode < 48 || charCode > 57) && !(charCode === 45 || charCode === 46 )){
        //alert("charCode="+charCode);
        //evt.preventdefault();
        return false;
        //setTimeout(function(){},1);
    }else{
        return true;
       // evt.preventdefault();
    }

    }
   
 
        </script>
       
       
        <div  id="login1">
    <label for="password">Password:</label>
    <input type="number" id="passwrd" pattern="[0-9]*" onkeypress="return isNumberKey(event);"/>
   
 
        </div>

</body>


</html>

Saturday, August 3, 2013

oracle create table

create table salaryExcel
(
    sal_id    NUMBER not null,
    start_date      DATE not null,
    end_date      DATE not null,
    ser_no   NUMBER not null,
    days   NUMBER not null,
    hours   NUMBER not null,
    additional_hours  NUMBER not null,
    rate   NUMBER not null,
    money_earned   NUMBER(9,2),
    paid_in_payroll  NUMBER(9,2),
    insurance  NUMBER(9,2),
    money_deducted  NUMBER(9,2),
    money_owed_to_us  NUMBER(9,2),
    already_paid NUMBER(1) not null check (already_paid in (0,1)),
    true_money_owed_to_us  NUMBER(9,2)
    );


create table moneyHeld(
  held_id NUMBER not null,
  amount_held NUMBER(9,2) not null,
  year_current NUMBER not null
);


Friday, February 15, 2013

sort compare

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package checkex;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 *
 * @author manju
 */
public class compareExample {
    public static void main(String[] args) {
        List<Person> persons = new java.util.ArrayList<Person>();
        persons.add(new Person("abc3", "def3", -10));
        persons.add(new Person("abc2", "def22", 32));
        persons.add(new Person("abc1", "def1", 65));
        persons.add(new Person("abc4", "def4", -10));
        persons.add(new Person("abc4", "def22", 10));
      
        System.out.println(persons);
        Collections.sort(persons, new Comparator<Person>() {

            @Override
            public int compare(Person t, Person t1) {
                //return t.getAge() - t1.getAge();
                        if(0 == t.getAge() || 0== t1.getAge() ){
            throw new NullPointerException();
        }else{
            int nameComparisonResult = t.getAge()-(t1.getAge());
            if(0 == nameComparisonResult){
                return t.getLname().compareTo(t1.getLname());
            }else{
                return nameComparisonResult;
            }
        }
            }
        });
        System.out.println(persons);

    }
  
}

Saturday, February 2, 2013