Created
July 17, 2015 22:41
-
-
Save boredstiff/980707449e8af4194e74 to your computer and use it in GitHub Desktop.
Test - Writing Empty Node Attributes into DOM in Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */ | |
/*global $, CSInterface, SystemPath, themeManager, require */ | |
var fs = require('fs'); | |
var XMLSerializer = require('xmldom').XMLSerializer; | |
var path = require('path'); | |
var constructDOM() { | |
'use strict'; | |
try { | |
var data = document.createElement('div'); | |
var testNode = document.createElement('testing'); | |
testNode.setAttribute('id', ''); | |
testNode.setAttribute('name', ''); | |
data.appendChild(testNode); | |
var XMLCreate = new XMLSerializer().serializeToString(data); | |
var tempFilePath = path.join('Users', 'alex', 'Desktop', 'testingEmptyNode.xml'); | |
fs.writeFile(tempFilePath, XMLCreate, function(err) { | |
if (err) alert(err); | |
else alert('File was written to ' + tempFilePath); | |
}); | |
} | |
catch(err) {alert(err);} | |
} | |
(function() { | |
'use strict'; | |
var csInterface = new CSInterface(); | |
function init() { | |
themeManager.init(); | |
$('#testingEmptyNodesButton').click(function() { | |
constructDOM(); | |
}); | |
} | |
init(); | |
}()); | |
/* | |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="css/topcoat-desktop-dark.min.css"/> | |
<link id="hostStyle" rel="stylesheet" href="css/styles.css"/> | |
</head> | |
<body class="hostElt"> | |
<div id="content" style="width:100%;"> | |
<div id="main"><br/> | |
<div id="cPanel" class="panel"> | |
<label class="topcoat-button-bar__item"> | |
<button id="testingEmptyNodesButton" class="topcoat-button-bar__button">Test Empty Nodes</button> | |
</label> | |
</div> | |
</div> | |
</div> | |
<script src="js/libs/CSInterface-4.0.0.js"></script> | |
<script src="js/libs/jquery-2.0.2.min.js"></script> | |
<script src="js/themeManager.js"></script> | |
<script src="js/main.js"></script> | |
</body> | |
</html> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment