Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(widget_container.dataset.loaded == "false"){
- var id = widget_container.dataset.squirrelId;
- var make = widget_container.dataset.make;
- var model = widget_container.dataset.model;
- var domain = window.location.origin;
- var amp = widget_container.querySelector('amp-iframe');
- if(amp != null)
- amp.remove();
- if(!id && (!make || !model))
- return;
- if(!id){
- var data = new FormData();
- data.append("make", make);
- data.append("model", model);
- data.append("domain", domain);
- data.append("href", window.location.href);
- var xhr = new XMLHttpRequest();
- xhr.addEventListener("readystatechange", function () {
- if (this.readyState === 4 && (this.status == 200 || this.status == 200)) {
- var body = JSON.parse(this.responseText);console.log(body);
- if(body.data != null){
- id = body.data;
- var divContainer = generateIframElement(position, id, editorialStandards);
- pushAd(id, position);
- widget_container.appendChild(divContainer);
- widget_container.dataset.squirrelId = id;
- widget_container.dataset.loaded = "true";
- widget_container.dataset.position = position;
- }
- }
- if (this.readyState === 4 && this.status == 500) {
- console.log(this.responseText);
- }
- });
- xhr.open("POST", "{{ report_route }}" + "make_model");
- xhr.send(data);
- }
- else{
- var divContainer = generateIframElement(position, id, editorialStandards);
- pushAd(id, position);
- widget_container.appendChild(divContainer);
- widget_container.dataset.loaded = "true";
- widget_container.dataset.position = position;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement