How do I get Eclipse to command complete Java Script string related functions - javascript

I'm doing string manipulation in Java Script. My Eclipse (Luna) is handling command completion for many things, but string functions it is not.
var sillyString = "hello";
sillyString. <- command complete here: ctrl-space triggers a dropdown with nothing in it.
I have to use Google to figure out things like this: http://www.sitepoint.com/15-javascript-string-functions/
Command complete works for other Java Script items in my code base.

To configure JavaScript Content Assist options:
Go to the JavaScript Content Assist preferences page, accessed from Window | Preferences | Web | JavaScript | Editor | Content Assist.
Configure the following options, according to your preferences:
Insertion
Completion Inserts/Completion Overwrites - Select whether choosing an item from the Content Assist list will cause new code to be entered or existing code to be overwritten.
Insert single proposals automatically -If enabled, the content assist suggestion will be inserted automatically when only one content assist option exists
Insert common prefixes automatically - If enabled, Content Assist will automatically insert the common prefix of all possible completions similar to Unix shell expansion. This can be used repeatedly, even while the Content Assist window is being displayed.
Click Apply to apply your settings.
taken from this link eclipse Javascript intelisense

Related

Can VS Code snippets be passed text-input by users?

Dynamic VS Code Snippets
Do VS Code snippets support dynamic input values, and if not, is there a way to add some sort of functionality that would allow me to define a snippet whose output is contingent on input received by the user?
For Example:
Lets say I added the following to my source code:
    "1/"
What I would like is for it to be automatically converted to:
    /frac(1)
Is this possible in VS Code?
After reading your question a few times over, I found that the way that I initially interpreted what you were asking for was not what you were actually asking.
You are not asking...
"How can one go about authoring a snippet whose output is contingent on text-input received by the user..?"
...rather, you are asking...
"How can one go about adding dynamic text-input support to snippets, such that the end user can create snippets whose output is contingent on the input received from the user..?"
In not so many words...
One asks how to do something, and the other asks, how to add support for doing something (in this context, "that something" is dynamic text-input in VS Code snippets).
The answer would be: "The VS Code API"
You need to use the "VS Code API" to add support for dynamic text-input to snippets because "VS Code's dynamic input variables mechanism" does not extend support to the snippets configuration file. By default dynamic input can only be defined by the user in a VS Code Tasks context whose environment can be worked in using a "launch.json" file located # "./.vscode/launch.json`.
"VS Code extensions built from the VS Code API" are however, quite proficient at getting (as well as setting & moving) dynamic input from the user then setting it in some arbitrary place (i.e. snippets, keyboard shortcuts, etc...).
I included a bunch of links that cover everything I wrote about. The links included are very helpful, and well written.
There are already extensions (as mentioned in the comments) that can provide support for dynamic snippets input, if you don't want to write one, but sometimes writing an extension can be the best solution, its really on a case by case basis.
Also, how you get the input from the user can be achieved by a myriad of different methods, for example:
The A.P.I. can fetch a dynamic value from...
The Quick-input Menu
(for example: pressing F1 key)
From Inside the Editor
(You can even specify specific lines & line-col values)
Entity names. (i.e. function names, variable names, parameter names, etc...)
You can even develop, design, and render your own menu to get input from via context menu_
-You can let the user define how they want to input the text by contributing your own custom settings
The links in the list just above this text should really help if you decide to add the functionality yourself.

Is there an inspection in PHPStorm that detects JavaScript debugging-only code?

When I've finished debugging an issue, occasionally, one or two console.log() calls and debugger; statements go unnoticed, and end up in source control as a result, which I'd like to avoid.
Is there an inspection that would detect this, and maybe even allow setting its severity (e.g. to treat it like an error), similar to other inspections?
Settings/Preferences | Editor | Inspections
JavaScript | JavaScript validity issues
'debugger' statement
This inspection reports JavaScript 'debugger' statements, used for interaction with Javascript debuggers. Such statements should probably not be found in production code.
Unfortunately I do not know about similar inspection for console statements.
P.S.
If it would be a PHP code .. it could be done via "Php Inspections (EA Extended)" plugin where in similar by functionality inspection you can provide your own functions/classes.
To detect console.log calls, it's possible to create a Structural Search Inspection, found under Editor > Inspections > General > Structural Search Inspection. After enabling it, you need to click the + icon in the bottom half of the right side, and pick "Add Search template…".
Then, use the following settings:
Use console.log($log$); as Search template
Tick Case-sensitive
Select JavaScript as the File type
And finally, click OK, and give your new inspection a name that will be shown when it matches, e.g. "Console logging detected".

Sharepoint - How to: dynamic Url for Note on Noteboard

I'm quite new to SharePoint (about 1 week into it actually) and I'm attempting to mirror certain functionality that my company has with other products. Currently I'm working on how to duplicate the tasking environment in Box.com. Essentially it's just an email link that goes to a webpage where users can view an image and comments related to that image side by side.
I can dynamically load the image based on url parameters using just Javascript so that part is not a problem. As far as the comments part goes I've been trying to use a Noteboard WebPart, and then my desire is to have the "Url for Note" property to change dependent on the same URL parameter. I've looked over the Javascript Object Model and Class Library on MSDN but the hierarchy seems to stop at WebPart so I'm not finding anything that will allow me to update the Url for Note property.
I've read comments saying that there's a lot of exploration involved with this so I've tried the following:
-loading the javascript files into VisualStudio to use intellisense for looking up functions and properties in the SP.js files.
-console.log() on: WebPartDefinitionCollection, WebPartDefinition, WebPart, and methods .get_objectData(), get_properties() on all the previous
-embedding script in the "Builder" on the Url for Note property (where it says "click to use Builder" - I'm still not sure what more this offers than just a bigger textbox to put in the URL path)
I'm certain I've missed something obvious here but am gaining information very slowly now that I've exhausted the usual suspects. I very much appreciate any more resources or information anyone has and am willing to accept that I may be approaching this incorrectly if someone has accomplished this before.
Normally I'd keep going through whatever info I could find but I'm currently on a trial period and start school back up again soon so I won't have as much time with it. Apologies if this seems impatient, I'm just not sure where else to look at the moment.
Did you check out the API libraries like SPServices or SharepointPlus? They could help you doing what you want...
For example with SharepointPlus you could:
Create a Sharepoint List with a "Note" column and whatever you need to record
When the user goes to the page with the image you just show a TEXTAREA input with a SAVE button
When the user hits the SAVE button it will save the Note to the related list using $SP().list("Your list").add()
And you can easily retrieve the information (to show them to the user if he goes back to the page) with $SP().list("Your list").get()
If I understood your problem, that way it may be easier for you to deal with a customized page :-)

tracking a javascript found in pagesource

ive tried everything i cud to figure this out, but i cannot track a piece of javascript in a webpage
so, just to give you some context even though my problem is not related to just this scenario. it depends on a much bigger spectrum.
Anyway, im developing on sugarCRM and im trying to edit the default onclick behavior of a slot in calendar module (you dont need to understand this to help me, so please keep reading). when i click on a slot, a modal dialog window opens that lets me log a meeting or a call.
So i tracked down the javascript behind this. ive used firebug and chrome, and they both give a list of all the JS files that are being used on a given webpage
for example i search for "SUGAR.collection" and firebug tells me its located in a file named "sugar_field_grp.js?v=FVh1Z-v5nA6bYov7-aFFqQ" i can see this piece of code resides in sugar_field_grp.js,
but the code im trying to change resides in "index.php?module=Calendar&action=index&parentTab=Activities", firebug actually tells me this is the file that has the javascript i want to change.
I can also right click view page source and i can see that piece of code inside the script tag. so considering this piece of code doesnt reside in a JS file, i cannot change it, its generated at runtime (i think) but there must be some source, there must be a file thats telling sugarCRM to generate this code
tl;dr how to track down a piece of javascript code that resides on pagesource and theres no JS file specified by firebug or chrome save for index.php (this file doesnt have that javascript either)
i know its been a long post
thanks for reading
Learn how to search for strings in files on disk on your machine.
On Linux, MacOS and most unixen the go-to tool for this is grep. This applies to any programming language you work with. For your case simply cd into the directory of your source code and do:
grep -r SUGAR.collection .
If you're using git as your source control tool then git grep is much faster.
On Windows there are various GUI tools you can use to search for text in files. Just google: grep for windows.
If you're using an IDE then just your IDE's find-in-files functionality.
To track down specific code using Chrome / Webkit go through the following two steps:
Client:
1. Search all static text sources
Open the Dev Panel using CTRL + SHIFT + I
Hit CTRL + SHIFT + F for a global search dialog to pop up
Right next to it you can set pretty printing of the JS code to on: button { }
Enter your search term or terms using regular expressions
Optional: Decide if you need a case insensitive search which has a greater searchspace and takes longer
Example:
2. Search the dynamic user-DOM contents
Go to the Tab 'Elements' hit CTRL + F.
Enter your search term (This will also search iframes, svg's etc... within the parent DOM)
3. Recommended:
Cross-reference the results of step 1. and step 2.
If a given string is present in both the DOM and the static sources, then you can assume that the content is not programmatically created on the client-side.
Server:
Many projects perform a media bundling step prior to content-delivery. They pack web-resources into the main file (e.g. index.php) to save HTTP roundtrips.
Use sourcemaps / and or search the entire codebase for a salient static string or a salient keyword near the static string to locate the original source files.
Searching files:
Locally, I generally use the rapid index, and heuristic search of JetBrain's IDE's (IDEA, PHPStorm,...) and Sublime. The grep-command tool can definitely not compete here in terms of performance. On Windows I additionally use Totalcommander and its archive/regex finding abilities.
When quickly looking up code on the server you may use something like:
grep -r -C10 --color=always 'keyword1|keyword2' htdocs/ | less -R
which will also provide you with line-context. two caveats: you may want to filter out binaries first and symlinks outside the scope will be ignored.

Generate an HTML table from a Word Document

I'm putting together a simple website for our department. I'd like to include one of the references that we use often on the main page, a word document that contains a priority list for outstanding work. This document is generated by another department and located on a shared drive. The info is not in a table, but uses a fairly consisten format for displaying info.
Ex: (the info is actually formatted like this)
--------------
Item Title
--------------
Tracker#: 12345-0012 Due; 01/01/12
Description...
My ultimate goal is to have a table on the main page that contains the various items in the priority list. I would like a mechanism that automatically checks the word docs about once an hour, parses the document, generates a table from the info in the doc, and updates the main page accordingly.
I've never done anything like this and have no idea where to start or if what I'm asking is even possible. I'm not in IT and do not have the ability to use ASP or PHP at the moment. So I'd like to avoid server-side scripting if possible, but I may be able to work something out if absolutely necessary.
Thanks
I know how to do this in java.. you can use the docx4j library.. Without that it would be difficult. Can't the team that create the doc store the file as a flat file as well maybe?
One possible solution is to save document as html (using automation - create Word.Application object, call Open, SaveAs) and serve it directly or inside frame.

Categories

Resources