Load HTML from applicationDirectory in TideSDK - javascript

I'm using the default index.html located in RessourcesFolder of my app. The index.html page is only there to check if my application has an update (new html pages to display in app).
It works perfectly.. I can download my new contents from the server in applicationDataDirectory
But.. when I finished the application update, I'd like to replace the current index.html page with my updateindex.html
Loading remote html pages works fine, for example:
currentWindow.setURL('http://www.stackoverflow.com/' );
However, when I try something like
currentWindow.setURL('C:\Documents and Settings\myuser\Application Data\TideSDK\testApp\index_update.html' );
Nothing is appended..
Can anyone help me?

you can modify the path of which index page you want to load within your application
this can be modified within the tiapp.xml file. Replace "app://index.html" with "app://updateindex.html" and you should be good to go

Related

How to get page extension with js

How can I get the current page format? I mean, if im in
abc.com/index.html
How could I get that the page is on index.html instead for example index.jsx / index.php?
I could try to split the URL after the '.', but if the link is on the index it wont show.
Any help would be appreciated.
You can't.
If you ask the server for the resource at / then you get the resource at /.
The server won't tell you if it generated it from a file called index.html or index.php or default.php or some logic internal to the server which doesn't involve loading a specific file at all.

Can I edit a file in any site and update the page?

I would like to know, is there a way to edit a Javascript file or a specific page, on any website, and refresh this page and show my changes?
For example, there is a website: http://example.com.
Many files are requested including a Javascript file:
http://example.com/assets/app.js
Can I modify this app.js file, and show my modifications when updating the page or is this not possible?
For example, save the file my cache? Or something like that?
and Thanks.
Normally speaking, you can't directly modify the files like assets/app.js, etc, since they are stored and read from the backend server of http://example.com.
However, you can still make custom changes to some specific pages/websites by scripts/styles injecting.
I think you might be interested in some browser plugins/scripts like:
Tampermonkey: https://www.tampermonkey.net/, Greasyfork: https://greasyfork.org/en, Stylish: https://userstyles.org and so on ... :)

Electron app. Multiple html files

I have an electron app with multiple html files in the root directory.
index.html
page1.html
page.html
I cannot find a way to redirect from index.html to page1.html once Electro has started.
Does anyone know how to do this?
When your first page is index.html you call that page, when you create your window.
const win = new BrowserWindow(options);
win.loadUrl(`file://${__dirname}/index.html`);
If you want to load another page maybe
win.loadUrl(`file://${__dirname}/page.html`);
could help you.
If the page should be loaded after a user action (e.g. click on a link). You can add the link to your index.hmtl page. Electron works here exactly like a browser.
Go to page

ASP.NET Javascript Not being loaded when ASP Page has URL Mapping

I'm trying to retrieve the ID of an employee and show them in my details page by retrieving the Employee ID from the URL using Page Mapping in ASP.NET:
RouteTable.Routes.MapPageRoute("", "employee/{id}", "~/details.aspx");
Such that the URL will be:
www.myexamplewebsite.com/employee/7937822353
The problem is, the Javascript files don't get loaded and the console is full of my javascript errors. I get a 404 error in my JS scrips as well. The page can't find any JS file when mapped. Why is this happening when I map the URL? This does not happen if the URL is www.myexamplewebsite.com/7937822353.
What am I doing wrong?
EDIT:
This is how my JS files are referenced:
<script src="js/chatbar/rightside.js"> </script>
The script is relative, and it's from the perspective of the client side URL. So when you change the page route to have the page appear to be served from a /employee subdirectory, the correct relative path to your scripts changes. So it's looking for the scripts at /employee/js/charbar/rightside.js. You could change those relative paths (to something like ../js/chartbar/rightside.js), but you might run into a problem later if you change the routing again.
So instead, it's best to make the reference application root relative.
<script src='<%= ResolveClientUrl("~/js/chatbar/rightside.js")%>'></script>

SharePoint 2013- Add custom web application/page which uses files from other folders

I've created a JavaScript web browser game. The HTML page, Game.html, within folder Game references several other JS/jQuery/CSS files stored in sub folders.
I simply want to add the Game folder, which includes the Game.html file and all of its related files to SharePoint 2013 as a page. That way people can play the game on SP 2013.
I've tried the following:
Clicked Add Page. This gives me the Master Page and only allows me to add web parts. So I tried adding a Content Editor Web Part and tried to reference the Game.html page, but then I can't reference the rest of the needed JavaScript.
Then I mapped my drive directly to the server and uploaded my Game folder to the server. From there, I created a Master Page of Game.html in Design Manager... this did not work.
Is there a simple way to add my Game.html page to SP 2013 and have it reference all of its required JS files and actually run the game?
Thanks
Edit: Okay, here's what I did:
1) I uploaded all assets to http://server/SiteAssets/Forms/AllItems.aspx, including main Game.html file, and supporting images and JS files.
2) Changed all references in Game.html to match the same folder that Game is in:
<script src="http://Server/SiteAssets/createjs.js"></script>
<script src="http://Server/SiteAssets/bootstrap.js"></script>
<script src="http://Server/SiteAssets/jquery.js"></script>
etc...
3) Went to Settings -> Add a page, which is now at http://Server/Pages/Game.aspx.
4) Added Content Editor Web Part (CEWP) to new Page, titled Game. Edited the CEWP to get the Game.html file located in SiteAssets.
5) Game.html seems to render okay:
However, when I submit my name in the text box, it's supposed to run the JavaScript game. But it's not working. I know it's running JavaScript because I did:
Game.html: <body onload="test()">
Game.html: function test() { alert("working"); } Outputs "working".
There's no console output error. And the jQuery and rest of the code seems to render for a second, flicker, and then return to the static HTML...
So initially the HTML text field and button from Game.html are loaded:
When I type my name in and press enter... it calls init(), and loads jquery/createJS,etc
But then a second later all that disappears and only shows static HTML from Game.html
Any thoughts?
We've had all sorts of issues with running our own apps within Sharepoint pages.
In the end we went for an entirely different approach. We simply set the app up as an independent site on the same server and then included it into the sharepoint page as a web part. (Essentially an iframe).
It's definitely worth checking out as it entirely removes the associated headaches of sharepoint intercepting requests and the like.

Categories