Created
April 4, 2017 18:04
-
-
Save BigBlueHat/24438d50d2231a2ba7d5841dbcc42c9e to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/yovebadoge
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://wzrd.in/standalone/n3"></script> | |
<link rel="stylesheet" href="https://semantic-ui.com/dist/semantic.min.css" /> | |
</head> | |
<body> | |
<div class="ui page container"> | |
<h1 class="ui dividing page header">Convert <code>@prefix</code> to <code>@context</code></h1> | |
<div class="ui form"> | |
<div class="ui field"> | |
<label for="turtle">turtle</label> | |
<textarea id="turtle" rows="10"> | |
@prefix foaf: <http://xmlns.com/foaf/0.1/> . | |
@prefix schema: <http://schema.org/> . | |
@base <http://bigbluehat.com/> . | |
<#me> | |
foaf:name "BigBlueHat" ; | |
foaf:workHomepage "http://wiley.com/" ; | |
foaf:knows <https://www.w3.org/People/Berners-Lee/card#i> ; | |
schema:description "Inventor & evangelist in love with the Web."@en . | |
</textarea> | |
</div> | |
<div id="error" class="ui hidden error message"></div> | |
<div class="ui one columne centered grid"> | |
<button class="ui labeled positive icon button" onclick="parse()"> | |
<i class="down arrow icon"></i> | |
extract context</button> | |
</div> | |
<div class="ui field"> | |
<label for="jsonld">json-ld @context</label> | |
<textarea id="jsonld" rows="6"></textarea> | |
</div> | |
</div> | |
</div> | |
<script id="jsbin-javascript"> | |
var parser = n3.Parser(); | |
var err = document.getElementById('error'); | |
function showError(message) { | |
err.textContent = message; | |
err.style.display = "block"; | |
} | |
function hideError() { | |
err.style.display = "none"; | |
} | |
function parse() { | |
var turtle = document.getElementById('turtle').value; | |
parser.parse(turtle, | |
function (error, triple, prefixes) { | |
if (error) { | |
showError(error); | |
throw error; | |
} else { | |
hideError(); | |
} | |
if (triple) { | |
// skip each triple | |
} else { | |
var context = prefixes; | |
context['@vocab'] = context['']; | |
delete context['']; | |
document.getElementById('jsonld').value = JSON.stringify({'@context': context}, null, ' '); | |
} | |
}); | |
} | |
parse(); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var parser = n3.Parser(); | |
var err = document.getElementById('error'); | |
function showError(message) { | |
err.textContent = message; | |
err.style.display = "block"; | |
} | |
function hideError() { | |
err.style.display = "none"; | |
} | |
function parse() { | |
var turtle = document.getElementById('turtle').value; | |
parser.parse(turtle, | |
function (error, triple, prefixes) { | |
if (error) { | |
showError(error); | |
throw error; | |
} else { | |
hideError(); | |
} | |
if (triple) { | |
// skip each triple | |
} else { | |
var context = prefixes; | |
context['@vocab'] = context['']; | |
delete context['']; | |
document.getElementById('jsonld').value = JSON.stringify({'@context': context}, null, ' '); | |
} | |
}); | |
} | |
parse();</script></body> | |
</html> |
This file contains 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
var parser = n3.Parser(); | |
var err = document.getElementById('error'); | |
function showError(message) { | |
err.textContent = message; | |
err.style.display = "block"; | |
} | |
function hideError() { | |
err.style.display = "none"; | |
} | |
function parse() { | |
var turtle = document.getElementById('turtle').value; | |
parser.parse(turtle, | |
function (error, triple, prefixes) { | |
if (error) { | |
showError(error); | |
throw error; | |
} else { | |
hideError(); | |
} | |
if (triple) { | |
// skip each triple | |
} else { | |
var context = prefixes; | |
context['@vocab'] = context['']; | |
delete context['']; | |
document.getElementById('jsonld').value = JSON.stringify({'@context': context}, null, ' '); | |
} | |
}); | |
} | |
parse(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment