PageSourceSearch

https://hotelbroker.com.au/ui.ashx?f=js&t=editor

js hotelbroker.com.au collected 2026-10-04 09:42:51 UTC 23,563 bytes, 632 lines download raw bytes

1//
2// IASP HTML Editor
3//
4//  v1.0 (IASP 6.0)
5//
6
7var version = "20180917";
8var command = "";
9// browser identification
10IASPeditor.agt = navigator.userAgent.toLowerCase();
11IASPeditor.is_ie = ((IASPeditor.agt.indexOf("msie") != -1 || IASPeditor.agt.indexOf("trident") != -1) && (IASPeditor.agt.indexOf("opera") == -1));
12IASPeditor.is_opera = (IASPeditor.agt.indexOf("opera") != -1);
13IASPeditor.is_mac = (IASPeditor.agt.indexOf("mac") != -1);
14IASPeditor.is_mac_ie = (IASPeditor.is_ie && IASPeditor.is_mac);
15IASPeditor.is_win_ie = (IASPeditor.is_ie && !IASPeditor.is_mac);
16IASPeditor.is_gecko = (navigator.product == "Gecko");
17
18IASPeditor.preHtml = '<html><head><link rel="stylesheet" href="https://secure.iasp.com.au/resources/v6/editor-inline.css" /><link rel="stylesheet" href="/site/style-inline.css" /></head><body>';
19
20IASPeditor.postHtml = '</body></html>';
21
22function IASPeditor(fieldname) {
23    this.doc = document.getElementById(fieldname + '_edit');
24    this.src = document.getElementById(fieldname + '_editSource');
25    this.id = fieldname;
26}
27
28IASPeditor.prototype._getSelection = function () {
29    if (this.doc.contentWindow.document.selection) {
30        return this.doc.contentWindow.document.selection;
31    }
32
33    return this.doc.contentWindow.getSelection();
34};
35
36IASPeditor.prototype.InitToolbarButtons = function () {
37    var kids = document.getElementsByTagName('DIV');
38
39    //
40    // Init toolbar buttons
41    //
42    for (var i = 0; i < kids.length; i++) {
43        var thisid = kids[i].id;
44        if (kids[i].className == "imagebutton" && thisid.substring(0, this.id.length) == this.id) {
45            kids[i].cmd = thisid.substring(this.id.length + 1);
46            kids[i].onmouseover = IASPeditor.tbmouseover;
47            kids[i].onmouseout = IASPeditor.tbmouseout;
48            kids[i].onmousedown = IASPeditor.tbmousedown;
49            kids[i].onmouseup = IASPeditor.tbmouseup;
50            kids[i].editor = this;
51            if (IASPeditor.is_ie) {
52                var func = "alert('" + kids[i].id + "'); document.getElementById('" + kids[i].id + "').style.visibility='hidden';";
53                kids[i].onclick = function (ev) { this.editor.tbclick(this); };
54                //"alert('" + kids[i].id + "'); document.getElementById('" + kids[i].id + "').style.visibility='hidden';";
55                //IASPeditor._addEvent(kids[i],"click",function (ev) { alert(obj.id); });
56            } else {
57                IASPeditor._addEvent(kids[i], "click", function (ev) {
58                    this.editor.tbclick(this);
59                });
60            }
61        }
62    }
63
64    //
65    // Init source checkbox
66    //
67    var chkobj = document.getElementById(this.id + '_chksource');
68    chkobj.editor = this;
69    IASPeditor._addEvent(chkobj, "click", function (ev) {
70        chkobj.editor.viewsource(chkobj.checked);
71    });
72
73    //var cchkobj = document.getElementById(this.id + '_css');
74    //cchkobj.editor = this;
75    //IASPeditor._addEvent(chkobj, "click", function (ev) {
76    //cchkobj.editor.usecss(cchkobj.checked);
77    //});
78};
79
80IASPeditor._addEvent = function (el, evname, func) {
81    if (el.attachEvent) {
82        el.attachEvent("on" + evname, func);
83    } else {
84        el.addEventListener(evname, func, true);
85    }
86};
87
88IASPeditor.tbmousedown = function (e) {
89    var evt = e ? e : window.event;
90
91    var agt = navigator.userAgent.toLowerCase();
92    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
93    if (is_ie) {
94        this.firstChild.style.left = 1;
95        this.firstChild.style.top = 1;
96    } else {
97        this.firstChild.style.left = 2;
98        this.firstChild.style.top = 2;
99    }
100
101    this.style.borderTop = "1px #999 solid";
102    this.style.borderLeft = "1px #999 solid";
103    this.style.borderBottom = "1px #fff solid";
104    this.style.borderRight = "1px #fff solid";
105    if (evt.returnValue) {
106        evt.returnValue = false;
107    } else if (evt.preventDefault) {
108        evt.preventDefault();
109    } else {
110        return false;
111    }
112};
113
114IASPeditor.tbmouseup = function () {
115    var agt = navigator.userAgent.toLowerCase();
116    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
117    if (is_ie) {
118        this.firstChild.style.left = 0;
119        this.firstChild.style.top = 0;
120    } else {
121        this.firstChild.style.left = 1;
122        this.firstChild.style.top = 1;
123    }
124
125    this.style.borderTop = "1px #fff solid";
126    this.style.borderLeft = "1px #fff solid";
127    this.style.borderBottom = "1px #999 solid";
128    this.style.borderRight = "1px #999 solid";
129};
130
131IASPeditor.tbmouseout = function () {
132    var agt = navigator.userAgent.toLowerCase();
133    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
134    if (is_ie) {
135        this.firstChild.style.left = 0;
136        this.firstChild.style.top = 0;
137    } else {
138        this.firstChild.style.left = 1;
139        this.firstChild.style.top = 1;
140    }
141
142    this.style.border = "solid 1px #ddd";
143    this.style.background = "none";
144};
145
146IASPeditor.tbmouseover = function () {
147    this.style.borderTop = "1px #fff solid";
148    this.style.borderLeft = "1px #fff solid";
149    this.style.borderBottom = "1px #999 solid";
150    this.style.borderRight = "1px #999 solid";
151    this.style.background = "#eee";
152};
153
154IASPeditor.prototype.insertNodeAtSelection = function (win, insertNode) {
155    // get current selection
156    var sel = win.getSelection();
157
158    // get the first range of the selection
159    // (theres almost always only one range)
160    var range = sel.getRangeAt(0);
161
162    // deselect everything
163    sel.removeAllRanges();
164
165    // remove content of current selection from document
166    range.deleteContents();
167
168    // get location of current selection
169    var container = range.startContainer;
170    var pos = range.startOffset;
171
172    // make a new range for the new selection
173    range = document.createRange();
174
175    if (container.nodeType == 3 && insertNode.nodeType == 3) {
176        // if we insert text in a textnode, do optimized insertion
177        container.insertData(pos, insertNode.nodeValue);
178
179        // put cursor after inserted text
180        range.setEnd(container, pos + insertNode.length);
181        range.setStart(container, pos + insertNode.length);
182    } else {
183        var afterNode;
184        if (container.nodeType == 3) {
185            // when inserting into a textnode
186            // we create 2 new textnodes
187            // and put the insertNode in between
188
189            var textNode = container;
190            container = textNode.parentNode;
191            var text = textNode.nodeValue;
192
193            // text before the split
194            var textBefore = text.substr(0, pos);
195            // text after the split
196            var textAfter = text.substr(pos);
197
198            var beforeNode = document.createTextNode(textBefore);
199            afterNode = document.createTextNode(textAfter);
200
201            // insert the 3 new nodes before the old one
202            container.insertBefore(afterNode, textNode);
203            container.insertBefore(insertNode, afterNode);
204            container.insertBefore(beforeNode, insertNode);
205
206            // remove the old node
207            container.removeChild(textNode);
208        } else {
209            // else simply insert the node
210            afterNode = container.childNodes[pos];
211            container.insertBefore(insertNode, afterNode);
212        }
213
214        range.setEnd(afterNode, 0);
215        range.setStart(afterNode, 0);
216    }
217
218    sel.addRange(range);
219};
220
221function getOffsetTop(elm) {
222    var mOffsetTop = elm.offsetTop;
223    var mOffsetParent = elm.offsetParent;
224
225    while (mOffsetParent) {
226        mOffsetTop += mOffsetParent.offsetTop;
227        mOffsetParent = mOffsetParent.offsetParent;
228    }
229
230    return mOffsetTop;
231}
232
233function getOffsetLeft(elm) {
234    var mOffsetLeft = elm.offsetLeft;
235    var mOffsetParent = elm.offsetParent;
236
237    while (mOffsetParent) {
238        mOffsetLeft += mOffsetParent.offsetLeft;
239        mOffsetParent = mOffsetParent.offsetParent;
240    }
241
242    return mOffsetLeft;
243}
244
245String.prototype.trim = function () {
246    // Strip leading and trailing white-space
247    return this.replace(/^\s*|\s*$/g, "");
248};
249
250IASPeditor.checkLinkCreated = function (sID) {
251    var link = document.getElementById(sID + '_linkurl');
252
253    if (!link) {
254        setTimeout("IASPeditor.checkLinkCreated('" + sID + "')", 250);
255        return;
256    }
257
258    var linkURL = link.value;
259    if (linkURL != "" && linkURL != null) linkURL = linkURL.trim();
260    if (linkURL != "" && linkURL != null) {
261        if (IASPeditor._selection && window.getSelection) {
262            var sel = window.getSelection();
263            sel.removeAllRanges();
264            sel.addRange(IASPeditor._selection);
265        } else if (IASPeditor._precedingrange) {
266            IASPeditor._precedingrange.select();
267        }
268        document.getElementById(sID + '_edit').contentWindow.document.execCommand("createlink", false, linkURL);
269        document.getElementById(sID + '_linkurl').value = '';
270
271        IASPeditor._selection = null;
272        IASPeditor._precedingrange = null;
273    }
274
275    var imgURL = document.getElementById(sID + '_imgurl').value;
276    if (imgURL != "" && imgURL != null) imgURL = imgURL.trim();
277
278    var imgClass = document.getElementById(sID + '_imgclass').value;
279    if (imgClass != "" && imgClass != null) imgClass = imgClass.trim();
280
281    if (imgURL != "" && imgURL != null) {
282        var img_html = '<img src="' + imgURL + '" class="' + imgClass + '" alt="" />';
283
284        if (IASPeditor.is_ie) {
285            var cur = document.getElementById(sID + '_edit').contentWindow.document.body.innerHTML;
286            document.getElementById(sID + '_edit').contentWindow.document.body.innerHTML = cur + img_html;
287        } else {
288            //if (IASPeditor._precedingrange) {
289            //document.getElementById(sID + '_edit').contentWindow.document.open();
290            //document.getElementById(sID + '_edit').contentWindow.document.write(img_html);
291            //document.getElementById(sID + '_edit').contentWindow.document.close();
292            //IASPeditor._precedingrange = null;
293            //} else {
294            var cur = document.getElementById(sID + '_edit').contentWindow.document.body.innerHTML;
295            document.getElementById(sID + '_edit').contentWindow.document.body.innerHTML = cur + img_html;
296            //}
297        }
298        document.getElementById(sID + '_imgurl').value = '';
299        document.getElementById(sID + '_imgclass').value = '';
300    }
301
302    setTimeout("IASPeditor.checkLinkCreated('" + sID + "')", 250);
303};
304
305IASPeditor.prototype.tbclick = function (button) {
306    var idx = this.id;
307    var command = button.cmd; //button.id.substring(this.id.length + 1);
308
309    //
310    // If it's IE, store the current selection
311    //
312    var selection = this._getSelection();
313    if (selection.createRange) {
314        IASPeditor._precedingrange = selection.createRange();
315    } else if (selection.getRangeAt && selection.rangeCount) {
316        IASPeditor._selection = selection.getRangeAt(0);
317    }
318
319    var win_width = (IASPeditor.is_ie) ? document.body.offsetWidth : window.innerWidth;
320
321    if (command == "createlink") {
322        buttonElement = document.getElementById(button.id);
323        var ltbx = document.getElementById(idx + "_linktoolbox");
324
325        buttonElement.style.position = "relative";
326        ltbx.parentNode.removeChild(ltbx);
327        buttonElement.appendChild(ltbx);
328        ltbx.style.display = "block";
329        ltbx.style.position = "absolute";
330        ltbx.style.left = (ltbx.offsetWidth / 2) * -1 + 'px';
331
332        ltbx.contentWindow.document.open();
333        ltbx.contentWindow.document.write('');
334        ltbx.contentWindow.document.close();
335        ltbx.src = CMS.appRoot + "ui.aspx?f=createlink&fid=" + idx + "_linktoolbox&id=" + idx;
336    } else if (command == "createimage") {
337        buttonElement = document.getElementById(button.id);
338        var ltbx = document.getElementById(idx + "_imagetoolbox");
339
340        buttonElement.style.position = "relative";
341        ltbx.parentNode.removeChild(ltbx);
342        buttonElement.appendChild(ltbx);
343        ltbx.style.display = "block";
344        ltbx.style.position = "absolute";
345        ltbx.style.left = (ltbx.offsetWidth / 2) * -1 + 'px';
346
347        ltbx.contentWindow.document.open();
348        ltbx.contentWindow.document.write('');
349        ltbx.contentWindow.document.close();
350        ltbx.src = CMS.appRoot + "ui.aspx?f=insertimage&fid=" + idx + "_imagetoolbox&id=" + idx;
351    } else if (command == "spellcheck") {
352        buttonElement = document.getElementById(button.id);
353        spellbox = document.getElementById(idx + "_spellbox");
354
355        buttonElement.style.position = "relative";
356        spellbox.parentNode.removeChild(spellbox);
357        buttonElement.appendChild(spellbox);
358        spellbox.style.display = "block";
359        spellbox.style.position = "absolute";
360        spellbox.style.left = (spellbox.offsetWidth / 2) * -1 + 'px';
361
362        spellbox.contentWindow.document.body.innerHTML = '';
363        spellbox.contentWindow.document.open();
364        qr = /"/g;
365        spellbox.contentWindow.document.write('<html><head></head><body><form id="spelldataform" method="post" action="'+ CMS.appRoot +'ui.aspx?f=spellcheck&fid=' + idx + '_spellbox&amp;id=' + idx + '"><input name="spelldata" type="hidden" value="' + escape(this.getHTML()) + '" /></form></body></html>');
366        spellbox.contentWindow.document.close();
367        setTimeout("spellbox.contentWindow.document.getElementById('spelldataform').submit()", 125);
368        //document.getElementById(idx + "_spellbox").src="ui.aspx?f=spellcheck&fid=" + idx + "_spellbox&id=" + idx;
369    } else if (command == "createtable") {
370        buttonElement = document.getElementById(button.id);
371        var ltbx = document.getElementById(idx + "_tablebox");
372
373        buttonElement.style.position = "relative";
374        ltbx.parentNode.removeChild(ltbx);
375        buttonElement.appendChild(ltbx);
376        ltbx.style.display = "block";
377        ltbx.style.position = "absolute";
378        ltbx.style.left = (ltbx.offsetWidth / 2) * -1 + 'px';
379
380        ltbx.contentWindow.document.body.innerHTML = '';
381        ltbx.src = CMS.appRoot + "ui.aspx?f=createtable&fid=" + idx + "_tablebox&id=" + idx;
382        e = this.doc;
383    } else if (command == "help") {
384        window.alert('not implemented yet.');
385    } else {
386        this.doc.contentWindow.document.execCommand(command, false, null);
387    }
388};
389
390IASPeditor.Select = function (selectname, edit_id) {
391    var cursel = document.getElementById(selectname).selectedIndex;
392    var editor = document.getElementById(edit_id + '_edit');
393    /* First one is always a label */
394    if (cursel != 0) {
395        var selected = document.getElementById(selectname).options[cursel].value;
396
397        if (!editor.contentWindow.document.execCommand('FormatBlock', null, selected)) {
398            editor.contentWindow.document.execCommand('FormatBlock', null, '<' + selected + '>');
399        }
400
401        document.getElementById(selectname).selectedIndex = 0;
402    }
403    document.getElementById(edit_id + '_edit').contentWindow.focus();
404};
405
406IASPeditor.SelectMergeField = function(selectname, edit_id) {
407    var cursel = document.getElementById(selectname).selectedIndex;
408    var editor = document.getElementById(edit_id + '_edit');
409    /* First one is always a label */
410    if (cursel != 0) {
411        var selected = document.getElementById(selectname).options[cursel].value;
412        editor.contentWindow.document.execCommand('insertText', false, selected);
413
414        document.getElementById(selectname).selectedIndex = 0;
415    }
416    document.getElementById(edit_id + '_edit').contentWindow.focus();
417};
418
419IASPeditor.dismisstools = function () {
420    var objects = document.getElementsByTagName('IFRAME');
421    for (var i = 0; i < objects.length; i++) {
422        if (IASPeditor.stringEndsWith(objects[i].id, "imagetoolbox")
423            || IASPeditor.stringEndsWith(objects[i].id, "linktoolbox")
424            || IASPeditor.stringEndsWith(objects[i].id, "spellbox")
425            || IASPeditor.stringEndsWith(objects[i].id, "tablebox"))
426            objects[i].style.display = 'none';
427    }
428};
429
430IASPeditor.prototype.Init = function () {
431    // if the editor has been initialized before then do nothing
432    if (this.doc.IASPeditor) return;
433    // otherwise assign the binding editor object
434    this.doc.IASPeditor = this;
435
436    //this.src.style.height=this.doc.offsetHeight + document.getElementById(this.id + '_editor_tools').offsetHeight + "px";
437    //this.src.style.width=this.doc.offsetWidth + "px";
438    this.doc.style.display = 'block';
439    this.doc.style.height = (this.src.offsetHeight - document.getElementById(this.id + '_editor_tools').offsetHeight) + 'px';
440    this.doc.style.width = this.src.offsetWidth + 'px';
441    this.src.style.display = 'none';
442    this.doc.contentWindow.document.designMode = "on";
443
444    if (IASPeditor.is_gecko) {
445        try {
446            this.doc.contentWindow.document.execCommand("undo", false, null);
447        } catch (e) {
448            alert("This demo is not supported on your level of Mozilla.");
449        }
450        this.doc.contentWindow.document.execCommand("useCSS", false, true);
451    }
452
453    this.InitToolbarButtons();
454
455    //
456    // Add dismiss palette handlers (don't worry about this for now, we have ui.aspx close buttons...
457    //
458    if (IASPeditor.is_ie) {
459        //
460        // IE's event model is screwed, so we just won't bother.
461        //
462        //document.body.onmousedown = IASPeditor.dismisstools;
463        //try { this.doc.contentWindow.document.onmousedown = IASPeditor.dismisstools; }
464        //catch(e) { }
465        //document.body.onkeypress = IASPeditor.dismisstools;
466        //try { this.doc.contentWindow.document.onkeypress = IASPeditor.dismisstools; }
467        //catch(e) { }
468    } else {
469        if (document.addEventListener) {
470            document.body.addEventListener("mousedown", IASPeditor.dismisstools, true);
471            this.doc.contentWindow.document.body.addEventListener("mousedown", IASPeditor.dismisstools, true);
472            document.body.addEventListener("keypress", IASPeditor.dismisstools, true);
473            this.doc.contentWindow.document.body.addEventListener("keypress", IASPeditor.dismisstools, true);
474        } else if (document.attachEvent) {
475            document.body.attachEvent("mousedown", IASPeditor.dismisstools, true);
476            this.doc.contentWindow.document.body.attachEvent("mousedown", IASPeditor.dismisstools, true);
477            document.body.attachEvent("keypress", IASPeditor.dismisstools, true);
478            this.doc.contentWindow.document.body.attachEvent("keypress", IASPeditor.dismisstools, true);
479        }
480    }
481
482    //
483    // Copy content from textarea to IFRAME
484    //
485    var temp = this.src.value;
486    var doc = this.doc.contentWindow.document;
487    doc.open();
488    doc.write(IASPeditor.preHtml + temp + IASPeditor.postHtml);
489    doc.close();
490
491    if (IASPeditor.is_ie) {
492        doc.body.contentEditable = true;
493    }
494
495    //
496    // Add onsubmit handler for copying content back
497    //
498    if (this.src.form) {
499        this.src.editor = this;
500        var f = this.src.form;
501        if (typeof f.onsubmit == "function") {
502            var funcref = f.onsubmit;
503            if (typeof f.__msh_prevOnSubmit == "undefined") {
504                f.__msh_prevOnSubmit = [];
505            }
506            f.__msh_prevOnSubmit.push(funcref);
507        }
508        var obj = {
509            textarea: this.src,
510            editor: this
511        };
512        f.onsubmit = function () {
513            obj.textarea.value = obj.editor.getHTML();
514            var a = this.__msh_prevOnSubmit;
515            // call previous submit methods if they were there.
516            if (typeof a != "undefined") {
517                for (var i = a.length; --i >= 0;) {
518                    a[i]();
519                }
520            }
521
522            return true;
523        };
524    }
525
526    //
527    // Start link passback checker
528    //
529    setTimeout("IASPeditor.checkLinkCreated('" + this.id + "')", 250);
530};
531
532IASPeditor.stringEndsWith = function (string, check) {
533    var result = false;
534
535    if (string.substring(string.length - check.length) == check) {
536        result = true;
537    }
538
539    return result;
540};
541
542//
543// Strip body tags and return text
544//
545IASPeditor.prototype.getHTML = function () {
546    if (document.getElementById(this.id + "_chksource").checked == true) {
547        return this.src.value;
548    } else {
549        return this.getHTMLinner();
550    }
551};
552
553IASPeditor.prototype.getHTMLinner = function () {
554    //
555    // Replace squiggly bracket escapes so it's caught properly by the engine later
556    //
557    var lr = /%7C/g;
558    var ar = /%7B/g;
559    var br = /%7D/g;
560    var data = this.doc.contentWindow.document.body.innerHTML.replace(ar, '{').replace(lr, '|').replace(br, '}');
561    //alert(data);
562    //data = data.substring(IASPeditor.preHtml.length);
563    //data = data.substring(0,data.length - IASPeditor.postHtml.length);
564    //alert(data);
565    return data;
566};
567
568//
569// Set body text including headers
570//
571IASPeditor.prototype.setHTML = function (data) {
572    this.doc.contentWindow.document.body.innerHTML = data; //IASPeditor.preHtml + data + IASPeditor.postHtml;
573};
574
575IASPeditor.prototype.viewsource = function (source) {
576    var is_gecko = (navigator.product == "Gecko");
577
578    if (is_gecko) {
579        //
580        // Mozilla content switch
581        //
582        var html;
583        if (source) {
584            this.src.value = this.getHTMLinner();
585
586            this.src.style.display = 'block';
587            this.doc.style.display = 'none';
588            this.src.focus();
589
590            document.getElementById(this.id + "_editor_tools").style.display = "none";
591        } else {
592            var temp = this.src.value;
593            this.setHTML(temp);
594
595            this.src.style.display = 'none';
596            this.doc.style.display = 'block';
597            this.doc.contentWindow.focus();
598
599            document.getElementById(this.id + "_editor_tools").style.display = "table-row";
600        }
601    } else {
602        //
603        // IE Content Switch
604        //
605        if (source) {
606            var temp = this.getHTMLinner();
607            this.src.value = temp;
608            this.src.style.display = 'block';
609            this.doc.style.display = 'none';
610            this.src.focus();
611
612            document.getElementById(this.id + "_editor_tools").style.display = "none";
613        } else {
614            var temp = this.src.value;
615            this.setHTML(temp);
616            //this.src.value = temp;
617            this.src.style.display = 'none';
618            this.doc.style.display = 'block';
619            this.doc.contentWindow.focus();
620
621            document.getElementById(this.id + "_editor_tools").style.display = "block";
622        }
623    }
624};
625
626IASPeditor.prototype.usecss = function (source) {
627    this.doc.contentWindow.document.execCommand("useCSS", false, !(source));
628};
629
630function readonly(source) {
631    this.doc.contentWindow.document.execCommand("readonly", false, !(source));
632}

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.