Created
June 11, 2021 19:07
-
-
Save saifulapm/fb63c2b1f9e43c0c3e1ffeb07a48c420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var years = [2022,2021,2020,2019,2018,2017,2016,2015,2014,2013,2012,2011,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001,2000,1999,1998,1997,1996,1995,1994,1993,1992,1991,1990,1989,1988,1987,1986,1985,1984,1983,1982,1981,1980,1979,1978,1977,1976,1975,1974,1973,1972,1971,1970,1969,1968,1967,1966,1965,1964,1963,1962,1961,1960,1959,1958,1957,1956,1955,1954,1953,1952,1951]; | |
| var config = { | |
| count: 0, | |
| make: 0, | |
| model: 0, | |
| submodel: 0, | |
| }; | |
| function syncStore(callback) { | |
| if (years.length > config.count) { | |
| if (config[years[config.count]] === undefined) { | |
| $.get("/makes?year=" + years[config.count], function(data){ | |
| config[years[config.count]] = JSON.parse(data); | |
| if (config[years[config.count] + '_' + config[years[config.count]][config.make]] === undefined) { | |
| $.get("/models?year=" + years[config.count] +"&make=" + config[years[config.count]][config.make], function(data){ | |
| config[years[config.count] + '_' + config[years[config.count]][config.make]] = JSON.parse(data); | |
| if (config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]] === undefined) { | |
| $.get("/submodels?year=" + years[config.count] +"&make=" + config[years[config.count]][config.make] + "&model=" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model], function(data){ | |
| config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]] = JSON.parse(data); | |
| $.getJSON("https://api.usautoparts.io/vehicle?op=getEngines&vehicle[year]="+years[config.count]+"&vehicle[make]="+config[years[config.count]][config.make]+"&vehicle[model]="+config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]+"&vehicle[submodel]=" + config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel] + "&pipeDelimited=1", function( data ) { | |
| var engines = data._payload.result.getEngines.value; | |
| var post_data = { | |
| 'action': 'importData', | |
| 'submodel': config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel], | |
| 'engines': engines, | |
| 'make': config[years[config.count]][config.make], | |
| 'model': config[years[config.count] + '_' + config[years[config.count]][config.make]][config.model], | |
| 'year': years[config.count] | |
| }; | |
| $.ajax({ | |
| type: 'POST', | |
| url: "/data", | |
| dataType: 'json', | |
| data: post_data | |
| }).done(function(json) { | |
| config.submodel = config.submodel + 1; | |
| setTimeout(callback, 100); | |
| }); | |
| }); | |
| }); | |
| } | |
| }); | |
| } | |
| }); | |
| } else { | |
| if (config[years[config.count]].length > config.make) { | |
| if (config[years[config.count] + '_' + config[years[config.count]][config.make]] === undefined) { | |
| $.get("/models?year=" + years[config.count] +"&make=" + config[years[config.count]][config.make], function(data){ | |
| config[years[config.count] + '_' + config[years[config.count]][config.make]] = JSON.parse(data); | |
| if (config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]] === undefined) { | |
| $.get("/submodels?year=" + years[config.count] +"&make=" + config[years[config.count]][config.make] + "&model=" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model], function(data){ | |
| config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]] = JSON.parse(data); | |
| $.getJSON("https://api.usautoparts.io/vehicle?op=getEngines&vehicle[year]="+years[config.count]+"&vehicle[make]="+config[years[config.count]][config.make]+"&vehicle[model]="+config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]+"&vehicle[submodel]=" + config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel] + "&pipeDelimited=1", function( data ) { | |
| var engines = data._payload.result.getEngines.value; | |
| var post_data = { | |
| 'action': 'importData', | |
| 'submodel': config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel], | |
| 'engines': engines, | |
| 'make': config[years[config.count]][config.make], | |
| 'model': config[years[config.count] + '_' + config[years[config.count]][config.make]][config.model], | |
| 'year': years[config.count] | |
| }; | |
| $.ajax({ | |
| type: 'POST', | |
| url: "/data", | |
| dataType: 'json', | |
| data: post_data | |
| }).done(function(json) { | |
| config.submodel = config.submodel + 1; | |
| setTimeout(callback, 100); | |
| }); | |
| }); | |
| }); | |
| } else { | |
| if (config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]].length > config.submodel) { | |
| $.getJSON("https://api.usautoparts.io/vehicle?op=getEngines&vehicle[year]="+years[config.count]+"&vehicle[make]="+config[years[config.count]][config.make]+"&vehicle[model]="+config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]+"&vehicle[submodel]=" + config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel] + "&pipeDelimited=1", function( data ) { | |
| var engines = data._payload.result.getEngines.value; | |
| var post_data = { | |
| 'action': 'importData', | |
| 'submodel': config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel], | |
| 'engines': engines, | |
| 'make': config[years[config.count]][config.make], | |
| 'model': config[years[config.count] + '_' + config[years[config.count]][config.make]][config.model], | |
| 'year': years[config.count] | |
| }; | |
| $.ajax({ | |
| type: 'POST', | |
| url: "/data", | |
| dataType: 'json', | |
| data: post_data | |
| }).done(function(json) { | |
| config.submodel = config.submodel + 1; | |
| setTimeout(callback, 100); | |
| }); | |
| }); | |
| } else { | |
| config.model = config.model + 1; | |
| config.submodel = 0; | |
| setTimeout(callback, 100); | |
| } | |
| } | |
| }); | |
| } else { | |
| if (config[years[config.count] + '_' + config[years[config.count]][config.make]].length > config.model) { | |
| if (config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]] === undefined) { | |
| $.get("/submodels?year=" + years[config.count] +"&make=" + config[years[config.count]][config.make] + "&model=" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model], function(data){ | |
| config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]] = JSON.parse(data); | |
| if (config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]].length > config.submodel) { | |
| $.getJSON("https://api.usautoparts.io/vehicle?op=getEngines&vehicle[year]="+years[config.count]+"&vehicle[make]="+config[years[config.count]][config.make]+"&vehicle[model]="+config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]+"&vehicle[submodel]=" + config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel] + "&pipeDelimited=1", function( data ) { | |
| var engines = data._payload.result.getEngines.value; | |
| var post_data = { | |
| 'action': 'importData', | |
| 'submodel': config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel], | |
| 'engines': engines, | |
| 'make': config[years[config.count]][config.make], | |
| 'model': config[years[config.count] + '_' + config[years[config.count]][config.make]][config.model], | |
| 'year': years[config.count] | |
| }; | |
| $.ajax({ | |
| type: 'POST', | |
| url: "/data", | |
| dataType: 'json', | |
| data: post_data | |
| }).done(function(json) { | |
| config.submodel = config.submodel + 1; | |
| setTimeout(callback, 100); | |
| }); | |
| }); | |
| } else { | |
| config.model = config.model + 1; | |
| config.submodel = 0; | |
| setTimeout(callback, 100); | |
| } | |
| }); | |
| } else { | |
| if (config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]].length > config.submodel) { | |
| $.getJSON("https://api.usautoparts.io/vehicle?op=getEngines&vehicle[year]="+years[config.count]+"&vehicle[make]="+config[years[config.count]][config.make]+"&vehicle[model]="+config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]+"&vehicle[submodel]=" + config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel] + "&pipeDelimited=1", function( data ) { | |
| var engines = data._payload.result.getEngines.value; | |
| var post_data = { | |
| 'action': 'importData', | |
| 'submodel': config[years[config.count] + "_" + config[years[config.count]][config.make] + "_" + config[years[config.count] + "_" + config[years[config.count]][config.make]][config.model]][config.submodel], | |
| 'engines': engines, | |
| 'make': config[years[config.count]][config.make], | |
| 'model': config[years[config.count] + '_' + config[years[config.count]][config.make]][config.model], | |
| 'year': years[config.count] | |
| }; | |
| $.ajax({ | |
| type: 'POST', | |
| url: "/data", | |
| dataType: 'json', | |
| data: post_data | |
| }).done(function(json) { | |
| config.submodel = config.submodel + 1; | |
| setTimeout(callback, 100); | |
| }); | |
| }); | |
| } else { | |
| config.model = config.model + 1; | |
| config.submodel = 0; | |
| setTimeout(callback, 100); | |
| } | |
| } | |
| } else { | |
| config.make = config.make + 1; | |
| config.model = 0; | |
| setTimeout(callback, 100); | |
| } | |
| } | |
| } else { | |
| config.count = config.count + 1; | |
| config.make = 0; | |
| config.model = 0; | |
| setTimeout(callback, 100); | |
| } | |
| } | |
| } | |
| } | |
| (function syncNow() { | |
| syncStore(syncNow); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment