SharePoint not always loading jquery in Word 365 "Online" add -in - javascript

I have created an Office add-in which side loads Documents in SharePoint into Word.
To debug I use Word online, and open a more or less blank Word document in the same folder in SharePoint.
I then "Upload" my manifest file and initialise the add-in.
The add-in makes extensive use of jquery - and to avoid pitfalls I access a jquery file in the same folder set in SharePoint (hardcoded URL for now) rather than using the default SharePoint jquery.
So in SharePoint I have folders
Main Hosting folder
followed by
ContentDOCX has 1..n Word documents
Images all the images I use in the add-in (+ and - treeview for jquery)
Scripts Office js 1, jquery latest stable, and my add-in js
generated.aspx (the add-in html) with references to above scripts and images and sp.js from SharePoint /_layouts/15/ folder
and a nearly empty testGen.docx - which I am using to debug the code - up to Word.run, at which point the browser naturally errors, but I can test the last in Word locally.
When I load using Word online, I can happily run, view debug, and Word locally all works fine.
But when I ask one of the team to test the add-in fails to load jquery treeview, so they get an ugly badly designed bullet list, and a broken up web page in their add-in. Both online Word, via a browser and local Word.
Comparing browser settings in IE 11, they look identical.
We all have the same level of access to the SharePoint folders
Any suggestions regarding what might be preventing the scripts from running on the team machines? (Antivirus and firewall have both been checked)
One of the team can load a locally based copy I built, and jquery treeview works, but SharePoint fails - so it seems to point at remote web or SharePoint access.

Turned out to be a stupid error on my part!
When you copy sets of files to SharePoint using OneDrive for business they load as "checked in" - so all the html, JavaScript files etc. were safely checked in.
What I didn't know is that css files dragged into "Custom" folder in the sites Style library are not checked in.
Here's the odd part, not checked in files will work for the creator, but not for anyone else.
Once I was able to get to another users machine with debugging, I could see the CSS files were not being found (this was the misleading part, as jQuery was available, but tree-view is reliant on the CSS!) A quick browse on the same users machine to the Style Library and I noticed the CSS files were not visible! A quick check-in and all immediately worked fine!
Oh well you live and you learn!
Thanks to all who took time to look at this.

Related

How to build VSCode to be used in the browser?

I found many projects that required a server. My question how do I start Visual Studio Code like any other jQuery/React/Angular library? How do I start it from the browser without using a server?
I know that I will need to provide the files using a script.
I don't need the extension marketplace, terminal and similar. I only need the files tab on the left, the search tab, and the editor itself. The editor is Monaco, I found out. But I didn't find something that also contains the files panel and the tabs switcher (The list of opened files).
There are projects like code-server, but it requires a server. It also should be executed by our clients, so I don't want resources or security risks on the server.
So how do I compile and embed Visual Studio Code into a Web page to be served by a static HTML server?

Would like to write a javascript that helps me to find documents in a folder

I would like to write a js for an offline website (located on a local Windows server or any other server). It's supposed to look for files like PDFs in several directories and display them as search result on the "website", which isn't a real website, since it's on a local server and not in the web. The PDF is supposed to open in the browser after clicking it. I already have this kind of search engine as a php file, which I wrote with some help from friends. I also want to share this site with other friends. Basically I'll send them the whole folder with the html - document (or the .php site), so they can use it to search for certain pdfs in the folder. Its like a offline wiki for medical research documents. But I don't want them to always install php on their local servers, so they can run my php-searchmachine, thus I need to write it new as a javascript. By google and stack overflow I came across this solution https://www.codegrepper.com/code-examples/javascript/find+file+in+directory+javascript but it seems like that this needs node.js, so all have to install node.js, which is similar to installing php, I guess (im not familiar with node.js). Also I'm not sure if node.js is running on a normal client or server, which is not a webserver.
How can I start with such a project? Is javascript the correct attempt to solve this?
Windows Search has the ability to search PDF contents when boosted by a PDF (index) iFilter, this means the user can search and find instantly a new search word or a saved search it took only a second to hand enter this search (actually took longer to save for double click next time) just for illustration I chose a word I knew was in one file and actually found it is also in two other PDFs.
The problem for your JS coding is how to use JavaScript to interface with Windows Search since using explorer I could not run that search on a remote server shared library drive (I could see their contents as per second screen but for search, had to pull a local library copy down to my documents) and that is where your JS skills come into play. Personally I would avoid JS and use a VLC method to share view via a remote Lan server or simpler invoke a plain text indexed local copy of remote files for download as and when required.

Visual Studio project type for client-side javascript

Could somebody advise me on which project type should I use to develop client side of web-based app (HTML + JavaScript) for Visual Studio 2013?
I tried to create New, Web Site, ASP.NET Empty Web site, then manually added all .js files to the project, but this is not exactly what I need, because I am working on a client-side code only, and the Web server is not IIS.
Of course, when a script error occurs, I can select “Debug using selected debugger”, manually choose my project and jump into debugging. However, this is only a half-solution.
First, I cannot start debugger with F5 – it launches web page connected to local IIS instead.
Second, I have duplicate source trees in solution explorer- the debugger does not match my source files with files loaded with web pages.
I have also tried New, Other project types, Visual Studio solution, Add existing Web site, and played with Start Options, but without much success too. It launches page in IE, but with script debugging disabled (???), and it does not start the debugger anyway.
Is there an appropriate project type to write and debug JavaScript for IE?
PS: When installing VS, I selected C++ development, as my primary settings, which might hide some useful Web development features. And I would prefer not to change this.
UPDATE: Problem #1 (starting with F5) was solved by setting IE as default Web browser (I have used Firefox). After specifying “Specific page” in Start options F5 starts the page under debugger.
Is it possible to debug scripts under IE, leaving my favorite browser as default? If I specify “Start External program” and set “iexplore.exe” with page url, it launches the page but does not allow me to debug it.
you have a bunch of questions in here, but let me try answer them.
To develop client-side of web-based app, Create an ASP.NET Empty Web site and manually add HTML + JavaScript
If the Web Server is not IIS, then you can change, right-click on your project in VS-2013, and in properties,check Web properties.
To Debug your HTML and JavaScript in IE, then follow this:
you have to enable Script debugging in IE as follow:
let, if you have a function named FirstFunction() in your HTML page then
<script type="script/javascript">
function FirstFunction()
{
debugger;
alert("Debugging now");
}
</script>

How to manipulate a local text file from an HTML page

I've generated an HTML file that sits on my local disk, and which I can access through my browser. The HTML file is basically a list of links to external websites. The HTML file is generated from a local text file, which is itself a list of links to the remote sites.
When I click on one of the links in the HTML document, as well the browser loading the relevant site (in a new tab), I want to remove the site from the list of sites in the local text file.
I've looked at Javascript, Flask (Python), and CherryPy (Python), but I'm not sure these are valid solutions.
Could someone advise on where I should look next? I'd prefer to do this with Python somehow - because it's what I'm familar with - but I'm open to anything.
Note that I'm running on a Linux box.
First, Javascript cannot modify the local filesystem from the context of a webpage. To allow that would be a massive security concern.
Any server-side web framework can do this, and Flask is a great one to use because it's so lightweight. The general steps you would want to take are:
When / is requested, load the list of links.
Change each link to point to /goto?line=<line_number>.
Display the list to the user.
Then when you click a link:
When /goto is requested, load the list of links.
Remove the line number from the list.
Save the list of links.
Return status code 302, with the real URL as the Location header.
There is many ways to do this
Here is the easiest 3
Use JavaScript
2 install wampserver or similar and use php o modify the file
3 don't use te browser to delete and instead use a bat file to open the browser and remove the link from the text file

Javascript fullcalendar prod server vs dev machine issue

<div id='calendar'></div>
Is the html tag that the fullcalendar uses to insert a calendar and do its magic. It's a great tool, but something weird is happening.
My calendar is created with events from the DB and all that stuff works well. Here's the issue...
Calendar on 2 pages - both work great on dev workstation.
Deployment - works on one page, but not on the other. The calendar div gets populated with some complex tables etc for rendering. Except this doesn't happen - ONLY on one page, ONLY on the production server - same browser. All the db stuff is there, pages coming back are identical other than the table stuff that gets inserted on my dev machine, but not when server from production. But again, the same control works just fine from prod on another page - stumped! Web server is IIS 7
Any thoughts or even wild speculations most welcome!!
Just to make it an official answer...
Commonly when something doesn't render in either a development or production settings but does in the other environment you're experiencing an absent resource. This is usually something along the lines of requiring the following:
<script type="text/javascript" src="..path/to/script.js"></script>
Since one location has the file in that location and the other doesn't, you can run in to scenarios where it works in one spot but not the other.
Easiest method to confirm this is to open the debugger in your favorite browser and use the "networking" section to determine if all the resources are loading correctly (and are resolved). Otherwise, chances are the page that's not working is getting a 404 (or other error) when trying to retrieve the file it needs and thus the page fails to operate.

Categories

Resources