MODX endless saving SyntaxError: expected expression, got '<' - extjs

I have to deal with MODX Revolution, when I edit any page and press Save, the progress bar keeps loading forever, console says SyntaxError: expected expression, got '<' ext-all.js:21
Tried to disable all extensions in package manager
Tested on Chrome 59 and Firefox 54
MODX Revolution 2.5.2-pl
Ext JS 3.4
IIS 8

OK, I solved this. In Chrome console I used beautifier to beautify ext-all.js. Then I replaced compressed javascript with beautified one. After a bit of debugging I've found this piece of code:
try {
A = r.contentWindow.document || r.contentDocument || g.frames[l].document;
if (A) {
if (A.body) {
if (/textarea/i.test((z = A.body.firstChild || {}).tagName)) {
w.responseText = z.value
} else {
w.responseText = A.body.innerHTML
}
}
w.responseXML = A.XMLDocument || A
}
}
The problem was that A.body.innerHTML returned JSON wrapped with "pre" tag. I didn't want to dig further into this, so just added
w.responseText = w.responseText.match(/\{.*\}/)[0]
This should be fixed by extjs or modix team I guess...

Related

console error when running npm start command in new react project

I would like you to help me repair an error that I have, is that every time I create a new project in react with the command npx create-react-app app-name and followed by a cd to the directory and an npm start, I says everything is correct:
Compiled successfully!
You can now view cacas in the browser.
Local: http://localhost:3000
On Your Network: http://172.27.248.214:3000
Note that the development build is not optimized.
To create a production build, use yarn build.
enter image description here
Followed by this I go to the browser, and I give f12 to start the inspector, and I run into the following errors:
First error
Error handling response: SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at chrome-extension://bmjmipppabdlpjccanalncobmbacckjn/js/content/content.js:60:21
According to the error is in this line
data = JSON.parse(data.cs_template);
Full code shown
document.addEventListener('DOMContentLoaded', function () {
for (var i = 0; i < blacklist.length; i++) {
if (location.href.search(blacklist[i]) > 0)
return;
}
cStyle = document.createElement('style');
cStyle.id = 'cs_cursor_css_no_hd';
document.head.appendChild(cStyle);
if (!document.getElementById('elem_ext')) {
elem_ext = document.createElement('div');
elem_ext.id = 'elem_ext';
elem_ext.style.display = 'none';
document.documentElement.appendChild(elem_ext);
}
chrome.storage.local.get('storage_data', function (data) {
if (localStorage.hasOwnProperty('storage_data'))
localStorage.removeItem('storage_data');
localStorage.setItem('storage_data', data.storage_data);
document.documentElement.dataset.csCursorMode = hd_mode;
insert_cs_script();
})
chrome.storage.local.get('cs_template', function (data) {
data = JSON.parse(data.cs_template);
js = document.createElement('script');
js.id = 'cs_cursor_template';
js.innerHTML = data.template;
document.head.appendChild(js);
});
})
Image showing what I already wrote above
enter image description here
Second error
Uncaught SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at main.js:97
The error sends me to this part of code
var storage_data = (localStorage.hasOwnProperty('storage_data')) ? JSON.parse(localStorage.getItem('storage_data')) : {};
enter image description here
Third error
Uncaught ReferenceError: showCsCursorNonHD is not defined
at <anonymous>:1:35
The third error shows me this
cs_hd_mode = false; showCsCursorNonHD(); hideCsCursor();
enter image description here
It is a new project, without any change
enter image description here
Directories
enter image description here
enter image description here
I have been using WSL2 for more than a year and about a month ago these errors began to appear when creating a new project in react
I believe the issue is that you are trying to call JSON.parse(...) on something that is already a JS object. your data in the callback to chrome.storage.local.get('cs_template',...) is already a JS object. I am not sure what the structure of your data is, but data should be the actual cs_template object that can be accessed like data.cs_template in the callback function.

SCRIPT1002: Syntax error - IE 11 , on my Next js

So I migrated from CRA to Next Js. At first my app is working fine on IE 11 while I'm migrating from CRA to next js (I was testing it on IE every time I'm making changes). But then I forgot to test on IE, and now I fully migrated my app on nextjs, and I tried to open it on IE, now the page doesn't fully load because of this error, ( on both dev mode and prod mode). I notice that this error occurs when I'm trying to add my page and component that has socket io-client, I think the error is in debug/src/browser in node_modules. What I don't get is my CRA app also has this dependency, but why it works on IE while the Nextjs version doesn't? I used my old CRA app and just installed next, and made changes, so it has babel.
This is the error:
SCRIPT1002: Syntax error
_app.js (24050,23)
Now when I click it, this is the code where the error occurs
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.storage = localstorage();
exports.destroy = (() => {
let warned = false;
return () => {
if (!warned) {
warned = true;
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
}
};
})();
Please help me! thank you.
I downgraded my socket.io-client version to socket.io-client#2.3.1

Protractor - Unable to access element due to fixed Top navigation bar

I'm facing the following issue in protractor with jasmine
Click/mouse hover not working because of fixed top navigation bar in my application. I need to click/perform mouse hover on a web page.
Unfortunately that element is displaying behind that fixed navigation bar. So scroll till element present & click by x & y coordinates are not working.
My dependencies are :
protractor version 5.2.2
node 8.9.3
selenium standalone 3.13
chrome driver-2.40
chromebrowser v67
OS- Windows 10
Thanks in advance
Try using prototype executeScript
Just try clicking that element from the browser console using id,name or xpath.
For example :
var el = element(by.module('header'));
var tag = browser.executeScript('return arguments[0].click()', el).then(function() {
expect(something).toMatch(something);
});
Another way, along the same lines as what Bharath Kumar S and knowing JeffC's caveat that this approach is cheating, I had a similar issue where the App-Header kept getting in my way of clicking, and I knew I was willing to never need it (so, for instance, to find other ways to navigate or log out and not check for stuff that was on it). I, therefore, did the following, which solved the problem. Note if you refresh the screen, you have to call it again. Also note I am using a number of functions from https://github.com/hetznercloud/protractor-test-helper, which do what you would expect from their names.
var removeAppHeaderIfAny = async function() {
//this function hides the app header
//it is useful to avoid having covers there when Protractor worries that something else will get the click
let found = false;
try {
found = await waitToBeDisplayed(by.className("app-header"), 2000);
} catch (e) {
let s: string = "" + e;
if (s.search("TimeoutError") != 0) flowLog("presumably fine, cover already removed: " + e);
found = false;
}
if (!found) return;
if (found) {
let coverElement = await element(by.className("app-header"));
browser.executeScript(
"arguments[0].style.visibility='hidden';",
coverElement
);
await waitToBeNotDisplayed(by.className("app-header"), 10000);
}
return;
//note after this is called you will not see the item, so you cannot click it
};
As I look at the code, it strikes me one can probably remove the if (found) and associated brackets at the end. But I pasted in something I know has been working, so I am not messing with that.
As indicated up front, I knew I was willing to forego use of the app-header, and it is a bit crude.

"SyntaxError: Unexpected token e in JSON at position 0" only on Chrome - why?

I discovered a strange error today that only appears when loading:
localhost:9000 and only on Chrome!
AND http://parke.linkpc.net:9000/ works fine on Chrome!
AND localhost:9000 works fine on Firefox.
I went back many builds and still see the same, so this has something to do with the hostname not specified? Note I have cleared chrome cache etc. but no help.
This happens when by 'Auth' service is being instantiated and calling:
$cookieStore.get('token'))
which calls:
$cookieStore.get('token'))
and then when it is attempting to parse a cookie at the code:
getObject: function(key) {
var value = this.get(key);
return value ? angular.fromJson(value) : value;
},
value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1NzY5ODI5Y2MyZjU5NGM0NWQwNjMxODkiLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE0NjY1MzI1NDAsImV4cCI6MTQ2NjU1MDU0MH0.Vm9GtPMxts1915J6UIzQtDDJ8LvXUKcbWrRxT8jQWzk"
It crashes with:
"Unexpected token e in JSON at position 0"
Why is this? And why only on Chrome?
NEXT: I deleted all the cookies and the problem went away. And I cannot generate it a second time. So go figure.... But it would be nice to know what could cause this issue!
Change the name of key 'token'.
Example:
$cookieStore.get('authKey'))
Instead of:
$cookieStore.get('token'))

Extjs - cant load content to panel

I created Extjs.Panel and now I would like to dynamically load a content to it. So I wrote this simple code
Ext.get('contentPanel').load({
url: '#Url.Action("TempView","Home")'
});
After executing this function, panel is populated with TempView, however couple of seconds later I get an error in Extjs library
Microsoft JScript runtime error:Unable to get value of the property
'events': object is null or undefined.
EDIT
I flollowed #DmitryB advice and I used debug version of library. Here is what I found out. It turned out that the problem is in function
getElementEventCache
which is defined in file ext-all-debug.js in line 11108. The function looks this way
getElementEventCache : function(element) {
if (!element) {
return {};
}
var elementCache = Ext.cache[this.getId(element)];
return elementCache.events || (elementCache.events = {});
},
The exception is thrown in the last line, because of the fact that elementCache is null.
Here is the stacktrace from visualstudio
I had a very similar error that was resolved by adding the following line. (from this forum thread)
if(Ext.isIE) {
Ext.enableGarbageCollector=false;
}
I'm using bellow code and work cool. This may help you.
Try this
var content_div = Ext.get(div_id);
content_div.load({
url:your_url,params:{id:'abc'},scripts:true,text: 'Loading...'});
content_div.show();

Resources