My site doesn't work after the update Chrome 83 - google-chrome

So, I have website on ext.net 1.7 (last version), and after updates my site doesn't works. The Chrome-console shows no errors. It's just no worked. But it worked in previous versions of Chrome.
WebConsoleErrors
I read about change in Chrome but found nothing the problem.
Does anyone know what the problem is?

try this
(function () {
function isChromium() {
var isChromium = window.chrome;
var winNav = window.navigator;
var isIOSChrome = winNav.userAgent.match("CriOS");
if (isIOSChrome)
return true;
else if (isChromium !== null && typeof isChromium !== "undefined")
return true;
else
return false;
}
if (isChromium()) {
Ext.override(Ext.data.Connection, {
doFormUpload: function (o, ps, url) {
var me = this;
var doc = document;
var form = Ext.getDom(o.form);
var hiddens = [];
var hd;
Ext.iterate(Ext.urlDecode(ps, false), function (k, v) {
hd = doc.createElement('input');
Ext.fly(hd).set({
type: 'hidden',
value: v,
name: k
});
form.appendChild(hd);
hiddens.push(hd);
});
var formData = new FormData(form);
function successCallback(data) {
var r = {
responseText: '',
responseXML: null,
argument: o.argument
};
if (data) {
var match = /<textarea>(.+)<\/textarea>/i.exec(data);
if (match != null && match.length >= 2) {
r.responseText = match[1];
} else {
r.responseText = data;
}
r.responseXML = $.parseXML(data);
}
me.fireEvent("requestcomplete", me, r, o);
function runCallback(fn, scope, args) {
if (Ext.isFunction(fn)) {
fn.apply(scope, args);
}
}
runCallback(o.success, o.scope, [r, o]);
runCallback(o.callback, o.scope, [o, true, r]);
}
$.ajax({
type: 'POST',
url: url,
data: formData,
processData: false,
contentType: false,
success: successCallback,
error: function () {
console.log(arguments);
}
});
Ext.each(hiddens, function (h) {
Ext.removeNode(h);
});
}
})
}
})();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
You should insert current script in body for all pages after load extjs

Related

Autodesk-XLSExtension, undefined viewer

Im trying to implement the XLS Extension. In the ModelData class, i cannot get objects leaf nodes because the viewer is undefined.
Here is the problematic method:
getAllLeafComponents(callback) {
// from https://learnforge.autodesk.io/#/viewer/extensions/panel?id=enumerate-leaf-nodes
viewer.getObjectTree(function (tree) {
let leaves = [];
tree.enumNodeChildren(tree.getRootId(), function (dbId) {
if (tree.getChildCount(dbId) === 0) {
leaves.push(dbId);
}
}, true);
callback(leaves);
});
}
Im getting Cannot read properties of undefined (reading 'getObjectTree') , meaning viewer is undefined.
However, viewer is working and displaying documents.
I tried to call it by window.viewer and this.viewer to no avail.
Thanks in advance for any help
It looks like it missed two lines. Could you try the revised one below?
// Model data in format for charts
class ModelData {
constructor(viewer) {
this._modelData = {};
this._viewer = viewer;
}
init(callback) {
var _this = this;
var viewer = _this._viewer;
_this.getAllLeafComponents(function (dbIds) {
var count = dbIds.length;
dbIds.forEach(function (dbId) {
viewer.getProperties(dbId, function (props) {
props.properties.forEach(function (prop) {
if (!isNaN(prop.displayValue)) return; // let's not categorize properties that store numbers
// some adjustments for revit:
prop.displayValue = prop.displayValue.replace('Revit ', ''); // remove this Revit prefix
if (prop.displayValue.indexOf('<') == 0) return; // skip categories that start with <
// ok, now let's organize the data into this hash table
if (_this._modelData[prop.displayName] == null) _this._modelData[prop.displayName] = {};
if (_this._modelData[prop.displayName][prop.displayValue] == null) _this._modelData[prop.displayName][prop.displayValue] = [];
_this._modelData[prop.displayName][prop.displayValue].push(dbId);
})
if ((--count) == 0) callback();
});
})
})
}
getAllLeafComponents(callback) {
var _this = this;
var viewer = _this._viewer;
// from https://learnforge.autodesk.io/#/viewer/extensions/panel?id=enumerate-leaf-nodes
viewer.getObjectTree(function (tree) {
var leaves = [];
tree.enumNodeChildren(tree.getRootId(), function (dbId) {
if (tree.getChildCount(dbId) === 0) {
leaves.push(dbId);
}
}, true);
callback(leaves);
});
}
hasProperty(propertyName){
return (this._modelData[propertyName] !== undefined);
}
getLabels(propertyName) {
return Object.keys(this._modelData[propertyName]);
}
getCountInstances(propertyName) {
return Object.keys(this._modelData[propertyName]).map(key => this._modelData[propertyName][key].length);
}
getIds(propertyName, propertyValue) {
return this._modelData[propertyName][propertyValue];
}
}

How change display value/color td based on JSON

I'm working on an app where I get a json via an ajax call. This json contains objects where you get a certain status code per extension (1 = online, 2, is ringing, 3 = busy)
How can I ensure that the value that I get back is converted to the text (preferably with a different color of the )
So when I get a 1 back I want it to show Online, and with a 2 Ring etc
$.ajax({
type:'GET',
url: url,
dataType: 'json',
error: function(jqXHR, exception) {ajax_error_handler(jqXHR, exception);},
success: function(data){
// console.log(JSON.parse(data.responseText));
// console.log(JSON.parse(data.responseJSON));
console.log(data['entry']);
var event_data = '';
$.each(data.entry, function(index, value){
/* console.log(data['entry']);*/
event_data += '<tr>';
event_data += '<td>'+value.extension+'</td>';
event_data += '<td>'+value.status+'</td>';
<!--event_data += '<td>'+value.registration+'</td>';-->
event_data += '</tr>';
});
$("#list_table_json").append(event_data);
},
error: function(d){
/*console.log("error");*/
alert("404. Please wait until the File is Loaded.");
}
});
Thanks in advance!
I have change the code
function get_blf() {
$.ajax({
type:'GET',
url: url,
dataType: 'json',
error: function(jqXHR, exception) {ajax_error_handler(jqXHR, exception);},
success: function(data){
$.each(data.entry, (index, value) => {
const tableRow = document.createElement('tr');
const tdExtension = document.createElement('td');
extension.textContent = value.status;
const tdStatus = document.createElement('td');
if (value.status == 3) status.textContent = 'Busy';
if (value.status == 2) status.textContent = 'Ringing';
if (value.status == 1) status.textContent = 'Online';
tdStatus.classList.add(`status-${value.status}`);
tableRow.appendChild(tdExtension);
tableRow.appendChild(tdStatus);
$('#list_table_json').append(tableRow);
}
});
}
}
and add the css, but now i can't get any values back. but now i can't get any values back. (sorry I'm fairly new to javascript)
Please use the DOM API
One way of getting colors would be to use CSS classes for the status:
// js
...
$.each(data.entry, (index, value) => {
const tableRow = document.createElement('tr');
const tdExtension = document.createElement('td');
extension.textContent = value.extension;
const tdStatus = document.createElement('td');
if (value.status == 3) status.textContent = 'Busy';
if (value.status == 2) status.textContent = 'Ringing';
if (value.status == 1) status.textContent = 'Online';
tdStatus.classList.add(`status-${value.status}`);
tableRow.appendChild(tdExtension);
tableRow.appendChild(tdStatus);
$('#list_table_json').append(tableRow);
});
...
// css
.status-1 {
color: green;
}
.status-2 {
color: red;
}
.status-3 {
color: orange;
}
I finally got the script working. I am now trying to build in a polling, however I see that the ajax call is executed again and the array is fetched. However, the table is not refreshed but a new table is added, does anyone know a solution for this?
code I'm using now for the repoll is
function repoll(poll_request, poll_interval, param=null) {
if (poll_interval != 0) {
if (window.timeoutPool) {
window.timeoutPool.push(setTimeout(function() { poll_request(param); }, poll_interval));
}
else {
setTimeout(function() { poll_request(param); }, poll_interval);
}
}
else {
log_msg('Poll cancelled.');
}
}
tableRow.appendChild(tdExtension);
tableRow.appendChild(tdNr);
tableRow.appendChild(tdStatus);
$('#list_table_json').append(tableRow);
});
repoll(get_blf, poll_interval_blf);

Angularjs using a factory properly

I was wondering if you could help.
I have the below code which sets a timeout delay before making a http request. The watch is bound to a input box. This is currently in my controller and it works.
$scope.$watch('query.keyword',function($http){
var searchInput = document.getElementById('searchInput').value;
var minLength = 3;
var req;
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(function(){
var newValue = searchInput;
if(newValue !== null && newValue.length > minLength) {
window.alert(newValue);
req = {
method: 'SET',
url: ''
};
}
}, 3000);
return $http(req);
});
Now I want this as a factory/service to call upon rather than listing it in my controller.
I then made this...
app.factory('sendSearchData', function($http) {
var searchInput = document.getElementById('searchInput').value;
var minLength = 3;
var req = null;
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(function(){
var newValue = searchInput;
if(newValue !== null && newValue.length > minLength) {
window.alert(newValue);
req = {
method: 'SET',
url: 'haha.php'
};
}
}, 3000);
return function() {
if($http !== null) {
return $http(req);
} else { return 0; }
};
});
Not sure if the return is right, as the previous return was flagging up a http null error.
So to use it I've done a few variations of the below code in my controller.
$scope.$watch('query.keyword', sendSearchData.success());
But I am having no luck and it's refusing to render.
Can anyone help?

Google Drive - Nested operations for undo/redo

If I have code like follows
model.beginCompoundOperation();
model.beginCompoundOperation()
someModelChanges();
model.endCompoundOperation();
model.beginCompoundOperation()
someMoreModelChanges();
model.endCompoundOperation();
model.endCompoundOperation()
When I call undo, will it group someModelChanges, and someMoreModelChanges together? I would like both to be undone as a batch operation. Thanks!
I put together a test page for this and it has the behavior you want and I would expect. Have fun with the realtime API!
var clientId = "<<<REPLACE WITH YOUR CLIENT ID>>>";
var REALTIME_MIMETYPE = 'application/vnd.google-apps.drive-sdk';
// Everything interesting is at the bottom in the onDocLoaded function.
function createRealtimeFile(title, description, callback)
{
console.log('Creating Drive Document');
gapi.client.drive.files.insert({
'resource':
{
'mimeType': REALTIME_MIMETYPE,
'title': title,
'description': description
}
}).execute(function (docInfo)
{
callback(docInfo, /*newDoc*/true);
});
}
function openRealtimeFile(title, callback)
{
gapi.client.load('drive', 'v2', function ()
{
gapi.client.drive.files.list(
{
'q': 'title='+"'"+title+"' and 'me' in owners and trashed=false"
}).execute(function (results)
{
if (!results.items)
{
createRealtimeFile(title, /*DocDescription*/"", callback);
}
else
{
callback(results.items[0], /*newDoc*/false);
}
});
});
}
function onPageLoad()
{
var GScope =
{
Drive: 'https://www.googleapis.com/auth/drive.file'
};
gapi.load('auth:client,drive-realtime,drive-share', function()
{
var handleAuthResult = function(authResult)
{
console.log('Requesting Drive Document');
openRealtimeFile("TESTDOC__", function (docInfo, newDoc)
{
if (docInfo && docInfo.id)
{
gapi.drive.realtime.load(docInfo.id, onDocLoaded, onDocInitialized, onDocLoadError);
}
else
{
console.log('Unable to find realtime doc');
debugger;
}
});
};
gapi.auth.authorize(
{
client_id: clientId,
scope: [ GScope.Drive ],
immediate: false
}, handleAuthResult);
});
}
function onDocInitialized(model)
{
console.log('Drive Document Initialized');
var docRoot = model.createMap();
model.getRoot().set('docRoot', docRoot);
}
function onDocLoaded(doc)
{
var docModel = doc.getModel();
var docRoot = docModel.getRoot();
console.log('Drive Document Loaded');
// If the loaded document has already been used to test, delete any previous data.
if (docRoot.has('testMap'))
{
docRoot.delete('testMap');
}
// Setup the new test data
docRoot.set('testMap', docModel.createMap());
var testMap = docRoot.get('testMap');
console.assert(testMap, 'Test map required');
var testString = docModel.createString();
testMap.set('testString', testString);
console.assert(testString.getText() === '');
docModel.beginCompoundOperation();
docModel.beginCompoundOperation();
testString.append('AAA');
docModel.endCompoundOperation();
docModel.beginCompoundOperation();
testString.append('BBB');
docModel.endCompoundOperation();
docModel.endCompoundOperation();
console.assert(testString.getText() === 'AAABBB');
docModel.undo();
console.assert(testString.getText() === '');
debugger;
}
function onDocLoadError(e)
{
console.log('Doc Load Error: ', e);
findAndLoadDoc();
}

MediaStreamRecorder - Recording Audio Issue

I've just rummaged through and put together an audio-video recorder that will record audio and video streams separately and upload them to my server where they'll get joined.
BUT, my implementation has the audio dropping off after a few seconds mostly 7 seconds and 14 seconds.
I'm using RecordRTC javascript library and here's the link: https://www.webrtc-experiment.com/RecordRTC.js
And here's the code:
var record = document.getElementById('replyfallback_record');
var stop = document.getElementById('replyfallback_cancel');
var audio = document.querySelector('audio');
var recordVideo = document.getElementById('record-video');
var preview = document.getElementById('replyfallback_video');
var recordAudio, recordVideo, progress;
$('#replyfallback_record').click(function(){
switch($('#replyfallback_record').text()){
case "Record":
//setup some variables
var video_constraints = {
mandatory: { },
optional: []
};
//trigger navigator.getUserMedia
navigator.getUserMedia({
audio: true,
video: true
}, function(stream) {
preview.src = window.URL.createObjectURL(stream);
preview.play();
// var legalBufferValues = [256, 512, 1024, 2048, 4096, 8192, 16384];
// sample-rates in at least the range 22050 to 96000.
recordAudio = RecordRTC(stream, {
type: 'audio',
bufferSize: 16384,
sampleRate: 45000
});
/*recordVideo = RecordRTC(stream, {
type: 'video'
});*/
recordAudio.startRecording();
//recordVideo.startRecording();
$('#replyfallback_record').text("Stop & Submit");
});
break;
case "Stop & Submit":
$('#replyfallback_record').attr('disable','disable');
fileName = uid();
recordAudio.stopRecording(function(url){
window.open(url);
});
PostBlob(recordAudio.getBlob(), 'HTML5UploadAudio', fileName);
//recordVideo.stopRecording();
//PostBlob(recordVideo.getBlob(), 'HTML5UploadVideo', fileName);
preview.src = '';
$('#replyfallback_record').text("submitting...");
break;
}
});
//basic ajax request object function
function xhr(url, data, progress, callback) {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState == 4 && request.status == 200) {
callback(request.responseText);
}
};
request.onprogress = function(e) {
if(!progress) return;
if (e.lengthComputable) {
progress = (e.loaded / e.total) * 100;
}
$('#replyfallback_record').text("submitting..."+progress);
if(progress == 100){
progress = 0;
}
};
request.open('POST', url);
request.send(data);
}
function PostBlob(blob, fileType, fileName) {
// FormData
var formData = new FormData();
formData.append('filename', fileName);
formData.append('blob', blob);
formData.append("function",fileType);
if(fileType=="HTML5UploadVideo"){
formData.append("CN_UL_title",$('#replyfallback_title').val());
formData.append("CN_UL_description",$('#replyfallback_desc').val());
formData.append("CN_UL_category","1");
}
// POST the Blob
xhr(SITE.api, formData, progress, function(data) {
$('#replyfallback_record').text("Record");
alert(data+" | "+getReadableFileSizeString(recordAudio.getBlob().size));
});
}
It is a little late reply, but may be help future visitor.
Please try PostBlob(recordAudio.getBlob(), 'HTML5UploadAudio', fileName); inside stopRecording callback function.
recordAudio.stopRecording(function(url){
PostBlob(recordAudio.getBlob(), 'HTML5UploadAudio', fileName);
window.open(url);
});