-
Notifications
You must be signed in to change notification settings - Fork 1
/
pages-edit.html
265 lines (249 loc) · 10.8 KB
/
pages-edit.html
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!DOCTYPE html>
<base href=".">
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width minimum-scale=1.0 maximum-scale=1.0 user-scalable=no" />
<title>Content Pages</title>
<link rel="shortcut icon" type="image/jpg" href="./favicon.ico"/>
<link rel="manifest" href="./manifest.json">
<link rel="apple-touch-icon" href="/assets/icons/icon-192x192.png"/>
<link rel="apple-touch-icon" sizes="152x152" href="/images/icons/icon-152x152.png"/>
<link rel="apple-touch-icon" sizes="167x167" href="/images/icons/icon-152x152.png"/>
<link rel="apple-touch-icon" sizes="180x180" href="/images/icons/icon-192x192.png"/>
<link type="text/css" rel="stylesheet" href="./css/style.css" />
<link type="text/css" rel="stylesheet" href="./css/pages.css" />
<link type="text/css" rel="stylesheet" href="./css/menu.css" />
<link rel="stylesheet" type="text/css" href="/css/loader.css"/>
<!--just for the home page-->
<link rel="stylesheet" href="./css/home.css">
<!--class declaration-->
<script src="./js/cPage.js" ></script>
<script src="./js/cMenu.js" ></script>
<script type="text/javascript" src="./simpleIDB/SimpleIDB.js"></script>
<!--DOES NOT WORK FOR SUB_SUB NAVIGATION ?ARIA issue-->
<script src="./js/dl_1.js"></script> <!--refactoring-->
<script src="./js/prl_1.js"></script> <!--refactoring-->
<script src="./js/functions_data.js"></script>
<!--include module for editor-->
<script src="./js/functions_editor.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
<script src="./js/tinymce/tinymce.min.js"></script>
<script>
window.addEventListener('load', ()=>{
//console.log("in window load");
if ("serviceWorker" in navigator) {
try {
navigator.serviceWorker.register('./serviceWorker.js');
//console.log("Service Worker Registered");
} catch (error) {
//console.log("Service Worker Registration Failed");
}
}else{
//console.log("Service Worker not supported?");
}
});
</script>
</head>
<body>
<header>
<h1><image src="./favicon.ico" alt="picture of stack of papers"/> STACK</h1>
</header>
<div id="page">
<div class="header" id="header">
<!--//-->
<div class="text"><a href="#menu" class="menulines"><span></span></a><div id="section_title">.....</div></div>
<!--//-->
<div id="mySidenav" class="sidenav">
<input type="search" name="searchbox" id="searchbox" onKeyUp="edValueKeyPress()"/>
<div id="menu">
<!--<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>-->
<ul>
<!--onclick="javascript:toggleMenu(1)"-->
<div id="html_menu">
<!--*****WILL BE POPULATED DYNAMICALLY JS******-->
</div>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#" id="logout">logout (exit)</a></li>
</ul>
</div>
</div>
<div class="ca_loaders" id="ca_loaders">
<div class="ca_loader" id="ca_loader">
<div class="loader-inner ball-grid-pulse">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<p> loading content....</p>
</div>
</div>
<!-- IMPORTANT THINGS TO CHANGE
headerimage
para_loader visible at the start - then changes on load
content =
login page first if not logged in
homepage IF logged and has a choice of sections
section page if logged and has one subscription
-->
<!-- change header depending on section-->
<div class="headerimage" id="headerimage"></div>
<!-- /////-->
<div class="content main" id="content_main">
<h3><!--does not appear after load--></h3><div id="para_loader"><p><div id="loading_text">loading ....</div><div class="lds-hourglass" id="loader"></div></p></div>
<!--content once the indexedDB is loaded-->
<p id="content">
<form name="form1" id="form1" class="form_addcontent">
<!--NEED TO ADD ID, NAME, PARENTID--><!--GET GREATEST NO FROM DATABASE AND ADD 1-->
<!-- IF I TAKE THE ID OF CURRENT and any page added would be child page-->
Page Name: <input type="text" id="editable_name" class="med"><br/>
ID <input type="text" id="editable_id" class="small">
SID<input type="text" id="editable_sectionid" class="small">
ParentID <input type="text" id="editable_parentid" class="small">
PageID <input type="text" id="editable_pageid" class="small">
PageOrder <input type="text" id="editable_pageorder" class="small">
<input type="button" value="Add SubPage" onClick="addSubPgae()" class="alignright">
<br/>
<strong>Content:</strong>
<textarea id="editable_content" name="editable_content" class="editor-content wide">
</textarea>
<div id="questions"></div>
<input type="button" onclick="addQuestion(false)" value="Add question"></input>
<hr/>
<p></p>
<!--<input type="button" value="Download JSON file" onClick="download()" class="alignright">-->
<input id="postSubmit" type="submit" value="Save Page" class="alignright">
<!--<button class="file-button" onclick="handleSubmit(event)">Save As</button>-->
</p>
<div id="storageA"></div>
</fieldset>
</form>
<!-- FINISHED ADDING-->
<!--END OF EDIT-->
</p>
</div>
<!-- /////-->
<div id="login_main">
<!--LOGIN START used on login page-->
<form method="post" id="loginForm">
<h3>Login</h3>
<label for="username">Email </label>
<input type="text" id="username" name="username" required><br/>
<label for="password">Password </label>
<input type="text" id="password" name="password" required><br/> <br/>
<button type="submit" id="submitBtn">Login</button>
</form>
<p id="passwordmessage"></p>
<!--//-->
<!--LOGIN END used on login page-->
<p><a href="#" id="logout">logout (exit)</a></p>
</div>
</div>
<script>
//*****global variables set in functions_shared.js
var cidb = new SimpleIDB();
var bIsLoggedIn = new Boolean(false);
//var gDataSource = getIDBMenuData;
//var gPageDataSource = getIDBPageData;
var gDataSource = getRemoteMenuData;
var gPageDataSource = getRemotePageData;
var listElem;
//IF YOU WANT TO GET THE DATA FROM MONGO THEN PASS getRemoteMenuData into getUserInfo AND in UserLogOut below
//<div class="content main textsection1" id="content_main">
//<h2>FRCA Primary</h2>
//<p id="content"> //everything written dynamically...
//lost the login form entirely.
//callbackFunction - specific to menu data - called from IDB OR fetch (edit)
window.onload = function() {
document.getElementById("loginForm").style.display = "block";
//document.getElementById("para_loader").style.display = "block";
//check in IndexedDB - see if the sectionid passed through to pages matches the user indexedDB db
//prl_1.js - if page refreshed....
verifyUserContent(cidb, gDataSource);
const contentItems = document.querySelectorAll(".content");
contentItems.forEach(function(cItems) {
//alert(cItems);
addEvent(cItems);
});
document.querySelector( 'a[href="#menu"]' )
.addEventListener( 'click', e => {
//alert("in query selector hash menu")
e.preventDefault();
changeNavState(); //called from functions_shared.js - simply changes classes
});
document.body.addEventListener("click", function(e) {
// e.target was the clicked element
//beasts.indexOf('bison')
e.preventDefault();
//e.target.getAttribute('class').indexOf("collapsible") == "-1")
//alert(e.target.nodeName); //the expand and collapse sections are also buttons?
if(e.target.id == "submitBtn"){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
///************************VERIFYLOGIN - needs to be called from LoginForm AND onload**************
const output = verifyLogin(cidb, gDataSource, username, password);
//cannot refer to output because it is just a PROMISE AND can't await it because i'm not in a module.
//handleLoginSubmit(gDataSource); //handleLoginSubmit() in functions_shared.js
//check this to see if the object goes...
}else if(e.target && e.target.id == "logout") {
///**clicked on LOGOUT in menu in ***functions_shared.js***
UserLoggedOut();
changeNavState();
//the login form in null?? don't know why'
//what about set sectionid == null
}else if(e.target && e.target.nodeName == "A") {
//console.log("e.target.parent=" + e.target.parentNode.className);
//console.log("e.target.href=" + e.target.href);
var loc_href = e.target.href
//to get start of url to add on the new ID
var equalsLoc = loc_href.indexOf("?id=") + 4; //? + 3
var eTargetID = loc_href.substring(equalsLoc, loc_href.length);
//if not a menu expansion
if(e.target.parentNode.className.indexOf("pad")!=-1){
var loc_href = e.target.href
history.pushState('data to be passed', 'Page Title', e.target.href );
//console.log("loc_href=" + loc_href);
//console.log("eTargetID=" + eTargetID);
//calls menu before user has picked section
//getIDBMenuData(cidb, url_id, sectionid);
const menuData = gDataSource(cidb, eTargetID, eTargetID); //var x = await **calls different function based on edit or NOT edit */
}
//console.log("e.target.href.indexOf(#menu)" + e.target.href.indexOf("#menu"));
if (e.target.href.indexOf("#menu") == -1){
resolveLink_ExpandMenu_printPage(e);
}
//changePage();
}else{
//console.log ("on click with no event listener attached");
}
});
tinymce.init({
selector: '.editor-content',
init_instance_callback: function (editor) {
// Shortcuts and useful things go here.
editor.shortcuts.add("alt+s", "Save Me My Content", function() {
savePage();
//alert("saved");
}),
editor.shortcuts.add("alt+b", "A New Way To Bold", "Bold");
},
plugins: 'table code lists fullscreen link image',
toolbar: 'undo redo | formatselect | bold italic | numlist bullist | link | image' +
'alignleft aligncenter alignright alignjustify | indent outdent | ' +
'table tabledelete | tableprops tablerowprops tablecellprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol'
});
//document.body.addEventListener
//document.getElementById("searchbox").addEventListener("keypress", edValueKeyPress);
/*******event listeners*****/
};
</script>
</body>
</html>