-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWidgetTplcode.js
More file actions
90 lines (66 loc) · 2.13 KB
/
Copy pathWidgetTplcode.js
File metadata and controls
90 lines (66 loc) · 2.13 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
/**
* @class Application_WidgetTplcode
*
* Append and substitute html and special chars
*
* <div class="x-lprjwdg-tplcode" id="areaHosts">
<span class="x-lprjelm x-lprjvar-CodeFile">code/start.code</span>
<span class="x-lprjelm x-lprjvar-Style">code</span>
<span class="x-lprjelm x-lprjvar-ShowFile">true</span>
</div>
*
*
*/
var Application_WidgetTplcode = Object.extend(Application_Widget, {
sWidget: "tplcode",
oElement: null,
oApplication: null,
sTemplate: "",
oTargetElement: null,
bShowFile: false,
aExternalLib:["highlight.pack.js"],
constructor: function(oElement, oApplication){
this.oElement = oElement;
this.oApplication = oApplication;
if (this.oApplication.bDebug){
this.oApplication.writeDebugMsg("Init Template code");
}
},
startWidget: function(oCallback){
if (this.oApplication.bDebug){
this.oApplication.writeDebugMsg("Init template code started");
}
var sCodeFile = this.oApplication.oLibClass.Vars.findElementVar(this.oElement,"CodeFile");
var sStyle = this.oApplication.oLibClass.Vars.findElementVar(this.oElement,"Style");
this.bShowFile = eval(this.oApplication.oLibClass.Vars.findElementVar(this.oElement,"ShowFile"));
if (sCodeFile != ""){
// Load file
if (this.oApplication.bDebug){
this.oApplication.writeDebugMsg("Loading file"+ sCodeFile);
}
// Purge code
this.oApplication.oLibClass.WS.simpleText(sCodeFile,function(sText){
sText = this.oApplication.oLibClass.Template.substituteHTMLTag(sText);
sText = this.oApplication.oLibClass.Template.insertBR(sText);
if (sStyle != ""){
sText = "<div class=\""+sStyle+"\"><pre><code>"+sText+"</code></pre></div>";
}else{
sText = "<div><pre><code>"+sText+"</code></pre></div>";
}
if (this.bShowFile){
sText +="<div class=\"code filename\">"+sCodeFile+"</div>"
}
$(this.oElement).append(sText);
if (sStyle != ""){
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
}
oCallback();
}.bind(this));
// Append content
}else{
oCallback();
}
}
});