Skip to content

Commit

Permalink
updated ccm.app_builder.js: provide app as downloadable QR Code
Browse files Browse the repository at this point in the history
  • Loading branch information
akless committed Feb 27, 2019
1 parent cef0c27 commit 3b26f97
Show file tree
Hide file tree
Showing 5 changed files with 2,388 additions and 185 deletions.
207 changes: 115 additions & 92 deletions app_builder/ccm.app_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @changes
* version 2.0.0 (18.02.2019):
* - changed default instance configuration
* - more ways for handover app (Embed Code, App ID, URL, Download, iBook Widget and SCORM)
* - more ways for handover app (Embed Code, App ID, URL, QR Code, Download, iBook Widget and SCORM)
* - more ways for loading existing app (Embed Code, App ID and URL)
* - use of modal dialogs
* - outsourcing of help functions to ES6 module
Expand Down Expand Up @@ -77,97 +77,107 @@
"id": "handover",
"inner": [
{
"id": "embed",
"class": "input-group mb-3",
"inner": [
{
"class": "input-group-prepend",
"inner": {
"tag": "span",
"class": "input-group-text",
"inner": "Embed"
}
},
{
"tag": "input",
"readonly": true,
"type": "text",
"id": "embed_code",
"class": "form-control bg-white",
"aria-label": "Embed Code"
},
{
"class": "input-group-append",
"inner": {
"tag": "button",
"id": "embed_copy",
"class": "btn btn-success",
"type": "button",
"inner": "Copy"
}
}
]
},
{
"class": "input-group mb-3",
"inner": [
{
"class": "input-group-prepend",
"inner": {
"tag": "span",
"class": "input-group-text",
"inner": "App ID"
}
},
{
"tag": "input",
"readonly": true,
"type": "text",
"id": "app_id",
"class": "form-control bg-white",
"aria-label": "App ID"
},
{
"class": "input-group-append",
"inner": {
"tag": "button",
"id": "id_copy",
"class": "btn btn-success",
"type": "button",
"inner": "Copy"
}
}
]
},
{
"class": "input-group mb-3",
"class": "d-flex",
"inner": [
{
"class": "input-group-prepend",
"inner": {
"tag": "span",
"class": "input-group-text",
"inner": "URL"
}
},
{
"tag": "input",
"readonly": true,
"type": "text",
"id": "app_url",
"class": "form-control bg-white",
"aria-label": "URL"
"inner": [
{
"id": "embed",
"class": "input-group mb-3",
"inner": [
{
"class": "input-group-prepend",
"inner": {
"tag": "span",
"class": "input-group-text",
"inner": "Embed"
}
},
{
"tag": "input",
"readonly": true,
"type": "text",
"id": "embed_code",
"class": "form-control bg-white",
"aria-label": "Embed Code"
},
{
"class": "input-group-append",
"inner": {
"tag": "button",
"id": "embed_copy",
"class": "btn btn-success",
"type": "button",
"inner": "Copy"
}
}
]
},
{
"class": "input-group mb-3",
"inner": [
{
"class": "input-group-prepend",
"inner": {
"tag": "span",
"class": "input-group-text",
"inner": "App ID"
}
},
{
"tag": "input",
"readonly": true,
"type": "text",
"id": "app_id",
"class": "form-control bg-white",
"aria-label": "App ID"
},
{
"class": "input-group-append",
"inner": {
"tag": "button",
"id": "id_copy",
"class": "btn btn-success",
"type": "button",
"inner": "Copy"
}
}
]
},
{
"class": "input-group mb-3",
"inner": [
{
"class": "input-group-prepend",
"inner": {
"tag": "span",
"class": "input-group-text",
"inner": "URL"
}
},
{
"tag": "input",
"readonly": true,
"type": "text",
"id": "app_url",
"class": "form-control bg-white",
"aria-label": "URL"
},
{
"class": "input-group-append",
"inner": {
"tag": "button",
"id": "url_copy",
"class": "btn btn-success",
"type": "button",
"inner": "Copy"
}
}
]
}
]
},
{
"class": "input-group-append",
"inner": {
"tag": "button",
"id": "url_copy",
"class": "btn btn-success",
"type": "button",
"inner": "Copy"
}
}
{ "id": "qr_code", "class": "pl-2" }
]
},
{
Expand All @@ -183,7 +193,7 @@
"tag": "span",
"class": "fas fa-file-download"
},
" Download"
" File"
]
},
{
Expand All @@ -208,7 +218,7 @@
"tag": "span",
"class": "fas fa-book"
},
" iBooks Author"
" iBook Widget"
]
},
{
Expand Down Expand Up @@ -349,6 +359,7 @@
]
} ],
"booklet": [ "ccm.component", "https://ccmjs.github.io/akless-components/window/versions/ccm.window-1.0.0.js" ],
"qr_code": [ "ccm.load", "https://ccmjs.github.io/akless-components/libs/qrcode-generator/qrcode.min.js" ],
"blockchain": [ "ccm.start", "https://ccmjs.github.io/rmueller-components/certificate_request/versions/ccm.certificate_request-1.0.0.js", [ "ccm.get", "https://ccmjs.github.io/rmueller-components/certificate_request/resources/config.js", "all" ] ],
"icon": "https://ccmjs.github.io/akless-components/dms/resources/component.png"
// "convert": { "app_to_builder": json => json, "builder_to_app": json => json },
Expand Down Expand Up @@ -680,9 +691,21 @@
content.querySelector( '#id_copy' ).addEventListener( 'click', () => copyToClipboard( content.querySelector( '#app_id' ) ) );

// provide App via URL
content.querySelector( '#app_url' ).value = self.helper.appURL( self.app.url, store_settings, app_id );
const app_url = self.helper.appURL( self.app.url, store_settings, app_id );
content.querySelector( '#app_url' ).value = app_url;
content.querySelector( '#url_copy' ).addEventListener( 'click', () => copyToClipboard( content.querySelector( '#app_url' ) ) );

// provide App via QR Code
if ( self.qr_code && qrcode ) {
let demoQRCode = qrcode( 0, 'M' );
demoQRCode.addData( app_url );
demoQRCode.make();
let qrCodeSVGTag = document.createElement( 'div' );
qrCodeSVGTag.innerHTML = demoQRCode.createImgTag();
$.setContent( content.querySelector( '#qr_code' ), qrCodeSVGTag.firstChild );
}
else $.removeElement( content.querySelector( '#qr_code' ) );

// provide App via Download as HTML File
if ( embed_code && self.helper.downloadApp )
content.querySelector( '#download' ).addEventListener( 'click', () => self.helper.downloadApp( embed_code ) );
Expand Down
1 change: 1 addition & 0 deletions app_builder/resources/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ccm.files[ 'configs.js' ] = {
"booklet": [ "ccm.component", "../window/ccm.window.js", [ "ccm.get", "../window/resources/configs.js", "local" ] ],
"builder.1": "../submit/ccm.submit.js",
"app": [ "ccm.component", "../cloze/ccm.cloze.js" ],
"qr_code": [ "ccm.load", "../libs/qrcode-generator/qrcode.min.js" ],
"user": [ "ccm.instance", "../user/ccm.user.js", [ "ccm.get", "../user/resources/configs.js", "guest" ] ],
"logger": [ "ccm.instance", "../log/ccm.log.js", [ "ccm.get", "../log/resources/configs.js", "greedy" ] ]
},
Expand Down
Loading

0 comments on commit 3b26f97

Please sign in to comment.