Make an HTA file run as admin (elevated) - jscript

In wsf, vbs and js files you can easily find out if they run elevated and if not you can easily make them.
The code I've written for that is this:
EnsureElevatedPrivileges();
WScript.Echo("Running elevated now!");
function EnsureElevatedPrivileges() {
if (!WScript.Arguments.Named.Exists("elevate")) {
new ActiveXObject("Shell.Application").ShellExecute(WScript.FullName, "\"" + WScript.ScriptFullName + "\" /elevate", "", "runas", 1);
WScript.Quit();
}
}
But this doesn't work in HTA files because the global WScript variable doesn't exist there.
So how can I force a specific HTA file run (itself) as admin?

You can take a look at this : Procedure to run HTA elevated
<html>
<head>
<title>HTA Helpomatic</title>
<HTA:APPLICATION
ID="oHTA"
APPLICATIONNAME="HTAHelpomatic"
SCROLL="yes"
SINGLEINSTANCE="yes"
>
<!-- ID="objHTAHelpomatic" -->
<!-- WINDOWSTATE="maximize" -->
</head>
<SCRIPT Language="VBScript">
If HTAElevate() = True Then
CreateObject("WScript.Shell").Run "mmc.exe compmgmt.msc", , True
Call Main()
End If
Sub Main()
MsgBox "HTA-Ende", 4096
End Sub
'*** v13.3 *** www.dieseyer.de *****************************
Function HTAElevate()
'***********************************************************
' Unter Windows x64 laufen VBS' nach einem Doppelklick in der x64-Umgebung
' mit %WinDi%\System32\wscript.exe oder mit %WinDi%\System32\cscript.exe.
' In der x64-Umgebung laufen VBS aber nicht (richtig). Die Prozedur
' HTAElevate() erkennt dies und startet ggf. das VBS in der
Const Elev = " /elevated"
' MsgBox oHTA.commandLine, , "5016 :: "
' Trace32Log "5018 :: oHTA.commandLine: ==" & oHTA.commandLine & "==", 1
HTAElevate = True
' If InStr( LCase( oHTA.commandLine ), Elev) > 0 then MsgBox oHTA.commandLine, , "5022 :: "
If InStr( LCase( oHTA.commandLine ), Elev) > 0 then Exit Function
On Error Resume Next
window.resizeto 750, 10 ' : window.moveto screen.width / 2, screen.height / 2
On Error GoTo 0
' MsgBox oHTA.commandLine, , "5030 :: "
createobject("Shell.Application").ShellExecute "mshta.exe", oHTA.commandLine & Elev, "", "runas", 1
HTAElevate = False
self.close
End Function ' HTAElevate()
</SCRIPT>
<body>
</body>
</html>

<html>
<head>
<SCRIPT LANGUAGE="VBScript" use="to move window offscreen so that it should not flicker">
X=top.screenleft
Y=top.screentop
window.moveTo -2000,-2000
</SCRIPT>
<hta:application
ID="thisHta"
ApplicationName="The Great ManojBhakarPCM"
Border="thin"
BorderStyle="Static"
Caption="Yes"
ContextMenu="No"
MaximizeButton="No"
MinimizeButton="No"
Navigable="No"
Scroll="yes"
Selection="yes"
ShowInTaskbar="Yes"
SingleInstance="no"
SysMenu="Yes"
WindowState="normal"
>
<SCRIPT Language="VBScript" use="to Run As Administrator And window onload.">
If InStr(LCase(thisHta.commandLine), " /elevated") = 0 Then
createobject("Shell.Application").ShellExecute "mshta.exe", thisHta.commandLine & " /elevated", "", "runas", 4
self.close
else
window.moveTo X,Y
End If
Sub Window_OnLoad 'On window loading elements compeleted. start work here.
Document.body.innerHtml = "hello public, to kaise hai aap log? तो कैसे है आप लोग ?"
End Sub
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<style>
/* Author: ManojBhakarPCM */
body {
font-family: Arial, Helvetica, sans-serif;
}
.tile{/* Tile: width:vary, height: content wrap, padding: 5px;*/
height: auto !important;
padding:10px;
margin:3px;
display:inline-block;
}
.tilehead{
height: auto !important;
padding-left:10px;
padding-right:10px;
padding-top:2px;
padding-bottom:2px;
margin:2px;
font-size:10px;
display:inline-block;
}
/*-----COLORS----*/
.pink{background-color:#FF4081;color:white;}
.red{background-color:#D32F2F;color:white;}
.purple{background-color:#E040FB;color:white;}
.deeppurple{background-color:#512DA8;color:white;}
.indigo{background-color:#536DFE;color:white;}
.blue{background-color:#1976D2;color:white;}
.lightblue{background-color:#0288D1;color:white;}
.cyan{background-color:#00BCD4;color:white;}
.teal{background-color:#00796B;color:white;}
.green{background-color:#388E3C;color:white;}
.lime{background-color:#CDDC39;color:white;}
.yellow{background-color:#FFEB3B;color:white;}
.darkyellow{background-color:#FBC02D;color:white;}
.orange{background-color:#FF5722;color:white;}
.bluegray{background-color:#607D8B;color:white;}
.gray{background-color:#333;color:white;}
.roundcorner{border-radius:5px;}
.bold{font-weight:bold;}
.padmin{padding:5px;}
.padmid{padding:10px;}
.padfull{padding:15px;}
.inline{display:inline-block;}
/* --------CONTROLS---------*/
/*NAVBAR*/
.navbar {overflow: hidden;background-color: #333;padding:3px;text-decoration: none;}
.navbar a{padding:5px;font-size: 10px;text-decoration: none;}
.navbar a:hover{background-color:red;}
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 50%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
<body>
Hellow Worlds
</body>
</html>
I have created this hta templet and i use it very often. I belive that templets are best way to work with scripting etc. i usually keep uploaded these templets to websites so when working on any computer(which is not mine) can do work done just by downloading and start coding.
FEATURES:
Run as administrator
Does Not Flicker.
Don't Even Show Before getting admin prev.
Unicode support.
All HTA tags.
usefull classes of css for smooth UI

Related

Replacing Font Awesome in heading with local SVG

I'm using this snippet for adding a Font Awesome icon in front of H1 headings:
h1:before {
content: "\f192 ";
font-family: "FontAwesome";
color: blueviolet;
}
How to adapt it for using a locally served (on site's server) SVG icon instead?
(that is uploaded in WP Media Library and using SVG Support plugin)
If your icon needs to remain a separate file, you can set it as a background image.
h1:before {
display: inline-block;
background-image: url(resources/icon.svg)
}
Otherwise you can embed your icon as a data url.
h1:before {
display: inline-block;
background-image: url(data:image/svg+xml,...etc...)
}
Update
Working example:
h1:before {
content: " ";
display: inline-block;
width: 0.7em;
height: 0.7em;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Ccircle cx='5' cy='5' r='5'/%3E%3C/svg%3E");
background-size: contain;
background-repeat: no-repeat;
}
<h1>This is a title</h1>

Font Awesome 4.7 to 5 broken?

Be forgiving, I am new to css let alone fontawesome :-)
I wanted to have a nice set of rating stars 0-5 and I managed it sort of using 4.7
https://jsfiddle.net/BoxRec/p3zgeLbt/36
content: "\f005\f006\f006\f006\f006";
However I needed half stars to complete the look and this required going to fontawesome 5
https://jsfiddle.net/BoxRec/p3zgeLbt/38
content: "\f005\f089\f006\f006\f006";
So I used the 5 library and now I now have the half star \f5c0 but the full star \f005 renders the same as the empty star \f006
https://jsfiddle.net/BoxRec/p3zgeLbt/46/
content: "\f005\f5c0\f006\f006\f006";
If you go to the cheatsheet, you can see that \f006 is gone in FontAwesome 5. I would (not a css guy) just use before and after tags to make the same effect. Regular vs solid is just changing the font weight.
note that I changed the font-family to 'Font Awesome\ 5 Free'
i.star {
font-family: 'Font Awesome\ 5 Free';
font-size: 16px;
color: #ffaa00;
font-style: normal;
}
i.s1::before {
content: "\f005";
font-weight: 900;
}
i.s1::after {
content: "\f005\f005\f005\f005";
font-weight: 200;
}
i.s1-5::before {
content: "\f005\f5c0";
font-weight: 900;
}
i.s1-5::after {
content: "\f005\f005\f005";
font-weight: 200;
}
Had to add this to the HTML:
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css">

Error occurred while populating metadata while reading items from S/4 using java cloud sdk VDM

Using java SAP Cloud SDK version 3.9.0
We have a code snippet for reading Outbound Delivery Items from S/4 while looks like this:
List<OutbDeliveryItem> items = new DefaultOutboundDeliveryV2Service()
.getAllOutbDeliveryItem()
.filter(OutbDeliveryItem.DELIVERY_DOCUMENT.eq("someDocument"))
.execute(someDestination);
The code executes successfully and is able to read the items from S/4. But below exception always gets logged:
ERROR com.sap.cloud.sdk.odatav2.connectivity.cache.metadata.GuavaMetadataCache - Error occurred while populating metadata:
com.sap.cloud.sdk.datamodel.odata.helper.ODataVdmErrorResultHandler$ErpODataException: The endpoint responded with HTTP error code 401.
Logon failed. 401 Not authorized.
Full error message:
<html><head><meta http-equiv="content-type" content="text/html; charset=windows-1252"><title>Logon failed</title><style>body { background: #ffffff; text-align:
center; width:100%; height:100%; overflow:hidden; }.content { display: table; position:absolute; width:100%; height:80%; }.valigned { display: table-cell; vertical-align: middle; }.lowerCenter { display: table-
cell; vertical-align: bottom; }.footer { position: absolute; bottom: 0; left: 0; width: 100%; z-index: -1; }.footerLeft { float: left; margin-left: 20px; }.footerRight { float: right; margin-right: 20px; positio
n: absolute; bottom: 0px; right: 0px; }.centerText { font-style: normal; font-family: Arial; font-size: 26px; color: #444444; z-index: 1; }.errorTextHeader { font-style: normal; font-family: Arial; font-size: 40
px; color: #444444; }.bottomText { align: center; font-style: normal; font-family: Arial; font-size: 14px; color: #444444; }.biggerBottomText { align: center; font-style: normal; font-family: Arial; font-size: 1
6px; color: #444444; }.detailTable { align: bottom; vertical-align: middle; margin-left:auto; margin-right:auto; font-style: normal; font-family: Arial; font-size: 16px; color: #444444; }</style></head><body><di
v class="content"><div class="valigned"><p class="centerText"><span class="errorTextHeader"> 401 Not authorized </span></p></div></div><div class="footer"><div class="footerLeft"><img width='150' height='80' tit
le='' alt='SAP logo'src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAABQCAYAAAGMt7zdAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAFhpJREFUeNpiZEAAJiBmZCAd/IdhmGYWhu0ffzNQAjz5mVigTGa291/JNudXlBQHA5K3
2P////8DWQHv9LsMnzOVGWTm3mf4+OsfmI0sBwNfslQ4gdRPkDeZkA24/OoHg1DHFTCGaX6SrMjA+vE7mA0SBwEQH4SRDUI2h120+sx/GDh67xOYhokhy8H4QD0cuCKMfcXJl/8lCo7+xwYevf0BpkHyIIzPIFiYYQDp9AP/Vx17jsLHZxBMkE02cc9PQrH2eL4L1jBCN4wZaiMzDlv
/gVIAFP/HZRlAADEi0YzUyAGMYFdt//iNgtTPCiT/sMAMIzcHAFM/PzQY4BlcCDkWeabdwcqG8WEYqE8AGs5wg+AAlvphKR6W2mFyM868BecMaOoXBAp/BuK/DGhFD4rLPnz/8x8fQHcRA7zogQLJwmNg+nm/FQM/B4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n/4VjMEurIhjanl0yOJ1+WUXRJ+CsRAPdi/pFsDJempsF0IAykcXfxmgv3zrEu1uCHpOCGLigiCFYQ3rDNtuZhzZBESIprY1Bdq6g8s9QugJIJFQ+TTvTpAhQzJajlKa8nOMFg04apMG1CHPvMroCSBhcQw81a/2KU
uZNsZPS5YGjsuzAb9kzDwGfYfF6J1Sqqa4EKpEWJGhNrW99xPftDcHlgZwSHvYbUNqMPL/BIoSTGWp6rXespKqswwfU2BW9teTZ2ENfQ8Yak5dzhl6JBZzbVL7+6as9ufgZLisZiBiX/hN5E2r/DeJDXMiVHj91LtRGEdrM66CTGjQiF1AXkdalRRmHQIcrYvd16HbZ+O9UxvcgyFVJ
MNqMy5sgDKXY+FXyMTTgv+Eg2BhoYj/BrWUQm9pLIRGpopIv3D7mzIQ9XsmScroIQ8FgOuv1phHgfvwjvW32/BjZRqvwIKlQDfK0+g+MByLAepYl3OMKAYB1D74mQNFBtYXF7KpakUsFxiqOqseAUokcG7q+qIAtYjD1W3VP9HXCbwp0/JCiiSGMv5b9r/u4MQqP/qk/RZ8zKd4GGDS
XZA8cXPctPHYgiW8+lIcaWhyxIoIARArop+fNKJXJCxLZetj1c0SMVBJkabU9ZBg6KaLH6IZET+rYDlwfX9GSyp68rC/gcKtRRHC4+EWgAAAABJRU5ErkJggg=='></div><div class="footerRight"><p class="bottomText"><span class="biggerBottomText">&c
opy;</span>2020 SAP SE, All rights reserved.</p></div></div></body></html>
at com.sap.cloud.sdk.datamodel.odata.helper.ODataVdmErrorResultHandler.createException(ODataVdmErrorResultHandler.java:117)
at com.sap.cloud.sdk.datamodel.odata.helper.ODataVdmErrorResultHandler.createError(ODataVdmErrorResultHandler.java:97)
at com.sap.cloud.sdk.datamodel.odata.helper.ODataVdmErrorResultHandler.createError(ODataVdmErrorResultHandler.java:33)
at com.sap.cloud.sdk.odatav2.connectivity.internal.ODataConnectivityUtil.checkHttpStatus(ODataConnectivityUtil.java:219)
at com.sap.cloud.sdk.odatav2.connectivity.cache.metadata.GuavaMetadataCache.getEdm(GuavaMetadataCache.java:239)
at com.sap.cloud.sdk.odatav2.connectivity.cache.metadata.GuavaMetadataCache.getEdm(GuavaMetadataCache.java:156)
at com.sap.cloud.sdk.odatav2.connectivity.ODataQuery.loadMetadata(ODataQuery.java:379)
at com.sap.cloud.sdk.odatav2.connectivity.ODataQuery.loadEntriesFromDestination(ODataQuery.java:310)
at com.sap.cloud.sdk.odatav2.connectivity.ODataQuery.internalExecute(ODataQuery.java:253)
at com.sap.cloud.sdk.odatav2.connectivity.ODataQuery.execute(ODataQuery.java:151)
at com.sap.cloud.sdk.odatav2.connectivity.ODataQuery.execute(ODataQuery.java:135)
at com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperRead.execute(FluentHelperRead.java:250)
I examined our destination setup on Cloud Foundry and the setup on cloud connector as well. The setup is correct. If it was a problem with the setup, then the code would not have been able to read the items from S/4.
Upon debugging the sdk code a bit, I found a method com.sap.cloud.sdk.odatav2.connectivity.OdataQuery.execute() while tries to execute the read request 2 times. First time the read fails as the code is not able to fetch metadata and throws the exception that I've mentioned earlier in my question. Second time the read is successful (Code is able to read the metadata). I could have pasted the code snippet from sdk here but I am not sure if it is appropriate to do so.
I have following questions:
Is something wrong with my code? (I suppose not since it is able to read the items from S/4) If something is wrong, then what is it?
Is this a bug in sdk? If yes then when will it be fixed?
If this is something internal to sdk, which I shouldn't be worried about then how can I stop this exception from being logged? I have to get rid of the error log since it will generate false alerts in our production system.
Please let me know if you require any more info.
P.S.: I have seen a lot of comments on this blog from people facing the same problem.
This issue is solved as of SAP Cloud SDK version 3.11.0.

Zingchart real time data feed

I have this Zingchart(gauge type) which displays random numbers from 1 to 100 using JS. I need to achieve the same via PHP. How can I do this? What are the necessary changes that needs to be done?
window.feed = function(callback) {
var tick = {};
tick.plot0 = Math.ceil(Math.random() * 100);
callback(JSON.stringify(tick));
refresh:{
type:"feed",
transport:"js",
url:"feed()",
interval:1000,
resetTimeout:1000
},
The necessary changes to work in php would be to set up a endpoint to hit. If you did something like:
window.feed = function(callback) {
var tick = {};
tick.plot0 = Math.ceil(Math.random() * <?php $phpValue ?>);
callback(JSON.stringify(tick));
The variable $phpValue would not work for a Javascript feed function because that value would printed only ONE time as the server compiles the php ONCE.
What to do then?
You want to add a proper url endpoint which returns the tick format. That would look something like this:
refresh: {
type: 'feed',
transport: 'http',
url: 'https://us-central1-zingchart-com.cloudfunctions.net/public_http_feed?min=0&max=50&plots=2',
interval: 200
}
Where the url returns the following data structure:
[{
plot0: 3,
plot1: 18,
'scale-x': "13:33:48" // optional scale-x argument to produce [x,y] plotting
}]
You can read more on the http docs.
Solution
Demo here
// define top level feed control functions
function clearGraph() {
zingchart.exec('myChart', 'clearfeed')
}
function startGraph() {
zingchart.exec('myChart', 'startfeed');
}
function stopGraph() {
zingchart.exec('myChart', 'stopfeed');
}
// window.onload event for Javascript to run after HTML
// because this Javascript is injected into the document head
window.addEventListener('load', () => {
// Javascript code to execute after DOM content
//clear start stop click events
document.getElementById('clear').addEventListener('click', clearGraph);
document.getElementById('start').addEventListener('click', startGraph);
document.getElementById('stop').addEventListener('click', stopGraph);
// full ZingChart schema can be found here:
// https://www.zingchart.com/docs/api/json-configuration/
const myConfig = {
//chart styling
type: 'line',
globals: {
fontFamily: 'Roboto',
},
backgroundColor: '#fff',
title: {
backgroundColor: '#1565C0',
text: 'Real-Time Line Chart',
color: '#fff',
height: '30x',
},
plotarea: {
marginTop: '80px'
},
crosshairX: {
lineWidth: 4,
lineStyle: 'dashed',
lineColor: '#424242',
marker : {
visible : true,
size : 9
},
plotLabel: {
backgroundColor: '#fff',
borderColor: '#e3e3e3',
borderRadius:5,
padding:15,
fontSize: 15,
shadow : true,
shadowAlpha : 0.2,
shadowBlur : 5,
shadowDistance : 4,
},
scaleLabel: {
backgroundColor: '#424242',
padding:5
}
},
scaleY: {
guide: {
visible: false
},
values: '0:100:25'
},
tooltip: {
visible: false
},
//real-time feed
refresh: {
type: 'feed',
transport: 'http',
url: 'https://us-central1-zingchart-com.cloudfunctions.net/public_http_feed?min=0&max=50&plots=1',
interval: 500,
},
plot: {
shadow: 1,
shadowColor: '#eee',
shadowDistance: '10px',
lineWidth:5,
hoverState: {visible: false},
marker:{ visible: false},
aspect:'spline'
},
series: [{
values: [],
lineColor: '#2196F3',
text: 'Blue Line'
},{
values: [],
lineColor: '#ff9800',
text: 'Orange Line'
}]
};
// render chart with width and height to
// fill the parent container CSS dimensions
zingchart.render({
id: 'myChart',
data: myConfig,
height: '100%',
width: '100%',
});
});
html, body {
height:100%;
width:100%;
margin:0;
padding:0;
}
#myChart {
margin: 0 auto;
height: 380px;
width: 98%;
box-shadow: 5px 5px 5px #eee;
background-color: #fff;
border: 1px solid #eee;
display: flex;
flex-flow: column wrap;
}
.controls--container {
display: flex;
align-items: center;
justify-content: center;
}
.controls--container button {
margin: 40px;
padding: 15px;
background-color: #FF4081;
border: none;
color: #fff;
box-shadow: 5px 5px 5px #eee;
font-size: 16px;
font-family: Roboto;
cursor: pointer;
transition: .1s;
}
.controls--container button:hover {
opacity: .9;
}
/*button movement*/
.controls--container button:active {
border-width: 0 0 2px 0;
transform: translateY(8px);
opacity: 0.9;
}
.zc-ref { display:none; }
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ZingGrid: Blank Grid</title>
<script src="https://cdn.zingchart.com/zingchart.min.js"></script>
</head>
<body>
<!-- CHART CONTAINER -->
<div id="myChart">
<a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a>
</div>
<div class="controls--container">
<button id="clear">Clear</button>
<button id="stop">Stop</button>
<button id="start">Start</button>
</div>
</body>
</html>

Indentation error while executing app.js code using node.js, express.js and socket.io npm

I am newbie in node.js, express.js framework and socket.io please help me.
When i execute below code using node app.js command in ubuntu terminal. Its giving indentation error:
oneadmin#openflow1:~/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master$ node app.js
Express server listening on port 1337 in development mode
Warning: missing space before text for line 33 of jade file "/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/views/layout.jade"
Error: unexpected token "indent"
at Parser.parseExpr (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:229:15)
at Parser.block (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:689:25)
at Parser.tag (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:800:26)
at Parser.parseTag (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:719:17)
at Parser.parseExpr (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:188:21)
at Parser.block (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:689:25)
at Parser.tag (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:800:26)
at Parser.parseTag (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:719:17)
at Parser.parseExpr (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:188:21)
at Parser.block (/home/oneadmin/Desktop/test-projects/nodejs/Datasift-Interaction-Counter-master/node_modules/jade/lib/parser.js:689:25)
app.js code following:
doctype html
html(lang='en')
head
meta(charset='utf-8')
//
Set the viewport width to device width for mobile
meta(name='viewport', content='width=device-width')
title DataSift :: Interaction Analyzer
//
Included CSS Files
link(rel='stylesheet', href='stylesheets/foundation.css')
link(rel='stylesheet', href='stylesheets/app.css')
//if lt IE 9
link(rel='stylesheet', href='stylesheets/ie.css')
//
IE Fix for HTML5 Tags
//if lt IE 9
script(src='http://html5shiv.googlecode.com/svn/trunk/html5.js')
//
Included JS Files
script(type='text/javascript', src='/socket.io/socket.io.js')
script(type='text/javascript', src='http://code.jquery.com/jquery-latest.js')
script(type='text/javascript', src='javascripts/modernizr.foundation.js')
script(type='text/javascript', src='javascripts/foundation.js')
script(type='text/javascript', src='javascripts/d3.js')
script(type='text/javascript', src='javascripts/d3.geom.js')
script(type='text/javascript', src='javascripts/d3.layout.js')
script(type='text/javascript', src='javascripts/d3.time.js')
script(type='text/javascript', src='javascripts/d3.word.cloud.js')
script(type='text/javascript', src='/javascripts/app.js')
script(type='text/javascript', src='/javascripts/graph-ic.js')
script
$(document).ready(function() {
$('#go').click(function() {
$.ajax({
type : 'POST',
url : '/submit',
data : $('#stream_creds').serialize(),
success : function(response) {
$('#ContactForm').find('.form_result').html(response);
}
});
});
});
body
//
container
.container
.row
.eight.columns
img(src='images/dslogo.png')
h4.subheader Interaction Volume
.panel
h4
| Total interactions:
span#countTotal
.four.columns
.panel.hide-on-phones
form#stream_creds.nice
input.input-text(type='text', placeholder='User Name', name='username')
input.input-text(type='text', placeholder='API Key', name='apikey')
input.input-text(type='text', placeholder='Stream ID', name='streamid')
p
a#go.nice.radius.blue.button.mobile.src-download(href='#') Subscribe
.row
.one.columns
.ten.columns
ul.nice.tabs-content
li#nice1Tab.active
#interactions
style(type='text/css')
svg {
font: 10px sans-serif;
}
.line {
fill: none;
stroke: #333;
stroke-width: 1.5px;
}
.axis path, .axis line {
fill: none;
stroke: #333;
shape-rendering: crispEdges;
}
.text {
fill: #333;
}
.data-line {
stroke: #F00;
stroke-width: 2;
fill: none;
stroke-dasharray: 0;
}
//
container
project link that i was trying to implementing in my local system ubuntu
http://www.benh.co.uk/datasift/visualising-a-datasift-feed-with-node-and-d3/
source code in git
https://github.com/haganbt/Datasift-Interaction-Counter
how to solve indentation error or how to execute successfully with fresh installation. Please let me help to solve this error
You need to add a dot . after your script/style tags if you're using inline javascript and CSS.
doctype html
html(lang='en')
head
meta(charset='utf-8')
//
Set the viewport width to device width for mobile
meta(name='viewport', content='width=device-width')
title DataSift :: Interaction Analyzer
//
Included CSS Files
link(rel='stylesheet', href='stylesheets/foundation.css')
link(rel='stylesheet', href='stylesheets/app.css')
//if lt IE 9
link(rel='stylesheet', href='stylesheets/ie.css')
//
IE Fix for HTML5 Tags
//if lt IE 9
script(src='http://html5shiv.googlecode.com/svn/trunk/html5.js')
//
Included JS Files
script(type='text/javascript', src='/socket.io/socket.io.js')
script(type='text/javascript', src='http://code.jquery.com/jquery-latest.js')
script(type='text/javascript', src='javascripts/modernizr.foundation.js')
script(type='text/javascript', src='javascripts/foundation.js')
script(type='text/javascript', src='javascripts/d3.js')
script(type='text/javascript', src='javascripts/d3.geom.js')
script(type='text/javascript', src='javascripts/d3.layout.js')
script(type='text/javascript', src='javascripts/d3.time.js')
script(type='text/javascript', src='javascripts/d3.word.cloud.js')
script(type='text/javascript', src='/javascripts/app.js')
script(type='text/javascript', src='/javascripts/graph-ic.js')
script.
$(document).ready(function() {
$('#go').click(function() {
$.ajax({
type : 'POST',
url : '/submit',
data : $('#stream_creds').serialize(),
success : function(response) {
$('#ContactForm').find('.form_result').html(response);
}
});
});
});
body
//
container
.container
.row
.eight.columns
img(src='images/dslogo.png')
h4.subheader Interaction Volume
.panel
h4
| Total interactions:
span#countTotal
.four.columns
.panel.hide-on-phones
form#stream_creds.nice
input.input-text(type='text', placeholder='User Name', name='username')
input.input-text(type='text', placeholder='API Key', name='apikey')
input.input-text(type='text', placeholder='Stream ID', name='streamid')
p
a#go.nice.radius.blue.button.mobile.src-download(href='#') Subscribe
.row
.one.columns
.ten.columns
ul.nice.tabs-content
li#nice1Tab.active
#interactions
style(type='text/css').
svg {
font: 10px sans-serif;
}
.line {
fill: none;
stroke: #333;
stroke-width: 1.5px;
}
.axis path, .axis line {
fill: none;
stroke: #333;
shape-rendering: crispEdges;
}
.text {
fill: #333;
}
.data-line {
stroke: #F00;
stroke-width: 2;
fill: none;
stroke-dasharray: 0;
}
//
container
html(lang='en')
<![endif]
head
meta(charset='utf-8')
//
Set the viewport width to device width for mobile
meta(name='viewport', content='width=device-width')
title DataSift :: Interaction Analyzer
//
Included CSS Files
link(rel='stylesheet', href='stylesheets/foundation.css')
link(rel='stylesheet', href='stylesheets/app.css')
//if lt IE 9
link(rel='stylesheet', href='stylesheets/ie.css')
//
IE Fix for HTML5 Tags
//if lt IE 9
script(src='http://html5shiv.googlecode.com/svn/trunk/html5.js')
//
Included JS Files
script(type='text/javascript', src='/socket.io/socket.io.js')
script(type='text/javascript', src='http://code.jquery.com/jquery-latest.js')
script(type='text/javascript', src='javascripts/modernizr.foundation.js')
script(type='text/javascript', src='javascripts/foundation.js')
script(type='text/javascript', src='javascripts/d3.js')
script(type='text/javascript', src='javascripts/d3.geom.js')
script(type='text/javascript', src='javascripts/d3.layout.js')
script(type='text/javascript', src='javascripts/d3.time.js')
script(type='text/javascript', src='javascripts/d3.word.cloud.js')
script(type='text/javascript', src='/javascripts/app.js')
script(type='text/javascript', src='/javascripts/graph-ic.js')
script.
$(document).ready(function() {
$('#go').click(function() {
$.ajax({
type : 'POST',
url : '/submit',
data : $('#stream_creds').serialize(),
success : function(response) {
$('#ContactForm').find('.form_result').html(response);
}
});
});
});
body
//
container
.container
.row
.eight.columns
img(src='images/dslogo.png')
h4.subheader Interaction Volume
.panel
h4
| Total interactions:
span#countTotal
.four.columns
.panel.hide-on-phones
form#stream_creds.nice
input.input-text(type='text', placeholder='User Name', name='username')
input.input-text(type='text', placeholder='API Key', name='apikey')
input.input-text(type='text', placeholder='Stream ID', name='streamid')
p
a#go.nice.radius.blue.button.mobile.src-download(href='#') Subscribe
.row
.one.columns
.ten.columns
ul.nice.tabs-content
li#nice1Tab.active
#interactions
style(type='text/css')
svg {
font: 10px sans-serif;
}
.line {
fill: none;
stroke: #333;
stroke-width: 1.5px;
}
.axis path, .axis line {
fill: none;
stroke: #333;
shape-rendering: crispEdges;
}
.text {
fill: #333;
}
.data-line {
stroke: #F00;
stroke-width: 2;
fill: none;
stroke-dasharray: 0;
}
//
container

Resources