I am making an Office add-in which has two ribbon buttons. Each button is linked to a different TaskpaneId, and clicking on each button opens a different taskpane:
<bt:Urls>
<bt:Url id="Contoso.Taskpane1.Url" DefaultValue="https://localhost:3000/addin/page1" />
<bt:Url id="Contoso.Taskpane2.Url" DefaultValue="https://localhost:3000/addin/page2" />
</bt:Urls>
Now, I want to realise some communication between these two pages. For example, after some manipulations on page1, I want page2 to be automatically refreshed (to reload data from server or localStorage). As a result, when we click on page2, it is already up-to-date. At the moment, it is not systematically updated, and to refresh page2, we have to click on its ribbon button.
https://localhost:3000/ is built with mean-stack, so the pages use angularjs and have a server behind. One way of communication of two pages is to via server: page1 sends a message by socket.io to the server, and then the server emits a message by socket.io to page2. It is a little bit tedious.
Does anyone know if JavaScript API for Office has already any easy (and cross-platform) way to permit of such a communication between 2 taskpanes?
PS: using StorageEvent of localStorage is not a good idea, because it does not seem to work in Excel for Mac or for Windows.
There is no great solution at the moment. For Script Lab, we use local storage and a timer to check a time stamp a couple times a second on platforms/browsers that don't support events (IE 11). The problem with local storage isn't so much the need for timers, but rather that you can't really scope it to just a particular set of task panes. Instead, it ends up impacting task panes on other documents as well. For script lab, we decided to live with that behavior, instead of spending the energy on a server-based communication (I assume you mean socket.io or similar?)
Related
I am developing a basic web app interfacing the Nordic BLE devkit.
I am new to javascript development and came across a rather common but a weird problem for me while testing my app.
Basically, I have 2 html pages and a common javascript file.
First page finds the nearby BLE devices and connects with it and then stores it's characteristics and services which are needed for the communication. (Processing done in the javascript file)
After a button press on the first html the app runs location.replace("path for second html") and switches the activity to the second html file.
Here I noticed that after transferring to the second page the devkit is disconnected.
I have few buttons on the second page which when pressed invokes routines in the javascript file.
Now since the device is disconnected the characteristics and the services read earlier were lost and the app crashes.
I know this is a typical binding problem but I am quite not familiar with the exact javascript concepts that I need to be looking at in order to have more information for this issue.
Can anyone help me with this?
It is not currently possible to transfer a BluetoothDevice or any of the other associated objects to a new page during a navigation (which is what happens when you call location.replace()). If possible you should keep the user on the same page for the entire time that it is connected to a device.
There is upcoming work on Chromium issue 974879 which will make it possible to keep the permission the user granted your site to connect to the device across navigations and sessions but you will still have to reconnect on each page.
I'm working on a javascript based web application. I have a webpage which has nothing but a button. When I click this button, it pulls data from another website and stores it in my Mongo database.
I need to automate this button click. That is, even without opening the website and clicking the button, the 'pulling data from another website and storing it in my database' should happen.
I literally do nothing but click a single button. So I believe this can be made automated and run automatically without human intervention at regular interval. (example: I need this process done everyday at 6 PM). Is this possible at all?
P.S: I've heard of Selenium but it isn't clear whether selenium would do this. Even if that's the case, I can't seem to use the tool. I was able to download a '.jar' file but it doesn't even open.
Appreciate any help!
You can almost certainly automated the click of a button with selenium, however, selenium works by opening a web browser and then interacting with different items as if it were a person. This would work, although it may be more resource intensive than you want.
Have you though about setting up the data pull to run via a console command/something else, which you could then automate without dealing with a GUI?
I have a client-side Golang application running on my machine. I also have a browser open, and in that browser there might be a tab running my web application (which is completely separate from the Golang app).
From the Golang app, I would like to programmatically refresh the browser tab (and maybe if possible, bring it to front, but that's less important).
I researched quite a lot already, and I concluded this is not possible just by communicating to the browser, there is no standard (especially cross-platform and cross-browser) interface with which we can trigger the refresh of a specific tab of a browser.
So I suppose I'll need to have some custom JS code running on the website with which my Golang application can communicate and trigger the refresh of the tab.
What's the easiest way to do this?
(I was looking at livereload.js and lrserver, but these all start with the premise that there is a folder of content we'd like to watch and automatically reload on any change. But I don't want that, I just programmatically want to trigger the refresh. Also, this Golang app is not hosting the website, it's just a separate client-side application.)
As suggested by some comments, there seems to be no API through which we could connect to a browser from Golang, query the list of tabs, and refresh a particular page (at least not in a cross-browser and cross-platform way).
One possible approach to do this is to host a small WebSocket endpoint in Golang, and connect to it from the site we want to refresh. Then send a message through the WS connection every time we want to reload the site, and in JavaScript call location.reload() when we receive the message.
I described all the details in a blog post, and uploaded a complete working example to GitHub.
I'm sorry if this is a newbie question but I don't really know what to search for either. How do you keep content from a previous page when navigating through a web site? For example, the right side Activity/Chat bar on facebook. It doesn't appear to refresh when going to different profiles; it's not an iframe and doesn't appear to be ajax (I could be wrong).
Thanks,
I believe what you're seeing in Facebook is not actual "page loads", but clever use of AJAX or AHAH.
So ... imagine you've got a web page. It contains links. Each of those links has a "hook" -- a chunk of JavaScript that gets executed when the link gets clicked.
If your browser doesn't support JavaScript, the link works as it normally would on an old-fashioned page, and loads another page.
But if JavaScript is turned on, then instead of navigating to an HREF, the code run by the hook causes a request to be placed to a different URL that spits out just the HTML that should be used to replace a DIV that's already showing somewhere on the page.
There's still a real link in the HTML just in case JS doesn't work, so the HTML you're seeing looks as it should. Try disabling JavaScript in your browser and see how Facebook works.
Live updates like this are all over the place in Web 2.0 applications, from Facebook to Google Docs to Workflowy to Basecamp, etc. The "better" tools provide the underlying HTML links where possible so that users without JavaScript can still get full use of the applications. (This is called Progressive Enhancement or Graceful degradation, depending on your perspective.) Of course, nobody would expect Google Docs to work without JavaScript.
In the case of a chat like Facebook, you must save the entire conversation on the server side (for example in a database). Then, when the user changes the page, you can restore the state of the conversation on the server side (with PHP) or by querying your server like you do for the chat (Javascript + AJAX).
This isn't done in Javascript. It needs to be done using your back-end scripting language.
In PHP, for example, you use Sessions. The variables set by server-side scripts can be maintained on the server and tied together (between multiple requests/hits) using a cookie.
One really helpful trick is to run HTTPFox in Firefox so you can actually monitor what's happening as you browse from one page to the next. You can check out the POST/Cookies/Response tabs and watch for which web methods are being called by the AJAX-like behaviors on the page. In doing this you can generally deduce how data is flowing to and from the pages, even though you don't have access to the server side code per se.
As for the answer to your specific question, there are too many approaches to list (cookies, server side persistence such as session or database writes, a simple form POST, VIEWSTATE in .net, etc..)
You can open your last closed web-page by pressing ctrl+shift+T . Now you can save content as you like. Example: if i closed a web-page related by document sharing and now i am on travel web page. Then i press ctrl+shift+T. Now automatic my last web-page will open. This function works on Mozilla, e explorer, opera and more. Hope this answer is helpful to you.
How to make static fixed HTML element on every page of site?
I mean - for example, it is music player on site. It's displaying in corner of page, and while navigating on site - it doesn't reload.
Also, If you open many pages of site (different tabs) than state of this element is the same on all pages. (If I change something in this element on one page - it's changed on every page).
For real example I can provide a link (I think, it's allowed to do this on this site):
http://www.jamendo.com/en/album/40689
If you click "Play" - music player is opened. If you open other artist in other window - two players will be the same. If you have changed volume in one window - volume is changed in other too.
What techniques are used here? Can you give some references to read about such technologies?
Hopefully the site is working the same as it was when you posted the link...
This site is using Flash which seems to be using LocalConnection and ExternalInterface. The Flash object in the popup is the one actually playing the music. The controls on the page are calling a Flash object on the page which just sends commands to the popup.
Well I can give you a general idea of how I would do it.
You would need to persist the data of the feature you wan't to be the same across all pages.
For example: if you wanted something to be in the same position across all pages, you could store the current position of that variable in a session variable, cookie, or database for that particular user/ip address. Then you would make GET requests to the server "asking" for the most recent position of whatever you're tracking. And if it's different update the position accordingly.
You would need to make use of Javascript, A programming language, and some kind of data persistence.
If you want to read about the newest stuff, you could easily do this with node.JS. There is a library out there that makes it very easy to reflect server side changes on the client w/o making GET requests (making it a good for chat applications).
You can use local storage to store the current settings and poll them from each open instance. You won't need to use AJAX or the server if you only care about the settings being synchronized across one machine.