Is it possible to write HTML-withASP-withJavascript-withCSS in EMACS? - javascript

I am enjoying learning the EMACS text editor...but I can't help thinking that the HTML mode could use some work.
I am currently programming in Legacy ASP/Javascript/CSS/HTML and was wondering if there is a mode that works with this. If possible, I was also hoping the mode wouldn't be from 10+ years ago or in a buggy state.
Thanks for your help!
Will

nXhtml supports classic ASP JavaScript, is frequently updated and is not very buggy. It has better ASP support (except debugging) than current versions of Visual Studio IMO; I just use VS2010 for server-side debugging when necessary.
Here are the relevant sections of my .emacs:
(load "autostart" t)
(eval-after-load "mumamo-fun"
'(define-mumamo-multi-major-mode asp-html-mumamo-mode
"Turn on multiple major modes for ASP with main mode `nxhtml-mode'.
This also covers inlined style and JavaScript."
("ASP Html Family" nxhtml-mode
(mumamo-chunk-asp%
mumamo-asp-chunk-inlined-script
mumamo-chunk-inlined-script
mumamo-chunk-style=
mumamo-chunk-onjs=
))))
(add-to-list 'auto-mode-alist '("\\.inc$" . asp-html-mumamo-mode))
; XXX this is a total hack, see:
; http://www.mail-archive.com/nxhtml#lists.launchpad.net/msg00197.html
(defun tab-width-4 ()
(setq tab-width 4))
(add-hook 'mumamo-after-change-major-mode-hook 'tab-width-4 t)
Update: For newer versions of nXhtml, you may need to change mumamo-asp-chunk-inlined-script to mumamo-chunk-asp-server-script.
(The last bit is necessary because the ASP code I'm working on assumes 4-space tabs; feel free to ignore it if this isn't a problem for you.)
If you have ASP that ends in anything other than .asp or .inc, you'll need to edit auto-mode-alist further.

Since version 2.0 web-mode.el (available on http://web-mode.org) is compatible with ASPX. This major mode is also compatible with JSP and PHP.

You can always use the Emacs Emulation for visual studio instead.

Related

Is there something similar to C# regions in JavaScript? Visual Studio 2017

I am doing work for somebody who would like their JavaScript library organized into categories: CRUD functions, Form functions, etc. They really like the utility of regions in C# and are asking for this in their JavaScript file. Any suggestions? I am using Visual Studio 2017 and Team Foundation Server.
For VS 2019, Microsoft has fully implemented regions for Javascript, they work exactly they way they work in C#, only, you have to preface the beginning and end of the regions as comments, for example:
//#region My Region
function foo(){
*//code*
}
//#endregion
For anything prior to VS 2019, See Michael Drum's answer. His shortcut also works in VS 2019.
The link in the given answer is broken. Here is a great plugin which I use daily and no issue so far:
Java Script Regions
PS: Not tried this with other than VS 2017
Select the code you want to compress. Press Ctrl + M + H. That code will now be collapsible. For readability, comment above the "region" to give it a name.
Source: http://blog.degree.no/2013/05/define-a-region-in-javascript-files-visual-studio-2010-2012/
a Lot of people have already answered on how to get this in Visual studio
I will however suggest a different approach. Since #region is a tag limited to visual studio, it will mostly not be detected by other editors.
But in most other editors, they do however recognize "if" and "while" conditions.
You can use
if (1) and While(1) to create blocks of collapsible code that can be folded.
for eg
// This is a comment for the code block below
if(1){
....
...
}
you will get a -/+ sign next to this code block in many others editors (Unless you are using basic notepad)
You can try this if using razor or asp web forms, just replace # with <% and end with %>.

How to check for version of illustrator that script is running on, and branch script based off that?

I have quite a problem as my team works on different versions of Adobe Illustrator, or have multiple versions of the software installed.
Is there a way to check for version of the adobe app that is running the script?
Especially knowing if it is 32 or 64 bit?
I need to properly define #target and BridgeTalk.target so the script runs in the current opened application. (Script is running directly from script file)
I can't seem to find any solid documentation on that topic.
Does anyone had similar issue and found and solutions or workarounds?
(Updating all the adobe software to single version is out of question sadly)
you can find the app version by calling app.version
$.writeln(app.version)
But there seems to be no way to find out if it is 32 or 64 bit
maybe the Extendscript helper object can give you some more infos. e.g.
$.writeln($.os)
This will check for sure what is the version of the app, and also if it's the 32 or 64 bit(not the os):
$.writeln(app.version); //writes the app version
$.writeln((app.path.fsName.indexOf('Program Files (x86)') > -1)?'32 bit':'64 bit'); //writes the bit version of the app
This code will work for any app that you want to check.
The only problem I can think of it's if the app is install somewhere else then Program Files or Program Files (x86). In this case you will have to use another ways.
#fabiantheblind
Using your tips i devised a piece of code that seems to be doing the trick (But it lacks elegance :P)
switch(app.version.split(".")[0])
{
case "16":
//32 bit versions run in emulated enviorment, so the $.os returns string
//containing 'emulation' substring. Not entierly sure it is reliable :P
var string = String($.os);
if(string.indexOf("emulation") > -1)
{
$.writeln("32 bit code here");
}
else
{
$.writeln("64 bit code here");
}
break;
default:
break;
}

Finding the version of dojo through IBM BPM 8

I am working on creating a process flow using IBM BPM 8 on a dojo platform which encompasses the use of javascript. We have in use three versions that supports NextGen coaches; Heritage coaches and Portal versions. Now through this, we are trying to implement a calendar view like that of FullCalendar or one like that of SharePoint. The group that I am working with is uncertain of how to incorporate the code function dojo.version.toString() in order to yield the results we want. I do have examples of what I have tried but am unsure of exact syntax due to using different tools.
Below are a few examples of what I have tried. Such a call is a little more out of my knowledge of what to do or the syntax to use, so laugh if you want, wont take offense, but I do hope to get some help or at least guided where I can get some help.
<script type=”text/javascript”>
getVersion(){
alert(“Version: “ + dojo.version.toString());
}
</script>
<input type=”button” onclick=”getVersion()”>Get Version</input>
RESULT: nothing
var foo: String=dojo.version.toString();
RESULT: nothing
var string=dojo.version.toString();
RESULT: nothing
var string=dojo.version.toString();
<button type="button">Get Version</button>;
RESULT: nothing
I am not the most savvy of programmers and have been directed by the group to just look up if there have been successes in this realm but have found a few that looked promising but when I try it out myself, everything works except for the version not appearing.
Thank you for your time and consideration. Any and all information is greatly appreciated.
I'm not exactly sure of your setup, but if you browse to:
http://dojotoolkit.org/
And then either in Firebug's console for Firefox, or Chrome developer tools' console, type this:
dojo.version.toString()
Then press enter, you will get (something like) this:
"1.8.3 (30226)"
To get this working in your code, you would use the following assignment:
var dojoVersion = dojo.version.toString();
Or in the style of your example
<script>
function getDojoVersion() {
alert("Version: " + dojo.version.toString());
}
</script>
<button onclick="getDojoVersion()">Get Version</button>
Off topic: I think some of your double quotes have pasted incorrectly, and I don't think they are valid JavaScript as they are.
Off topic: The <input> tag is not supposed to have any content.
dojo 1.7.3 is used in IBM BPM 8, if i remember correctly.
IBM BPM 8, 8.0.1 and 8.0.1.1 all use the dojo version 1.7.3. IBM BPM 8.0.1.2 now uses 1.7.4. However, these dojo builds are IBM customized. They are not necessarily the ones released officially by dojo. Many of their features are specific for IBM BPM.
I know it's been a while since you posted this question
If you still in need or maybe someone else who has the same issue
you can use Firebug onload it will give you which version is used
dojo version used by Coach is: 1.8.6

Can I create a cross browser compatible silverlight page without code behind?

I have been developing a silverlight page using just xaml, javascript and html (I literally only have a .html, .js and .xaml file). The problem is, I just realized that it isn't working in any browser EXCEPT Internet Explorer (7 for sure).
I have too many lines of code to want to add vb.net or visual c code behind and use the html bridge. I just want the xaml mouse events to work directly as before. In other words, when the xaml's MouseLeftButtonDown says "highlightMe" I want that highlightMe function to be a javascript function. But I also want my page to work in any browser.
Now, I've played around with creating a brand new visual studio project with vb.net or visual c.net but the xaml file events seem to point to code behind events. Also, it compiles the silverlight into a .XAP file. The XAP file is actually a .ZIP file with a compiled dll and an appmanifest.xaml.
So, how do I configure my appManifest.xaml to handle a silverlight page that has only javascript and xaml (and an html file pointing to the .XAP as the source). The html part, I THINK I understand. AppManifest is a different story and I definitely need help with that one.
I think it has something to do with creating an app.xaml and page.xaml and using the x:Class value of the main tag.
Since I asked this question I found a page...
http://pagebrooks.com/archive/2009/02/19/custom-loading-screens-in-silverlight.aspx
...that 1) showed people recently using a similar model of .js, .xaml and .html for their silverlight page and 2) someone in the comments recommended using firebug to track down issues with silverlight javascript errors.
This proved to me it's ok to use this model of silverlight and that it should work in other browsers. This also made me go try firebug. Firebug is AWESOME. If you enable the console tab, you can see exactly where the javascript was hanging up. And now that it's working, I can see the result of my gets/posts to google app engine.
Firebug showed that I was using if then else statements in a way that only internet explorer allows. For example,
if (blah == 1) { blah2 = 3}
else { blah2 = 5};
works in every browser, but this doesn't:
if (blah == 1) { blah2 = 3} ;
else { blah2 = 5};
Firefox and chrome and safari all apparently need there to NOT be a ; end statement character between the else and if.
So, for the moment, I appear to have fixed my problem with cross-browser compatibility, but I'd still like to know more about appmanifest.xaml and how to make a .xap file with only javascript. I might need it later.

Javascript major mode in Emacs

Which javascript major modes exist in Emacs, and what are their key-features ?
js2-mode: a new JavaScript mode for Emacs This is part of a larger
project, in progress, to permit writing Emacs extensions in JavaScript
instead of Emacs-Lisp.
Features: M-x customize Accurate syntax
highlighting Indentation Code folding
Comment and string filling Syntax errors Strict
warnings jsdoc highlighting
http://steve-yegge.blogspot.com/2008/03/js2-mode-new-javascript-mode-for-emacs.html
With some documentation.
I think what you want is this:
http://www.corybennett.org/download/javascript-mode.el
Then again, maybe this what you are looking for?
or this?
People seem to prefer (at least given the highest rated answer):
Updated: http://steve-yegge.blogspot.com/2008/03/js2-mode-new-javascript-mode-for-emacs.html
I use Steve Yegge's js2-mode, and like it a lot. It's quite configurable, its indentation ideas match mine, and most impressively it has a full JavaScript parser in it, so it can alert me to syntax errors as I type (indispensable for little things like trailing commas in property lists that bork IE).
Espresso mode is supposed to be quite good as well.

Categories