-
-
Notifications
You must be signed in to change notification settings - Fork 688
/
edit.php
135 lines (122 loc) · 5.1 KB
/
edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<?php
if (!empty($_GET['log'])) {
echo '
<title>'.$_GET['log'].'</title>';
} else {
echo '
<title>GLSL Editor</title>';
}
?>
<link href='/favicon.gif' rel='shortcut icon'/>
<!— Open Graph data —>
<meta property="og:type" content="article" />
<meta property="og:title" content="GLSL Shader Editor" />
<meta property="og:site_name" content="The Book of Shaders"/>
<meta property="og:description" content="The Book of Shaders Editor" />
<?php
if (!empty($_GET['log'])) {
echo '
<meta property="og:image" content="http://thebookofshaders.com/log/'.$_GET['log'].'.png"/>
<meta property="og:image:secure_url" content="https://thebookofshaders.com/log/'.$_GET['log'].'.png"/>';
} else {
echo '
<meta property="og:image" content="https://thebookofshaders.com/thumb.png"/>';
}
echo'
<meta property="og:image:type" content="image/png"/>
<meta property="og:image:width" content="500" />
<meta property="og:image:height" content="500" />';
?>
<!-- <!— Twitter Card—>
<meta name="twitter:card" content="image">
<meta name="twitter:site" content="@bookofshaders">
<meta name="twitter:title" content="GLSL Shader Editor">
<meta name="twitter:description" content="The Book of Shaders editor">
<meta name="twitter:domain" content="thebookofshaders.com"> -->
<?php
// if (!empty($_GET['log'])) {
// echo '
// <meta name="twitter:image" content="https://thebookofshaders.com/log/'.$_GET['log'].'.png"/>';
// } else {
// echo '
// <meta name="twitter:image" content="https://thebookofshaders.com/thumb.png"/>';
// }
// echo '
// <meta name="twitter:image:width" content="500">
// <meta name="twitter:image:height" content="500">';
?>
<style>
body {
height: 100%;
margin: 0;
background: #272822;
}
#glsl_editor {
height: 100%;
}
</style>
</head>
<body>
<div id='glsl_editor'></div>
</body>
<link type='text/css' rel='stylesheet' href='https://thebookofshaders.com/glslEditor/glslEditor.css'>
<script type='application/javascript' src='https://thebookofshaders.com/glslEditor/glslEditor.js'></script>
<script type='text/javascript'>
var glslEditor = {};
function loadjscssfile(filename, filetype, callback){
if (filetype=="js") { //if filename is a external JavaScript file
var fileref = document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
}
else if (filetype=="css") { //if filename is an external CSS file
var fileref = document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", filename)
}
fileref.onload = callback;
fileref.onreadystatechange = callback;
if (typeof fileref != "undefined") {
document.getElementsByTagName("head")[0].appendChild(fileref)
}
}
window.onload = function() {
// if ()
if (window.GlslEditor && window.GlslEditor) {
init();
}
else {
console.log('Try to load a local glslEditor');
if (!window.glslEditor) {
loadjscssfile('src/glslEditor/build/glslEditor.css', 'css');
loadjscssfile('src/glslEditor/build/glslEditor.js', 'js', init);
}
}
};
function init() {
glslEditor = new GlslEditor('#glsl_editor', {
canvas_size: 500,
canvas_draggable: true,
theme: 'monokai',
multipleBuffers: true,
watchHash: true,
fileDrops: true,
menu: true
});
document.body.style.backgroundColor = window.getComputedStyle(glslEditor.editor.getWrapperElement(),null).getPropertyValue('background-color');
}
</script>
<script>
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
ga("create", "UA-18824436-2", "auto");
ga("send", "pageview");
</script>
</html>