Embedded JS in XML syntax highlighting - sublimetext3

Is there any way to make syntax highlighting work with JavaScript code which is embedded into XML?
<file name="admin/view/template/sale/order_list.tpl">
<operation>
<search position="before"><![CDATA[<?php echo $footer; ?>]]></search>
<add><![CDATA[
<script type="text/javascript">
$(document).ready(function() {
setOptions(); // on load
]]></add>
</operation>
</file>

Related

using bluetoothserial plugin in phonegap build

I'm trying to use a plugin for phonegap build:
https://github.com/don/BluetoothSerial/tree/master
the src code is just an index.html:
<!DOCTYPE html>
<html>
<head>
<title>Simple Serial</title>
</head>
<body>
<div class="app">
<div id="ui">
<button id="connectButton">Connect</button>
</div>
<div id="message">Hello.</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script>
alert("test");
bluetoothSerial.isEnabled(
function() {
alert("Bluetooth is enabled");
},
function() {
alert("Bluetooth is *not* enabled");
}
);
</script>
</body>
</html>
here is my config.xml, just the sample one with the plugin for bluetoothserial:
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.phonegap.example"
versionCode = "10"
version = "1.0.0" >
<!-- versionCode is optional and Android only -->
<name>PhoneGap Example</name>
<description>
An example for phonegap build docs.
</description>
<author href="https://build.phonegap.com" email="support#phonegap.com">
Hardeep Shoker
</author>
<gap:plugin name="com.megster.cordova.bluetoothserial" />
</widget>
The ipa that I get built does not work as intended, I do not get an alert at all.
What am I doing wrong?

SharePoint XSLT Column Display Name

I currently try to display the column name in a custom form in SharePoint Designer. I use Sharepoint 2013 so the design view doesnt exists anymore :(.
The form is used to create a new element in a custom list.
I cant put the name directly in the tempate because i would like use this template in different forms so i have to recover the name of my columns dynamically.
The problem is that I only found the internal name.
I saw in the datafileds tag there are couples where the internal name is relied to the display name but I didnt find how recover the display name with that too.
Is it only possible ? Someone has an idea to help me?
I put some code if u want to look at my code.
This part looks for an attribute where the name contains "question" and calls the template "title_line" when it finds one. The function name() gives me the internal name, that is the pb...
<xsl:template match="Row">
<xsl:for-each select="#*">
<xsl:choose>
<xsl:when test="contains(name(),'Question')">
<xsl:call-template name="title_line" >
<xsl:with-param name="title" select="name()"/>
<xsl:with-param name="class" select="'class_title'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
This part is to display the title:
<xsl:template name="title_line" >
<xsl:param name="title" select="'no title'" />
<xsl:param name="class" select="'no_class'" />
<tr>
<td colspan ="2" class="{$class}" style="font-weight:bold;font-size:medium">
<xsl:value-of select="$title" />
</td>
</tr>
</xsl:template>
MY SOLUTION :
I used JQuery 1.9.0 and SPServices 0.7.2
Import these libraries into the header.
The ContentPlacdeHolderId PlaceHolderAdditionalPageHead is at the bottom of the page, i didnt see it and have some problems because of the duplicate...)
About the source, i activated the publishing and create a folder Scripts into the Styles Library.
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
<SharePoint:DelegateControl runat="server" ControlId="FormCustomRedirectControl" AllowMultipleControls="true"/>
<SharePoint:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>
<SharePoint:CssRegistration Name="forms.css" runat="server"/>
<!-- add JQuery 1.9.0-->
<script id ="JQUERY_ID" type="text/javascript" src="../../Style%20Library/Scripts/jquery-1.9.0.js">
</script>
<!-- add SPServices 0.7.2 -->
<script id ="JQUERY_ID" type="text/javascript" src="../../Style Library/Scripts/jquery.SPServices-0.7.2.js">
</script>
</ContentTemplate>
</SharePoint:UIVersionedContent>
</asp:Content>
Now the display of the title is :
<xsl:template name="title_line" >
<xsl:param name="title" select="'no title'" />
<xsl:param name="class" select="'no_class'" />
<tr>
<td colspan ="2" class="{$class}" style="font-weight:bold;font-size:medium">
<script type="text/javascript">
var static_name = &apos;<xsl:value-of select="$title" />&apos;;
var display_name = $().SPServices.SPGetDisplayFromStatic ({
listName: "listeperso",
columnStaticName: static_name
});
document.write(display_name);
</script>
</td>
</tr>
</xsl:template>
I just need to have the name of the list dynamically and it's over.
Cya.
EDIT : the script with the list name dynamically
<script type="text/javascript">
var list_name = $().SPServices.SPListNameFromUrl();
var static_name = &apos;<xsl:value-of select="$title" />&apos;;
var display_name = $().SPServices.SPGetDisplayFromStatic ({
listName : list_name,
columnStaticName: static_name
});
document.write(display_name);
</script>
listName uses either the list name either the list ID. SPListNameFromUrl returns the list ID.
I see anybody have an idea.
I find a Javascript library SPServices which can convert the static name t the display name.
Link
My new is to integrate the script. I tried to put it into the header like that :
<asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<script type="text/javascript" src="../../Style%20Library/Scripts/jquery-1.9.0.js">
</script>
<script type="text/javascript" >
var azerty="jquery script";
alert($azerty);
$(document).ready(function() {
alert("jQuery");
});
</script>
</asp:Content>
But the import doesnt appear into the generated page. Someone has an idea ?
I used JQuery 1.9.0 and SPServices 0.7.2
Import these libraries into the header.
The ContentPlacdeHolderId PlaceHolderAdditionalPageHead is at the bottom of the page, i didnt see it and have some problems because of the duplicate...)
About the source, i activated the publishing and create a folder Scripts into the Styles Library.
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
<SharePoint:DelegateControl runat="server" ControlId="FormCustomRedirectControl" AllowMultipleControls="true"/>
<SharePoint:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>
<SharePoint:CssRegistration Name="forms.css" runat="server"/>
<!-- add JQuery 1.9.0-->
<script id ="JQUERY_ID" type="text/javascript" src="../../Style%20Library/Scripts/jquery-1.9.0.js">
</script>
<!-- add SPServices 0.7.2 -->
<script id ="JQUERY_ID" type="text/javascript" src="../../Style Library/Scripts/jquery.SPServices-0.7.2.js">
</script>
</ContentTemplate>
</SharePoint:UIVersionedContent>
</asp:Content>
Now the display of the title is :
<xsl:template name="title_line" >
<xsl:param name="title" select="'no title'" />
<xsl:param name="class" select="'no_class'" />
<tr>
<td colspan ="2" class="{$class}" style="font-weight:bold;font-size:medium">
<script type="text/javascript">
var static_name = &apos;<xsl:value-of select="$title" />&apos;;
var display_name = $().SPServices.SPGetDisplayFromStatic ({
listName: "listeperso",
columnStaticName: static_name
});
document.write(display_name);
</script>
</td>
</tr>
</xsl:template>
I just need to have the name of the list dynamically and it's over.
Cya.
EDIT : the script with the list name dynamically
<script type="text/javascript">
var list_name = $().SPServices.SPListNameFromUrl();
var static_name = &apos;<xsl:value-of select="$title" />&apos;;
var display_name = $().SPServices.SPGetDisplayFromStatic ({
listName : list_name,
columnStaticName: static_name
});
document.write(display_name);
</script>
listName uses either the list name either the list ID. SPListNameFromUrl returns the list ID.

how to use the updatepanl and postback trigger and progress templete in asp.net ajax

hi i am using update panel in my project, one page i have file upload control is there, so save the page file upload is not working that time i used post back trigger control (id is button id) now my problem is progress bar is not working , please give me any suggestion. my code is
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="IBtnSave" />
<asp:PostBackTrigger ControlID="ddlAgent" />
<asp:PostBackTrigger ControlID="btnSelectCity" />
<asp:PostBackTrigger ControlID="imgBtnAgent" />
<asp:PostBackTrigger ControlID="ImgBtnCancel" />
</Triggers>
progress bar code is
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="up1"
DynamicLayout="true">
<ProgressTemplate>
<div id="Progressbar" class="Progressbar" align="center" valign="middle" runat="server">
<asp:Image ID="Image1" Width="75" Height="95" runat="server" ImageUrl="~/images/animation_processing.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
how to solve that problem, please give me any suggestion
Thank u
hemanth
i can find out the answer it is working
just write the java script like this
<script type="text/javascript">
var updateProgress = null;
function postbackButtonClick() {
updateProgress = $find("<%= UpdateProgress1.ClientID %>");
window.setTimeout("updateProgress.set_visible(true)", updateProgress.get_displayAfter());
return true;
}
</script>
after that
<asp:UpdatePanel runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="IBtnSave" />
</Triggers>
button onclick event just call that function like this
<asp:Button ID="IBtnSave" runat="server" Text="Save" CssClass="art-button"
ClientIDMode="Static" onclick="IBtnSave_Click" OnClientClick="return postbackButtonClick();"/>

MovableType: Is it possible to have a rss feed for "todays" entries?

Background
Our email vendor supports rss feeds for dynamic content, which we use successfully for "daily headline" type emails. This is a great help in automating many different emails that we don't have staffing to create daily. One of our staff as requested that his daily email (which has recent headlines from his Movable Type blog) only have headlines from entries posted on that day.
My Question
Since we use Movable Type for his blog, is there a way to generate a rss feed that only contains items posted on the current day?
Your solution can be simplified by using the "days" parameter on mt:Entries:
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><$MTBlogName remove_html="1" encode_xml="1"$></title>
<link rel="alternate" type="text/html" href="<$MTBlogURL encode_xml="1"$>" />
<link rel="self" type="application/atom+xml" href="<$MTBlogURL$>atom.xml" />
<id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<$MTDate format="%Y"$>:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$></id>
<link rel="service.post" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>" title="<$MTBlogName encode_html="1"$>" />
<updated><MTEntries lastn="1"><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTEntries></updated>
<MTIfNonEmpty tag="MTBlogDescription"><subtitle><$MTBlogDescription remove_html="1" encode_xml="1"$></subtitle></MTIfNonEmpty>
<generator uri="http://www.sixapart.com/movabletype/">Movable Type <$MTVersion$></generator>
<MTEntries days="1">
<entry>
<title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
<link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>" />
<link rel="service.edit" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>/entry_id=<$MTEntryID$>" title="<$MTEntryTitle encode_html="1"$>" />
<id><$MTEntryAtomID$></id>
<published><$MTEntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
<updated><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>
<summary><$MTEntryExcerpt remove_html="1" encode_xml="1"$></summary>
<author>
<name><$MTEntryAuthorDisplayName encode_xml="1"$></name>
<MTIfNonEmpty tag="MTEntryAuthorURL"><uri><$MTEntryAuthorURL encode_xml="1"$></uri></MTIfNonEmpty>
</author>
<MTEntryCategories>
<category term="<$MTCategoryLabel encode_xml="1"$>" />
</MTEntryCategories>
<content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
<$MTEntryBody encode_xml="1"$>
<$MTEntryMore encode_xml="1"$>
</content>
</entry>
</MTEntries>
No need for checking the date yourself, this also removes the empty "entry" tags your version creates.
Okay, so i figured it out myself.
First I had to create a new feed, which i named "daily.xml" and copied the default code from atom.xml into it. Then I used setvarblock to define variables for the current date and publish date. Once this was done I used if to compare the 2 variables, and show the ones that matched.
code:
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><$MTBlogName remove_html="1" encode_xml="1"$></title>
<link rel="alternate" type="text/html" href="<$MTBlogURL encode_xml="1"$>" />
<link rel="self" type="application/atom+xml" href="<$MTBlogURL$>atom.xml" />
<id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<$MTDate format="%Y"$>:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$></id>
<link rel="service.post" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>" title="<$MTBlogName encode_html="1"$>" />
<updated><MTEntries lastn="1"><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTEntries></updated>
<MTIfNonEmpty tag="MTBlogDescription"><subtitle><$MTBlogDescription remove_html="1" encode_xml="1"$></subtitle></MTIfNonEmpty>
<generator uri="http://www.sixapart.com/movabletype/">Movable Type <$MTVersion$></generator>
<MTEntries lastn="15">
<entry>
<!-- this sets the current date to a variable named "TodaysDate" -->
<mt:setvarblock name="TodayDate"><$mt:Date format="%Y%m%d"></mt:setvarblock>
<!-- this sets the entry publish date to a variable named "PublishedDate" -->
<mt:setvarblock name="PublishedDate"><$mt:EntryDate format="%Y%m%d"></mt:setvarblock>
<!-- starts an IF statement comparing equality of "PublishedDate" and "TodayDate". note: for some reason the second variable needs to have an '$' added to the front -->
<mt:if name="PublishedDate" eq="$TodayDate">
<!-- the rest of this (except the end of the IF statement) is copied from default template -->
<title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
<link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>" />
<link rel="service.edit" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>/entry_id=<$MTEntryID$>" title="<$MTEntryTitle encode_html="1"$>" />
<id><$MTEntryAtomID$></id>
<published><$MTEntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
<updated><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>
<summary><$MTEntryExcerpt remove_html="1" encode_xml="1"$></summary>
<author>
<name><$MTEntryAuthorDisplayName encode_xml="1"$></name>
<MTIfNonEmpty tag="MTEntryAuthorURL"><uri><$MTEntryAuthorURL encode_xml="1"$></uri></MTIfNonEmpty>
</author>
<MTEntryCategories>
<category term="<$MTCategoryLabel encode_xml="1"$>" />
</MTEntryCategories>
<content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
<$MTEntryBody encode_xml="1"$>
<$MTEntryMore encode_xml="1"$>
</content>
<!-- end of our IF statement -->
</mt:if>
</entry>
</MTEntries>
</feed>

How to combine WMD and prettify, like Stack Overflow?

Prettify needs class="prettyprint" to be add to <pre> or <code>. How to let WMD do this?
Take a look at the PageDown Markdown editor...
AFAIK, WMD is dead, but PageDown is a fork based on the WMD source.
It's an active project based on the work done in WMD. That takes care of the Markdown editor. To get syntax highlighting working you'll also need to download source from the Google-Code-Prettify project.
Combine the demo.html, demo.css, prettify.js, prettify.css into the same folder.
Modify the imports accordingly:
<link rel="stylesheet" href="demo.css" />
<link rel="stylesheet" href="prettify.css" />
<script src="../Markdown.Converter.js"></script>
<script src="../Markdown.Sanitizer.js"></script>
<script src="../Markdown.Editor.js"></script>
<script src="prettify.js"></script>
Note: This assumes that the PageDown source files are in the parent directory.
To enable syntax highlighting, you'll need to do two things:
Add the 'prettyprint' class to all 'code' elements generated by the editor.
Fire the prettyPrint() event after a change is made.
If you take a look at the code, I modified the non-sanitized converter to do both:
var converter2 = new Markdown.Converter();
converter2.hooks.chain("postConversion", function (text) {
return text.replace(/<pre>/gi, "<pre class=prettyprint>");
});
var editor2 = new Markdown.Editor(converter2, "-second");
editor2.hooks.chain("onPreviewRefresh", function () {
prettyPrint();
});
editor2.run();
To give you an idea of the flexibility. Google-Code-Prettify is the same library that enables syntax highlighting on code.google.com and stackoverflow.com.
It took me a little while to figure out how to get it to work but it's amazing how easy it is to implement. This is only a demo example but it shouldn't be too hard to extend it further.
With the help of jquery and using the timer plugin this can be done in the following way.
<html>
<head>
<title>My Page Title</title>
<link rel="stylesheet" type="text/css" href="wmd/wmd.css" />
<script type="text/javascript" src="wmd/showdown.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.timers.js"></script>
<link href="lib/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="lib/prettify/prettify.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#wmd-input').keydown(function() {
$(this).stopTime();
$(this).oneTime(1000, function() { styleCode(); });
});
});
function styleCode(){
$("#wmd-preview pre").addClass("prettyprint");
$("#wmd-preview code").html(prettyPrintOne($("#wmd-preview code").html()));
}
</script>
</head>
<body onload="prettyPrint()">
<div style="width:400px;min-height: 500px;">
<div id="wmd-button-bar" class="wmd-panel"></div>
<br/>
<textarea id="wmd-input" class="wmd-panel"></textarea>
<br/>
<div id="wmd-preview" class="wmd-panel"></div>
<br/>
<div id="wmd-output" class="wmd-panel"></div>
</div>
<script type="text/javascript" src="lib/wmd/wmd.js"></script>
</body>
The mechanism of the above is described here
Hope it helps.
You may be interested in the Stack Overflow version of WMD on Github. This version may have the feature you're looking for in it (but I'm not certain).

Resources