Space to separate "&&" so that all "&$var" can be made into "$var" later
[openemr.git] / library / js / ajax_functions_writer.js
blob70952e7d36fb4832a9c9ccafd505101f0ab07aa5
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 2
4 // of the License, or (at your option) any later version.
5 function moveOptions_11(theSelFrom, theSelTo){
6     document.getElementById(theSelFrom).style.color="red";
7     document.getElementById(theSelFrom).style.fontStyle="italic";
8     var str=document.getElementById(theSelFrom).innerHTML;
9     if(window.frames[0].document.body.innerHTML=='<br>')
10     window.frames[0].document.body.innerHTML="";
11     var patt=/\?\?/;
12     var result=patt.test(str);
13     if(result){
14         url = 'quest_popup.php?content='+str;
15         window.open(url,'quest_pop','width=640,height=190,menubar=no,toolbar=0,location=0, directories=0, status=0,left=400,top=375');
16     }
17     else{
18         val = str;
19        CKEDITOR.instances.textarea1.insertText(val);
20     }
22 function movePD(val,theSelTo){
23     var textAreaContent = window.frames[0].document.body.innerHTML;
24     var textFrom = val;
25     if(textAreaContent != '')
26     textAreaContent += "  "+textFrom;
27     else
28     textAreaContent += textFrom;
29     window.frames[0].document.body.innerHTML=textAreaContent;
31 function edit(id){
32     val=window.parent.document.getElementById(id).value;
33     arr=val.split("|*|*|*|");
34     document.getElementById('textarea1').value=arr[0];
36 function ascii_write(asc, theSelTo){
37     var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
38     var is_ie = navigator.userAgent.toLowerCase().indexOf('msie') > -1;
39     var is_apple = navigator.userAgent.toLowerCase().indexOf('apple') > -1;
40     if(asc == 13)
41     {
42         if(!is_ie){
43         var plugin = CKEDITOR.plugins.enterkey,
44                 enterBr = plugin.enterBr,
45         editor=CKEDITOR.instances.textarea1;
46         forceMode = editor.config.forceEnterMode;
47         mode = editor.config.enterMode;
48         editor.fire( 'saveSnapshot' );  // Save undo step.
49                 enterBr( editor, mode, null, forceMode );
50                 if(is_chrome || is_apple)
51                 enterBr( editor, mode, null, forceMode );
52         }
53         else{
54             CKEDITOR.instances.textarea1.insertText('\r\n');
55         }
56     }
57     else{
58         if (asc == 'para'){
59         var textFrom = "\r\n\r\n";
60         CKEDITOR.instances.textarea1.insertText(textFrom);
61         if(is_chrome || is_apple)
62         CKEDITOR.instances.textarea1.insertText(textFrom);
63         }
64         else
65         {
66             if (asc == 32)
67             var textFrom = "  ";
68             else
69             var textFrom = String.fromCharCode(asc);
70             CKEDITOR.instances.textarea1.insertText(textFrom);
71         }
72     }
74 function SelectToSave(textara){
75     var textAreaContent = window.frames[0].document.body.innerHTML;
76     mainform=window.parent.document;
77     if(mainform.getElementById(textara+'_div'))
78     mainform.getElementById(textara+'_div').innerHTML = textAreaContent;
79     if(mainform.getElementById(textara+'_optionTD') && document.getElementById('options'))
80     mainform.getElementById(textara+'_optionTD').innerHTML =document.getElementById('options').innerHTML;
81     if(mainform.getElementById(textara)){
82     mainform.getElementById(textara).value = textAreaContent;
83     if(document.getElementById('options'))
84     mainform.getElementById(textara).value +="|*|*|*|"+document.getElementById('options').innerHTML;
85     }
86     parent.$.fn.fancybox.close();
88 function removeHTMLTags(strInputCode){
89             /* 
90                     This line is optional, it replaces escaped brackets with real ones, 
91                     i.e. < is replaced with < and > is replaced with >
92             */  
93             strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
94                     return (p1 == "lt")? "<" : ">";
95             });
96             var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
98 function TemplateSentence(val){
99     if(val){
100         document.getElementById('share').style.display='';
101     }
102     else{
103         document.getElementById('share').style.display='none';
104     }
105     $.ajax({
106     type: "POST",
107     url: "ajax_code.php",
108     dataType: "html",
109     data: {
110          templateid:    val
111     },
112     success: function(thedata){
113                 //alert(thedata)
114                 document.getElementById('template_sentence').innerHTML = thedata;
115                 },
116     error:function(){
117         //alert("fail");
118     }   
119    });
120    return;
122 function delete_item(id){
123     //alert(id);
124     if(confirm("Do you really wants to delete this?")){
125     $.ajax({
126     type: "POST",
127     url: "ajax_code.php",
128     dataType: "html",
129     data: {
130          templateid: document.getElementById('template').value,
131          item: id,
132          source: "delete_item"
133     },
134     success: function(thedata){
135                 //alert(thedata)
136                 document.getElementById('template_sentence').innerHTML = thedata;
137                 },
138     error:function(){
139         //alert("fail");
140     }   
141    });
142    return;
143     }
144     return false;
146 function add_item(){
147     document.getElementById('new_item').style.display='';
148     document.getElementById('item').focus();
150 function cancel_item(id){
151     if(document.getElementById('new_item'))
152     document.getElementById('new_item').style.display='none';
153     if(document.getElementById('update_item'+id))
154     document.getElementById('update_item'+id).style.display='none';
156 function save_item(){
157     $.ajax({
158     type: "POST",
159     url: "ajax_code.php",
160     dataType: "html",
161     data: {
162          item:  document.getElementById('item').value,
163          templateid: document.getElementById('template').value,
164          source: "add_item"
165          
166     },
167     success: function(thedata){
168                 //alert(thedata)
169                 document.getElementById('template_sentence').innerHTML = thedata;
170                 cancel_item('');
171                 },
172     error:function(){
173         //alert("fail");
174     }   
175    });
176    return;
178 function update_item_div(id){
179     document.getElementById('update_item'+id).style.display='';
180     document.getElementById('update_item_txt'+id).focus();
182 function update_item(id){
183     $.ajax({
184     type: "POST",
185     url: "ajax_code.php",
186     dataType: "html",
187     data: {
188          item:  id,
189          templateid: document.getElementById('template').value,
190          content: document.getElementById('update_item_txt'+id).value,
191          source: "update_item"
192          
193     },
194     success: function(thedata){
195                 //alert(thedata)
196                 document.getElementById('template_sentence').innerHTML = thedata;
197                 cancel_item(id);
198                 },
199     error:function(){
200         //alert("fail");
201     }   
202    });
203    return;