⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vinlib.js

📁 identification number (VIN) service check
💻 JS
字号:
/* Copyright 2005, David Berube */
/* http://berubeconsulting.com */

/*
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
*/


function is_valid_vin(vin)
{
	var check_digit='', check_digit_value=0, sum=0;
	var has_invalid_characters=0;
	var check_digit_position=8;

	var letter_values = 	
	"0=0,1=1,2=2,3=3,4=4,5=5,6=6,7=7,8=8,9=9,A=1,B=2," + 
	"C=3,D=4,E=5,F=6,G=7,H=8,J=1,K=2,L=3,M=4,N=5,O=6," + 
	"P=7,R=9,S=2,T=3,U=4,V=5,W=6,X=7,Y=8,Z=9".split(",");
	
	var digit_weights = "8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2".split(",");
	
	if(vin.length !=17 ){
		return false;
	} 

	for(i=0 ; i<= 16 ; i++){	
		
		digit=vin.substring(i,i+1).toUpperCase();
		
		if (i==check_digit_position){
			check_digit=digit;
		} else {
			var digit_value=-1;

			for(j=0;j<=letter_values.length-1;j++){
				if(letter_values[j].split("=")[0]==digit){
					digit_value= 
					(parseInt(letter_values[j].split("=")[1])*
					parseInt(digit_weights[i]));
				}

			}
			
			//alert(digit + ":" + digit_value);

			sum+= digit_value;			
			if(digit_value==-1){
				return false;
			}
		}
	}
	
	if(check_digit=='X'){
		check_digit_value=10
	} else {
		check_digit_value=parseInt(check_digit) ;
	}
		


	if((sum % 11) != check_digit_value){
		return false;
	}

	return true;

}

function get_vin_year(vin)
{
	year_digit = vin.substring(9,10);
	if (year_digit == 'A') {

		year = '1980';

	} else if (year_digit == 'B') {

		year = '1981';

	} else if (year_digit == 'C') {

		year = '1982';

	} else if (year_digit == 'D') {

		year = '1983';

	} else if (year_digit == 'E') {

		year = '1984';

	} else if (year_digit == 'F') {

		year = '1985';

	} else if (year_digit == 'G') {

		year = '1986';

	} else if (year_digit == 'H') {

		year = '1987';

	} else if (year_digit == 'I') {

		year = '';

	} else if (year_digit == 'J') {

		year = '1988';

	} else if (year_digit == 'K') {

		year = '1989';

	} else if (year_digit == 'L') {

		year = '1990';

	} else if (year_digit == 'M') {

		year = '1991';

	} else if (year_digit == 'N') {

		year = '1992';

	} else if (year_digit == 'O') {

		year = '';

	} else if (year_digit == 'P') {

		year = '1993';

	} else if (year_digit == 'Q') {

		year = '';

	} else if (year_digit == 'R') {

		year = '1994';

	} else if (year_digit == 'S') {

		year = "1995";

	} else if (year_digit == 'T') {

		year = "1996";

	} else if (year_digit == 'V') {

		year = "1997";

	} else if (year_digit == 'W') {

		year = "1998";

	} else if (year_digit == 'X') {

		year = "1999";

	} else if (year_digit == 'Y') {

		year = "2000";

	} else if (year_digit == '1') {

		year = "2001";

	} else if (year_digit == '2') {

		year = "2002";

	} else if (year_digit == '3') {

		year = "2003 ";

	} else if (year_digit == '4') {

		year = "2004";

	} else if (year_digit == '5') {

		year = "2005";

	} else if (year_digit == '6') {

		year = "2006";

	} else if (year_digit == '7') {

		year = "2007";

	} else if (year_digit == '8') {

		year = "2008";

	} else if (year_digit == '9') {

		year = "2009";

	} else {

		year = "";
	}

	return(year);
}

function get_vin_make(vin)
{
	make_digit=vin.substring(1,2).toUpperCase();
	if (make_digit=='0') { 
		make='Cadillac';
	} else if (make_digit=='6') { 
		make='Articat';
	} else if (make_digit=='7') { 
		make='Honda';
	} else if (make_digit=='9') { 
		make='Acura';
	} else if (make_digit=='A') { 
		make='Audi';
	} else if (make_digit=='B') { 
		make='BMW';
	} else if (make_digit=='C') { 
		make='Chrysler';
	} else if (make_digit=='D') { 
		make='Ducati';
	} else if (make_digit=='F') { 
		make='Ford';
	} else if (make_digit=='G') { 
		make='Chevrolet';
	} else if (make_digit=='H') { 
		make='Honda';
	} else if (make_digit=='J') { 
		make='Jeep';
	} else if (make_digit=='K') { 
		make='Kawasaki';
	} else if (make_digit=='L') { 
		make='Lincoln';
	} else if (make_digit=='M') { 
		make='Buell';
	} else if (make_digit=='N') { 
		make='Nissan';
	} else if (make_digit=='P') { 
		make='Porsche';
	} else if (make_digit=='R') { 
		make='Red Horse';
	} else if (make_digit=='S') { 
		make='Suzuki';
	} else if (make_digit=='T') { 
		make='Toyota';
	} else if (make_digit=='U') { 
		make='BMW';
	} else if (make_digit=='V') { 
		make='Volkswagen';
	} else if (make_digit=='X') { 
		make='Polaris';
	} else if (make_digit=='Y') { 
		make='Yamaha';
	} else if (make_digit=='Z') { 
		make='Bombardier';
	}
	return(make);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -