Is there any way to collect data from console to javascript? - javascript

I want to take input from the console and process it for another function.
Is there any way to do that instead of setting those datas as variable before logging them to console.
<html><head><script>
/*
* based on JavaScript Client Detecting by viazenetti GmbH (Christian Ludwig)
*/
(function (window) {
{
var unknown = '-';
// screen
var screenSize = '';
if (screen.width) {
width = (screen.width) ? screen.width : '';
height = (screen.height) ? screen.height : '';
screenSize += '' + width + " × " + height;
}
// browser
var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browser = navigator.appName;
var version = '' + parseFloat(navigator.appVersion);
var majorVersion = parseInt(navigator.appVersion, 10);
var nameOffset, verOffset, ix;
// Opera
if ((verOffset = nAgt.indexOf('Opera')) != -1) {
browser = 'Opera';
version = nAgt.substring(verOffset + 6);
if ((verOffset = nAgt.indexOf('Version')) != -1) {
version = nAgt.substring(verOffset + 8);
}
}
// Opera Next
if ((verOffset = nAgt.indexOf('OPR')) != -1) {
browser = 'Opera';
version = nAgt.substring(verOffset + 4);
}
// MSIE
else if ((verOffset = nAgt.indexOf('MSIE')) != -1) {
browser = 'Microsoft Internet Explorer';
version = nAgt.substring(verOffset + 5);
}
// Chrome
else if ((verOffset = nAgt.indexOf('Chrome')) != -1) {
browser = 'Chrome';
version = nAgt.substring(verOffset + 7);
}
// Safari
else if ((verOffset = nAgt.indexOf('Safari')) != -1) {
browser = 'Safari';
version = nAgt.substring(verOffset + 7);
if ((verOffset = nAgt.indexOf('Version')) != -1) {
version = nAgt.substring(verOffset + 8);
}
}
// Firefox
else if ((verOffset = nAgt.indexOf('Firefox')) != -1) {
browser = 'Firefox';
version = nAgt.substring(verOffset + 8);
}
// MSIE 11+
else if (nAgt.indexOf('Trident/') != -1) {
browser = 'Microsoft Internet Explorer';
version = nAgt.substring(nAgt.indexOf('rv:') + 3);
}
// Other browsers
else if ((nameOffset = nAgt.lastIndexOf(' ') + 1) < (verOffset = nAgt.lastIndexOf('/'))) {
browser = nAgt.substring(nameOffset, verOffset);
version = nAgt.substring(verOffset + 1);
if (browser.toLowerCase() == browser.toUpperCase()) {
browser = navigator.appName;
}
}
// trim the version string
if ((ix = version.indexOf(';')) != -1) version = version.substring(0, ix);
if ((ix = version.indexOf(' ')) != -1) version = version.substring(0, ix);
if ((ix = version.indexOf(')')) != -1) version = version.substring(0, ix);
majorVersion = parseInt('' + version, 10);
if (isNaN(majorVersion)) {
version = '' + parseFloat(navigator.appVersion);
majorVersion = parseInt(navigator.appVersion, 10);
}
// mobile version
var mobile = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(nVer);
// cookie
var cookieEnabled = (navigator.cookieEnabled) ? true : false;
if (typeof navigator.cookieEnabled == 'undefined' && !cookieEnabled) {
document.cookie = 'testcookie';
cookieEnabled = (document.cookie.indexOf('testcookie') != -1) ? true : false;
}
// system
var os = unknown;
var clientStrings = [
{s:'Windows 10', r:/(Windows 10.0|Windows NT 10.0)/},
{s:'Windows 8.1', r:/(Windows 8.1|Windows NT 6.3)/},
{s:'Windows 8', r:/(Windows 8|Windows NT 6.2)/},
{s:'Windows 7', r:/(Windows 7|Windows NT 6.1)/},
{s:'Windows Vista', r:/Windows NT 6.0/},
{s:'Windows Server 2003', r:/Windows NT 5.2/},
{s:'Windows XP', r:/(Windows NT 5.1|Windows XP)/},
{s:'Windows 2000', r:/(Windows NT 5.0|Windows 2000)/},
{s:'Windows ME', r:/(Win 9x 4.90|Windows ME)/},
{s:'Windows 98', r:/(Windows 98|Win98)/},
{s:'Windows 95', r:/(Windows 95|Win95|Windows_95)/},
{s:'Windows NT 4.0', r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},
{s:'Windows CE', r:/Windows CE/},
{s:'Windows 3.11', r:/Win16/},
{s:'Android', r:/Android/},
{s:'Open BSD', r:/OpenBSD/},
{s:'Sun OS', r:/SunOS/},
{s:'Linux', r:/(Linux|X11)/},
{s:'iOS', r:/(iPhone|iPad|iPod)/},
{s:'Mac OS X', r:/Mac OS X/},
{s:'Mac OS', r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},
{s:'QNX', r:/QNX/},
{s:'UNIX', r:/UNIX/},
{s:'BeOS', r:/BeOS/},
{s:'OS/2', r:/OS\/2/},
{s:'Search Bot', r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}
];
for (var id in clientStrings) {
var cs = clientStrings[id];
if (cs.r.test(nAgt)) {
os = cs.s;
break;
}
}
var osVersion = unknown;
if (/Windows/.test(os)) {
osVersion = /Windows (.*)/.exec(os)[1];
os = 'Windows';
}
switch (os) {
case 'Mac OS X':
osVersion = /Mac OS X (10[\.\_\d]+)/.exec(nAgt)[1];
break;
case 'Android':
osVersion = /Android ([\.\_\d]+)/.exec(nAgt)[1];
break;
case 'iOS':
osVersion = /OS (\d+)_(\d+)_?(\d+)?/.exec(nVer);
osVersion = osVersion[1] + '.' + osVersion[2] + '.' + (osVersion[3] | 0);
break;
}
// flash (you'll need to include swfobject)
/* script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" */
var flashVersion = 'no check';
if (typeof swfobject != 'undefined') {
var fv = swfobject.getFlashPlayerVersion();
if (fv.major > 0) {
flashVersion = fv.major + '.' + fv.minor + ' r' + fv.release;
}
else {
flashVersion = unknown;
}
}
}
window.jscd = {
screen: screenSize,
browser: browser,
browserVersion: version,
browserMajorVersion: majorVersion,
mobile: mobile,
os: os,
osVersion: osVersion,
cookies: cookieEnabled,
flashVersion: flashVersion
};
}(this));
console.log(
'OS: ' + jscd.os +' '+ jscd.osVersion + '\n' +
'Browser: ' + jscd.browser +' '+ jscd.browserMajorVersion +
' (' + jscd.browserVersion + ')\n' +
'Mobile: ' + jscd.mobile + '\n' +
'Flash: ' + jscd.flashVersion + '\n' +
'Cookies: ' + jscd.cookies + '\n' +
'Screen Size: ' + jscd.screen + '\n\n' +
'Full User Agent: ' + navigator.userAgent
);
// http://stackoverflow.com/a/3922353/846193
/* MAC Key Binding on Browsers
Firefox: 224
Opera: 17
WebKit (Safari/Chrome): 91 (Left Apple) or 93 (Right Apple)
*/
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
// At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera; // Chrome 1+
var isIE = /*#cc_on!#*/false || !!document.documentMode; // At least IE6
</script></head>
<body bgcolor="lightgray">
Output is in console.
Check them through developers mode
</body></html>
I tried every possible ways as solutions and read multiple blogs but none of them giving efficient answer in this case. Especially when it comes to JavaScript console.
I can't set them as variable before this script completely compiled. So is there any way to collect those datas from console.
[ The given code logs datas about user's device specifications to console.
eg: Operating system, Browser, is a bot?, Is Cookies enabled? ]

You can do so via prompt as easy as:
const input = prompt("What's your name?");
console.log(input);

These lines in the code you are presenting:
console.log(
'OS: ' + jscd.os +' '+ jscd.osVersion + '\n' +
'Browser: ' + jscd.browser +' '+ jscd.browserMajorVersion +
' (' + jscd.browserVersion + ')\n' +
'Mobile: ' + jscd.mobile + '\n' +
'Flash: ' + jscd.flashVersion + '\n' +
'Cookies: ' + jscd.cookies + '\n' +
'Screen Size: ' + jscd.screen + '\n\n' +
'Full User Agent: ' + navigator.userAgent
);
Are those who print the output in the console. So if you want to reuse any of this values in Js you just need to reference to the matching variable. So for example: OS is stored in the javascript variable jscd.os and its version is in the javascript variable jscd.osVersion

Related

Javascript for Phone Number Formatting in Dynamics 365

Javascript we had for Unified interface of Dynamics 365 to format phone numbers was working perfectly until the latest update, now it only works in custom interface and has stopped working in UI, anybody has any idea how this can be fixed?
var XXX = window.XXX || {};
(function() {
// Code to run in the form OnLoad event
this.formOnLoad = function(executionContext) {
var formContext = executionContext.getFormContext();
// display the form level notification as an INFO
formContext.ui.setFormNotification(message, "INFO", myUniqueId);
// Wait for 5 seconds before clearing the notification
window.setTimeout(function() {
formContext.ui.clearFormNotification(myUniqueId);
}, 5000);
}
// Code to run in the attribute OnChange event
this.mobilePhoneFormatting = function(executionContext) {
var formContext = executionContext.getFormContext();
var mobilePhone = formContext.getAttribute("mobilephone").getValue();
var formatPhone = "";
try {
if (mobilePhone != null) {
var phoneNumbers = mobilePhone.replace(/\D/g, '');
if (phoneNumbers.length == 10) { //10 digit case. Output adds +1 and proper format
formatPhone = ("+1 (" + phoneNumbers.substring(0, 3) + ") " + phoneNumbers.substring(3, 6) + "-" + phoneNumbers.substring(6, 10));
} else if (phoneNumbers.length == 11) { //11 digit case. Output proper format
formatPhone = ("+" + phoneNumbers.substring(0, 1) + " (" + phoneNumbers.substring(1, 4) + ") " + phoneNumbers.substring(4, 7) + "-" + phoneNumbers.substring(7, 11));
} else if (phoneNumbers.length == 14) { //14 digit case. Without Country code and with extension
formatPhone = ("+1 (" + phoneNumbers.substring(0, 3) + ") " + phoneNumbers.substring(3, 6) + "-" + phoneNumbers.substring(6, 10) + " x" + phoneNumbers.substring(10, 14));
} else if (phoneNumbers.length == 15) { //15 digit case. With Country code and extension
formatPhone = ("+" + phoneNumbers.substring(0, 1) + " (" + phoneNumbers.substring(1, 4) + ") " + phoneNumbers.substring(4, 7) + "-" + phoneNumbers.substring(7, 11) + " x" + phoneNumbers.substring(11, 15));
} else if (phoneNumbers.length == 4) { //4 digit case. Extension Only
formatPhone = ("x" + phoneNumbers.substring(0, 4));
} else {
formatPhone = mobilePhone;
}
formContext.getAttribute("mobilephone").setValue(formatPhone);
formContext.data.entity.save();
}
} catch (err) {
txt = "There was an error formatting the Phone Number.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
}

How to prevent decode encodeURIComponent in address bar in mobile device? Google Blogger Error - Pagination is not working correct in mobile device

Please read carefully. The problem is coming in the Google Blogger template. Pagination are not working properly in the mobile devices. It is working fine in the Desktop and tablet mode. The pagination is the code of JavaScript.
I tried to find the issue and I got that - "URL is not encoding in the address bar in the mobile mode". That's why the pagination buttons are not showing as per the number of pages. Due to this blogger unable to read the proper url in address bar. See below example
Correct Encoded Address in Desktop- https://www.example.com/search?updated-max=2019-06-25T21%3A53%3A00%2B05%3A30&max-results=4
Incorrect Address in Mobile - https://www.example.com/search?updated-max=2019-06-25T21:53:00%2B05:30&max-results=4&m=1
2019-06-25T21:53:00+05:30 This part of URL in Address Bar should be encoded.
Means 2019-06-25T21:53:00+05:30 should be 2019-06-25T21%3A53%3A00%2B05%3A30 in Mobile same as Desktop. But the colon(:) is not encoding in %3A. This is the main issue.
If I manually edit the URL in address bar and write %3A instead of colon(:) and press the enter, then it is working correct.
I debug the JavaScript Code from the chrom developer tool. I applied the breakpoint here f = encodeURIComponent(f); Then I got that - the encoding is working fine in Desktop and Mobile too. This is shocking.
So, what's the problem? Why the URL is not encoding in the address bar in Mobile mode? 90% I guess that - the Encoded URL part is again Decoding in mobile mode. Means colon(:) is encoding in %3A then again decoding in colon(:) in mobile mode.
This is the problem analysis by me. But I may be wrong. I haven't much stronger knowledge of JS. This kind of issue is shocking and facing first time.
<script>
/*JavaScript Code of Pagination*/
var pageNaviConf = {
perPage: 4,
numPages: 4,
firstText: "First ",
lastText: "Last ",
nextText: "Next ",
prevText: "Prev "
}
//<![CDATA[
function pageNavi(o) {
var m = location.href,
l = m.indexOf("/search/label/") != -1,
a = l ? m.substr(m.indexOf("/search/label/") + 14, m.length) : "";
a = a.indexOf("?") != -1 ? a.substr(0, a.indexOf("?")) : a;
var g = l ? "/search/label/" + a + "?updated-max=" : "/search?updated-max=",
k = o.feed.entry.length,
e = Math.ceil(k / pageNaviConf.perPage);
if (e <= 1) {
return
}
var n = 1,
h = [""];
l ? h.push("/search/label/" + a + "?max-results=" + pageNaviConf.perPage) : h.push("/?max-results=" + pageNaviConf.perPage);
for (var d = 2; d <= e; d++) {
var c = (d - 1) * pageNaviConf.perPage - 1,
b = o.feed.entry[c].published.$t,
f = b.substring(0, 19) + b.substring(23, 29);
f = encodeURIComponent(f);
if (m.indexOf(f) != -1) {
n = d
}
h.push(g + f + "&max-results=" + pageNaviConf.perPage)
}
pageNavi.show(h, n, e)
}
pageNavi.show = function(f, e, a) {
var d = Math.floor((pageNaviConf.numPages - 1) / 2),
g = pageNaviConf.numPages - 1 - d,
c = e - d;
if (c <= 0) {
c = 1
}
endPage = e + g;
if ((endPage - c) < pageNaviConf.numPages) {
endPage = c + pageNaviConf.numPages - 1
}
if (endPage > a) {
endPage = a;
c = a - pageNaviConf.numPages + 1
}
if (c <= 0) {
c = 1
}
var b = '<span class="pages">Pages ' + e + ' of ' + a + "
</span> ";
if(c > 1){
b += '<a href="' + f[1] + '">' + pageNaviConf.firstText
+ "</a>"
}
if (e > 1) {
b += '<a href="' + f[e - 1] + '">' +
pageNaviConf.prevText + "</a>"
}
if (e < a) {
b += '<a href="' + f[e + 1] + '">' +
pageNaviConf.nextText + "</a>"
}
if (endPage < a) {
b += '<a href="' + f[a] + '">' + pageNaviConf.lastText +
" </a>"
}
document.write(b)
};
(function() {
var b = location.href;
if (b.indexOf("?q=") != -1 || b.indexOf(".html") != -1) {
return
}
var d = b.indexOf("/search/label/") + 14;
if (d != 13) {
var c = b.indexOf("?"),
a = (c == -1) ? b.substring(d) : b.substring(d, c);
document.write('<script type="text/javascript"
src="/feeds/posts/summary/-/' + a + '?alt=json-in-script&callback=pageNavi&max-results=99999"><\/script>')
}
else {
document.write('<script type="text/javascript" src="/feeds/posts/summary?alt=json-in-script&callback=pageNavi&max-results=99999"><\/script>')
}
})()
//]]>
</script>
Overall our target is to Encode colon(:) into %3A in address bar in Mobile. I couldn't find any strong solution on the internet. I humble request to please look for it briefly and fix this issue.
Thanks in advance.

How to create a SharedWorker using a blob?

I would like to create a SharedWorker as described in a chapter of an excellent book: https://github.com/getify/You-Dont-Know-JS/blob/master/async%20%26%20performance/ch5.md
I was able to cook up a very good example for normal web workers:
function createAsker(limit) {
var blob = new Blob(["onmessage = function(e) { " +
"if (self.higher === undefined) self.higher = " + limit + "; " +
"if (self.lower === undefined) self.lower = 1;" +
"if (e.data === 'correct') { " +
"postMessage('Party time'); " +
"} else {" +
"if (e.data === 'greater') self.lower = parseInt((self.lower + self.higher) / 2);" +
"if (e.data === 'lower') self.higher = parseInt((self.lower + self.higher) / 2);" +
"postMessage(parseInt((self.lower + self.higher) / 2));" +
"}" +
"}"]);
var blobURL = window.URL.createObjectURL(blob);
var worker = new Worker(blobURL);
return worker;
}
var asker = createAsker(1000);
function createAnswerer(limit) {
var blob = new Blob(["onmessage = function(e) { " +
"postMessage((e.data == " + limit + ") ? 'correct' : ((e.data < " + limit + ") ? 'greater' : 'lower'));" +
"}"]);
var blobURL = window.URL.createObjectURL(blob);
var worker = new Worker(blobURL);
return worker;
}
var answerer = createAnswerer(42);
asker.onmessage = function(e) {
console.log('Asker says: ' + e.data);
if (e.data !== "Party time") {
setTimeout(function() {answerer.postMessage(e.data)}, 1000);
}
};
answerer.onmessage = function(e) {
console.log('Answerer says: ' + e.data);
setTimeout(function() {asker.postMessage(e.data)}, 1000);
};
asker.postMessage('start');
Yet, I have difficulty on creating a shared worker. I attempted to create one with this code:
function createWorker() {
var blob = new Blob(['addEventListener( "connect", function(evt){ ' +
'var port = evt.ports[0]; ' +
'port.addEventListener( "message", function(evt){' +
'port.postMessage( .. );debugger;' +
'} );' +
'port.start();' +
'} );']);
var blobURL = window.URL.createObjectURL(blob);
var w = new SharedWorker(blobURL);
return w;
}
var w = createWorker();
w.port.start();
w.port.onmessage = function(e) {
console.log(e.data);
};
w.port.onmessage('foobar');
and after sending the message of foobar I would expect my shared worker to post a message, or at least I expect to be guided into the code by the debugger, yet, when I run this code the console gives two undefined as a response.
Base64 encoding gives a permanent URL until the source code changes.
const source = 'importScript("https://anotherhost/worker.js")';
const url = 'data:application/javascript;base64,' + btoa(source);
const worker = new SharedWorker(url);
It works at least in Chrome 73 and Firefox 66.
There is a limit to the length of the encoded URL of about 65 kilobytes.

QtCreator intellisense missing when importing js files with Qt.include(...)

Qt Creator is a good editor, but sometimes it is very frustrating. The fact is that intellisense does not always work correctly.
Sample project would look`s like this:
//Test1.js file
function test1() {
console.log('hi from test1');
}
//Test2.js file
Qt.include('Test1.js');
function test2() {
console.log('hi from test2');
test1();
}
//Test.qml file
import QtQuick 1.1
import "Test2.js" as Test2
QtObject {
Component.onCompleted: {
Test2.test1(); //<--- intellisense missing here
Test2.test2();
}
}
The trouble:
The editor intellisense miss the test1 function included in imported Test2.js. The Qt.include is simple thing - just say qml compiler - hey, copy and paste this js file content here.
The questions is
Is any way to fix this QtCreator behavior?
Is QtCreator plugin model allow to add this behaviour to existing intellisense code? Or this should be fixed with patching QtCreator code base?
Quick and dirty patch.
Need to patch 2 files
source\qt-creator\src\libs\qmljs\qmljsdocument.h and qmljsdocument.cpp.
But the function "Follow symbol under cursor" might not work correctly, if the file has Qt.include
## -104,9 +104,13 ## public:
private:
bool parse_helper(int kind);
+ void parseQtInclude(QString dir, QString fileName, QString& result);
+
+ QList<QString> _parsedFileNames;
private:
QmlJS::Engine *_engine;
+ QmlJS::Engine *_codeCompleteEngine;
AST::Node *_ast;
Bind *_bind;
QList<QmlJS::DiagnosticMessage> _diagnosticMessages;
## -168,6 +168,7 ## QList<Language::Enum> Document::companionLanguages(Language::Enum language)
Document::Document(const QString &fileName, Language::Enum language)
: _engine(0)
+ , _codeCompleteEngine(0)
, _ast(0)
, _bind(0)
, _fileName(QDir::cleanPath(fileName))
## -197,6 +198,9 ## Document::~Document()
if (_engine)
delete _engine;
+
+ if (_codeCompleteEngine)
+ delete _codeCompleteEngine;
}
Document::MutablePtr Document::create(const QString &fileName, Language::Enum language)
## -337,9 +341,54 ## public:
} // anonymous namespace
+void Document::parseQtInclude(QString dir, QString fileName, QString& result)
+{
+
+ QFile file(dir + QDir::separator() + fileName);
+
+ if (_parsedFileNames.contains(file.fileName()) || !file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ return;
+ }
+
+ _parsedFileNames.append(file.fileName());
+
+ QFileInfo fileInfo(file);
+ QTextStream in(&file);
+ QString source = QString();
+
+ while(!in.atEnd()) {
+ source += in.read(2048);
+ }
+
+ file.close();
+ source.remove(QLatin1String(".pragma library"));
+
+ int endPos = 0;
+ int pos = source.indexOf(QLatin1String("Qt.include("), endPos);
+
+ while (pos >= 0 && pos + 11 < source.length()) {
+ QChar comma = source.at(pos + 11);
+ endPos = source.indexOf(comma + QLatin1String(")"), pos);
+ if (endPos == -1)
+ return;
+
+ QString fullStaterment = QString(source.begin() + pos, endPos - pos + 2);
+ QString importName = QString(source.begin() + pos + 12, endPos - pos - 12);
+
+ parseQtInclude(fileInfo.absolutePath(), importName, result);
+
+ source.replace(fullStaterment, QString());
+
+ pos = source.indexOf(QLatin1String("Qt.include("));
+ }
+
+ result += source;
+}
+
bool Document::parse_helper(int startToken)
{
Q_ASSERT(! _engine);
+ Q_ASSERT(! _codeCompleteEngine);
Q_ASSERT(! _ast);
Q_ASSERT(! _bind);
## -349,6 +398,31 ## bool Document::parse_helper(int startToken)
Parser parser(_engine);
QString source = _source;
+ QString fullSource = _source;
+
+ int endPos = 0;
+ int pos = fullSource.indexOf(QLatin1String("Qt.include("), endPos);
+
+ while (pos >= 0 && pos + 11 < fullSource.length()) {
+ QChar comma = fullSource.at(pos + 11);
+ endPos = fullSource.indexOf(comma + QLatin1String(")"), pos);
+ if (endPos == -1)
+ break;
+
+ QString fullStaterment = QString(fullSource.begin() + pos, endPos - pos + 2);
+ QString importName = QString(fullSource.begin() + pos + 12, endPos - pos - 12);
+ QString result = QString();
+
+ parseQtInclude(this->path(), importName, result);
+
+ fullSource.replace(fullStaterment, result);
+
+ pos = fullSource.indexOf(QLatin1String("Qt.include("));
+ if (pos == -1 || pos + 11 == source.length())
+ break;
+ comma = fullSource.at(pos + 11);
+ }
+
lexer.setCode(source, /*line = */ 1, /*qmlMode = */isQmlLikeLanguage(_language));
CollectDirectives collectDirectives(path());
## -369,9 +443,37 ## bool Document::parse_helper(int startToken)
}
_ast = parser.rootNode();
+ AST::Node *savedAst = _ast;
_diagnosticMessages = parser.diagnosticMessages();
+ if (endPos > 0) {
+ _codeCompleteEngine = new Engine();
+ Lexer lexerCodeComplete(_codeCompleteEngine);
+ Parser parserCodeComplete(_codeCompleteEngine);
+
+ bool _parsed;
+
+ lexerCodeComplete.setCode(fullSource, /*line = */ 1, /*qmlMode = */isQmlLikeLanguage(_language));
+ switch (startToken) {
+ case QmlJSGrammar::T_FEED_UI_PROGRAM:
+ _parsed = parserCodeComplete.parse();
+ break;
+ case QmlJSGrammar::T_FEED_JS_PROGRAM:
+ _parsed = parserCodeComplete.parseProgram();
+ break;
+ case QmlJSGrammar::T_FEED_JS_EXPRESSION:
+ _parsed = parserCodeComplete.parseExpression();
+ break;
+ default:
+ Q_ASSERT(0);
+ }
+
+ if (_parsed)
+ _ast = parserCodeComplete.rootNode();
+ }
+
_bind = new Bind(this, &_diagnosticMessages, collectDirectives.isLibrary, collectDirectives.imports);
+ _ast = savedAst;
return _parsedCorrectly;
}

Angular not working in IE8 document mode 7

Angular working well with IE7 document Mode 7. It's also working well with IE8 document Mode 8, but with IE8 document mode 7 not working.
This is the error:
{
description: "Member not found.
",
message: "Member not found.
",
name: "Error",
number: -2147352573
}
And this is the line where the error is throw:
this.$$element.attr(attrName, value);
Member not found
I'm using Angular 1.2.9. How can i fix it?
i have found the solution. Just check if (msie && msie <= 8) and it's work also in IE7.
I have also changed jqLiteRemoveClass and jqLiteAddClass
function jqLiteRemoveClass(element, cssClasses) {
if (msie && msie <= 8) {
if (cssClasses) {
forEach(cssClasses.split(' '), function(cssClass) {
element.className = trim(
(" " + element.className + " ")
.replace(/[\n\t]/g, " ")
.replace(" " + trim(cssClass) + " ", " ")
);
});
}
} else {
if (cssClasses && element.setAttribute) {
forEach(cssClasses.split(' '), function(cssClass) {
element.setAttribute('class', trim(
(" " + (element.getAttribute('class') || '') + " ")
.replace(/[\n\t]/g, " ")
.replace(" " + trim(cssClass) + " ", " "))
);
});
}
}
}
function jqLiteAddClass(element, cssClasses) {
if (msie && msie <= 8) {
if (cssClasses) {
forEach(cssClasses.split(' '), function(cssClass) {
if (!jqLiteHasClass(element, cssClass)) {
element.className = trim(element.className + ' ' + trim(cssClass));
}
});
}
} else {
if (cssClasses && element.setAttribute) {
var existingClasses = (' ' + (element.getAttribute('class') || '') + ' ')
.replace(/[\n\t]/g, " ");
forEach(cssClasses.split(' '), function(cssClass) {
cssClass = trim(cssClass);
if (existingClasses.indexOf(' ' + cssClass + ' ') === -1) {
existingClasses += cssClass + ' ';
}
});
element.setAttribute('class', trim(existingClasses));
}
}
}

Categories