Passing a string variable into a marquee - string

Please help, I am trying to pass a string that exists in a variable I created. It is todo with weather info I am grabbing with an API. This is the variable I am creating;
success : function(parsed_json) {
var temp_f = parsed_json['current_observation']['temp_f'];
var wind_kph = parsed_json['current_observation']['wind_kph'];
var wind_gust_kph = parsed_json['current_observation']['wind_gust_kph'];
var wind_string = parsed_json['current_observation']['wind_string'];
alert(wind_string);
gauge3 = wind_gust_kph
gauge4 = wind_kph
The alert works and prints my string. Now I want to pass it into a
<td><div><marquee behavior="scroll" direction="left">("wind_string")</marquee></div></td>
I have tried many options and can only get what I type and not the actually string inside the variable.
Hope that is clear!

Add an id - "wind", as you suggested - to the marquee element to make it more searchable:
<marquee id="wind" behavior="scroll" direction="left"></marquee>
Get the marquee element with getElementById and assign the string you want to its innerHTML:
var wind_string = parsed_json['current_observation']['wind_string'];
//alert(wind_string);
document.getElementById('wind').innerHTML = wind_string;
Note: the marquee element became obsolete in HTML5.

Related

Find HTML Element value in Inline Code Connector Logic App

I am trying to get the value from an API multipart Response which contains json, xml and html. Plus HTML doesn't have any id and any class on its elements in that response. I want to get the complete table in an element and want to get the values from its tr. Please suggest me how can I do this in inline code in logic apps.
var response = workflowContext.trigger.outputs.body; // API Response
var multiBody = response.body.$multipart[4].body; // multipartBody
var table = multiBody. // How to get table section and get its tr values
return table;
I have already written the javascript code which I want to implement in inline code connector. My code is
var rows = document.getElementsByTagName('table')[4].rows;
var firstRow = rows[0]; // LTV/CLTV Row
var firstCell = firstRow.cells[1]; // LTV/CLTV Index
var firstText = firstCell.innerText;
var firstValue = firstText.substring(0, firstText.indexOf('/') - 1); // LTV
var secondValue = firstText.substring(firstText.indexOf('/') + 2, firstText.lastIndexOf('/') - 1); // CLTV
Please help me how can I do this.
Plus as it is mentioned in the documentation that we can write the javascript in inline code connector then why getElementById, getElementByTagname functions are not working here.
The Inline Code Actions runs NodeJS for JavaScript which doesn't really have a DOM Object to work with like a browser.
Instead, you will have to parse the DOM or just perform string searches to get what you need.
Parsing the DOM wouldn't be that simple of course and it would be best to use something like jsdom inside an Azure Function instead, if string/regex searches won't cut it for you.

NotesException: Unknown or unsupported object type in Vector

I'm trying to add new names to the address book programmatically but I'm getting the following error:
[TypeError] Exception occurred calling method NotesDocument.replaceItemValue(string, Array)
Unknown or unsupported object type in Vector
Code snippet below:
var addressBook = session.getDatabase("","names.nsf");
var gView:NotesView = addressBook.getView("($VIMGroups)");
var gDoc:NotesDocument = gView.getDocumentByKey("groupName", true);
var newg:java.util.Vector = [];
var mems:java.util.Vector = new Array(gDoc.getItemValue('Members'));
newg.push(mems);
var newNames:java.util.Vector = new Array(getComponent("NewMems").getValue());
newg.push(newNames);
gDoc.replaceItemValue("Members", newg);
gDoc.save();
Adding a single user works fine, but then it does not save users in the required canonical format below:
CN=John Doe/O=Org
Instead it is saved in the original format below:
John Doe/Org
I look forward to your suggestions. Thanks.
You can't store an Array in a field. Make newg a java.util.Vector instead and integrate with that.
For OpenNTF Domino API the team wrote a lot of code to auto-convert to Vectors, which may cover Arrays.
Don't use an Array (which is a JS thing). Initialize it as a Vector.
var newg:java.util.Vector = new java.util.Vectory();
Then look up the Vector methods to see how to add to that vector. Not sure if you will have to convert the names using the Name method but I would store them as "CN=Joe Smith/O=Test Org" to be sure you got the right format.
I was able to solve the issue using a forloop to loop through the list and push it into a newly created array. Using the forloop seems to make the difference.
var newg = [];
var group = new Array(getComponent("NewMems").getValue()), lenGA = group.length;
for(i = 0; i < lenGA; i++){
newg.push(group[i]);
}
gDoc.replaceItemValue("Members", newg);
gDoc.save();
An explanation about this behaviour will be appreciated.

Get element Id from a found element

I'm using the Chrome driver and Selenium tools in my CodedUI tests. I can find the element I need using the SearchProperties and a Contains operator however I need the full Id for subsequent searches.
For example I need to find an input element with Id "pm_modal_28".
This is easy enough by doing a search where Id contains "pm_modal".
I then need to parse the value "28" out of the Id that was found so I can search for the next nested element which has an Id of "dp_28".
When I use the Id property of HtmlDiv I get a NotSupportedException. Is there anyway I can get all of the Html attributes from an Element or get the Id from an element after it has been found?
Not sure if this what you are after, once the control is identified, you would have all its properties to play around with.
For example
var control = new HtmlDiv ();
control.SearchProperties.Add("Id", "MyDiv_28");
if (!control.TryFind()) return;
var newControl = new HtmlDiv();
newControl.SearchProperties.Add("Id", control.Id.Split('_')[1]);
newControl.TryFind();
HtmlDiv myDiv = new HtmlDiv(browser);
//Add the search logic u want !
myDiv.SearchProperties.Add("class", "ClassName");
string onewayforID = myDiv.Id;
string anotherWay = myDiv.GetProperty(HtmlDiv.PropertyNames.Id).ToString(); // Or u can simpy pass "Id"
See if that Works !

Create [NS]Dictionary from single string in Swift

I have a string var dictAsString:String = '["foo" : 123, "bar" : 456]' that I want to convert to a Dictionary (or NSDictionary, I'm not particular.) I've tried
var dictAsObj:AnyObject = dictAsString as AnyObject
var dictAsDict:NSDictionary = dictAsObj as NSDictionary
but that doesn't work. I've also tried
var dictAsDict:NSDictionary = NSDictionary(objectsAndKeys: dictAsString)
and
var dictAsObj:AnyObject = dictAsString as AnyObject
var dictAsDict:NSDictionary = NSDictionary(objectsAndKeys: dictAsObj)
Nothing seems to work, and I can't seem to find any help in the documentation. Any ideas?
That string resembles a JSON object.
You could replace the square brackets with curly brackets and use NSJSONSerialization class to get a dictionary out of it.
Worst case scenario, you should write a little parser.
I suggest using Ragel.
Both tasks are an overkill for a string like that, though.

How can I get the properties from a property Group of a Custom Control as an Object?

I'm working on a Custom Control that displays markers on Google Maps. I have a couple of properties like "maptype" , "zoom", etc. It is easy to access them in Javascript: I can use #{javascript:compositeData.zoom} to get the value of the zoom property.
Now this is my problem: I use a group of properties for each marker.
The name of the group is "marker" and a marker has 6 properties: "title", "layer", "infotext", "icon", "address" and "animation".
If I try to access the group with
var markers = #{javascript:compositeData.marker};
I'm getting an error in firebug:
missing : after property id var markers = [{layer=2,
address=Oldenzaal, animation=DROP, icon=/ogo_notes.png...
an arrow is pointing to the first = between layer and 2
(I am not allowed to put in an image in stackoverflow)
If I use
var markers = #{javascript:'"' + compositeData.marker + '"'};
markers is an Object, but each Object contains a string with all the propperties of the marker.
I know I can do some coding to make an object of each string, but this is not easy if not all propperties are required. If a propperty is not required than it will not show up in the string.
I guess that there must be a more easy way to get each marker as an object so I can get the value of the icon with code like:
var icon = marker.icon
How can I do this?
You can use compositeData.marker.icon to get the property icon inside the group marker. If you have checked "Allow multiple instances" for the group then to get the properties you will have to go:
compositeData.marker[0].icon
compositeData.marker[1].icon
and so on...
Update 26-Apr-2012 (Naveen)
To use it with client side javascript you can try to put the value in a hidden input field like this:
<xp:inputHidden id="hdnIcon">
<xp:this.defaultValue><![CDATA[#{javascript:var value = new Array();
for (var i=0 ; i<compositeData.marker.length ; i++) {
value.push(compositeData.marker[i].icon);
}
return #Implode(value, ",");}]]></xp:this.defaultValue>
</xp:inputHidden>
The value of this hidden input field can be read through client-side javascript like this:
var value = document.getElementById("#{id:hdnIcon}").value.split(",");
for (var i=0 ; i<value.length ; i++) {
<YOUR CODE>
}
Another way to do this can be to convert compositeData.marker and its contents to a JSON string and then run the client-side javascript on it.

Resources