示例#1
0
        public override void PageInject(string url, Collection <string> toInject, Collection <KeyValuePair <string, string> > replacements)
        {
            if (AcApiHosts.Contains(url.GetDomainNameFromUrl(), StringComparer.OrdinalIgnoreCase))
            {
                toInject.Add(@"<script>!function(){
window.__AC = {};
window.__AC.CarsArray = JSON.parse(window.external.GetCars());
window.__AC.TracksArray = JSON.parse(window.external.GetTracks());
window.__AC.Cars = {};
window.__AC.Tracks = window.__AC.TracksArray.reduce(function (a, b){ a[b.id] = b; return a; }, {});
for (var i = 0; i < window.__AC.CarsArray.length; i++){
    var car = window.__AC.CarsArray[i];
    window.__AC.Cars[car.id] = car;
    car.__defineGetter__('skins', getSkins.bind(null, car));
    car.__defineGetter__('skinmeta', getSkinMeta.bind(null, car));
}
function getSkins(car){ return car._skins || (car._skins = JSON.parse(window.external.GetSkins(car.id))); }
function getSkinMeta(car){ return car._skinmeta || (car._skinmeta = JSON.parse(window.external.GetSkinMeta(car.id))); }
function find(a, f, p1, p2) {
    if (p1 === 'id') window.external.SetLastAccessed(f, a === __AC.CarsArray);
    return p1 && a.filter(function (n){ return (p2 ? n[p1][p2] : n[p1]).indexOf(f) > -1; });
}
window.__AC.findCar = find.bind(null, __AC.CarsArray);
window.__AC.findTrack = find.bind(null, __AC.TracksArray);
}()</script>");
            }
        }
示例#2
0
 public RaceUApiBridge()
 {
     AcApiHosts.Add(@"raceu.net");
     AcApiHosts.Add(@"localhost:3000");
 }
示例#3
0
 public SrsFixAcCompatibleApiBridge()
 {
     _srsFix = null;
     AcApiHosts.Add(@"simracingsystem.com");
 }
示例#4
0
 public TrackTitanApiBridge()
 {
     AcApiHosts.Add(@"tracktitan.io");
     AcApiHosts.Add(@"www.tracktitan.io");
 }
示例#5
0
 public UnitedRacingDataApiBridge()
 {
     AcApiHosts.Add(@"unitedracingdata.com");
     AcApiHosts.Add(@"www.unitedracingdata.com");
 }
示例#6
0
 public GridFinderApiBridge()
 {
     AcApiHosts.Add(@"grid-finder.com");
     AcApiHosts.Add(@"www.grid-finder.com");
 }
示例#7
0
 public WorldSimSeriesApiBridge()
 {
     AcApiHosts.Add(@"worldsimseries.com");
     AcApiHosts.Add(@"paddock.worldsimseries.com");
     AcApiHosts.Add(@"local.wss:8000");
 }