webview and jquery vs javascript clock

Discussion in 'Android Questions' started by aubete, May 8, 2013.

  1. aubete

    aubete Member Licensed User

    Hi!

    I try the webview, but the javascript not working. The js:

    Code:
    function twatch(){
      var ttm= $(
    "#acttm").text();
            var t= ttm.split(
    ":");
            var m;
      var s= Number(t[
    2]);
      var wrt= 
    true;

      
    if( s>=59 ){
        s= 
    0;
        m= Number(t[
    1]);
        
    if( m>=59 ){
          clearInterval(timerWatch);
          $.get(
    'index.php?a=0', function(data) {
            if(data.hiba==0){
              $(
    "#actdt").text(data.date);
              $(
    "#acttm").text(data.time);
            
    }
          }, "json");
          timerWatch= setInterval(function(){twatch()},1000);
          wrt= false;
        }
        else{
          m++;
        }
        t[1]= m.toString();
        if(m<10) t[1]= '0'+t[1];
      }
      else{
        s++;
      }
      if(wrt){
        t[2]= s.toString();
        if(s<10) t[2]= "0"+t[2];
        $("#acttm").text(t[0]+":"+t[1]+":"+t[2]);
      }
    }// twatch
    This is a "easy" watch. The inbuilt web browser, can use this. counting the seconds. but my webview can't.

    my code:

    Code:
    Sub Globals
       
    'These global variables will be redeclared each time the activity is created.
       'These variables can only be accessed from this module.
       Dim wv1 As WebView
       
    Dim wvs1 As WebViewSettings
       
    Dim wvx1 As WebViewXtender
       
    Dim wvxx1 As WebViewExtras
       
    Dim p1,p2 As Panel
       
    Dim l1, lx, ly As Label
       
    Dim timer1 As Timer
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
       
    'Do not forget to load the layout file created with the visual designer. For example:
       'Activity.LoadLayout("Layout1")
       wv1.Initialize("wv")
       
    Activity.AddView(wv1,0,0,99%x,99%y)
       
       wv1.JavaScriptEnabled = 
    True
       wv1.ZoomEnabled = 
    False
       wvs1.setDefaultZoom(wv1,
    "FAR")
       wvs1.setAppCacheEnabled(wv1,
    False)
       wvs1.setLightTouchEnabled(wv1,
    False)
       wvs1.setLoadWithOverviewMode(wv1,
    True)
       
    End Sub

    Sub Activity_Resume
       wv1.LoadUrl(
    "http://192.168.242.145/flyvision/index.php")
       wvx1.resumeTimers(wv1)
       wvx1.setJavaScriptEnabled(wv1, 
    True)
    '   wvxx1.addJavascriptInterface(wv1, "jsi")

    End Sub
    i try webviewextras, webviewsettings, webviewextend. but not counting that clock.

    TY

    AuBeTe
     
  2. warwound

    warwound Expert Licensed User

    Use WebViewExtras addWebChromeClient method.
    Run the JavaScript again and look at the device log - do you see any JavaScript errors logged?

    Martin.

    Sent from my HUAWEI U8815 using Tapatalk 2
     
  3. aubete

    aubete Member Licensed User

    The addWebChromeClient is the solution.

    But this the far zoom is not work perfectly. always draw a grey bar to the left and bottom on the screen The showed page and the phone's screen is perfectly same resolution

    AuBeTe

    Ps.: Sorry my english
     
  4. warwound

    warwound Expert Licensed User

    You have a layout problem in the webpage?
    If so you'll have to modify the webpage's CSS styles to suit your device screen.

    Martin.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice