samedi 31 décembre 2016

Why is client-side web still using an interpreted language?

To my knowledge JavaScript is the only language that will execute on the client side after the HTML file has been retrieved from the server. As far as I know JavaScript is by no means compiled in anyway and thus it is an interpreted language.

With Web becoming more and more popular, so much so that some say mobile and desktop applications will soon cease to exist.

We see new technologies like WebGL, that makes use of JS.

When I develop for WebGL I have to optimize so much more to achieve a reasonable performance benchmark, then what I would have to for PC or Console.

So why do we still use an interpreted client side language? Is it a security issue, hardware (cross platform) issue or is it simply because it's difficult to introduce such a large change into the web architecture? I know web developers have headaches over even the smallest and simplest changes, like using CSS 3, simply because not everyone has their browser up to date.

Am I correct in thinking that interperated languages are slower then compiled ones? Am I making sense or are my assumptions completely incorrect? I am by no means a JS/web expert, please educate me.




WebView failed to load all the js

http://ift.tt/2iuqTNV http://ift.tt/2iRtYEh

The first one is the WebView I created,but it is always loading,and fails to load the other is in the assets folder.

The second picture is using a browser to load,and it works well

I have already added setJavaScriptEnabled(true) ,setWebViewClient ,and setWebChromeClient, it doesn't change.

Can someone help me??




Reverse Google Image Search

I'm trying to reverse image search a url from an android app. The base url I'm using is:

http://ift.tt/2iumpqI

This works for most urls, however certain ones don't working from the app, for example with the url from a reddit post:

http://ift.tt/2ijG0tc

which becomes

http://ift.tt/2iRqEcj

But that says "The URL doesn't refer to an image, or the image not publicly accessible." However if I go to images.google.com and paste http://ift.tt/2ijG0tc manually it works perfectly fine. Any ideas why it would be having an issue with some urls and not others?




is there an api in Javascript that i can use to create a canvas where i can type in, drag images, and draw something?

So i have been working on a small web app where I need to achieve three functionalities: type text, copy/paste images (and drag them), and draw something with a draw tool. So far i came across HTML5 Canvas api that lets me achieve two of the functionalities i desire (i.e images and draw tool). However I am really having a hard time figuring out how to go about typing text dynamically on Canvas.I came across CanvasInput API which lets me draw a small textinput box on canvas but it is not useful since there are limited number of options. SO is there any other way i can achieve these three functionalities in javascript or in any other programming language? Thank You




What is the difference between web services/API and cloud services/API?

I have basic knowledge in web tech. I am learning. I came across this while going through GCM and APNS. I have searched before asking about this "comparision".




How can I pull a block of a pivot table off of a Google Sheet into a web frame?

I have a tree farm. I have a Google spreadsheet that has my inventory in the form that I took it.

I have Pivot table that summarizes that spreadsheet.

How can I run a query from the Blue Spruce description page on my website that pulls the appropriate blob off the pivot table on the spreadsheet?




How to make a website like Lonely Planet

First of all I apologise for violating the guidelines for questions on stackoverflow. But, I really don't know where else to go, googling did not help.

I want to make a tourism information website for my country. I have a bucket load of articles on different places and activities, and I want to put them all on the web. I want an interface that allows users to search for stuff by location, e.g. province>city>attraction. And also by type of experience or activity e.g. skiing or desert safari etc. For example see these links

http://ift.tt/93Sswb

and

http://ift.tt/2hAaGSP

What I don't know is how to go about doing it. Well I could imagine putting every articel in a wordpress post and assign categories and tags etc and then use those to display results according to the user's selection. I've also looked at wordpress knowledgebase, but most don't look very good at all and don't work well with themes either.

I feel like there should be a better (profound?) way to do this. I am at a dead end, may be because I can't quite condense what I want to do in to a single line, thus no good googling.

If any one could look at the websites above and tell me what I should be googling. Or if you could lead me to some tutorials etc. Just about anything is appreciated, really.




How can i tell the javascript in this html code not to influence all the buttons?

I have created a html website with bootstrap and jquery. I wanted, that a button change his label text and his design depending on a boolean variable. That worked with javascript. But I have this button (in green and blue) all over the page. Now either all buttons appear green or all buttons appear green.

Here is an example of what I mean with two buttons:

<div class="alert alert-danger" role="alert">
                                        <center><strong></strong></center>
                                    </div>

                                    <script>
                                        var open = true;

                                        if (open) {
                                            $(".alert").addClass("alert-success");
                                            $(".alert").removeClass("alert-danger");
                                            $(".alert").html("<center><strong>Geoeffnet</strong></center>");
                                        } else {
                                            $(".alert").removeClass("alert-success");
                                            $(".alert").addClass("alert-danger");
                                            $(".alert").html("<center><strong>Geschlossen</strong></center>");
                                        };

                                    </script>


<div class="alert alert-danger" role="alert">
                                        <center><strong></strong></center>
                                    </div>

                                    <script>
                                        var open = false;

                                        if (open) {
                                            $(".alert").addClass("alert-success");
                                            $(".alert").removeClass("alert-danger");
                                            $(".alert").html("<center><strong>Geoeffnet</strong></center>");
                                        } else {
                                            $(".alert").removeClass("alert-success");
                                            $(".alert").addClass("alert-danger");
                                            $(".alert").html("<center><strong>Geschlossen</strong></center>");
                                        };

                                    </script>

How can I stop, that this two buttons always have the same features?

Thank you, you help me a lot!




Avoiding simultaneous acces to a shared resource in a web application

I have a web application consisting of users having projects , projects belong to to a single user and are access by the URI:root/project/[pid] .

Now I have a middleware to restrict users from accessing each others projects. Although I also have a feature in my web application by which an user may share their projects with other users, so multiple users can access a single shared project.

The problem is I don't want them to access the same project simultaneously , say if project1 is shared by user1 and user2 . URI root/project/project1_id could be accessed by both but not at the same time .

I am currently thinking how I could do this , I have some ideas but wanted to know if there is best or easier way to do this.

I am thinking of altering the project table in the database to have an active flag which would be set to true every time any user accesses the project web page and unset when he/she leaves the webpage or the session ends.

But I have not sure if this would be the best way to go .

I am using laravel as a framework for my web application . So a solution within that framework would be great




How to integrate a html bootstrap code into a javascript code?

I wrote a html website. There is a button created with bootstrap. I want to change the design of the button and the label text on it, depending on a boolean variable.

Here are the two types of buttons:

<div class="alert alert-success" role="alert">
    <center><strong>Open</strong></center>
</div>

<div class="alert alert-danger" role="alert">
    <center><strong>Close</strong></center>
</div>

How can I integrate this html buttons in this javascript code?:

    <script>
    var open = true;

    if (open = true) {


    } else {

    }

</script>

Thanks for your help!




What tools do I need to learn to manipulate Excel files and update some values into a Web page?

To be more detailed, let's say I have an Excel file with some numerical values that need to be updated every day into a Web platform, and I would like to automate this process as it is very time consuming to do it manually. I know some basic Java but that's it, but I'm keen to learn what it takes to improve this process.




An html code to a website

I just learnt the basics of html . I wanted to know the different milestones in the development of an html code into a website . I did some googling and came across different pages . I got to know that there are something called as "frameworks " or "platforms " with names like Drupal , Wordpress etc which let websites to be developed in an easy way .

I haven't seen this platforms but I guess these platforms or frameworks run some codes in background which get triggered on some mouse clicks .(Please correct me If I am wrong ). Then I got to know about the choice of servers available and that we need to decide which server we want the website to run on .

Further , there are things like domains and host(These , along with servers, are somethings whose rigorous technical definitions are not known to me) . And I wonder how do we allocate a domain to a website and how do we relate it to a SQL or a DB for its operations ?

So , Can anyone explain in a nutshell what are the dots on the line to take a simple html(or maybe CSS Or Javascript) code into a website(Building from a scratch not by any platform ) and how to join those dots ? ( I hope , phrasing this question like " What does an html code ,written in a notepad need to have to become a website , will nearly mean the same thing ).




vendredi 30 décembre 2016

web data mining , from a web site without knowing the url

Please,How do i get a data from site e.g www.xyz.com I know the site has this data e.g a house image in the form of a download link . The challenge is i don't know the URL of the image all i know is the site plain url (xyz.com) .How do i get the URL without crawling the whole site assuming the site doesn't have a searchbox too . I know this is a web data mining problem but i really don't know an effective way to approach it .I thought about crawling the whole website but it seems ineffective.




Web GUI for python scripts

Lets say I have some scripts that I run on FreeBSD 11 (python or SH), they take some arguments, etc and return some metrics or console output messages, is it possible to write a Web GUI to provide a front-end for those scripts? Some way that it would let the user input the arguments (or pick from dropdown boxes) and display the output of the scripts.

I was reading around and cant find where to start. I would like the GUI to be visually appealing, so it can also show a Dashboard with gauges, for CPU, HDD and RAM.

I guess I need some sort of Web Server on the FreeBSD machine, and perhaps to create some site using some widgets, etc. Thanks.




Python Webscraping with BS4 and html not downloading correctly

I've been trying to web scrape information off the website: http://ift.tt/2iyCLeM

And the information I wanted were in the elements, with the class of "RecogniaEventSummaryBodyLinks"

But when I tried to download the html file and print it, it showed that the html file didn't download correctly. What I mean by this is that when I copied and pasted the whole html text I got from my python code into notepad++ and did CTRL+F to find if these elements were in the html text, they weren't there.

I also tried manually downloading the file directly from the website, but this also didn't work either.

Heres my code (python):

import mechanize
import cookielib
from bs4 import BeautifulSoup

def viewPage(url,proxy,userAgent):
    br = mechanize.Browser()
    cookieJar = cookielib.LWPCookieJar()
    br.set_cookiejar(cookieJar)
    br.set_proxies(proxy)
    br.addheaders = userAgent
    page = br.open(url)
    htmlFile = page.read()
    for cookie in cookieJar:
          print("cookie:  " + str(cookie))
          print("")
    return htmlFile

def ScrapeFigures(url):
    html = viewPage(url,proxyAdress,agentStringSample)
    soup = BeautifulSoup(html,"html.parser")
    info = soup.find("a",attrs={"class":"RecogniaEventSummaryBodyLinks"})  

I tried printing out variable info, but it returned null.

However, after this I tried copy & pasting the python output for the whole soup variable in the above code into another text file, and saved it as a html file. When I opened this html file with my web browser (Chrome), the elements I needed were on the page, despite not being present in the html file in text format. So I just wondered, is this caused by some sort of JS in the background thats triggered when the page is opened?

My question is, how can I scrape off the elements described above? Is there a way to get around this weird bug?

Thank you for your time




Laravel not installing dependencies incorrect php version

I cannot install all the laravel dependencies because of the php version but I'm using xampp with (PHP 7.0.13) using echo phpversion(); to determine my php version but this laravel keeps telling me that I'm using php version 5.4.24 when I'm installing a new laravel directory.

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\User>cd C:\xampp

C:\xampp>laravel new htdocs
Crafting application...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - This package requires php >=5.6.4 but your PHP version (5.4.24) does not satisfy that requirement.
  Problem 2
    - Installation request for classpreloader/classpreloader 3.1.0 -> satisfiable by classpreloader/classpreloader[3.1.0].
    - classpreloader/classpreloader 3.1.0 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 3
    - Installation request for laravel/framework v5.3.28 -> satisfiable by laravel/framework[v5.3.28].
    - laravel/framework v5.3.28 requires php >=5.6.4 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 4
    - Installation request for league/flysystem 1.0.32 -> satisfiable by league/flysystem[1.0.32].
    - league/flysystem 1.0.32 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 5
    - Installation request for nikic/php-parser v3.0.2 -> satisfiable by nikic/php-parser[v3.0.2].
    - nikic/php-parser v3.0.2 requires php >=5.5 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 6
    - Installation request for symfony/console v3.1.8 -> satisfiable by symfony/console[v3.1.8].
    - symfony/console v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 7
    - Installation request for symfony/debug v3.1.8 -> satisfiable by symfony/debug[v3.1.8].
    - symfony/debug v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 8
    - Installation request for symfony/event-dispatcher v3.2.1 -> satisfiable by symfony/event-dispatcher[v3.2.1].
    - symfony/event-dispatcher v3.2.1 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 9
    - Installation request for symfony/finder v3.1.8 -> satisfiable by symfony/finder[v3.1.8].
    - symfony/finder v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 10
    - Installation request for symfony/http-foundation v3.1.8 -> satisfiable by symfony/http-foundation[v3.1.8].
    - symfony/http-foundation v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 11
    - Installation request for symfony/http-kernel v3.1.8 -> satisfiable by symfony/http-kernel[v3.1.8].
    - symfony/http-kernel v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 12
    - Installation request for symfony/process v3.1.8 -> satisfiable by symfony/process[v3.1.8].
    - symfony/process v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 13
    - Installation request for symfony/routing v3.1.8 -> satisfiable by symfony/routing[v3.1.8].
    - symfony/routing v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 14
    - Installation request for symfony/translation v3.1.8 -> satisfiable by symfony/translation[v3.1.8].
    - symfony/translation v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 15
    - Installation request for symfony/var-dumper v3.1.8 -> satisfiable by symfony/var-dumper[v3.1.8].
    - symfony/var-dumper v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 16
    - Installation request for phpdocumentor/reflection-common 1.0 -> satisfiable by phpdocumentor/reflection-common[1.0].
    - phpdocumentor/reflection-common 1.0 requires php >=5.5 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 17
    - Installation request for phpdocumentor/reflection-docblock 3.1.1 -> satisfiable by phpdocumentor/reflection-docblock[3.1.1].
    - phpdocumentor/reflection-docblock 3.1.1 requires php >=5.5 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 18
    - Installation request for phpdocumentor/type-resolver 0.2.1 -> satisfiable by phpdocumentor/type-resolver[0.2.1].
    - phpdocumentor/type-resolver 0.2.1 requires php >=5.5 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 19
    - Installation request for phpunit/php-code-coverage 4.0.4 -> satisfiable by phpunit/php-code-coverage[4.0.4].
    - phpunit/php-code-coverage 4.0.4 requires php ^5.6 || ^7.0 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 20
    - Installation request for phpunit/phpunit 5.7.5 -> satisfiable by phpunit/phpunit[5.7.5].
    - phpunit/phpunit 5.7.5 requires php ^5.6 || ^7.0 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 21
    - Installation request for phpunit/phpunit-mock-objects 3.4.3 -> satisfiable by phpunit/phpunit-mock-objects[3.4.3].
    - phpunit/phpunit-mock-objects 3.4.3 requires php ^5.6 || ^7.0 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 22
    - Installation request for sebastian/code-unit-reverse-lookup 1.0.0 -> satisfiable by sebastian/code-unit-reverse-lookup[1.0.0].
    - sebastian/code-unit-reverse-lookup 1.0.0 requires php >=5.6 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 23
    - Installation request for sebastian/environment 2.0.0 -> satisfiable by sebastian/environment[2.0.0].
    - sebastian/environment 2.0.0 requires php ^5.6 || ^7.0 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 24
    - Installation request for sebastian/object-enumerator 2.0.0 -> satisfiable by sebastian/object-enumerator[2.0.0].
    - sebastian/object-enumerator 2.0.0 requires php >=5.6 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 25
    - Installation request for sebastian/resource-operations 1.0.0 -> satisfiable by sebastian/resource-operations[1.0.0].
    - sebastian/resource-operations 1.0.0 requires php >=5.6.0 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 26
    - Installation request for sebastian/version 2.0.1 -> satisfiable by sebastian/version[2.0.1].
    - sebastian/version 2.0.1 requires php >=5.6 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 27
    - Installation request for symfony/css-selector v3.1.8 -> satisfiable by symfony/css-selector[v3.1.8].
    - symfony/css-selector v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 28
    - Installation request for symfony/dom-crawler v3.1.8 -> satisfiable by symfony/dom-crawler[v3.1.8].
    - symfony/dom-crawler v3.1.8 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 29
    - Installation request for symfony/yaml v3.2.1 -> satisfiable by symfony/yaml[v3.2.1].
    - symfony/yaml v3.2.1 requires php >=5.5.9 -> your PHP version (5.4.24) does not satisfy that requirement.
  Problem 30
    - nikic/php-parser v3.0.2 requires php >=5.5 -> your PHP version (5.4.24) does not satisfy that requirement.
    - psy/psysh v0.8.0 requires nikic/php-parser ~1.3|~2.0|~3.0 -> satisfiable by nikic/php-parser[v3.0.2].
    - Installation request for psy/psysh v0.8.0 -> satisfiable by psy/psysh[v0.8.0].

Application ready! Build something amazing.

C:\xampp>




Mange sessions between client and server

How to Mange sessions between client and server either by cookies or url rewrite management What will happen if i manged session using cookies and then i logged in from different browser? does it will support ?




Is it possible to run compiled as opposed to interpreted code on web browser

I would like to implement a fast web based math plotting tool which allows the animation of math functions in real time, the feature is very demanding in terms of performance especially with expensive math functions and I'm wondering if there's a way to implement it using compiled code that would run on a web browser (client side). Reason is the performance gain of compiled language (such as C++, Java, etc..) over javascript (interpreted at runtime) would be huge.

A quick Google research pointed Nacl... not really a good fit since it has no support for basic graphic operations such as drawing pixels, lines, shapes etc..

Note that I already implemented a desktop standalone proof of concept using java, it looks great but desktop is old fashion obviously.




Convert Google form to PHP code?

Is there a way to convert a Google form with multiple sections (with GOTOs questions) directly to multiple webpage (one per section) ?

In fact, I want to retrieve user's inputs directly into the web page and without storing answers in a Google sheet.

Sorry for my bad english, Thank you per advance !




Graceful degradation / Progressive Enhancement best practices

What are some best practices in handling graceful degradation/ progression enhancements while developing a website. For example, is it better to use conditional html tags to load some javascript:

<--[if IE]>
   <script>ieScript.js</script>
<[endif]-->

or is it better to use try catches?

try{
   nonIeCompatibleCode();
} catch(){
   ieCompatibleCode();
}




Storing images in a directory - Spring MVC

I am a beginner using Spring MVC , i am developing a social network android application. The user should have the ability to upload posts in news feed.

The each post can have maximum one image attached , so i need to store image files on server.

I have already implemented an example of the upload process using RestTemplate :

FormHttpMessageConverter formHttpMessageConverter = new FormHttpMessageConverter();
    formHttpMessageConverter.setCharset(Charset.forName("UTF8"));

    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add( formHttpMessageConverter );
    restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
    restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());


    MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
    map.add("file", new FileSystemResource(path)); /* path - is the path of the
                                                        image i want to upload */
    map.add("username","user1");

    HttpHeaders imageHeaders = new HttpHeaders();
    imageHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
    HttpEntity<MultiValueMap<String, Object>> imageEntity = new HttpEntity<>(map, imageHeaders);
    restTemplate.exchange(messageURL, HttpMethod.POST, imageEntity, Boolean.class);

And on the Spring MVC side :

@RequestMapping(value = "/uploadPhoto/{id}", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<String> uploadPhoto(@RequestParam("file") MultipartFile srcFile,
                                           @PathVariable("id") Integer id,
                                           @RequestParam("username") String username)
{
    System.out.println("Photo name = "+srcFile.getName());
    System.out.println("Photo size = "+srcFile.getSize());
    System.out.println("Photo original name = "+srcFile.getOriginalFilename());
    System.out.println("Username = "+username);


    String uploadsDir = "/uploads/";


    String realPathtoUploads =  context.getRealPath(uploadsDir);
    if(! new File(realPathtoUploads).exists())
    {
        new File(realPathtoUploads).mkdir();
    }



    String orgName = srcFile.getOriginalFilename();
    String filePath = realPathtoUploads + orgName;
    File dest = new File(filePath);
    try 
    {
        srcFile.transferTo(dest);
    } 
    catch (IllegalStateException | IOException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


    return null;
}

This code works, using it i can upload a photo from the phone storage to the server, but, the problem is that i want to get the URL for the uploaded photo, in order to save it on database and to be able to download it in the future, how can i do that ?




Angular 2, Update a component from another

Angular2 it's a new technology for me and I have some problems ... I have 2 components:

  1. user login form
  2. connect/disconnect button

My App screen shoot

I would like when I connect with the form, that my component 1 says to my component 2: "Get up to date!". Knowing that to update itself it must request a web service that it already makes when the component 2 initializes.

How do I call my LoginButtonComponent in my LoginComponent?

LoginComponent

import { Component, OnInit }        from '@angular/core';
import { FormBuilder, Validators }  from '@angular/forms';
import { LoginService }             from './login.service';
import {Router}                     from '@angular/router';


@Component({
  selector: 'app-login',
  providers: [LoginService],
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {

  errorMessage: string;
  strings: String[];
  mode = 'Observable';

  public loginForm = this.fb.group({
    mail: ["", Validators.required],
    password: ["", Validators.required]
  });  

  constructor(public fb: FormBuilder, private loginService: LoginService, private router : Router) { }

  ngOnInit() {
    
  }

  login(event){
    this.loginService.login(this.loginForm.value)
      .subscribe(
        success => {
          this.router.navigate(['/']);
        },
        error => function(){}
      );
  }

 

}

LoginButtonComponent

import { Component, OnInit } from '@angular/core';
import { LoginService }      from '../login.service';
import {Router} from '@angular/router';


@Component({
  selector: 'app-login-button',
  templateUrl: './login-button.component.html',
  styleUrls: ['./login-button.component.css']
})
export class LoginButtonComponent implements OnInit {

  errorMessage: string;
  mode = 'Observable';
  public isConnected : boolean;
  public message = "Connectez vous !";

  constructor(private loginService: LoginService, private router : Router) { 
    this.isConnected = false;
  }

  

  ngOnInit() {
    this.connect();  
  }


  setLogin(){
    this.isConnected = true;   
    this.message = "Se déconnecter";
  }

  setLogout(){
    this.isConnected = false;
    this.message = "Connectez vous !";
  }

  connect(){
    /**
     * Send query to web service
     *  web service returns 200 on success and 401 on failure
     *  */
    this.loginService.connected()
    .subscribe(
        str  => {
          this.setLogin();
        },
        error =>  function(){
          this.setLogout();
        });

  }

  

  logout(){
    this.loginService.logout()
      .subscribe(
          str  => this.setLogout,
          error =>  function(){
            this.errorMessage = <any>error;
            this.setLogout();
          });
        this.connect();
  }

  click(){
    this.ngOnInit;
    if(this.isConnected){
      this.logout();          
    }else{
      this.router.navigate(['/login']);
    }
  }

}
<li>
  <a (click)="click()"><i class="fa fa-user-circle"></i> </a>          
</li>

Thank you for your help.




deploying WT web app on google cloud

I have build a wt (witty) hello world example and I am trying to deploy this on a Google Cloud instance. It seems to run fine locally (hence it has all the necessary library dependencies). However, I am not able to it to deploy on the server.

I am trying (using my actual http address which is different from the example below)

./hello --docroot . --http-address 105.150.47.754 --http-port 80

but it responds with

Error (asio): bind : cannot assign requested address

It seems to work fine using (0.0.0.0/0)

The cloud instance allows HTTP tcp/80 traffic.

I have tried

setcap 'cap_net_bind_service=+ep' ~/hello

to allow non-root users to publish on ports below 1024, but also to no avail.

Any suggestions?

Cheers, Mike




My ` ` sizes are different on different pages

On my home page the dropdown ul looks exactly how I want it to: The home page dropdown

But on all my other pages the ul looks much bigger like this: Another page's dropdown

Here is the HTML for the home page:

<header id="header" class="alt">
            <h1><strong><a href="index.html">South Somerset Motocross Club</a></strong></h1>
            <nav id="nav">
                <ul>
                    <li><a href="index.html">Home</a></li>
                    <li><a>Info</a>
          <ul class="alt">
                            <li><a href="pages/info/clubrules.html">Club Rules</a></li>
                            <li><a href="pages/info/preracecheck.html">Pre-Race Bike Check</a></li>
                            <li><a href="pages/info/jobdescriptions.html">Job Descriptions</a></li>
                            <li><a href="pages/info/racefees.html">Race Fees</a></li>
                            <li><a href="pages/info/groupsandages.html">Groups And Ages</a></li>
          </ul>
        </li>
                    <li><a>About Us</a>
                        <ul class="alt">
                            <li><a href="pages/aboutus/ourheritage.html">Our Heritage</a></li>
                            <li><a href="pages/aboutus/committee.html">Committee</a></li>
                        </ul>
                    </li>
                    <li><a href="pages/news/news.html">News</a></li>
                    <li><a href="pages/fixtures.html">Fixtures</a></li>
                </ul>
            </nav>
        </header>

Here is the HTML for the other page:

<header id="header">
            <h1><strong><a href="../../index.html">South Somerset Motocross Club</a></strong></h1>
            <nav id="nav">
                <ul>
        <li><a href="../../index.html">Home</a></li>
                    <li><a>Info</a>
          <ul class="alt">
                            <li><a href="clubrules.html">Club Rules</a></li>
                            <li><a href="preracecheck.html">Pre-Race Bike Check</a></li>
                            <li><a href="jobdescriptions.html">Job Descriptions</a></li>
                            <li><a href="racefees.html">Race Fees</a></li>
                            <li><a href="groupsandages.html">Groups And Ages</a></li>
          </ul>
        </li>
                    <li><a>About Us</a>
                        <ul class="alt">
                            <li><a href="../aboutus/ourheritage.html">Our Heritage</a></li>
                            <li><a href="../aboutus/committee.html">Committee</a></li>
                        </ul>
                    </li>
                    <li><a>News</a></li>
                    <li><a href="../fixtures.html">Fixtures</a></li>
                </ul>
            </nav>
        </header>

Here is the CSS for both:

#header {
    background-color: #fff;
    border-bottom: solid 1px rgba(144, 144, 144, 0.25);
    box-shadow: 0px 0.0375em 0.125em 0px rgba(0, 0, 0, 0.05);
    color: #000;
    cursor: default;
    font-size: 1.25em;
    height: 4.5em;
    left: 0;
    line-height: 4.4em;
    position: fixed;
    text-transform: uppercase;
    top: 0;
    width: 100%;
    z-index: 10000;
    z-index: 10001;
}

#header a {
    color: #000;
}

    #header h1 {
        color: #000;
        font-weight: 400;
        height: inherit;
        left: 1.25em;
        line-height: inherit;
        margin: 0;
        padding-left: 10px;
        padding-right: 10px;
        position: absolute;
        top: 0;
    }


    #header nav {
        height: inherit;
        line-height: inherit;
        position: absolute;
        right: 1.25em;
        top: 0;
        vertical-align: middle;
    }

        #header nav ul {
            list-style: none;
            margin: 0;
            padding-left: 0;
        }

            #header nav ul li {
                color: #fff;
                display: inline-block;
                padding-top: 0;
                padding-bottom: 0;
                padding-left: 10px;
                padding-right: 10px;
                margin-left: 1em;
            }


            #header nav ul li ul {
                display: none;
                padding: 0;
                margin: 0;
                background-color: #eee;
                border-radius: 4px;
            }

            #header nav ul li:hover ul {
                display: block;
                position: absolute;
            }

            #header nav ul li ul li {
                border-radius: 4px;
                margin: 0 0 0 0;
                padding-left: 4px;
                padding-top: 0;
                padding-right: 50px;
                display: block;
                color: black;
                font-size: 12pt;
            }

        #header nav ul li ul li a {
            color: #111;
            padding: 0;
            margin: 0;
            display: block;
        }

        #header nav ul li ul li a:hover {
            color: rgba(255, 255, 0, 1);
        }

        #header.alt nav ul li ul li a:hover {
            color: rgba(255, 255, 0, 1);
        }

        #header.alt nav ul li ul li:hover {
            background-color: #3477ff;
        }

        #header nav ul li ul li:hover {
            background-color: #3477ff;
        }

        #header.alt nav ul li ul li a {
            color: #000;
            padding: 0;
            display: block;
        }


                #header nav ul li a {
                    -moz-transition: color 0.1s ease-in-out;
                    -webkit-transition: color 0.1s ease-in-out;
                    -ms-transition: color 0.1s ease-in-out;
                    transition: color 0.1s ease-in-out;
                    color: #000;
                    display: inline-block;
                    text-decoration: none;
                }

                    #header nav ul li a:hover {
                        color: #000;
                    }


                #header nav ul li .button {
                    border-color: rgba(144, 144, 144, 0.25);
                    box-shadow: none;
                    height: 3em;
                    line-height: 2.9em;
                    margin-bottom: 0;
                    padding: 0 1.5em;
                    position: relative;
                    top: -0.075em;
                    vertical-align: middle;
                }

    #header .container {
        position: relative;
    }

        #header .container h1 {
            left: 0;
        }

        #header .container nav {
            right: 0;
        }

    #header.alt {
        background-color: transparent;
        border: 0;
        box-shadow: none;
        height: 3.25em;
        line-height: 3.25em;
        position: absolute;
    }

        #header.alt h1 {
            color: #ffffff;
            left: 2.5em;
            top: 2em;
        }

            #header.alt h1 a {
                color: #FFF;
            }

        #header.alt nav {
            right: 2em;
            top: 2em;
        }

            #header.alt nav a {
                color: #ddd;
            }

                #header.alt nav a:active, #header.alt nav a:hover {
                    color: #FFF;
                }

        #header.alt .button {
            border-color: rgba(255, 255, 255, 0.5);
            color: #ffffff !important;
        }

    @media screen and (max-width: 980px) {

        #header {
            display: none;
        }

    }

I would like the other page's <ul> elements to be the same size as the home page but I can't seem to find any extra margins or padding on them.




How do I convert a ASP.NET method to ASP.NET .asmx web service

I have following asp.net method which I want to convert it into .asmx web service. How I can do that. Any help please. public ActionResult AddCpty(string Id, string Type) { //code for Addcp return result; }

I am trying to convert it by putting a [WebMethod] attribute on the top of the method.

[WebMethod] public ActionResult AddCpty(string Id, string Type) { //code for Addcp return result; }




REST API - What to return when search criteria (queryParams) doesn't yield any results

I am designing a REST API and throughout the API we have used HTTP Not found / 404 when an object/resource we are trying to access doesn't exist.

Ex: http://host/someobject/1

But the current one scenario is little different. I have the URI which searches the data with query parameters.

Ex: http://host/someObject/find?param1=param1value&param2=param2value

The query parameters are optional but at least one criteria must be provided for successful request. I am currently returning empty list when search result is empty assuming the URI exists but data not present at the moment.

Can any one shed some light on this scenario ? Should I return empty array with Status code 200 or something else ?




Laravel PHP Fatal error: Uncaught Error: Class

I'm very new with laravel and i am working on a project to manage images. I can handle the input when im uploading the files by drag and drop, everything right. Now i have a smartphone app, where i can send the images to the server. I can send the images to my server, and save them.

I have 2 scripts for this:

  1. login.php -> checks user data
  2. upload.php -> handels images

The app requires an url to the file : http:\ip\myproject\server\php\upload.php

Now im trying to integrate this 2 files in my laravel project, so i created a new folder under app with the files: App\server\php\files

In my Controller class is a method which takes the info from the images and write them into the database. I use this method when i upload the images on the web-page.

My Problem: When i try to call the method in my php file, i get an error in my apache2 error.log where he says that i can not find the controller class. I tried to include the class, but still getting an error. I don't know what is my error and i hope u guys can give a tip for the solution.

This is my controller method:

public  function autoupload($filepath){

    $file = $filepath;
    $filename = basename($file);

    if (!file_exists('study/images')) {
        mkdir('study/images', 0777, true);
    }
    $file->move('study/images', $file);

    if (!file_exists('study/images/thumbs')) {
        mkdir('study/images/thumbs', 0777, true);
    }

    $thumb = Image::make('study/images/' . $filename)->resize(240, 160)->save('study/images/thumbs/' . $filename, 60);

    /*Split Filename into Tokens
    A_123_22-10-2016_12-05_R.jpg
    * Array =
     * 0 = Studienkrzl
     * 1 = ProbandenNummer
     * 2 = Datum
     * 3 = Uhrzeit
     * 4 = Kat.
     */

    //22-10-2016 12-05 Datetime Format
    $filename_tokens = explode('_', $filename);

    $temp = $filename_tokens[2].' '.$filename_tokens[3];

    $dateTime = \Datetime::createfromformat('d-m-Y H-i',$temp);

    $study_krzl = substr($filename, 0, 2);

    //save image details in database
    $study = Study::where('study_short','=',$study_krzl)->get();
    $image = $study->images()->create([
        'study_id' => $study->study_id,
        'file_name' => $file,
        'date' => $dateTime,
        'file_size' => $file->getClientSize(),
        'file_path' => 'study/images/' . $filename,
        'patient' => $filename_tokens[1],
        'category' => basename($filename_tokens[4], ".jpg"),
        'study_short' => $study_krzl,
    ]);
}

This is my upload.php

--> http://ift.tt/2ifbRem

Why i cant call the method in the end of the file ??




The in my nav extends to the side of the page

I have a nested <ul> within my nav ul. When the <ul> has only one element its padding is fine and the <li> fits nicely. However when I have more than one element in the nested <ul> it extends to the side of the page. I can see nothing to do with padding changes in my :first-child or anything in my css for the nested <ul>.

The nested ul with multiple elements The nested ul with multiple elements

The nested ul with only one element The nested ul with only one element

Any ideas on how I can keep the width of the <ul> to the max length of one of the items?




jeudi 29 décembre 2016

How can I get all of the text and the Search Bar on the same line?

Ok I'm trying to re-create the BBC website. In the process when I tried to add the search bar it seemed to wrap my top bar under itself, and I'm not sure how to fix the issue. I'll post the code (about 120 lines, not much) and a link to the reference site and hopefully somebody out there knows how to deal with this.

http://ift.tt/1gbv2PA ---- all I'm trying to do at the top bar that will take you to other portions of the website (i.e. the top tabs labelled "News, Sports, Weather,...etc." But like i said the code makes my search bar wrap down.My code.

<head>  

    <meta charset="utf-8">
        <title>Technology - BBC News</title>

        <style type="text/css">

            #topbar {
                width:800px;
                margin: 0 auto;
                height: 40px;
            }


            body {
                margin: 0 auto;
                padding: 0;
                font-family: Helvetica, Arial, sans-serif;
            }

            #logo {
                margin-top: 8px;
                float: left;
                margin-right: 8px;
            }

            .topbar-section {
                float:left;
                border-left: 1px #CCCCCC solid;
                height:100%;

            }

            #signin-text {
                font-weight: bold;
                font-size: 90%;
                position:relative;
                top:11px;
                padding-right: 65px;

            }

            #signin-image {
                width:25px;
                margin: 9px 15px;
                float:left;

            }

            .topbar-menu {
                    font-weight: bold;
                    font-size: 80%;
                    padding: 10px 14px 0px 14px;
                    height: 27px;
                }

            #more-arrow {
                width:6px;
                margin-left: 65px;
            }

            #search-box {
                background-color: #E4E4E4;
                border: none;
                font-weight:bold;
                font-size: 14px;
                padding:5px;
                margin:7px 0px 7px;
                float:left;
            }

            #search-icon {
                height: 26px;
                margin-top: 7px;
                background-color:#E4E4E4;
            }

        </style>

            <body>

                <div id="topbar">

                    <img id="logo" src="images/bbc-blocks-dark.png">



                    <div id="signin-div" class="topbar-section">

                        <img id="signin-image" src="images/signinimage.png">

                        <span id="signin-text">Sign in</span>

                    </div>

                    <div class="topbar-section topbar-menu">

                        News

                    </div>

                    <div class="topbar-section topbar-menu">

                        Sport

                    </div>

                    <div class="topbar-section topbar-menu">

                        Weather

                    </div>

                    <div class="topbar-section topbar-menu">

                        Shop

                    </div>

                    <div class="topbar-section topbar-menu">

                        Earth

                    </div>

                    <div class="topbar-section topbar-menu">

                        Travel

                    </div>

                    <div class="topbar-section topbar-menu">

                        More

                        <img id="more-arrow" src="images/more-arrow.png"

                    </div>

                    <div class="topbar-section topbar-menu">

                        <input id="search-box" type="text" value="Search">

                        <input type="image" id="search-icon" src="images/search-icon.png">

                    </div>


                </div>

            </body>

</head>




Creating an audit trail on php

What is the best way on implementing an audit trail on multiple tables which requires an audit trail?

This is so far what I've done. It's too much work if I put the same column on other tables repeatedly. Is there a better way to achieve than this approach?

[Users Table]
id
user_id
username
password
first_name
middle_name
last_name
email_address
is_active
date_and_time_activated
activated_by
date_and_time_deactivated
deactivated_by
date_and_time_created
created_by
date_and_time_modified
modified_by
is_locked
date_and_time_locked
locked_by
is_deleted
date_and_time_deleted
deleted_by
date_and_time_restored
restored_by

[IP Addresses Table]
id
ip_address
subnet_mask
name
description
is_active
date_and_time_activated
activated_by
date_and_time_deactivated
deactivated_by
date_and_time_created
created_by
date_and_time_modified
modified_by
is_locked
date_and_time_locked
locked_by
is_deleted
date_and_time_deleted
deleted_by
date_and_time_restored
restored_by




VAT Percentages calculator

I made a simple VAT calculator that when you put a price in without VAT it calculates the 20% TAX on it and then if you put a price with the VAT on it it will take it off to show you the true cost of the item.

So when I input £100 it shows that with VAT its £120. I then for example place the £120 price into the next setting which removes the VAT from the price, 20% of £120 is £24 not £20... how? How is £100 at 20% £120 but then £120 without the 20% £96? I feel like i'm brain damaged or something, jesus. I just cant figure it out!!




PHP code not running (XAMP(latest version))

I have checked the php.ini file for common default_mimetype="text.html". And this is so strange because I it was working fine in earlier stages of my studies on the same machine. Using xampp 7.x




Which language replace javascript in client side, WEB? [duplicate]

For server side we find c php ruby perl .... But for client side what are the languages that exist ?




what language would I use?

I'm trying to make a program/ app/ web page ( i'm not sure what would be the best way to do this) for myself and my fellow installers to use. The "thing" would have drop downs for who we are billing, what we installed, what kind of car. it would keep track of what we used that day and be able to email a list of what we had done to the office for billing. 1) can I do this as a web site and keep track of each installers different product and usage? 2) should it be a stand alone program able to be used by each person? If so what language would be best for something like this?




Race condition on website deployment

Say I have a website with 2 files, which are statically hosted on S3:

  1. index.html
  2. script.js

I have a scheme where these files are updated via a git pull from a remote origin every time I push. This got me thinking, though, that there's the possibility for a request to be made to the server as a git pull is happening to update the files. This seems like it could create two problems that would cause page errors:

  1. A partially-updated index.html or script.js is returned.
  2. An old index.html is returned to the client. The files are then updated on the server. The client then makes a request for script.js, which returns the new version.

What is a good practice for mitigating these two issues?

I imagine the first issue won't be a problem, assuming filesystem operations are atomic and the files are updated in a single go. However, I haven't seen anything that addresses the second issue, which seems more difficult to address.




ajax status custom jsf 2 update from bean

I have a slow process with about 10 steps, and I would like to inform the user in which step the process is, I would like to update some msg on the screen with each process.

I tried the following way but I did not succeed, because only the last msg is rendered, and then it executes the whole process. I made an outputext and a binding called msgAjax, has anyone had it or do you know how to solve it?

public void processar(Sigtap sigtap) {
    try {
        this.sigtap = null;
        this.sigtap = sigtap;
        if (sigtap != null) {
            RequestContext context = RequestContext.getCurrentInstance();
            msgAjax.setValue("Baixando arquivo sigtap..");
            context.update("msgAjax:painel");
            Download.gravaArquivoDeURL(sigtap.getUrl(), path + sigtap.getCompetencia().getDescricao() + "\\", sigtap.getCompetencia().getDescricao() + ".zip");
            msgAjax.setValue("Extraindo arquivo..");
            context.update("msgAjax:painel");
            Download.unZipIt(path + sigtap.getCompetencia().getDescricao() + "\\" + sigtap.getCompetencia().getDescricao() + ".zip", path + sigtap.getCompetencia().getDescricao() + "\\");
            session = HibernateUtil.currentSession();
            financiamentoDao = new FinanciamentoDao(session, Financiamento.class);
            msgAjax.setValue("Financiamento");
            context.update("msgAjax:painel"); 




How to start a website for college project

I have developed a simple website as my academic project using Xampp server which works on only one computer ! But now I am planning to create a website for the same project ! So how to start with and how to get the server for my website ??




Python , Web Parsing

I was watching a tutorial on web paring in python .

   import re
   import urllib.request

    # http://ift.tt/TcXbw1
    url = "http://ift.tt/TcXbw1"
    stock = input("Enter Your Stock : ")
    url = url + stock
    data = urllib.request.urlopen(url).read()
    newData = data.decode('utf-8')
    # meta itemprop="price"
    m = re.search('meta itemprop="price"', newData)
    start = m.start()
    end = start + 50
    newStock = newData[start:end]
    m = re.search('content="', newStock)
    start = m.end()
    newStock1 = newStock[start:]
    m = re.search('/', newStock1)
    start = 0
    end = m.end() - 3
    final = newStock1[0:end]
    print("The Value Of " + stock + " Is " + final)

There is no error but I dont understand these parts :

    start = m.start()
     end = start + 50 

    start = 0
   end = m.end() - 3

Can anyone give me an explanation ? Please elaborate




How to get live data from a cell in Excel to a webpage for statistical purposes?

I want a variable on a webpage to update live each time a cell in an Excel file gets updated. Kind of like a live counter. Any ideas? Maybe through JavaScript or something?

Thanks.




Node, JSDOM, TinyMCE Script loading works in strange scenario only

I am running a node script with JSDOM, and attempting to load tinyMCE.

var fs = require('fs');
var jsdom = require("jsdom");
jsdom.defaultDocumentFeatures = {
  FetchExternalResources   : ['script'],
  ProcessExternalResources : ['script'],
  MutationEvents           : '2.0',
};

var tiny = fs.readFileSync("./node_modules/tinymce/tinymce.min.js", "utf-8");
var editors;
var tinyDoc = jsdom.env({
  html: "<p id='textarea'></p>",
  src: [tiny],
  scripts: ["//cdn.tinymce.com/4/tinymce.min.js"],
  done: function (err, window) {
    console.log(window.tinymce);
  }
});

According to the JSDOM documentation, http://ift.tt/t1YGLW we can either use src OR script, to grab from a url or in this case CDN. If, I do one without the other, logging window.tinymce returns undefined. Logging tiny, simply returns the string representation of the script, and therefore I cannot call any of it's methods. This implementation should not work.

What exactly is going on here. Attempting to load something like JQUERY by the way works exactly as intended and described by the JSDOM documentation.

Here is the link to the tinymce docs on how to load it under NPM. http://ift.tt/2ii1nIZ

Additonal Info- logging the window object, reveals that tinymce is added as a property to the window object twice, which at least makes sense, since the script is being included both through the, src option, and the scripts option. But again I would love to understand why it is not being added to the window object without having both.




How to get create your real-work simple server on Python

I am writing simple app with using Python socket lib. I wrote a simple Server and Client. On my local computer is works. But I want to send Client app to my friend. The problem is here:

Server:
HOST = "127.0.0.1"
port = 3010
serverSocket.bind((HOST, port))

Client:
HOST = "127.0.0.1"
port = 3010
clientSocket.connect((HOST, port))

When this apps run on my local machine it is ok. But what HOST should be to make possible communicate with MY computer from other computer?




which is better href="#" or href="javascript:void();" [duplicate]

which is better href="#" or href="javascript:void();" in terms of all aspects

like user experience, speed etc

is it necessary to put a 0 inside void when using href="javascript:void();" .like this href="javascript:void(0);"




How to make iOS lock screen animation on JS/CSS?

How to can I do animation like this ( slide to unlock) at JavaScript / CSS ??? enter image description here




How To Redirect Whole site to another site except the Root Page

I want to redirect every url of my site except the root i.e., the home index.html

Basically I want everything after the / to redirect.

For example: If I visit website.com it should normally show the index.html page placed in the root. But if I goto website.com/someurl then it should redirect to website2.com/someurl

The site shouldn't redirect only for the root (home) page, and Should redirect for all other links.

Please help me with the relevant .htaccess code.

Thank You




why is external css applied randomly?

I'm trying to style my web page with an external CSS file, but there is a problem I have never faced before. That external CSS is sometimes applied and sometimes not. I'm getting different outputs by the time I refresh the page. How can I solve the problem? When I use inline CSS there is no problem.




mercredi 28 décembre 2016

How to start learning Node js

I have learned PHP and basics of javascript. Now, I want to start learning node js. where should I start from? And which resources should I learn for node js? can anyone help? Thanks in advance.




firebase for web - how to resize image on upload

There are instructions here as to how to upload files in Firebase. But the issue is how to resize images when we upload it in firebase from a webpage. I could not find any method in the Firebase API . And no need to paste any code here as well I think.

Shouldn't I try to resize it after I upload the image ? How to do that ?




description The requested resource is not available. Tomcat 7.0

I am getting this error while running an app with Tomcat

HTTP Status 404 - /ResumeParsingEngine/

type Status report

message /ResumeParsingEngine/

description The requested resource is not available.

My web.xml is as below

Resume Parsing Engine

<servlet>
    <servlet-name>resume-parser</servlet-name>
    <servlet-class>
        com.sun.jersey.spi.container.servlet.ServletContainer
    </servlet-class>

    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.mtc.resume</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
        <param-value>true</param-value>
    </init-param>

    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>resume-parser</servlet-name>
    <url-pattern>/engine/*</url-pattern>
</servlet-mapping>




CSS Background placement

.container {
    width: 800 px;
    margin: 0 auto;
}
#main {
    background: url(images/header_slice.jpg) repeat-x;
}
#main.container {
    background: url(images/header.jpg) no-repeat;
}
#sidebar {
    float: left;
}
#sidebar h3 {
    font-size: 24px;
    color: #044055;
    font-weight: normal;
}
#sidebar ul li a {
    font-size: 14px;
    color: #393838;
}
ul#subscribe li a {
    font-size: 18px;
    padding-left: 30px;
}
#sidebar ul {
    list-style: none;
}
#sidebar {
    float: left;
    margin-left: 155px;
    margin-top: 35px;
    background: #d4d6d3;
    border: 1px solid #BEBDBD;
    padding: 15px 15px 30px 30px;
}
#sidebar h3 {
    font-size: 24px;
    color: #044055;
    font-weight: normal;
    padding-bottom: 20px;
    padding-left: 15px;
}
#sidebar ul {
    list-style: none;
    padding-bottom: 25px;
}
#sidebar ul li a {
    font-size: 14px;
    color: #393838;
}
ul#subscribe li {
    padding-bottom: 5px;
}
ul#subscribe li a {
    font-size: 16px;
    padding-left: 40px;
}
ul#subscribe li {
    padding-bottom: 5px;
    padding-left: 35px;
}
li#rss {
    background: url(images/rss_icon.png) no-repeat;
    background-size: 20px;
}
li#email {
    background: url(images/email_icon.png) no-repeat;
    background-size: 20px;
}
li#twitter {
    background: url(images/twitter_icon.png) no-repeat;
    background-size: 20px;
}

I was learning how to make a basic website from: http://ift.tt/1h19RSO The header background from the container isn't loading.

enter image description here

Also the the sidebar icons are being overlapped by the text. I tried adding padding in the sidebar anchor but it didn't work. What am I doing wrong?




web deployment task during the web hosting in myasp.net site

web deployment failed in myasp.net

during the web deployement in myasp.net there is an error showing Error 1 Web deployment task failed. ((12/29/2016 10:55:55 AM) An error occurred when the request was processed on the remote computer.)

(12/29/2016 10:55:55 AM) An error occurred when the request was processed on the remote computer. An error was encountered when processing operation 'Create Directory' on 'site1'.

I/O error occurred. 0 0 Test




Fill the whole page and keep the contents centered when zooming

I'm facing a problem while making a webpage. I want the contents to be 100% of the browser width and when users zoom out the background should appear. Everything works great as long as the width is set in pixels. This doesn't work if the width is set with percentage. Objects just stay at left/right and drift apart when zoomed out. In what direction should I search to fix this problem? Is this even possible? What other methods should be considered to keep webpage looking kinda good when zooming out/in?

I hope I was clear enough. I'm still new to this. If necessary I will provide code. I wasn't sure about what I should and should not post.

Here is a picture of how I'd like it to look: http://ift.tt/2ij1Lto and here is how it actually looks: http://ift.tt/2hpZ9Wa

Thanks!




Website resizes locally but not on server, what did I do wrong?

I managed to have the website resize depending on width, however when I upload it into my server, it wont work.

Picture shows both the local and website

enter image description here

@media(max-width: 990px){

    .jumbotron img{
        width:80%;
}
    .jumbotron video{
        display: none;

    }
@media(min-width: 200px) and (max-width:780px ){

    .jumbotron img{
        width:180%;
    }

    .jumbotron #Tag-Line{
        font-size: 25px;

    }

    #aboutme h1{
        font-size: 20px;
    }

    #aboutme img{
        display: none;
    }

    #skills p{
        font-size: 16px;
    }
    }




Cannot query boardreader?

I am using VB.net and Webbrowser control(wbMain) to access website. I set the url to:

http://ift.tt/2iG0uwZ

Then check the value in wbMain.Document.DomDocument.Body.innerHTML, but find the value is:

    <div id="angular-content" style="height: 100%; min-height: 100%;">





        <app-root>



        </app-root>

    </div>

<script>

    localStorage.setItem('currentYear', 2016);

localStorage.setItem('noCheck', 'ok');

localStorage.removeItem('searchQuery');

localStorage.removeItem('searchParams');

localStorage.removeItem('currentUrl');

</script>

type="text/javascript">

src="styles.5f7f16a82a4f91544984.bundle.js"

type="text/javascript">

src="scripts.64dba058e16f4b72599d.bundle.js"

type="text/javascript">

src="main.3c0725bdf3863d8a267c.bundle.js" type="text/javascript">

Then I check wbMain.Document.DomDocument.Body.innerText and the its value

is:

localStorage.setItem('currentYear', 2016); localStorage.setItem('noCheck', 'ok'); 
localStorage.removeItem('searchQuery');

localStorage.removeItem('searchParams');

localStorage.removeItem('currentUrl'); 

None of them contain the actual search result. Why?

In my code, I have codes to wait until the web page is completely loaded, as follows:

        wbMain.Navigate(New System.Uri(strURL))
        LoadCompleted = False              ' set the global flag to False to indicate the page has not been loaded completedly
        Call WaitForNavigation2(wbMain)

and WaitForNavigation2 is:

' Wait for navigation to complete

Public Const conTimeOut As Integer = 3000
Public Sub WaitForNavigation2(ByRef wbMain As System.Windows.Forms.WebBrowser)
    Dim iTickCount As Integer

    iTickCount = GetTickCount()
    Do While (Not LoadCompleted)
        ' Sleep 10
        System.Windows.Forms.Application.DoEvents()

        ' Check for timeout
        If (GetTickCount() - iTickCount) \ 1000 > conTimeOut Then
            Exit Do
        End If
    Loop 
End Sub

and in the DocumentCompleted event of the web browser control wbMain, I will set the global flag LoadCompleted to True to indicate it is loaded completedly:

Private Sub wbMain_DocumentCompleted(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wbMain.DocumentCompleted
    LoadCompleted = True

End Sub

Thanks




How do I make JavaScript Code change image, using an Image Array

this is my first question on StackOverflow, so I am sorry if this is not up to standard.

<html>
<body>


<button onclick="ChangeLights()">Change Lights</button>

<img src="redlight.jpg" id="traffic" width="83" height="232">

<script>
    var imgarray = ["redlight.jpg", "yellowlight.jpg", "greenlight.jpg"];
document.getElementById("traffic").innerHTML = traffic;
function ChangeLights(){
document.getElementById("traffic").src = "redlight.jpg";
}

function ChangeLights() {
if (traffic.src.match(imgarray[0])){
traffic.src = imgarray[1];
}else if (traffic.src.match(imgarray[1])){
traffic.src = imgarray[2];
}else if (traffic.src.match(imgarray[2])){
traffic.src = imgarray[3];
}}



</script>
</body>
</html>

Whenever I press the button, the image does not appear.




Can I re-enable Window.alert after override?

If I have a page overriding window.alert box:

Window.alert = function() {}

can I re-enable the alert box if I have access to the Javascript?




Not able to copy from my application

I have my web application written in EmberJS. I am able to copy the text in 'input' fields , but not able to copy those in 'labels' , 'h1' such kind of fields in any of the browsers.

Any special handling needs to be done for those to make them enable for copy?

Any help much appreciated.Thanks.




JavaScript Duck Hunt bug

I am trying to create a duck hunting game using JavaScript. The following code should move duck images from the left side to the right side of the canvas. There doesn't seem to be any syntax error but nothing happens when I test the code. I would appreciate any help.

var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
var time = Math.round(Math.random()*100);
var ducs = [];
canvas.width = 500;
canvas.height = 500;
document.body.appendChild(canvas);


// Background image
var bgReady = false;
var bgImage = new Image();
bgImage.onload = function () {
        bgReady = true;
};
bgImage.src = "images/DHbackground.jpg";

// Duck image
var duckReady = false;
var duckImage = new Image();
duckImage.onload = function () {
        duckReady = true;
};
duckImage.src = "images/duck.png";

// Handle mouse and keyboard controls
var mouseDown = {
        x: 0,
        y: 0,
};

function getClickPosition(e) {
    mouseDown.x = e.clientX;
    mouseDown.y = e.clientY;
};

canvas.addEventListener("click", getClickPosition, false);

var reset = function(){
 // To do: resets the game 
  };

// Draw everything
var render = function () {
        if (bgReady) {
                ctx.drawImage(bgImage, 0, 0);
        }
        time = time-1;
        if (time < 0){ 
                var duck = {
                cur_X: 0,
                cur_Y: Math.round(Math.random()*500),
                final_X: 500,
                final_Y: Math.round(Math.random()*500),
                };
                time = Math.round(Math.random()*100);
                ducs.push(duck);
                for (var i = 0; i < ducs.Lenght; i++){
                        ctx.drawImage(duckImage, ducs[i].cur_X, ducs[i].cur_Y);
                        console.log(ducs[i].cur_X);
                }
        }

        // Score
        ctx.fillStyle = "rgb(250, 250, 250)";
        ctx.font = "24px Helvetica";
        ctx.textAlign = "left";
        ctx.textBaseline = "top";
        ctx.fillText("Ducks killed: " + 3, 10, 10);
};

var update = function (modifier) {
        for (var i = 0; i < ducs.Lenght; i++){
                ducs[i].cur_X = ducs[i].cur_X + Math.floor(((ducs[i].final_X - ducs[i].cur_X)/500)+1);
                ducs[i].cur_Y = ducs[i].cur_Y + Math.floor(((ducs[i].final_Y - ducs[i].cur_Y)/500)+1);
                if (ducs[i].cur_X > 500){
                        ducs.splice(i, 1);
                }
        }
};
        


// The main game loop
var main = function () {
        var now = Date.now();
        var delta = now - then;

        render();
        update(delta / 1000);

        then = now;

        // Request to do this again ASAP
        requestAnimationFrame(main);
};

// Cross-browser support for requestAnimationFrame
var w = window;
requestAnimationFrame = w.requestAnimationFrame || w.webkitRequestAnimationFrame || w.msRequestAnimationFrame || w.mozRequestAnimationFrame;

var then = Date.now();
reset();
main();
<!DOCTYPE html>
<html>
        <head>
        <meta charset="utf-8" />
        <title>Duck Hunt Pandy</title>
        </head>
        <body>
                <script src="js/game.js"> </script>
        </body>
</html>



(HTML)Cant store the browser height into variable and use the same in a class which is used for a div?

How do I get the height of the browser window in jquery and use that in a class in CSS.I used this code but it doesn't work , some modifications are needed

<style>
.browserHeight
{
height:h ;
}
</style>

<body>
<div class="container browserHeight"> ANOTHER PAGE 
</div>
</body>

<script>
var h=$(window).height()+"px";
</script>




The website layout is not fixed

folks, I am learning the basics of web development. I have used two fieldsets in the page as CSS id

#lfieldset
{
    width: 1019px;
    height: 500px;
    background: #ffffff;
    border-radius: 8px;
    border: none;
    float: left;
}
#rfieldset
{
    width: 300px;
    height: 200px;
    background: #ffffff;
    border-radius: 8px;
    border: none;
    float: right;
}

this is how it looks

Screenshot1

and the meta tag

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

for layout, but the second fieldset comes to the bottom if I reduce the window, see

Screenshot2

how can I solve this?




What technologies for a 2d football field simulator with draggable players on web?

I want to make a football field simulator on web. I need to have draggable players and ball and everything. I don't exactly know how are the animations and game-like effects are going to designed. I am a web developer and I know few languages on web but I don't seem to find the best way to design these parts of the application. It's like a game.




Pale hexadecimal colors in Google Chrome

Maybe it's a stupid question, but I have these lines of code which are not correctly interpreted in Google Chrome

border: 6px solid #FA3650; color: #FA3650;

right : safari (correct color), left: google chrome : image

How can I avoid this ?




Explain the syntax for function declaration

Please explain the below syntax, I found this below snippet from godoc. I understand Cookie is function name and name is its argument and return type are (*Cookie, error), the part I could not understand is (r *Request), What exactly this part signifies. By the way I am from OOP background.

func (r *Request) Cookie(name string) (*Cookie, error)




How to find dominant country of .com website visitor/users?

There are tons of .com websites which are designed for users of certain countries. For instance, www.qq.com and www.168.com are two Chinese websites registered under .com - even these are in Chinese language.

For lots of analytic solutions, it is beneficial to know which country does a certain website serve. But, I am not yet able to find such information. I am wondering if you have come across any website, service, trick or dataset that provides such an information.

Please not that my question is not about domestic domains like .ca,.jp,.de but I am only asking about .com

Thanks in advance




How to include html file in a content_script of chrome Extension?

I am creating a chrome extension.I have a small extension which includes css,javascript and html file. I want to run this extension on any web page but content script allows me to run only script file and when i add css html file extension doesn't work. It doesn't show html page that i create for extension except for script.js.So please help me how can i add html file in content_script.

This is my manifest.json file: {

"manifest_version":2,

"name":"News Plugin",
"description": "This extension will show you the latest news with headlines and small description",
"version":"1.0",


"browser_action":{
"default_icon":"news_icon.png",
"default_popup":"NewsApp.html"
},
//"chrome_url_overrides":{
//"newtab":"NewsApp.html"
//},

"content_scripts":[
    {
        "matches":["http://*/*","https://*/*"],
        "js":["news.js"],
        "html":["news.js"],
        "css":["style.js"]
    }
],

"permissions":[
"activeTab"
]

}




php form label disappeared

the form doesnt have the "require input" function before, meaning, it will submit if you click send button without typing anything. I have fixed this problem but another problem came up: the label in my form disappeared.

how can i bring back the labels without affecting the require function? a real beginner here...

HTML:

<form id="agp" class="form-horizontal"  action="mail.php" method="post" enctype="">
                        <div class="form-group">
                            <div class="col-sm-4" style="position:relative">
                                <input type="text" name="name" data-new-placeholder="What is your name?" class="form-control label_better" placeholder="Name" required="" value="">

                            </div>
                            <div class="col-sm-4">
                                <input type="text" name="email" class="form-control label_better" placeholder="Email"  required="" value="">
                            </div>
                            <div class="col-sm-4">
                                <input type="text" name="phone" class="form-control label_better" placeholder="Phone"  required="" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <textarea class="form-control label_better" placeholder="Your message..." rows="7" name="inquiry"></textarea>
                            </div>
                        </div>
                        <div class="form-group commands" input type="submit" value="send">
                            <button class="btn btn-primary" myFunction('email@email.com')"> Send message </button>

                        </div>
                    </form>

PHP

<?php
if(!isset($_POST['submit']))
{
$to = "email@email.com";
$headers = "From: ".$_POST['email'];
$name = check_input($_POST["name"]);
$email = check_input($_POST["email"]);
$phone = check_input($_POST["phone"]);
$inquiry = check_input($_POST["inquiry"]);

$subject = 'Form Submission';

$message =  "name: ".$name;
$message .=  " | email: ".$email;
$message .=  " | phone: ".$phone;
$message .=  " | message: ".$inquiry;


//$to,$subject,$message,$headers
mail($to,$subject,$message,$headers);
header('Location: thanks.html');
}




// define variables and set to empty values
$nameErr = $emailErr = $phoneErr = $inquiryErr = "";
$name = $email = $phone = $inquiry = "";


if ($_SERVER["REQUEST_METHOD"] == "POST") {
  if (empty($_POST["name"])) {
    $nameErr = "";
  }







if (empty($_POST["email"])) {
    $emailErr = "";
  } 

  if (empty($_POST["phone"])) {
    $phoneErr = "";
  } 
}



//Send the email!
//done. redirect to thank-you page.


// Function to validate against any email injection attempts
function IsInjected($str)
{
  $injections = array('(\n+)',
              '(\r+)',
              '(\t+)',
              '(%0A+)',
              '(%0D+)',
              '(%08+)',
              '(%09+)'
              );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
    {
    return true;
  }
  else
    {
    return false;
  }
}


function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}


?> 


                    <form id="agp" class="form-horizontal"  action="" method="post" enctype="multipart/form-data">
                        <div class="form-group">
                            <div class="col-sm-4" style="position:relative">
                                <input type="text" name="name" placeholder="What is your name?" class="form-control label_better" placeholder="Name" required="" value="">
                            </div>
                            <div class="col-sm-4">
                                <input type="text" name="email" class="form-control label_better" placeholder="Email"  required="" value="">
                            </div>
                            <div class="col-sm-4">
                                <input type="text" name="phone" class="form-control label_better" placeholder="Phone"  required="" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <textarea class="form-control label_better" placeholder="Your message..." rows="7" name="message"></textarea>
                            </div>
                        </div>
                        <div class="form-group commands" input type="submit" value="send">
                            <button class="btn btn-primary" onclick="myFunction('email@email.com')" >Send message</button>

                        </div>
                    </form>



                            <script>
function myFunction() {
    document.getElementById("agp").submit();
}
</script>

gen_validatorv31.js

function myFunction() {
    document.getElementById("agp").submit();
}

function validateForm() {
    var x = document.forms["agp"]["name"]["email"]["phone"]["inquiry"].value;
    if (x == "") {
        alert("Must be filled out");
        return false;
    }
}



function Validator(frmname)
{
  this.formobj=document.forms[frmname];
    if(!this.formobj)
    {
      alert("Error: couldnot get Form object "+frmname);
        return;
    }
    if(this.formobj.onsubmit)
    {
     this.formobj.old_onsubmit = this.formobj.onsubmit;
     this.formobj.onsubmit=null;
    }
    else
    {
     this.formobj.old_onsubmit = null;
    }
    this.formobj._sfm_form_name=frmname;
    this.formobj.onsubmit=form_submit_handler;
    this.addValidation = add_validation;
    this.setAddnlValidationFunction=set_addnl_vfunction;
    this.clearAllValidations = clear_all_validations;
    this.disable_validations = false;//new
    document.error_disp_handler = new sfm_ErrorDisplayHandler();
    this.EnableOnPageErrorDisplay=validator_enable_OPED;
    this.EnableOnPageErrorDisplaySingleBox=validator_enable_OPED_SB;
    this.show_errors_together=true;
    this.EnableMsgsTogether=sfm_enable_show_msgs_together;
    document.set_focus_onerror=true;
    this.EnableFocusOnError=sfm_validator_enable_focus;

}

function sfm_validator_enable_focus(enable)
{
    document.set_focus_onerror = enable;
}

function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}

function sfm_set_focus(objInput)
{
    if(document.set_focus_onerror)
    {
        objInput.focus();
    }
}

function sfm_enable_show_msgs_together()
{
    this.show_errors_together=true;
    this.formobj.show_errors_together=true;
}
function clear_all_validations()
{
    for(var itr=0;itr < this.formobj.elements.length;itr++)
    {
        this.formobj.elements[itr].validationset = null;
    }
}

function form_submit_handler()
{
   var bRet = true;
    document.error_disp_handler.clear_msgs();
    for(var itr=0;itr < this.elements.length;itr++)
    {
        if(this.elements[itr].validationset &&
       !this.elements[itr].validationset.validate())
        {
          bRet = false;
        }
        if(!bRet && !this.show_errors_together)
        {
          break;

        }
    }

    if(this.addnlvalidation)
    {
      str =" var ret = "+this.addnlvalidation+"()";
      eval(str);

     if(!ret) 
     {
       bRet=false; 
     }

    }

   if(!bRet)
    {
      document.error_disp_handler.FinalShowMsg();
      return false;
    }
    return true;
}

function add_validation(itemname,descriptor,errstr)
{
    var condition = null;
    if(arguments.length > 3)
    {
     condition = arguments[3]; 
    }
  if(!this.formobj)
    {
        alert("Error: The form object is not set properly");
        return;
    }//if
    var itemobj = this.formobj[itemname];
    if(itemobj.length && isNaN(itemobj.selectedIndex) )
    //for radio button; don't do for 'select' item
    {
        itemobj = itemobj[0];
    }   
  if(!itemobj)
    {
        alert("Error: Couldnot get the input object named: "+itemname);
        return;
    }
    if(!itemobj.validationset)
    {
        itemobj.validationset = new ValidationSet(itemobj,this.show_errors_together);
    }
    itemobj.validationset.add(descriptor,errstr,condition);
    itemobj.validatorobj=this;
}
function validator_enable_OPED()
{
    document.error_disp_handler.EnableOnPageDisplay(false);
}

function validator_enable_OPED_SB()
{
    document.error_disp_handler.EnableOnPageDisplay(true);
}
function sfm_ErrorDisplayHandler()
{
  this.msgdisplay = new AlertMsgDisplayer();
  this.EnableOnPageDisplay= edh_EnableOnPageDisplay;
  this.ShowMsg=edh_ShowMsg;
  this.FinalShowMsg=edh_FinalShowMsg;
  this.all_msgs=new Array();
  this.clear_msgs=edh_clear_msgs;
}
function edh_clear_msgs()
{
    this.msgdisplay.clearmsg(this.all_msgs);
    this.all_msgs = new Array();
}
function edh_FinalShowMsg()
{
    this.msgdisplay.showmsg(this.all_msgs);
}
function edh_EnableOnPageDisplay(single_box)
{
    if(true == single_box)
    {
        this.msgdisplay = new SingleBoxErrorDisplay();
    }
    else
    {
        this.msgdisplay = new DivMsgDisplayer();        
    }
}
function edh_ShowMsg(msg,input_element)
{

   var objmsg = new Array();
   objmsg["input_element"] = input_element;
   objmsg["msg"] =  msg;
   this.all_msgs.push(objmsg);
}
function AlertMsgDisplayer()
{
  this.showmsg = alert_showmsg;
  this.clearmsg=alert_clearmsg;
}
function alert_clearmsg(msgs)
{

}
function alert_showmsg(msgs)
{
    var whole_msg="";
    var first_elmnt=null;
    for(var m=0;m < msgs.length;m++)
    {
        if(null == first_elmnt)
        {
            first_elmnt = msgs[m]["input_element"];
        }
        whole_msg += msgs[m]["msg"] + "\n";
    }

    alert(whole_msg);

    if(null != first_elmnt)
    {
        sfm_set_focus(first_elmnt);
    }
}
function sfm_show_error_msg(msg,input_elmt)
{
    document.error_disp_handler.ShowMsg(msg,input_elmt);
}
function SingleBoxErrorDisplay()
{
 this.showmsg=sb_div_showmsg;
 this.clearmsg=sb_div_clearmsg;
}

function sb_div_clearmsg(msgs)
{
    var divname = form_error_div_name(msgs);
    show_div_msg(divname,"");
}

function sb_div_showmsg(msgs)
{
    var whole_msg="<ul>\n";
    for(var m=0;m < msgs.length;m++)
    {
        whole_msg += "<li>" + msgs[m]["msg"] + "</li>\n";
    }
    whole_msg += "</ul>";
    var divname = form_error_div_name(msgs);
    show_div_msg(divname,whole_msg);
}
function form_error_div_name(msgs)
{
    var input_element= null;

    for(var m in msgs)
    {
     input_element = msgs[m]["input_element"];
     if(input_element){break;}
    }

    var divname ="";
    if(input_element)
    {
     divname = input_element.form._sfm_form_name + "_errorloc";
    }

    return divname;
}
function DivMsgDisplayer()
{
 this.showmsg=div_showmsg;
 this.clearmsg=div_clearmsg;
}
function div_clearmsg(msgs)
{
    for(var m in msgs)
    {
        var divname = element_div_name(msgs[m]["input_element"]);
        show_div_msg(divname,"");
    }
}
function element_div_name(input_element)
{
  var divname = input_element.form._sfm_form_name + "_" + 
                   input_element.name + "_errorloc";

  divname = divname.replace(/[\[\]]/gi,"");

  return divname;
}
function div_showmsg(msgs)
{
    var whole_msg;
    var first_elmnt=null;
    for(var m in msgs)
    {
        if(null == first_elmnt)
        {
            first_elmnt = msgs[m]["input_element"];
        }
        var divname = element_div_name(msgs[m]["input_element"]);
        show_div_msg(divname,msgs[m]["msg"]);
    }
    if(null != first_elmnt)
    {
        sfm_set_focus(first_elmnt);
    }
}
function show_div_msg(divname,msgstring)
{
    if(divname.length<=0) return false;

    if(document.layers)
    {
        divlayer = document.layers[divname];
        if(!divlayer){return;}
        divlayer.document.open();
        divlayer.document.write(msgstring);
        divlayer.document.close();
    }
    else
    if(document.all)
    {
        divlayer = document.all[divname];
        if(!divlayer){return;}
        divlayer.innerHTML=msgstring;
    }
    else
    if(document.getElementById)
    {
        divlayer = document.getElementById(divname);
        if(!divlayer){return;}
        divlayer.innerHTML =msgstring;
    }
    divlayer.style.visibility="visible";    
}

function ValidationDesc(inputitem,desc,error,condition)
{
  this.desc=desc;
    this.error=error;
    this.itemobj = inputitem;
    this.condition = condition;
    this.validate=vdesc_validate;
}
function vdesc_validate()
{
    if(this.condition != null )
    {
        if(!eval(this.condition))
        {
            return true;
        }
    }
    if(!validateInput(this.desc,this.itemobj,this.error))
    {
        this.itemobj.validatorobj.disable_validations=true;

        sfm_set_focus(this.itemobj);

        return false;
    }
    return true;
}
function ValidationSet(inputitem,msgs_together)
{
    this.vSet=new Array();
    this.add= add_validationdesc;
    this.validate= vset_validate;
    this.itemobj = inputitem;
    this.msgs_together = msgs_together;
}
function add_validationdesc(desc,error,condition)
{
  this.vSet[this.vSet.length]= 
  new ValidationDesc(this.itemobj,desc,error,condition);
}
function vset_validate()
{
    var bRet = true;
    for(var itr=0;itr<this.vSet.length;itr++)
    {
        bRet = bRet && this.vSet[itr].validate();
        if(!bRet && !this.msgs_together)
        {
            break;
        }
    }
    return bRet;
}
function validateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
        var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
        if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

function IsCheckSelected(objValue,chkValue)
{
    var selected=false;
    var objcheck = objValue.form.elements[objValue.name];
    if(objcheck.length)
    {
        var idxchk=-1;
        for(var c=0;c < objcheck.length;c++)
        {
           if(objcheck[c].value == chkValue)
           {
             idxchk=c;
             break;
           }//if
        }//for
        if(idxchk>= 0)
        {
          if(objcheck[idxchk].checked=="1")
          {
            selected=true;
          }
        }//if
    }
    else
    {
        if(objValue.checked == "1")
        {
            selected=true;
        }//if
    }//else 

    return selected;
}
function TestDontSelectChk(objValue,chkValue,strError)
{
    var pass = true;
    pass = IsCheckSelected(objValue,chkValue)?false:true;

    if(pass==false)
    {
     if(!strError || strError.length ==0) 
        { 
            strError = "Can't Proceed as you selected "+objValue.name;  
        }//if             
      sfm_show_error_msg(strError,objValue);

    }
    return pass;
}
function TestShouldSelectChk(objValue,chkValue,strError)
{
    var pass = true;

    pass = IsCheckSelected(objValue,chkValue)?true:false;

    if(pass==false)
    {
     if(!strError || strError.length ==0) 
        { 
            strError = "You should select "+objValue.name;  
        }//if             
      sfm_show_error_msg(strError,objValue);

    }
    return pass;
}
function TestRequiredInput(objValue,strError)
{
 var ret = true;
 var val = objValue.value;
 val = val.replace(/^\s+|\s+$/g,"");//trim
    if(eval(val.length) == 0) 
    { 
       if(!strError || strError.length ==0) 
       { 
         strError = objValue.name + " : Required Field"; 
       }//if 
       sfm_show_error_msg(strError,objValue); 
       ret=false; 
    }//if 
return ret;
}
function TestMaxLen(objValue,strMaxLen,strError)
{
 var ret = true;
    if(eval(objValue.value.length) > eval(strMaxLen)) 
    { 
      if(!strError || strError.length ==0) 
      { 
        strError = objValue.name + " : "+ strMaxLen +" characters maximum "; 
      }//if 
      sfm_show_error_msg(strError,objValue); 
      ret = false; 
    }//if 
return ret;
}
function TestMinLen(objValue,strMinLen,strError)
{
 var ret = true;
    if(eval(objValue.value.length) <  eval(strMinLen)) 
    { 
      if(!strError || strError.length ==0) 
      { 
        strError = objValue.name + " : " + strMinLen + " characters minimum  "; 
      }//if               
      sfm_show_error_msg(strError,objValue); 
      ret = false;   
    }//if 
return ret;
}
function TestInputType(objValue,strRegExp,strError,strDefaultError)
{
   var ret = true;

    var charpos = objValue.value.search(strRegExp); 
    if(objValue.value.length > 0 &&  charpos >= 0) 
    { 
     if(!strError || strError.length ==0) 
      { 
        strError = strDefaultError;
      }//if 
      sfm_show_error_msg(strError,objValue); 
      ret = false; 
    }//if 
 return ret;
}
function TestEmail(objValue,strError)
{
var ret = true;
     if(objValue.value.length > 0 && !validateEmail(objValue.value)  ) 
     { 
       if(!strError || strError.length ==0) 
       { 
          strError = objValue.name+": Enter a valid Email address "; 
       }//if                                               
       sfm_show_error_msg(strError,objValue); 
       ret = false; 
     }//if 
return ret;
}
function TestLessThan(objValue,strLessThan,strError)
{
var ret = true;
      if(isNaN(objValue.value)) 
      { 
        sfm_show_error_msg(objValue.name +": Should be a number ",objValue); 
        ret = false; 
      }//if 
      else
      if(eval(objValue.value) >=  eval(strLessThan)) 
      { 
        if(!strError || strError.length ==0) 
        { 
          strError = objValue.name + " : value should be less than "+ strLessThan; 
        }//if               
        sfm_show_error_msg(strError,objValue); 
        ret = false;                 
       }//if   
return ret;          
}
function TestGreaterThan(objValue,strGreaterThan,strError)
{
var ret = true;
     if(isNaN(objValue.value)) 
     { 
       sfm_show_error_msg(objValue.name+": Should be a number ",objValue); 
       ret = false; 
     }//if 
     else
     if(eval(objValue.value) <=  eval(strGreaterThan)) 
      { 
        if(!strError || strError.length ==0) 
        { 
          strError = objValue.name + " : value should be greater than "+ strGreaterThan; 
        }//if               
        sfm_show_error_msg(strError,objValue);  
        ret = false;
      }//if  
return ret;           
}
function TestRegExp(objValue,strRegExp,strError)
{
var ret = true;
    if( objValue.value.length > 0 && 
        !objValue.value.match(strRegExp) ) 
    { 
      if(!strError || strError.length ==0) 
      { 
        strError = objValue.name+": Invalid characters found "; 
      }//if                                                               
      sfm_show_error_msg(strError,objValue); 
      ret = false;                   
    }//if 
return ret;
}
function TestDontSelect(objValue,dont_sel_index,strError)
{
var ret = true;
    if(objValue.selectedIndex == null) 
    { 
      sfm_show_error_msg("ERROR: dontselect command for non-select Item"); 
      ret =  false; 
    } 
    if(objValue.selectedIndex == eval(dont_sel_index)) 
    { 
     if(!strError || strError.length ==0) 
      { 
      strError = objValue.name+": Please Select one option "; 
      }//if                                                               
      sfm_show_error_msg(strError,objValue); 
      ret =  false;                                   
     } 
return ret;
}
function TestSelectOneRadio(objValue,strError)
{
    var objradio = objValue.form.elements[objValue.name];
    var one_selected=false;
    for(var r=0;r < objradio.length;r++)
    {
      if(objradio[r].checked)
      {
        one_selected=true;
        break;
      }
    }
    if(false == one_selected)
    {
      if(!strError || strError.length ==0) 
       {
        strError = "Please select one option from "+objValue.name;
       }    
      sfm_show_error_msg(strError,objValue);
    }
return one_selected;
}

function validateInput(strValidateStr,objValue,strError) 
{ 
    var ret = true;
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 
    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
           ret = TestRequiredInput(objValue,strError)
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             ret = TestMaxLen(objValue,cmdvalue,strError)
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             ret = TestMinLen(objValue,cmdvalue,strError)
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
                ret = TestInputType(objValue,"[^A-Za-z0-9]",strError, 
                        objValue.name+": Only alpha-numeric characters allowed ");
                break; 
           }
        case "alnum_s": 
        case "alphanumeric_space": 
           { 
                ret = TestInputType(objValue,"[^A-Za-z0-9\\s]",strError, 
                        objValue.name+": Only alpha-numeric characters and space allowed ");
                break; 
           }           
        case "num": 
        case "numeric": 
           { 
                ret = TestInputType(objValue,"[^0-9]",strError, 
                        objValue.name+": Only digits allowed ");
                break;               
           }
        case "dec": 
        case "decimal": 
           { 
                ret = TestInputType(objValue,"[^0-9\.]",strError, 
                        objValue.name+": Only numbers allowed ");
                break;               
           }
        case "alphabetic": 
        case "alpha": 
           { 
                ret = TestInputType(objValue,"[^A-Za-z]",strError, 
                        objValue.name+": Only alphabetic characters allowed ");
                break; 
           }
        case "alphabetic_space": 
        case "alpha_s": 
           { 
                ret = TestInputType(objValue,"[^A-Za-z\\s]",strError, 
                        objValue.name+": Only alphabetic characters and space allowed ");
                break; 
           }
        case "email": 
          { 
               ret = TestEmail(objValue,strError);
               break; 
          }
        case "lt": 
        case "lessthan": 
         { 
              ret = TestLessThan(objValue,cmdvalue,strError);
              break; 
         }
        case "gt": 
        case "greaterthan": 
         { 
            ret = TestGreaterThan(objValue,cmdvalue,strError);
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
            ret = TestRegExp(objValue,cmdvalue,strError);
           break; 
         }
        case "dontselect": 
         { 
             ret = TestDontSelect(objValue,cmdvalue,strError)
             break; 
         }
        case "dontselectchk":
        {
            ret = TestDontSelectChk(objValue,cmdvalue,strError)
            break;
        }
        case "shouldselchk":
        {
            ret = TestShouldSelectChk(objValue,cmdvalue,strError)
            break;
        }
        case "selone_radio":
        {
            ret = TestSelectOneRadio(objValue,strError);
            break;
        }        
    }//switch 
    return ret;
}
function VWZ_IsListItemSelected(listname,value)
{
 for(var i=0;i < listname.options.length;i++)
 {
  if(listname.options[i].selected == true &&
   listname.options[i].value == value) 
   {
     return true;
   }
 }
 return false;
}
function VWZ_IsChecked(objcheck,value)
{
 if(objcheck.length)
 {
     for(var c=0;c < objcheck.length;c++)
     {
       if(objcheck[c].checked == "1" && 
         objcheck[c].value == value)
       {
        return true; 
       }
     }
 }
 else
 {
  if(objcheck.checked == "1" )
   {
    return true; 
   }    
 }
 return false;
}
/*
    Copyright (C) 2003-2009 JavaScript-Coder.com . All rights reserved.
*/

thanks in advance for your help! #firstpost