cpee-frames 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,64 @@
1
+ <!--
2
+ This file is part of centurio.work/out/frame.
3
+
4
+ centurio.work/out/frame is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by the Free
6
+ Software Foundation, either version 3 of the License, or (at your option) any
7
+ later version.
8
+
9
+ centurio.work/out/frame is distributed in the hope that it will be useful, but
10
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
+ more details.
13
+
14
+ You should have received a copy of the GNU General Public License along with
15
+ centurio.work/out/frame (file LICENSE in the main directory). If not, see
16
+ <http://www.gnu.org/licenses/>.
17
+ -->
18
+
19
+ <!DOCTYPE html>
20
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">
21
+ <head>
22
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
23
+ <title>template frame</title>
24
+
25
+ <!-- libs, do not modify. When local than load local libs. -->
26
+ <script type="text/javascript" src="/js_libs/jquery.min.js"></script>
27
+ <script type="text/javascript" src="/js_libs/jquery.browser.js"></script>
28
+ <script type="text/javascript" src="/js_libs/jquery.svg.min.js"></script>
29
+ <script type="text/javascript" src="/js_libs/jquery.svgdom.min.js"></script>
30
+ <script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
31
+ <script type="text/javascript" src="/js_libs/util.js"></script>
32
+ <script type="text/javascript" src="/js_libs/printf.js"></script>
33
+ <script type="text/javascript" src="/js_libs/strftime.min.js"></script>
34
+ <script type="text/javascript" src="/js_libs/parsequery.js"></script>
35
+ <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
36
+ <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
37
+ <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
38
+
39
+ <!-- custom stuff, play arround -->
40
+ <script type="text/javascript" src="../js/ui.js"></script>
41
+ <script type="text/javascript" src="../js/language.js"></script>
42
+ <link rel="stylesheet" href="../css/frames.css" type="text/css"/>
43
+ <link class='custom' rel="stylesheet" href="" type="text/css"/>
44
+
45
+
46
+ <link rel="icon" type="image/png" sizes="32x32" href="../css/favicon-32x32.png">
47
+ <link rel="icon" type="image/png" sizes="96x96" href="../css/favicon-96x96.png">
48
+ <link rel="icon" type="image/png" sizes="16x16" href="../css/favicon-16x16.png">
49
+
50
+
51
+ <!-- Forms
52
+ <script src='https://centurio.work/out/forms/js/formio.full.min.js'></script>
53
+ -->
54
+ <script>
55
+ if (location.href.match(/\/$/) == null) {
56
+ location.href = location.href + '/';
57
+ }
58
+ </script>
59
+ </head>
60
+ <body is="x-ui">
61
+ <div id="container">
62
+ </div>
63
+ </body>
64
+ </html>
@@ -0,0 +1,55 @@
1
+ <!--
2
+ This file is part of centurio.work/out/frame.
3
+
4
+ centurio.work/out/frame is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by the Free
6
+ Software Foundation, either version 3 of the License, or (at your option) any
7
+ later version.
8
+
9
+ centurio.work/out/frame is distributed in the hope that it will be useful, but
10
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
+ more details.
13
+
14
+ You should have received a copy of the GNU General Public License along with
15
+ centurio.work/out/frame (file LICENSE in the main directory). If not, see
16
+ <http://www.gnu.org/licenses/>.
17
+ -->
18
+
19
+ <!DOCTYPE html>
20
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">
21
+ <head>
22
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
23
+ <title>test frame</title>
24
+
25
+ <!-- libs, do not modify. When local than load local libs. -->
26
+ <script type="text/javascript" src="/js_libs/jquery.min.js"></script>
27
+ <script type="text/javascript" src="/js_libs/jquery.browser.js"></script>
28
+ <script type="text/javascript" src="/js_libs/jquery.svg.min.js"></script>
29
+ <script type="text/javascript" src="/js_libs/jquery.svgdom.min.js"></script>
30
+ <script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
31
+ <script type="text/javascript" src="/js_libs/util.js"></script>
32
+ <script type="text/javascript" src="/js_libs/printf.js"></script>
33
+ <script type="text/javascript" src="/js_libs/strftime.min.js"></script>
34
+ <script type="text/javascript" src="/js_libs/parsequery.js"></script>
35
+ <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
36
+ <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
37
+ <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
38
+
39
+ <!-- custom stuff, play arround -->
40
+ <script type="text/javascript" src="../js/test.js"></script>
41
+ <link rel="stylesheet" href="../css/design.css" type="text/css"/>
42
+ <link class='custom' rel="stylesheet" href="" type="text/css"/>
43
+ <script>
44
+ if (location.href.match(/\/$/) == null) {
45
+ location.href = location.href + '/';
46
+ }
47
+ </script>
48
+ </head>
49
+ <body is="x-ui">
50
+ <div id="container">
51
+ test
52
+ </div>
53
+
54
+ </body>
55
+ </html>
@@ -0,0 +1,170 @@
1
+ <!--
2
+ This file is part of centurio.work/out/frame.
3
+
4
+ centurio.work/out/frame is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by the Free
6
+ Software Foundation, either version 3 of the License, or (at your option) any
7
+ later version.
8
+
9
+ centurio.work/out/frame is distributed in the hope that it will be useful, but
10
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
+ more details.
13
+
14
+ You should have received a copy of the GNU General Public License along with
15
+ centurio.work/out/frame (file LICENSE in the main directory). If not, see
16
+ <http://www.gnu.org/licenses/>.
17
+ -->
18
+
19
+ <!DOCTYPE html>
20
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">
21
+ <head>
22
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
23
+ <title>Frames - Tutorial</title>
24
+
25
+ <!-- libs, do not modify. When local than load local libs. -->
26
+ <script type="text/javascript" src="/js_libs/jquery.min.js"></script>
27
+ <script type="text/javascript" src="/js_libs/jquery.browser.js"></script>
28
+ <script type="text/javascript" src="/js_libs/jquery.svg.min.js"></script>
29
+ <script type="text/javascript" src="/js_libs/jquery.svgdom.min.js"></script>
30
+ <script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
31
+ <script type="text/javascript" src="/js_libs/util.js"></script>
32
+ <script type="text/javascript" src="/js_libs/printf.js"></script>
33
+ <script type="text/javascript" src="/js_libs/strftime.min.js"></script>
34
+ <script type="text/javascript" src="/js_libs/parsequery.js"></script>
35
+ <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
36
+ <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
37
+ <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
38
+
39
+ <!-- custom stuff, play arround -->
40
+ <link class='custom' rel="stylesheet" href="" type="text/css"/>
41
+ <script>
42
+ if (location.href.match(/\/$/) == null) {
43
+ location.href = location.href + '/';
44
+ }
45
+ </script>
46
+ </head>
47
+ <body is="x-ui">
48
+ <div id="container">
49
+
50
+ First Steps:<br>
51
+ <ul>
52
+
53
+ <li>define Endpoint: *adapt to your needs*</li>
54
+ <ul>
55
+ <li>init: https-post://centurio.work/out/frames/</li>
56
+ <li>frames: https-put://centurio.work/out/frames/</li>
57
+ </ul>
58
+ <li>define Data Element: (url where your frame will be reached)</li>
59
+ <ul>
60
+ <li><a href="getConfigs">check if frame is not already in use </a></li>
61
+ <li>frameID: YourFrameName</a></li>
62
+ </ul>
63
+ <li>Create Init Activity</li>
64
+ <ul>
65
+ <li>Create a new "Service Call with Script"</li>
66
+ <li>Set the Endpoint to "init"</li>
67
+ <li>Set your arguments e.g. width: 10, height:10, languge: de-at and some title</li>
68
+ <li>Set the Prepare Code to: "endpoints.init = File.join(endpoints.init,data.frameID)" where data.frameID is the name from the variable we created before</li>
69
+ </ul>
70
+ <li>Create Frame Activity</li>
71
+ <ul>
72
+ <li>Create a new "Service Call with Script"</li>
73
+ <li>Set the Endpoint to "frames"</li>
74
+ <li>Set your argument Type to "Set UI and contion" (default option)
75
+ <li>Set your other arguments e.g. DisplacementLeft:0, top:0, width:10, Height:10</li>
76
+ <li>In Section "Form Url" click on the button "New Language"</li>
77
+ <li>Define the URL that should be displayed</li>
78
+ <li>Set the Prepare Code to: "endpoints.frames = File.join(endpoints.frames,data.frameID)" where data.frameID is the name from the variable we created before</li>
79
+
80
+ </ul>
81
+ <li>Execute your Process</li>
82
+ <li>Open your frame URL (add the defined name (YourFrameName) to the url currently open in this browser Window</li>
83
+ </ul>
84
+
85
+
86
+ Ohter Steps:<br>
87
+ <ul>
88
+
89
+ <li>My new frame site process runs through once and then its done</li>
90
+ <ul>
91
+ <li>Use an endless loop within your proces engine</li>
92
+ <li>Be aware that in case you do not wait for input at some point your loop will run a gazillion times per second!!!</li>
93
+ </ul>
94
+ <li>Ohhh nooo i forgot the process engine instance that drives my frames application</li>
95
+ <ul>
96
+ <li>In the case your site is not empty</li>
97
+ <ul>
98
+ <li>Inspect the site (ctrl+shift+c)</li>
99
+ <li>Find one of your iframes</li>
100
+ <li>Arguments "name" or "id" will give you the instance ID</li>
101
+ </ul>
102
+ <li>In the case your site is empty</li>
103
+ <ul>
104
+ <li>HAHA</li>
105
+ <li>Nah its not that bad, look in your process engine and best thing to do is to use the design service next time</li>
106
+ </ul>
107
+ </ul>
108
+ </ul>
109
+
110
+ There are more Ohter Steps?<br>
111
+ <ul>
112
+ <li>My Frame needs to Return something to the process engine Step1</li>
113
+ <ul>
114
+ <li>Create a new "Service Call with Script"</li>
115
+ <li>Set the Endpoint to "frames"</li>
116
+ <li>Set your argument Type to "Set UI and wait for input"
117
+ <li>Set your other arguments e.g. DisplacementLeft:0, top:0, width:10, Height:10</li>
118
+ <li>In Section "Form Url" click on the button "New Language"</li>
119
+ <li>Define the URL that should be displayed</li>
120
+ <li>Set the Prepare Code to: "endpoints.frames = File.join(endpoints.frames,data.frameID)" where data.frameID is the name from the variable we created before</li>
121
+ <li>Set the Finalize Code to: "data.yourDataElementName = result</li>
122
+ <li>How to return data from your Frame? see Step2 (below)</li>
123
+ </ul>
124
+ <li>My Frame needs to Return something to the process engine Step2</li>
125
+ <ul>
126
+ <li>You have some fancy html site that wants to send oodles of data back to centurio</li>
127
+ <li>Within your frame call the javascript function parent.sendJson(window.name,yourJsonDataHere)</li>
128
+ <li>All you need to change is define "yourJsonDataHere"</li>
129
+ </ul>
130
+ <li>I want to delete some frames</li>
131
+ <ul>
132
+ <li>Create a new "Service Call with Script"</li>
133
+ <li>Set the Endpoint to "frames"</li>
134
+ <li>Set your argument Type to "Set UI and contion" (default option)
135
+ <li>Set your other arguments e.g. DisplacementLeft:0, top:0, width:10, Height:10 to match the frames you would like to delete</li>
136
+ <li>Set the Prepare Code to: "endpoints.frames = File.join(endpoints.frames,data.frameID)" where data.frameID is the name from the variable we created before</li>
137
+ <li>Thats it</li>
138
+ </ul>
139
+ <li>Do i need to delete a frame in order to create one at that poisiton?</li>
140
+ <ul>
141
+ <li>Nope, when one frame overlaps one or multiple frames the overlapped ones will be deleted automatically</li>
142
+ </ul>
143
+ </ul>
144
+
145
+
146
+
147
+ I Would like to use the Forms service:<br>
148
+ <ul>
149
+ <li>Will be described soon ;)</li>
150
+ </ul>
151
+
152
+ Data Handling:<br>
153
+ <ul>
154
+ <li>Will be described soon ;)</li>
155
+ </ul>
156
+
157
+
158
+ Other questions you could have: (note this is not other steps!)<br>
159
+ <ul>
160
+ <li>I want to do a circular iframe</li>
161
+ <ul>
162
+ <li>Why?</li>
163
+ <li>You have to manage this within your html site</li>
164
+ </ul>
165
+ </ul>
166
+
167
+ </div>
168
+
169
+ </body>
170
+ </html>
data/server/frames ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # This file is part of CPEE-FRAMES.
4
+ #
5
+ # CPEE-FRAMES is free software: you can redistribute it and/or
6
+ # modify it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or (at your
8
+ # option) any later version.
9
+ #
10
+ # CPEE-FRAMES is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13
+ # Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along with
16
+ # CPEE-FRAMES (file LICENSE in the main directory). If not, see
17
+ # <http://www.gnu.org/licenses/>.
18
+
19
+ if File.exists?(File.join(__dir__,'..','lib','cpee-frames','implementation.rb'))
20
+ require_relative File.join(__dir__,'..','lib','cpee-frames','implementation')
21
+ else
22
+ require 'cpee-frames/implementation'
23
+ end
24
+
25
+ options = {
26
+ :host => 'localhost',
27
+ :port => 8305,
28
+ :secure => false
29
+ }
30
+
31
+ Riddl::Server.new(CPEE::Frames::SERVER, options) do
32
+ accessible_description true
33
+ cross_site_xhr true
34
+
35
+ @riddl_opts[:data_dir] ||= File.join(__dir__,'data')
36
+
37
+ use CPEE::Frames::implementation(@riddl_opts)
38
+ end.loop!
@@ -0,0 +1,2 @@
1
+ :port: 8305
2
+ :host: localhost
data/tools/cpee-frames ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # This file is part of CPEE-FRAMES.
4
+ #
5
+ # CPEE-FRAMES is free software: you can redistribute it and/or modify it under
6
+ # the terms of the GNU Lesser General Public License as published by the Free
7
+ # Software Foundation, either version 3 of the License, or (at your option) any
8
+ # later version.
9
+ #
10
+ # CPEE-FRAMES is distributed in the hope that it will be useful, but WITHOUT
11
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
+ # details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with CPEE-FRAMES (file LICENSE in the main directory). If not, see
17
+ # <http://www.gnu.org/licenses/>.
18
+
19
+ curpath = __dir__
20
+ require 'rubygems'
21
+ require 'optparse'
22
+ require 'fileutils'
23
+ require 'xml/smart'
24
+ require 'yaml'
25
+ require 'typhoeus'
26
+ require 'stringio'
27
+
28
+ def wrap(s, width=78, indent=18, extra_indent=4) #{{{
29
+ lines = []
30
+ line, s = s[0..indent-2], s[indent..-1]
31
+ s.split(/\n/).each do |ss|
32
+ ss.split(/[ \t]+/).each do |word|
33
+ if line.size + word.size >= width
34
+ lines << line
35
+ line = (" " * (indent + extra_indent)) + word
36
+ else
37
+ line << " " << word
38
+ end
39
+ end
40
+ lines << line if line
41
+ line = (" " * (indent-1))
42
+ end
43
+ return lines.join "\n"
44
+ end #}}}
45
+
46
+ exname = File.basename($0)
47
+
48
+ ARGV.options { |opt|
49
+ opt.summary_indent = ' ' * 2
50
+ opt.summary_width = 15
51
+ opt.banner = "Usage:\n#{opt.summary_indent}#{exname} new [DIR] | newui [DIR]\n"
52
+ opt.on("Options:")
53
+ opt.on("--help", "-h", "This text") { puts opt; exit }
54
+ opt.on("")
55
+ opt.on(wrap("new [DIR] scaffolds a sample logging service. Add a handler to a cpee instance to experience the pleasure.",78,18,0))
56
+ opt.on("")
57
+ opt.on(wrap("newui [DIR] scaffolds css/js directors that are use by the UI into your webserver dir."))
58
+ opt.parse!
59
+ }
60
+ if (ARGV.length != 2)
61
+ puts ARGV.options
62
+ exit
63
+ else
64
+ command = ARGV[0]
65
+ dir = ARGV[1]
66
+ end
67
+
68
+ if command == 'new'
69
+ if !File.exists?(dir)
70
+ FileUtils.cp_r(File.join(curpath,'..','server'),dir)
71
+ FileUtils.mkdir(File.join(dir,'data')) rescue nil
72
+ else
73
+ puts 'Directory already exists.'
74
+ end
75
+ elsif command == 'newui'
76
+ if !File.exists?(dir)
77
+ FileUtils.cp_r(File.join(curpath,'..','ui'),dir)
78
+ else
79
+ puts 'Directory already exists.'
80
+ end
81
+ else
82
+ puts ARGV.options
83
+ end
Binary file
Binary file
Binary file
data/ui/css/frames.css ADDED
@@ -0,0 +1,49 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ padding: 0;
4
+ margin: 0;
5
+ }
6
+
7
+ :root {
8
+ --grid-cols: 1;
9
+ --grid-rows: 1;
10
+ }
11
+
12
+ body {
13
+ width: 100vw;
14
+ height: 100vh;
15
+ }
16
+
17
+ #container {
18
+ display: grid;
19
+ grid-template-rows: repeat(var(--grid-rows), 1fr);
20
+ grid-auto-rows: calc(100vh/var(--grid-rows));
21
+ grid-auto-columns: calc(100vw/var(--grid-cols));
22
+ grid-template-columns: repeat(var(--grid-cols), 1fr);
23
+ overflow: hidden;
24
+ width: 100%;
25
+ height: 100%;
26
+ }
27
+
28
+ .grid-item {
29
+ border: none;
30
+ background-color: #fff;
31
+ text-align: center;
32
+ }
33
+
34
+ .grid-item-invis{
35
+ border: none;
36
+ text-align: center;
37
+ width: 0px;
38
+ height: 0px;
39
+ background-color: #fff;
40
+ }
41
+
42
+ .formbutton{
43
+ position: relative;
44
+ bottom: 4.8em;
45
+ right: 0.8em;
46
+ z-index: 9;
47
+ padding: 1em;
48
+ float: right;
49
+ }
@@ -0,0 +1,68 @@
1
+
2
+
3
+ function showDocument(fr = "") {
4
+
5
+ if(fr != ""){
6
+ $.ajax({
7
+ type: "GET",
8
+ url: 'https://centurio.work/out/frames/' + fr + '/dataelements.json',
9
+ success: function(ret) {
10
+
11
+ $("#alldata").text(JSON.stringify(ret["ausfuehrungen"]));
12
+ },
13
+ error: function() {
14
+ reason = '';
15
+ clearDocument();
16
+ }
17
+ });
18
+ }
19
+ }
20
+
21
+
22
+ function clearDocument() {
23
+ console.log('rrrr');
24
+ }
25
+
26
+
27
+ function init() {
28
+ es = new EventSource('handler/sse/');
29
+ es.onopen = function() {
30
+ showDocument("FormTest");
31
+ // load
32
+ };
33
+ es.onmessage = function(e) {
34
+ if (e.data == 'new') {
35
+ reason = '';
36
+ showDocument();
37
+ }
38
+ if (e.data == 'reset') {
39
+ reason = '';
40
+ showDocument();
41
+ }
42
+ else{
43
+ if(e.data != "keepalive" && e.data != "started"){
44
+ try {
45
+ showDocument(e.data);
46
+ }
47
+ catch (e) {
48
+ }
49
+ }
50
+
51
+ }
52
+ };
53
+ es.onerror = function() {
54
+ reason = 'Server down.';
55
+ clearDocument();
56
+ setTimeout(init, 10000);
57
+ };
58
+ }
59
+
60
+
61
+
62
+
63
+
64
+
65
+ $(document).ready(function() {
66
+ init();
67
+ });
68
+
data/ui/js/language.js ADDED
@@ -0,0 +1,71 @@
1
+ function lang_init(obj,target){
2
+ if (obj == null) {
3
+ obj = $(document);
4
+ } else {
5
+ obj = $(obj);
6
+ }
7
+ $(target).empty();
8
+ let langSelect = new Set();
9
+ $("[lang]", obj).each(function(){
10
+ if(langSelect.has($(this).attr("lang"))){ return true; }
11
+ $(target).append("<span class=\"lang-select-item\" data-lang="+$(this).attr("lang")+">"+countryCodeToUTF8Flag($(this).attr("lang"))+"</span>");
12
+ langSelect.add($(this).attr("lang"));
13
+ });
14
+ if(langSelect.size <= 1){
15
+ $(target).hide();
16
+ return;
17
+ }
18
+ $(target).show();
19
+ displayLang($("html").attr("lang"), obj);
20
+ $(".lang-select-item").click(function(){
21
+ $("html").attr("lang", $(this).data("lang"));
22
+ let lang = $("html").attr("lang");
23
+ displayLang(lang);
24
+ });
25
+ }
26
+
27
+ function displayLang(lang, obj){
28
+ if(obj == null) obj = $(document);
29
+ let elementsWithLangAttr = new Set();
30
+ let elementIdsLangTrue = new Set();
31
+ $("[lang]").each(function(){
32
+ if($(this).is("html")){
33
+ return true;
34
+ }
35
+ elementsWithLangAttr.add($(this).attr("id"));
36
+ if($(this).attr("lang") != lang){
37
+ $(this).hide();
38
+ }else{
39
+ $(this).show();
40
+ elementIdsLangTrue.add($(this).attr("id"));
41
+ }
42
+ });
43
+ let elemWithLangAttrArr = Array.from(elementsWithLangAttr);
44
+ let elemIdsLangFalse = elemWithLangAttrArr.filter(x => !elementIdsLangTrue.has(x));
45
+ elemIdsLangFalse.forEach(function(x){
46
+ $("#"+x).first().show();
47
+ });
48
+ }
49
+
50
+ function countryCodeToUTF8Flag(code){
51
+ let charCodeA = "A".charCodeAt(0);
52
+ let utf8CountryIndicatorA = 127462;
53
+ let langCode = code;
54
+ let langFlagMap = new Map([["en", "gb"]]);
55
+ if(langFlagMap.has(code.toLowerCase())){
56
+ langCode = langFlagMap.get(code);
57
+ }
58
+ const utf8CountryIndicator = function(letter) {return (letter.toUpperCase().charCodeAt(0) - charCodeA) + utf8CountryIndicatorA;}
59
+ let firstIndicator = utf8CountryIndicator(langCode.charAt(0));
60
+ let secondIndicator = utf8CountryIndicator(langCode.charAt(1));
61
+ return "&#" + firstIndicator + ";&#" + secondIndicator + ";";
62
+ }
63
+
64
+ function fitTextToDiv(divTextElem, divFitToHeight, divFitToWidth){
65
+ let measureDiv = $('<div/>').text(divTextElem.text()).css("font-size", divTextElem.css("font-size"));
66
+ console.log($(this));
67
+ divTextElem.css("font-size", parseInt(divTextElem.css("font-size"))*divFitToWidth/divTextElem.width());
68
+ if(divTextElem.height() > divFitToHeight){
69
+ divTextElem.css("font-size", parseInt(divTextElem.css("font-size"))*divFitToHeight/divTextElem.height());
70
+ }
71
+ }