how to get the value of of jquery current date to " $('#current-date')" to abc :after { content: - css-content

I need to get the p id='current-date' to replace the.abc :after.
This is the code:
....
$('#current-date').html("<i class="fa fa-calendar"> "+ mm + " " + dd + ", " + yyyy + ", "+ n);
/** this would be the value of content**/
.abc :after {
content: "This text replaces the original."; } /**replace this to the value <p id=**/

Related

Cypress: Assign and access global variable in cypress

I'm new with cypress, I tried to set several global variables to use for different purposes. However, the scope of those variables are different even they are declared as global. My expectation is output 3: 0 and 4 and 1, how could I do that? Thanks everyone, my code as below:
var totalCouponCredit = []
var arrayGameCredit = []
var totalSelectedCredit, userUsedCredit, gameCredit
describe ('Testing',function(){
it('Login',function(){
cy.get('div.row.flex-lg-column.h-100>div:nth-of-type(1)>div>div>h6').then(($selectedCredit)=>{
//This is the string return "SELECTED CREDITS 0/4", userUsedCredit is 0 and totalSelectedCredit is 4 after split
totalCouponCredit = $selectedCredit.text().match(/[a-zA-Z]+|[0-9]+(?:\.[0-9]+|)/g)
userUsedCredit = parseInt(totalCouponCredit[2])
totalSelectedCredit = parseInt(totalCouponCredit[3])
cy.get('div.col>p:nth-of-type(1)>span>span').then(($gameCredit)=>{
//This is the string return "This title is worth 1 credit(s)", gameCredit is 1 after split
arrayGameCredit = $gameCredit.text().match(/[a-zA-Z]+|[0-9]+(?:\.[0-9]+|)/g)
gameCredit = parseInt(arrayGameCredit[4])
cy.log("Out put 1:" + userUsedCredit + " and " + totalSelectedCredit + " and " +gameCredit)
})
cy.log("Out put 2:" + userUsedCredit + " and " + totalSelectedCredit + " and " +gameCredit)
})
cy.log("Out put 3:" + userUsedCredit + " and " + totalSelectedCredit + " and " +gameCredit)
})
})
OUTPUT:
Output 1: 0 and 4 and 1
Output 2: 0 and 4 and undefined
Output 3: undefined and undefined and undefined

Is it possible to add a Relative Time Field to a Kibana Datatable

I would like to add a field to a datatable which shows the elapsed time based on another date field. Specifically, I have a field which provides the event date and time, and need another field which shows that event happened 1 day 2 hours and 15 minutes ago. When they look at the same visualization a minute later the field should update to 1 day 2 hours and 16 minutes ago.
I know that I can have users select the time range they would like to focus on, but I'm attempting to duplicate functionality from a previous (non-ELK) solution which offered this field.
So here's what I came up with:
long different = (System.currentTimeMillis() - doc['BeginDate'].value);
long secondsInMilli = 1000;
long minutesInMilli = secondsInMilli * 60;
long hoursInMilli = minutesInMilli * 60;
long daysInMilli = hoursInMilli * 24;
long elapsedDays = different / daysInMilli;
different = different % daysInMilli;
long elapsedHours = different / hoursInMilli;
different = different % hoursInMilli;
long elapsedMinutes = different / minutesInMilli;
different = different % minutesInMilli;
long elapsedSeconds = different / secondsInMilli;
different = different % secondsInMilli;
if(elapsedSeconds < 1) {
different.toString() + " milliseconds";
} else if (elapsedSeconds == 1) {
elapsedSeconds.toString() + " second, " + different.toString() + " milliseconds";
} else if (elapsedMinutes < 1) {
elapsedSeconds.toString() + " seconds, " + different.toString() + " milliseconds";
} else if (elapsedMinutes == 1) {
elapsedMinutes.toString() + " minute, " + elapsedSeconds.toString() + " seconds";
} else if (elapsedHours < 1) {
elapsedMinutes.toString() + " minutes, " + elapsedSeconds.toString() + " seconds";
} else if (elapsedHours == 1) {
elapsedHours.toString() + " hour, " + elapsedMinutes.toString() + " minutes";
} else if (elapsedDays < 1) {
elapsedHours.toString() + " hours, " + elapsedMinutes.toString() + " minutes";
} else if (elapsedDays == 1) {
elapsedDays.toString() + " day, " + elapsedHours.toString() + " hours";
} else {
elapsedDays.toString() + " days, " + elapsedHours.toString() + " hours";
}
I added a scripted field to the Index Pattern, chose "painless" for language, "date" for Type, "String" for Format, and Transform is "- none -".
It isn't pretty, but it appears to work. I'm certain that it could be improved greatly, but it appears to fit my needs. Hope this helps someone else.

Bash script to get mongoStats

Hoping someone has a bash script handy that will hit a mongodb and get the collection stats something like the below that I can use in a shell script?
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
UPDATE
one other question --- looking to prefix the line with a datestamp
"db.getCollectionNames().forEach(function (n) { var s = db[n].stats(); print('date +'%D %r %Z'''namespace=' + s['ns'] +',count=' + s['count']+',avgObjSize=' + s['avgObjSize']+',storageSize=' + s['storageSize']) })"
but my date code doesn't seem to be working :(
mongo $DB_NAME --quiet --eval "db.getCollectionNames().forEach(function (n) { var s = db[n].stats(); print(s['ns'] + ',' + s['size'] + ',' + s['storageSize']) })" | sort --numeric-sort --reverse
It will print in a CSV format which you can you couple of tools to manipulate.
Update:
Just add avgObjSize, totalIndexSize and other keys you need, edit your main question with an output example so we can sort by whatever column you desire.
Update 2:
db.getCollectionNames().forEach(function (n) { var s = db[n].stats(); printjson({'namespace': s['ns'], 'size': s['size'], 'storage': s['storageSize']}) })
db.getCollectionNames().forEach(function (n) { var s = db[n].stats(); print('size=' + s['size'] +',avgObjSize=' + s['avgObjSize']) })

How to display fields in new line in same textBox in telerik reporting?

I am using Silverlight4 and Telerik Reporting Q3 2011. I am trying to Generate Reports of all Outlets. I used Table to display its fields. And I want to Display Full Address in same cell. How could I?
I Used following Experession to display Full Address in same cell.
= Fields.AddressLine1
+ ", " + Fields.AddressLine2
+ ", " + Fields.Suburb
+ ", " + Fields.City
+ ", " + Fields.State
+ ", " + Fields.Country
I want do display this in same cell but want output like below..
=====================
Address
=====================
15A,
xxxx xxxRoad,
xxxxxx,
xxxxxxxx
====================
But I m getting this
=====================
Address
=====================
15A, xxxx xxxRoad, xxxxxx, xxxxxxxx
=====================
How do I get Output Which I want?
made the Function NewLineFeeds() in this function I used Replace() Method to replace the specific string to newLine(\n) .
public static string NewLineFeeds(string text)
{
string result = text.Replace(", ", "\n");
result = result.Replace(", ", "\n");
result = result.Replace(", ", "\n");
return result;
}
and my Expression is
=NewLineFeeds(Fields.AddressLine1
+ ", " + Fields.AddressLine2
+ ", " + Fields.Suburb
+ ", " + Fields.City
+ ", " + Fields.State
+ ", " + Fields.Country)
This call the Function NewLineFeeds() and replace ", " to \n (new Line). Add this will work Fine..

Ace editor, inaccurate horizontal scroll, how to fix?

Using Ace editor, works OK, except: and start and end of line, if there is at least one line of the document that doesn't fit the screen, horizontal scroll is incomplete. For caret at start of line, once the view is h-scrolled, it won't scroll back fully when caret is at start of line, and thus the caret won't show. Annoying. And the same for caret at end of line (although it seems it doesn't scroll at all, rather than not flush right, so might be different bugs. Anybody know how to fix? And what versions are affected?
(Oh, right, forgot to mention: the gutter is enabled.)
(Edit II: using Google Chrome 18.0.1025.162)
(E#3: forgot to mention: using Shift+scroll wheel I can manually fix it, scrolling full left. (E4: ...and that's just a clue; not a solution. One should not have to do any extraneous manual mousing.))
(Edit#N: managed to hide the gutter: "editor_loaded.renderer.setShowGutter(false);". Problem persists.)
Well, as requested (by 'WarFox'), here's what I did to get around the scrolling issues in version 0.2.0, straight out of local repo. HTH, YMMV. No guarantees for modifying this or any version, of course. The code for this.scrollCursorIntoView is modified to be:
this.scrollCursorIntoView = function() {
var log = function (s) {
// console.log("### scrollCursorIntoView ###: " + s);
};
// log("(scrollCursorIntoView...)");
function loge(expr) {
var value = eval(expr);
log("" + expr + " => " + value);
}
// the editor is not visible
if (this.$size.scrollerHeight === 0)
return;
var pos = this.$cursorLayer.getPixelPosition();
var left = pos.left + this.$padding;
log("left = " + left);
var top = pos.top;
log("top = " + top);
if (this.scrollTop > top) {
this.scrollToY(top);
}
if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) {
this.scrollToY(top + this.lineHeight - this.$size.scrollerHeight);
}
var scrollLeft = this.scroller.scrollLeft;
var left_ = left - this.characterWidth;
log("(scrollLeft > left): " + scrollLeft + " > " + left);
log("(scrollLeft > left_): " + scrollLeft + " > " + left_);
if (scrollLeft > left_) {
this.scrollToX(left_);
} else {
log("NOT (scrollLeft > left): " + scrollLeft + " > " + left);
log("NOT (scrollLeft > left_): " + scrollLeft + " > " + left_);
}
loge("scrollLeft");
log("scrollLeft = " + scrollLeft);
log("this.$size.scrollerWidth = " + this.$size.scrollerWidth);
log("left = " + left);
log("this.characterWidth = " + this.characterWidth);
var right_side_scroll_yes = scrollLeft + this.$size.scrollerWidth < left + this.characterWidth;
if (right_side_scroll_yes) {
log("(right side scroll...)");
//loge("this.layerConfig.width");
if (left > this.layerConfig.width) {
log("right #1");
log("this.layerConfig.width = " + this.layerConfig.width);
this.$desiredScrollLeft = left + 2 * this.characterWidth;
this.scrollToX(this.$desiredScrollLeft);
} else {
log("right #2");
var tmp = Math.round(left + this.characterWidth - this.$size.scrollerWidth);
loge("tmp");
this.scrollToX(tmp);
}
} else {
log("NOT (right_side_scroll_yes): " + scrollLeft + " > " + left);
}
};
Obviously, the logging calls are not necessary for anything but debugging.

Resources