PageSourceSearch

https://abelie.no/MathTeam/Notis/cssjs/mathPages.js

js abelie.no collected 2026-10-03 02:55:46 UTC 8,035 bytes, 289 lines download raw bytes

1
2
3
4    //Modal  
5    
6    function popUp(infoHold){
7      const popover = document.getElementById('popover');
8      //const infoHold = document.getElementById('word'+nr);
9        
10        
11        popover.innerHTML = infoHold.dataset.info + "<br><button  style='float:right;border:none;background-color:inherent' onclick='closePopover()'>X</button>"
12        popover.style.display = 'block';
13        rect = infoHold.getBoundingClientRect()
14        popover.style.top = `${window.scrollY + rect.bottom + 8}px`;
15        popover.style.left = `${rect.left + rect.width-30 }px`;
16    
17    }
18    
19        function popRight(infoHold){
20      const popover = document.getElementById('popRight');
21      //const infoHold = document.getElementById('word'+nr);
22        
23        
24        popover.innerHTML = infoHold.dataset.info + "<br><button  style='float:right;border:none;background-color:inherent' onclick='closeRight()'>X</button>"
25        popover.style.display = 'block';
26        rect = infoHold.getBoundingClientRect()
27        popover.style.top = `${window.scrollY + rect.bottom + 8}px`;
28       
29    
30    }
31   
32    function closePopover(){
33        const popover = document.getElementById('popover');
34        popover.style.display = 'none';
35    }  
36       function closeRight(){
37        const popover = document.getElementById('popRight');
38        popover.style.display = 'none';
39    }
40
41
42
43
44function geoLink(code){
45 document.ggbApplet.evalCommand(code)
46
47} 
48
49
50function closeNotes(){ 
51
52   document.getElementById("notes").style.display = 'none'
53}
54
55function showNote(nr){
56
57   const noten = document.getElementById("note"+nr).innerHTML 
58   document.getElementById("notes").style.display='block'
59   document.getElementById("showNote").innerHTML=noten
60} 
61
62function emptyNote(){ 
63     const sn=document.getElementById("sideNote")
64     sn.style.display="none"
65}
66
67 function sideNote(noter){
68         const sn=document.getElementById("note-content")
69         //const noteContent = "<button id='close-note' onclick='emptyNote()'>x</button><br><br><hr>"
70       sn.innerHTML=noter.dataset.note  
71       //sn.style.display="block"
72}
73
74//Replace theorem etc.
75    function replaceCode(text) {
76      const codesInput = "qTheoq:Theorem,qDefiq:Definition,qCoroq:Corollary,qLemmq:Lemma,qEquaq:Equation,qDemoq:Demonstration"
77      //document.getElementById('codes').value.trim();
78      //const text = document.getElementById('text').value;
79      
80      // Parse mappings like qTheoq:Theorem
81      const mappings = Object.fromEntries(
82        codesInput.split(',').map(entry => {
83          const [code, word] = entry.split(':').map(s => s.trim());
84          return [code, word];
85        }).filter(([code, word]) => code && word)
86      );
87
88      const counters = {};
89      let result = text;
90
91      // Replace codes with word + number
92      for (const [code, word] of Object.entries(mappings)) {
93        counters[word] = counters[word] || 1;
94        const regex = new RegExp(code, "g");
95        result = result.replace(regex, () => `${word} ${counters[word]++}`);
96      }
97
98      //outputDiv.textContent = result; 
99      return result
100    }
101    
102 //Replace theorem etc.
103    function replacePara(text) {
104      const codesInput = "qSectq:. "
105      //document.getElementById('codes').value.trim();
106      //const text = document.getElementById('text').value;
107      
108      // Parse mappings like qTheoq:Theorem
109      const mappings = Object.fromEntries(
110        codesInput.split(',').map(entry => {
111          const [code, word] = entry.split(':').map(s => s.trim());
112          return [code, word];
113        }).filter(([code, word]) => code && word)
114      );
115
116      const counters = {};
117      let result = text;
118
119      // Replace codes with word + number
120      for (const [code, word] of Object.entries(mappings)) {
121        counters[word] = counters[word] || 1;
122        const regex = new RegExp(code, "g");
123        result = result.replace(regex, () => `${counters[word]++}${word}  `);
124      }
125
126      //outputDiv.textContent = result; 
127      return result
128    }
129
130
131 
132  // Render tekst med MathJax
133function renderMath() {
134  let text1 = editor.getDoc().getValue() //document.getElementById("redText").value  
135  let text2 = replaceCode(text1)
136  let text = replacePara(text2)
137
138   // Example using typesetPromise for robustness
139    const newMathElement = document.getElementById("seText");
140    newMathElement.innerHTML = text; // Add your LaTeX content
141
142    MathJax.typesetPromise([newMathElement]).then(() => {
143        console.log("Dynamic math rendered successfully!");
144    }).catch((err) => {
145        console.error("Error rendering dynamic math:", err);
146    });
147 
148
149  //preview.innerHTML = text;
150} 
151   
152function settTegn(nr){
153    tegnList=["","<p></p>","<h3></h3>","\\frac\{\}\{\}","\\sqrt\{\}"]
154    const tegn= tegnList[nr]
155    insertTextAtCursor(tegn)
156} 
157
158function settTheorem(nr){
159    theoremList=["","Theorem","Definition","Remark","Corrolary"] 
160    colorList=["","Theorem","Definition","\\frac\{\}\{\}","\\sqrt\{\}"]
161    const tegn= tegnList[nr]
162    insertTextAtCursor(tegn)
163}
164
165function settGeo(){  
166const nr=document.getElementById("geoNr").value 
167const geoRef=document.getElementById("geoKode").value
168const geometry="<button id='but" + nr + "' onclick='setGeo("+nr+","+nr+")'  title='"+geoRef+"'>+</button><br>\n<div id='div" + nr +"' >-Geometry comes here-</div>" 
169
170  insertTextAtCursor(geometry)  
171   document.getElementById("geoNr").value=nr*1+1
172}
173
174
175 //Insert at cursor
176    function insertTextAtCursor(tegn) {
177
178// Get the current cursor position
179var cursor = editor.getCursor();
180
181// Insert the text at the cursor position
182editor.replaceRange(tegn, cursor, cursor);
183    }  
184    
185 clist=[1,1,1,1,1,1,1,1,1,1,1,1]   
186  function colaps(nr){
187  if(clist[nr]==1){document.getElementById("cdiv"+nr).style.display="block";clist[nr]=0}
188   else{document.getElementById("cdiv"+nr).style.display="none";clist[nr]=1}
189  }
190  
191function copyCode(text){
192       copyClip(text)
193}
194 
195 async function copyClip(textToCopy) {
196  try {
197    await navigator.clipboard.writeText(textToCopy);
198    console.log('Text copied to clipboard successfully!');
199  } catch (err) {
200    console.error('Failed to copy text: ', err);
201  }
202}
203
204
205 function geoCode(preen){
206   document.getElementById("geoText").value=preen
207 } 
208 
209
210function evalGeo(){ 
211   into=document.getElementById("geoText").value
212   document.ggbApplet.evalCommand(into)
213} 
214
215function getValue(){
216
217   const app=document.ggbApplet   
218   document.getElementById("listTall").innerHTML = app.getValueString("list") +"<br>Values on clipboard."
219   copyClip(app.getValueString("list"))
220   
221}
222
223function nyFunk(){
224    alert("Hallo")
225}
226
227
228
229 function setGeoParam(param,di){ 
230
231   var parameters = {
232   "showToolBar":param.dataset.tools,
233   "showAlgebraInput":param.dataset.input,
234   "material_id":param.dataset.material,
235   "customToolBar":param.dataset.toolbar, 
236   }
237   
238  new GGBApplet('5.0', parameters).inject('div'+di, 'preferHTML5');
239}
240
241
242function setGeo(param,di){
243
244var parameters = {
245   "material_id":param.dataset.material,
246   }
247   
248  new GGBApplet('5.0', parameters).inject('div'+di, 'preferHTML5');
249 } 
250 
251 function demoShow(nr){
252 
253  const demodiv=document.getElementById('demoDiv'+nr)
254  if(demodiv.style.display==="none") demodiv.style.display="block"
255  else demodiv.style.display="none"
256 
257 } 
258 
259 function setBase(param,di){
260
261var parameters = {
262   "ggbBase64":param,
263   } 
264   }   
265   
266    function setBase(param,di){
267
268var parameters = {
269   "ggbBase64":param,
270   } 
271   }
272   
273 function setImage(bildet) {
274     //const title = document.getElementById("note-title");
275     const tekst = document.getElementById("note-text");
276  const content = document.getElementById("note-content");
277  content.innerHTML=bildet.dataset.bilde
278  tekst.innerHTML=bildet.dataset.text
279  
280 }
281 
282 function setNote(noten){
283      const content = document.getElementById("note-content"); 
284      content.style.margin="1px"
285      content.style.margin="auto"
286      content.innerHTML=noten.dataset.note
287       const teksten = document.getElementById("note-text");
288       teksten.innerHTML="" 
289 }

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.