-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
97 lines (86 loc) · 3.78 KB
/
Copy pathindex.html
File metadata and controls
97 lines (86 loc) · 3.78 KB
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
<html>
<head>
<title>Moodle Utils</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="page-header">
<h2>Moodle Utils</h2>
</div>
<div class="row">
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">Jump to</span>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#convert-tags">Convert SQL</a></li>
</ul>
</div>
</div>
<div class="row" id="convert-tags">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Convert moodle SQL tags</h3>
</div>
<div class="panel-body">
<form role="form">
<div class="form-group">
<label for="mdl_sql_in" class="control-label">In</label>
<p class="help-block">Paste your unfiltered SQL here (eg. "SELECT * FROM {course};")</p>
<textarea id="mdl_sql_in" class="form-control" rows="10"></textarea>
</div>
<div class="form-group">
<label for="mdl_sql_out" class="control-label">Out</label>
<p class="help-block">Your SQL with tags filtered will appear here</p>
<textarea id="mdl_sql_out" class="form-control" rows="10"></textarea>
</div>
<div class="form-group">
<p class="help-block">If you use a different table prefix, add it here. Otherwise just hit "Convert".</p>
<div class="input-group col-md-3">
<span class="input-group-addon">prefix</span>
<input type="text" class="form-control text-right" id="dbprefix" value="mdl_" />
<span class="input-group-btn">
<button class="btn btn-primary" type="button" onclick="convertSQL('mdl_sql_in','mdl_sql_out');">Convert</button>
</span>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var mdlsqlreg = /(\{)([A-Za-z_]*)(\})/g;
function convertSQL(srctarget,desttarget){
var src = document.getElementById(srctarget);
var dest = 'ERROR INPUT';
var prefix = document.getElementById('dbprefix').value;
src = src && src.value;
if (src) {
dest = src.replace(mdlsqlreg, prefix+'$2');
}
document.getElementById(desttarget).value = dest;
}
</script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>