Tag Archives: javascript

SharePoint, Web Services, JavaScript, SPAPI

Having wrangled a little with JQuery to obtain data from SharePoint lists I stumbled across SPAPI; a fantastic library to aid you in development. Do check it out over at darrenjohnstone.net 

The ajax function of JQuery had meant toying around with the SOAP packets one was trying to send to get them to work correctly. Tiresome and really not that productive! Big relief that Darren had actually gone through all the pain to create this library as I could see the mountain in front of me and wasn’t personally that keen!

Combining the SPAPI library with JQuery to deal with the returned web service XML however, has proved to be a very successful marriage. To extend this, the below prototyped function has allowed me to only require one hit to the server per request to play with the returned XML. The UI in how its presented to the user is down to your artistic flair ;)

Do note you are required to update your access to your uploaded SPAPI files and JQuery + you’re going to have to write the CAML query you want and add in your own column names etc. to display per item. It’s there, but not for your particular list ;) Enjoy.

  • Share/Bookmark

Javascript English Stoplists / Stopwords

Not listed verbs, adjectives nor articles but the below arrays are very handy should one be running language based queries over rendered pages.

Why? I dunno … say you’re trying to make a tag cloud or something but it’s full of filler words!

Articles are “a”, “an” and “the” only for English. Verbs and adjectives, well that’ll be down to what you’re up to I guess?!

  • Share/Bookmark

Javascript Export HTML table to MS Excel (JScript)

Here’s a little code snippet to export an HTML table to MS Excel through utilising ActiveXObject(“Excel.Application”) from Internet Explorer.

The JavaScript (in this case utilising Microsoft’s JScript) runs over the table displayed pulling out the relevant data and exporting into the instantiated copy of Excel. This is a working example based loosely on Microsoft’s http://support.microsoft.com/kb/234774 Knowledgebase Article “How to automate Excel from an HTML Web page by using JScript”.

Worth noting is that the garbage collection between the JScript and MS Excel doesn’t work too well and more often than not one can be left with the instantiated copy of MS Excel still in memory (see it in the Task Manager). One must manually remove these instances.

Perhaps dynamically inputting a module to clean up from within MS Excel on the workbook deactivating might clear this up – not tried this though!?

  • Share/Bookmark

JavaScript GET URL Parameter GUP JQuery

Having used GUP from Netlobo http://www.netlobo.com/comments/url_query_string_javascript for some time to pull back parameters from the URL in JavaScript for fiddling with, I decided to create a handy JQuery extension for reuse.

Extending this further with the gpn section to get all parameters, which is also from their website, you’ll find within the below code the handy gpnv now too. The gpnv section pulls down all URL parameters and their values storing them in a handy 2D JavaScript array for manipulation.

  • Share/Bookmark

Use Javascript to find which render mode browser is in

When designing pages utilising CSS for their styling and splitting the semantic content away in an attempt to move legacy systems into the dot com era it might be necessary to show why kicking a browser into CSS Compatability mode might be a good idea. Not least that you can position elements as you see fit and can move away finally from table based layouts.

Though how are you physically able to show a change having taken place to management other than through overkill style demo pages or pointing with your finger ..? Using the below code by simply pasting it into the URL address bar and launching by pressing the enter key, you will receive a dialog box detailing which CSS rendering mode you are in.

BackCompat = Backwards Compatibility (quirks mode)
CSS1Compat = Standards Compliance mode.

Quick and simple! This hidden Javascript browser gem and further great insights can be found at quirksmode.org “for all your browser quirks”. A fantastic resource on all things browser based!

  • Share/Bookmark