In a web app, how do I preload a set of arbitrary files to view them more quickly as I go through them? - ajax

Suppose I have a .NET web application that contains two panes. One pane is a viewer capable of displaying a variety of large file types. The other pane contains an arbitrary list of files, e.g. file1.docx, file2.xlsx, file3.pptx, file4.txt, file5.doc, file6.htm, file7.zxz, file8.exe etc.
The user is capable of selecting any file in the list and displaying it in the adjacent pane when the selection changes, presumably via client-side Javascript. Given the user has selected some file, e.g. file1.docx, is there a way to prefetch/preload some number of files in the list, e.g. file2.xlsx and file3.pptx while the user is viewing file1.docx?
If this could be done in the background with an asynchronous Ajax-like call, it would make the application appear faster for users who went from file to file in sequence. I am assuming that the prefetch call could be smart enough not to attempt to request files that could not be viewed, e.g. exe files.
Any help or examples would be much appreciated.

Use hidden iframes to load subsequent documents after the first click. Use a plugin detection script to check file extension support prior to allowing the click event. If you want to prerender, then use each browsers prefetch API:
Chromium Prerender API
MDN: Link Prefetching FAQ
MSDN: Prefetch and Prerender Support
MDN: Link Types

Related

Delete or replace an image in PowerPoint using OfficeJS

I am building an Office JS add-in for PowerPoint, which operates on images of a certain type. I want to be able to delete or replace/update such images, but I cannot find the correct APIs to do this either on a single selected image or even any old image(s).
The Office JS API does not appear to have any PowerPoint specific methods, so it seems I will have to rely on what is available in the Common API. There is no obvious delete method visible.
I am already calling GetFileAsync (similar to this guide) in order to look at the file contents. I could presumably modify those contents, but haven't tried, since I cannot see an API that allows me to re-save those modifications.
Have I missed any useful info?

Possible to include an image in the meta data in code? VS 2013

I would like to be able to include a screenshot of a control inside my code, this way making control identification easier for new members on my team, is such a thing possible?
Maybe even the ability to just have the image on a network share with the path in a comment, and then have a plugin that when hovering over the link brings up the image?
EDIT (More detail):
I'm creating a test project, the application under test has over 1000 controls, some of them are similar in name and purpose, this can make it difficult at times for developers to reuse the API I am creating because the control name is simply not enough for quick identification of the control in use.
I use the word API very loosely too, none of this stuff will be consumed in web services, and it will always be white box with developers including a project reference and have direct access to the source code.
For every form in my application (The test one), I have a controls.cs file where all the controls for that form in the application under test are listed - This is where I want the hover to screenshot ability in the control definitions.
Another sure factor is that all developers will be using VS2013 (For now the base version), later this could be update 1 or 2.
As the initial author and senior developer on this project, these hover / image references (in the code) will be as useful to me personally as any 3rd party developers, or any later developers to join the initiative.
Thanks again, and I added a bounty!
I believe you can use Whole Tomato's free SourceLinks Visual Studio extension to do what you want - or at least get pretty close to it.
Built-in Functionality:
Out of the box, the extension allows you to specify comment patterns you want users to be able to take an action on. Once the patterns are specified, SourceLinks will highlight any occurrences of those patterns in the text editor. You will be able to double click the highlighted items and perform a pre-configured action (such as opening a link in an internal/external browser, or launching an executable).
You can see an example in the SourceLinks configuration dialog shown below:
(source: wholetomato.com)
So you could use this feature pretty painlessly to define a keyword such as Control Image and then put comments like the following in your code:
// Control Image: my_smart_list.jpg
SourceLinks would allow you double click this text, and you could have that configured to launch the image (using a file:// or http:// url depending on how and where your images are stored) either inside Visual Studio in it's internal browser, or in an external browser.
Custom Tooltips!
Now, if you want to put in some more effort into this and actually write some code, then SourceLinks allows you to create API Extensions to display custom tooltips when the user hovers over the marked text in the editor. The default installation of SourceLinks comes with sample API extensions that you can copy to create your own. See the article linked at the very top of the answer for more details on these samples.
This post in the SourceLinks forum informs us that SourceLinks expects the custom API Extension to return the tooltip value as FlowDocument XAML text. This is awesome news for us, because a FlowDocument can contain many types of elements, including formatted text, hyperlinks, and images.
Imanges in a Flow document can be specified both inline as well as externally.
Hope this helps!
I would use doxygen -- create the images somewhere in the source tree and use doxygen comments. You can embed the \image command in source comments (see docs) and doxygen will generate all the HTML documentation from there. I think doxygen is a great tool for documenting a codebase as you can generate the documentation directly from comments in the source and distribute or host the HTML separately.

How to show photos in Dropbox Chooser window by default?

My application accepts photographs from end-users. They will most likely select pictures that are recently taken. The initial view of Chooser, which shows the file structure of the user's Dropbox folder is therefore far less useful compared to the Photos view. Is there a parameter than can be passed to make the window opens to that view? Just a matter of saving an inevitable click.
I tried to examine the source code but the library appears to be written in Coffee.
There's no way to open a specific folder in the Dropbox Chooser. You can make the UI a bit nicer by using the extensions option to specify only image file types.

Fineuploader open queued items

Is it possible to open files directly from the list of the stored items. I want to implement this function so that the user can check the files before they getting uploaded.
If you would like to allow users to open submitted files in an external application via the browsers by clicking on these files (for example), this is not really possible. The browser does not provide sufficient access to the file system to make this possible. As Mark mentioned, Fine Uploader will already optionally generate previews for images. We intend to look into providing client-side previews for audio and video files in the future as well.

A way to prevent 3rd-party elements to be loaded on Safari?

Basically, I'm looking for RequestPolicy for Safari. GlimmerBlocker, Privoxy and BFilter etc, those work well but none of them support "block 3rd party elements" feature.
I use GlimmerBlocker, and to imitate (barely) the function, I mainly put this code to filter script flooded website.
replace(/<(script|noscript|iframe)([\s\S]*?)<\/(script|noscript|iframe)>/img, "")
However I'm tired of repeating creating filters for each websites. Vice-versa, whitelisting will be the same.
If anybody had an idea to solve this, that would be so great. Thanks.
I made this proof-of-concept Safari extension to block external resources (images, objects, and scripts, but NOT link elements, such as stylesheet links) until allowed. It has a bare minimum number of features, but if you are interested, I might develop it further.
I say "external" and not "third-party" because I don't know to tell reliably if a resource is third-party or not. This extension just blocks all resources that come from a different host than the web page. As a result, it blocks too many resources by default.
You can right-click a blocked image and use a context menu command to whitelist the image host. If the blocked image didn't have a specified width and height, it will be invisible, so you won't be able to right-click it. (To remedy this, I will need to add code to make the empty image visible as a box.)
The whitelist command does not show up for blocked plugin objects (such as Flash objects) or scripts. I will have to add code to deal with that.
You can also whitelist the current site itself, meaning that all external resources will be allowed on that site. Again, this is done with a context menu command.
As yet, there is no way to remove items from either whitelist. This can be added.
Download the extension from here.
You can extract the source files from the extension package using this command:
xar -xf PartyPooper.safariextz
You are welcome to do whatever you like with the source.

Resources