1 // This program is free software; you can redistribute it and/or
2 // modify it under the terms of the GNU General Public License
3 // as published by the Free Software Foundation; either version 3
4 // of the License, or (at your option) any later version.
5 // modified to use activeElement for general edit sjpadgett@gmail.com 06/18/2019
8 function moveOptions_11(theSelFrom, theSelTo) {
9 document.getElementById(theSelFrom).style.color = "red";
10 document.getElementById(theSelFrom).style.fontStyle = "italic";
11 var str = document.getElementById(theSelFrom).innerHTML;
12 if (window.frames[0].document.body.innerHTML == '<br />')
13 window.frames[0].document.body.innerHTML = "";
15 var result = patt.test(str);
17 url = 'quest_popup.php?content=' + str;
18 window.open(url, 'quest_pop', 'width=640,height=190,menubar=no,toolbar=0,location=0, directories=0, status=0,left=400,top=375');
19 //dlgopen(url,'quest_pop', '', 640, 190);
22 CKEDITOR.instances.textarea1.insertText(val);
26 function movePD(val, theSelTo) {
27 var textAreaContent = window.frames[0].document.body.innerHTML;
29 if (textAreaContent != '')
30 textAreaContent += " " + textFrom;
32 textAreaContent += textFrom;
33 window.frames[0].document.body.innerHTML = textAreaContent;
37 return str.replace(/(?:\r\n|\r|\n)/g, '<br />');
41 return str.replace(/<\s*\/?br\s*[/]?>/gi, "\r\n");
44 function edit(id, ccFlag = '') {
48 if (ccFlag === 'id') {
49 val = window.opener.document.getElementById(id).value;
52 val = window.opener.document.querySelector('textarea[name=' + id + ']').value;
54 val = window.opener.document.querySelector("input[name=" + id + "]").value;
57 document.getElementById('textarea1').value = nl2br(val);
60 val = window.opener.document.getElementById(id).value;
62 arr = val.split("|*|*|*|");
63 document.getElementById('textarea1').value = arr[0];
66 function ascii_write(asc, theSelTo) {
67 var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
68 var is_ie = navigator.userAgent.toLowerCase().indexOf('msie') > -1;
69 var is_apple = navigator.userAgent.toLowerCase().indexOf('apple') > -1;
72 var plugin = CKEDITOR.plugins.enterkey,
73 enterBr = plugin.enterBr,
74 editor = CKEDITOR.instances.textarea1;
75 forceMode = editor.config.forceEnterMode;
76 mode = editor.config.enterMode;
77 editor.fire('saveSnapshot'); // Save undo step.
78 enterBr(editor, mode, null, forceMode);
79 if (is_chrome || is_apple)
80 enterBr(editor, mode, null, forceMode);
82 CKEDITOR.instances.textarea1.insertText('\r\n');
86 var textFrom = "\r\n\r\n";
87 CKEDITOR.instances.textarea1.insertText(textFrom);
88 if (is_chrome || is_apple)
89 CKEDITOR.instances.textarea1.insertText(textFrom);
94 var textFrom = String.fromCharCode(asc);
95 CKEDITOR.instances.textarea1.insertText(textFrom);
100 function SelectToSave(textara, ccFlag = '') {
101 let textAreaContent = '';
102 let mainForm = window.opener.document;
106 textAreaContent = window.frames[0].document.body.innerText;
107 if (ccFlag === 'id') {
108 textEl = mainForm.getElementById(textara);
109 if (textEl === null) {
110 alert(xl('Can not find where to insert.'));
114 textEl = mainForm.querySelector('textarea[name=' + textara + ']');
115 if (textEl === null) {
116 // maybe input for sentence
117 textEl = mainForm.querySelector("input[name=" + textara + "]");
120 textEl.value = jsText(br2nl(textAreaContent));
122 // must be html for nation note.
123 textAreaContent = window.frames[0].document.body.innerHTML;
124 if (mainForm.getElementById(textara + '_div'))
125 mainForm.getElementById(textara + '_div').innerHTML = textAreaContent;
126 if (mainForm.getElementById(textara + '_optionTD') && document.getElementById('options'))
127 mainForm.getElementById(textara + '_optionTD').innerHTML = document.getElementById('options').innerHTML;
128 if (mainForm.getElementById(textara)) {
129 mainForm.getElementById(textara).value = textAreaContent;
130 if (document.getElementById('options')) {
131 mainForm.getElementById(textara).value += "|*|*|*|" + document.getElementById('options').innerHTML;
135 // close our dialog however insert turns out.
139 function removeHTMLTags(strInputCode) {
141 This line is optional, it replaces escaped brackets with real ones,
142 i.e. < is replaced with < and > is replaced with >
144 strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1) {
145 return (p1 == "lt") ? "<" : ">";
147 var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
150 function supportDragAndDrop(thedata) {
151 let tempEl = document.createElement('div'), finalEl = '';
152 tempEl.innerHTML = thedata;
153 for (let i = 0; i < tempEl.children.length; i++) {
154 let ele = tempEl.children[i], temp;
156 ele.classList.add("draggable")
157 temp = document.createElement('div')
158 temp.classList.add("droppable");
159 temp.appendChild(ele.cloneNode(true));
160 finalEl += temp.outerHTML;
162 finalEl += ele.outerHTML;
168 function TemplateSentence(val) {
170 document.getElementById('share').style.display = '';
172 document.getElementById('share').style.display = 'none';
176 url: "ajax_code.php",
181 success: function (thedata) {
183 document.getElementById('template_sentence').innerHTML = supportDragAndDrop(thedata);
192 function delete_item(id) {
194 if (confirm("Do you really wants to delete this?")) {
197 url: "ajax_code.php",
200 templateid: document.getElementById('template').value,
202 source: "delete_item"
204 success: function (thedata) {
206 document.getElementById('template_sentence').innerHTML = supportDragAndDrop(thedata);
217 function add_item() {
218 document.getElementById('new_item').style.display = '';
219 document.getElementById('item').focus();
222 function cancel_item(id) {
223 if (document.getElementById('new_item'))
224 document.getElementById('new_item').style.display = 'none';
225 if (document.getElementById('update_item' + id))
226 document.getElementById('update_item' + id).style.display = 'none';
229 function save_item() {
232 url: "ajax_code.php",
235 item: document.getElementById('item').value,
236 templateid: document.getElementById('template').value,
240 success: function (thedata) {
242 document.getElementById('template_sentence').innerHTML = supportDragAndDrop(thedata);
252 function update_item_div(id) {
253 document.getElementById('update_item' + id).style.display = '';
254 document.getElementById('update_item_txt' + id).focus();
257 function update_item(id) {
260 url: "ajax_code.php",
264 templateid: document.getElementById('template').value,
265 content: document.getElementById('update_item_txt' + id).value,
266 source: "update_item"
269 success: function (thedata) {
271 document.getElementById('template_sentence').innerHTML = supportDragAndDrop(thedata);