Is it possible to show actual progress from Async Method in Node.Js - node.js

I am now showing a simple .gif image of moving progress lines on html user interface. Which will not show the actual progress (in percentage) happening at the server. I am retrieving data from a server(MongoDB) of lower bandwidth.
I have two choices:
1.To show simple loading/progress .gif image on user interface and then after completion of server end process pop a message to user saying that it is completed.
2.Parallel update can be shown in percentage to user as and when there is a considerable progress at server end.
There are some node-upload-progress, node-progress. But how to use them with long running MongoDB query. (instead of file upload for node-upload-progress).
How can I achieve the (2nd choice) show parallel progress on UI, is it possible to show actual progress from Async Method in Node.Js?

I have used socket.io for this purpose. Here is a demo app (link) which I had referred.
So emitting an event on every 5% completing of process from server end and listening at client side to update percentage on a progress bar.
Techie guys are most welcome to answer if any other efficient alternatives are in existence with Node.js to achieve the same

Related

How to make "Openseadragon" prioritize tile requests?

I am using Openseadragon to show Whole Slide Images running on a server.
When internet connection is not very fast and navigating inside the image, I have many requests pending on the queue that needs to be finished until the specific area I want to see is loaded and rendered.
Is there a way to prioritize new requests over older?
I think it would really improve User Experience.
I tried to change some Openseadragon parameters to make User Experience better but I think there should be a better solution.
Also I found the code below that cancels the requests but also clears everything that has already render and cached so every tile should load again.
I also tried to just cancel all pending requests but there are NO new requests starting so the canceled tiles never load.
window.stop()
viewer = viewport.viewer
var oldImage = viewer.world.getItemAt(0);
var oldBounds = oldImage.getBounds();
var oldSource = oldImage.source;
// Modify tile source as needed
viewer.addTiledImage({
tileSource: oldSource,
x: oldBounds.x,
y: oldBounds.y,
width: oldBounds.width, // It'll do height automatically based on aspect ratio
success: function() {
viewer.world.removeItem(oldImage);
}
});
I want to cancel pending requests and make new ones or just prioritize new requests over older so the user can see new tiles faster and load older tiles on the background.
I don't want the user to just wait for the image to load and keep waiting to load tiles that just passed through that need to load before the actual tiles that they are looking to.
Any thoughts?
Thank you in advance.
By default, OpenSeadragon tries to load as many images simultaneously as the browser will allow. If the user navigates away while those images are in transit, it doesn't cancel their loading. You can adjust this for low bandwidth by asking it to limit tile loads to 1 at a time, by including imageLoaderLimit: 1 in your options when you create your viewer.

Limit Printing of Web Page

I'm in the beginning phases of developing a website. I want to be able to limit the amount of printing of web pages of circulars. These will be in an image format and usually consist of between 2 and 16 web pages. The circulars change each week.
Is there a way to limit the user to only 1 or X number of prints for each page and for each week? Is this easier done with standard web development or can it be done even easier in a content management system such as WordPress?
Not unless you have full control over the client-side.
You can TRY to prevent that SAME computer (via cookie) from
navigating to the same page twice.
If you are giving the user a unique ID to access the circular pages,
you can mark that ID as already having displayed the pages.
But there is simply no way to make sure that the user can't call the print calls in the browser.
One trick, which a js hacker could easily get around.. tie into the page printed event. The answers to that question talk about just how poorly the events are supported, and not cross-browser. If this browser has already had that event fire, nav away or change the #media rule for printing to return css making the whole page display:none (or some trickery).
As far as the actual print dialog ("Copies: x"), there's nothing you can do.

Requesting Advice with parallel programming and webrequest

Currently I have about 20 websites in a list box on my windows form that contain url's.
Each url will navigate to the website download a picture and place the picture into a picture box on the windows form
I have setup 4 picture boxes for the pictures to be entered into.
The user will see the picture of an animal and then will type in the picture and hit a submit button to send the result back to the website for confirmation.
My problem is that when I do try to implement a thread pool I don't have enough time to enter the name of the animal before the next picture loads.
Would it be better for me to create each thread manually and then toggle the button that submits the picture to the site to destroy the thread and grab the next one? I'm very confused. Any help would be awesome.
Thanks
you can use workers to do your background stuff, and a setinterval hack to simulate threads.
start throwing events, and move up the thread ladder when the event signifying completion is thrown.

Need to reload content script for chrome extension on facebook

I created a Chrome extension that adds links to items (things your friends share with you) on your facebook feed. Facebook loads about 10 or 20 items on the feed on page load, and then the rest are loaded via ajax when you scroll down.
I managed to get my content script to work for the first items, but not for the rest. I've read everything i could find, and it seems that I have to reload my content script.
How can i do that considering that the URL does not change?
You can use document.addEventListener with the DOMNodeInserted event to listen for new items getting rendered in the feed. The callback will have to check each node insertion to see if it is a feed item or not. Something like the following should work.
function nodeInsertedCallback(event) { console.log(event); });
document.addEventListener('DOMNodeInserted', nodeInsertedCallback);
Well, you can hang some time driven listener that runs every XX seconds, to verify if there's new items to work with.
Unfortunately there's no event you can hang from, fired when the page's code do some Ajax.
May be you can figure out what evet you can han from to detect the user has reached the end of the loaded item's list, knowing that de page's code will do some Ajax to retrieve more items. Then you start you time driven listenter.

What is window message for a loaded website in Internet Explorer?

I am currently have this message handler line:
MESSAGE_HANDLER(`WM_SETREDRAW`, onSetRedraw)
I would like to know, is there any window message (eg: WM_???) that is connected/related to 'when a website has finish loading inside IE' ?
So I can use it to replace the above WM_SETREDRAW. I want to do something like, when the IE finish loaded a website, it call onSetRedraw.
If no one answers, go Gogoling for an application "spy" tool, which will tell you which messages your program receives. Make a one line app which one launches the browser and spy on that.
Alternatively, what API are you using to launch the browser? Look at it's return value.
Btw, I strongly suspect that you will only get a message when the browser is launched, not every time it loads a new page (or even the first page).
You may not be able to do what you want very easily. A possibility might be to search for the window by title bar, get it's handle, walk its control list until you get to the status bar and check its text in a loop until it is done.
A further possibility, if this is only for yourself, woudl be to get an open source browser which uses the MSIE rendering engine and make a one line change at "the right place in the code" to send a message to your app every time a new page is loaded.

Resources