-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformcradle.js
More file actions
55 lines (48 loc) · 1.56 KB
/
formcradle.js
File metadata and controls
55 lines (48 loc) · 1.56 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
// mark em with its value to rechange it later
function markEmWithText () {
$('em').each( function () {
$(this).attr( 'id', $(this).text().toLowerCase() )
});
};
function input2italic() {
// change content of em with given values form inputs
$("input").each( function () {
inputvalue = $(this).val();
$('em#' + $(this).attr('name') ).each( function () {
if ( inputvalue != "") $(this).text( inputvalue )
});
});
};
function setQRcode() {
document.getElementById("qrcodeurl").innerHTML = "" ;
if( $('#fcqr').prop('checked') ) {
var qrcode = new QRCode(document.getElementById("qrcodeurl"), {
text: window.location.href ,
width: 192,
height: 192,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.L
});
}
};
jQuery(document).ready(function() {
var formcradleform = window.location.search.substring(6) ; // remove the string '?form='
if ( formcradleform ) {
document.title = formcradleform ;
$.ajax( { url : formcradleform , dataType: "text" } )
.done(function( data ) {
// prepareForm ;
$("#content").html( Markdown(data) );
hashsplit();
updateHash();
markEmWithText()
input2italic();
setQRcode();
}).fail(function() {
alert( formcradleform + " is not available" );
});
}
});
window.onhashchange = input2italic ;
window.onhashchange = setQRcode ;