How to use doc.createElement method in Cypress

Best JavaScript code snippet using cypress

table-operations.js

Source:table-operations.js Github

copy

Full Screen

...92 if (/\S/.test(val)) {93 // contains non white-space characters94 var caption = table.getElementsByTagName("caption")[0];95 if (!caption) {96 caption = dialog.editor._doc.createElement("caption");97 table.insertBefore(caption, table.firstChild);98 }99 caption.innerHTML = val;100 } else {101 // search for caption and delete it if found102 var caption = table.getElementsByTagName("caption")[0];103 if (caption) {104 caption.parentNode.removeChild(caption);105 }106 }107 break;108 case "f_summary":109 table.summary = val;110 break;111 case "f_width":112 table.style.width = ("" + val) + params.f_unit;113 break;114 case "f_align":115 table.align = val;116 break;117 case "f_spacing":118 table.cellSpacing = val;119 break;120 case "f_padding":121 table.cellPadding = val;122 break;123 case "f_borders":124 table.border = val;125 break;126 case "f_frames":127 table.frame = val;128 break;129 case "f_rules":130 table.rules = val;131 break;132 }133 }134 // various workarounds to refresh the table display (Gecko,135 // what's going on?! do not disappoint me!)136 dialog.editor.forceRedraw();137 dialog.editor.focusEditor();138 dialog.editor.updateToolbar();139 var save_collapse = table.style.borderCollapse;140 table.style.borderCollapse = "collapse";141 table.style.borderCollapse = "separate";142 table.style.borderCollapse = save_collapse;143 },144145 // this function gets called when the dialog needs to be initialized146 function (dialog) {147148 var f_caption = "";149 var capel = table.getElementsByTagName("caption")[0];150 if (capel) {151 f_caption = capel.innerHTML;152 }153 var f_summary = table.summary;154 var f_width = parseInt(table.style.width);155 isNaN(f_width) && (f_width = "");156 var f_unit = /%/.test(table.style.width) ? 'percent' : 'pixels';157 var f_align = table.align;158 var f_spacing = table.cellSpacing;159 var f_padding = table.cellPadding;160 var f_borders = table.border;161 var f_frames = table.frame;162 var f_rules = table.rules;163164 function selected(val) {165 return val ? " selected" : "";166 };167168 // dialog contents169 dialog.content.style.width = "400px";170 dialog.content.innerHTML = " \171<div class='title'\172 style='background: url(" + dialog.baseURL + dialog.editor.imgURL("table-prop.gif", "TableOperations") + ") #fff 98% 50% no-repeat'>" + i18n["Table Properties"] + "\173</div> \174<table style='width:100%'> \175 <tr> \176 <td> \177 <fieldset><legend>" + i18n["Description"] + "</legend> \178 <table style='width:100%'> \179 <tr> \180 <td class='label'>" + i18n["Caption"] + ":</td> \181 <td class='value'><input type='text' name='f_caption' value='" + f_caption + "'/></td> \182 </tr><tr> \183 <td class='label'>" + i18n["Summary"] + ":</td> \184 <td class='value'><input type='text' name='f_summary' value='" + f_summary + "'/></td> \185 </tr> \186 </table> \187 </fieldset> \188 </td> \189 </tr> \190 <tr><td id='--HA-layout'></td></tr> \191 <tr> \192 <td> \193 <fieldset><legend>" + i18n["Spacing and padding"] + "</legend> \194 <table style='width:100%'> \195"+// <tr> \196// <td class='label'>" + i18n["Width"] + ":</td> \197// <td><input type='text' name='f_width' value='" + f_width + "' size='5' /> \198// <select name='f_unit'> \199// <option value='%'" + selected(f_unit == "percent") + ">" + i18n["percent"] + "</option> \200// <option value='px'" + selected(f_unit == "pixels") + ">" + i18n["pixels"] + "</option> \201// </select> &nbsp;&nbsp;" + i18n["Align"] + ": \202// <select name='f_align'> \203// <option value='left'" + selected(f_align == "left") + ">" + i18n["Left"] + "</option> \204// <option value='center'" + selected(f_align == "center") + ">" + i18n["Center"] + "</option> \205// <option value='right'" + selected(f_align == "right") + ">" + i18n["Right"] + "</option> \206// </select> \207// </td> \208// </tr> \209" <tr> \210 <td class='label'>" + i18n["Spacing"] + ":</td> \211 <td><input type='text' name='f_spacing' size='5' value='" + f_spacing + "' /> &nbsp;" + i18n["Padding"] + ":\212 <input type='text' name='f_padding' size='5' value='" + f_padding + "' /> &nbsp;&nbsp;" + i18n["pixels"] + "\213 </td> \214 </tr> \215 </table> \216 </fieldset> \217 </td> \218 </tr> \219 <tr> \220 <td> \221 <fieldset><legend>Frame and borders</legend> \222 <table width='100%'> \223 <tr> \224 <td class='label'>" + i18n["Borders"] + ":</td> \225 <td><input name='f_borders' type='text' size='5' value='" + f_borders + "' /> &nbsp;&nbsp;" + i18n["pixels"] + "</td> \226 </tr> \227 <tr> \228 <td class='label'>" + i18n["Frames"] + ":</td> \229 <td> \230 <select name='f_frames'> \231 <option value='void'" + selected(f_frames == "void") + ">" + i18n["No sides"] + "</option> \232 <option value='above'" + selected(f_frames == "above") + ">" + i18n["The top side only"] + "</option> \233 <option value='below'" + selected(f_frames == "below") + ">" + i18n["The bottom side only"] + "</option> \234 <option value='hsides'" + selected(f_frames == "hsides") + ">" + i18n["The top and bottom sides only"] + "</option> \235 <option value='vsides'" + selected(f_frames == "vsides") + ">" + i18n["The right and left sides only"] + "</option> \236 <option value='lhs'" + selected(f_frames == "lhs") + ">" + i18n["The left-hand side only"] + "</option> \237 <option value='rhs'" + selected(f_frames == "rhs") + ">" + i18n["The right-hand side only"] + "</option> \238 <option value='box'" + selected(f_frames == "box") + ">" + i18n["All four sides"] + "</option> \239 </select> \240 </td> \241 </tr> \242 <tr> \243 <td class='label'>" + i18n["Rules"] + ":</td> \244 <td> \245 <select name='f_rules'> \246 <option value='none'" + selected(f_rules == "none") + ">" + i18n["No rules"] + "</option> \247 <option value='rows'" + selected(f_rules == "rows") + ">" + i18n["Rules will appear between rows only"] + "</option> \248 <option value='cols'" + selected(f_rules == "cols") + ">" + i18n["Rules will appear between columns only"] + "</option> \249 <option value='all'" + selected(f_rules == "all") + ">" + i18n["Rules will appear between all rows and columns"] + "</option> \250 </select> \251 </td> \252 </tr> \253 </table> \254 </fieldset> \255 </td> \256 </tr> \257 <tr> \258 <td id='--HA-style'></td> \259 </tr> \260</table> \261";262 var st_prop = TableOperations.createStyleFieldset(dialog.doc, dialog.editor, table);263 var p = dialog.doc.getElementById("--HA-style");264 p.appendChild(st_prop);265 var st_layout = TableOperations.createStyleLayoutFieldset(dialog.doc, dialog.editor, table);266 p = dialog.doc.getElementById("--HA-layout");267 p.appendChild(st_layout);268 dialog.modal = true;269 dialog.addButtons("ok", "cancel");270 dialog.showAtElement(dialog.editor._iframe, "c");271 });272};273274// this function requires the file PopupDiv/PopupWin to be loaded from browser275TableOperations.prototype.dialogRowCellProperties = function(cell) {276 var i18n = TableOperations.I18N;277 // retrieve existing values278 var element = this.getClosest(cell ? "td" : "tr");279 var table = this.getClosest("table");280 // this.editor.selectNodeContents(element);281 // this.editor.updateToolbar();282283 var dialog = new PopupWin(this.editor, i18n[cell ? "Cell Properties" : "Row Properties"], function(dialog, params) {284 TableOperations.processStyle(params, element);285 for (var i in params) {286 var val = params[i];287 switch (i) {288 case "f_align":289 element.align = val;290 break;291 case "f_char":292 element.ch = val;293 break;294 case "f_valign":295 element.vAlign = val;296 break;297 }298 }299 // various workarounds to refresh the table display (Gecko,300 // what's going on?! do not disappoint me!)301 dialog.editor.forceRedraw();302 dialog.editor.focusEditor();303 dialog.editor.updateToolbar();304 var save_collapse = table.style.borderCollapse;305 table.style.borderCollapse = "collapse";306 table.style.borderCollapse = "separate";307 table.style.borderCollapse = save_collapse;308 },309310 // this function gets called when the dialog needs to be initialized311 function (dialog) {312313 var f_align = element.align;314 var f_valign = element.vAlign;315 var f_char = element.ch;316317 function selected(val) {318 return val ? " selected" : "";319 };320321 // dialog contents322 dialog.content.style.width = "400px";323 dialog.content.innerHTML = " \324<div class='title'\325 style='background: url(" + dialog.baseURL + dialog.editor.imgURL(cell ? "cell-prop.gif" : "row-prop.gif", "TableOperations") + ") #fff 98% 50% no-repeat'>" + i18n[cell ? "Cell Properties" : "Row Properties"] + "</div> \326<table style='width:100%'> \327 <tr> \328 <td id='--HA-layout'> \329"+// <fieldset><legend>" + i18n["Layout"] + "</legend> \330// <table style='width:100%'> \331// <tr> \332// <td class='label'>" + i18n["Align"] + ":</td> \333// <td> \334// <select name='f_align'> \335// <option value='left'" + selected(f_align == "left") + ">" + i18n["Left"] + "</option> \336// <option value='center'" + selected(f_align == "center") + ">" + i18n["Center"] + "</option> \337// <option value='right'" + selected(f_align == "right") + ">" + i18n["Right"] + "</option> \338// <option value='char'" + selected(f_align == "char") + ">" + i18n["Char"] + "</option> \339// </select> \340// &nbsp;&nbsp;" + i18n["Char"] + ": \341// <input type='text' style='font-family: monospace; text-align: center' name='f_char' size='1' value='" + f_char + "' /> \342// </td> \343// </tr><tr> \344// <td class='label'>" + i18n["Vertical align"] + ":</td> \345// <td> \346// <select name='f_valign'> \347// <option value='top'" + selected(f_valign == "top") + ">" + i18n["Top"] + "</option> \348// <option value='middle'" + selected(f_valign == "middle") + ">" + i18n["Middle"] + "</option> \349// <option value='bottom'" + selected(f_valign == "bottom") + ">" + i18n["Bottom"] + "</option> \350// <option value='baseline'" + selected(f_valign == "baseline") + ">" + i18n["Baseline"] + "</option> \351// </select> \352// </td> \353// </tr> \354// </table> \355// </fieldset> \356" </td> \357 </tr> \358 <tr> \359 <td id='--HA-style'></td> \360 </tr> \361</table> \362";363 var st_prop = TableOperations.createStyleFieldset(dialog.doc, dialog.editor, element);364 var p = dialog.doc.getElementById("--HA-style");365 p.appendChild(st_prop);366 var st_layout = TableOperations.createStyleLayoutFieldset(dialog.doc, dialog.editor, element);367 p = dialog.doc.getElementById("--HA-layout");368 p.appendChild(st_layout);369 dialog.modal = true;370 dialog.addButtons("ok", "cancel");371 dialog.showAtElement(dialog.editor._iframe, "c");372 });373};374375// this function gets called when some button from the TableOperations toolbar376// was pressed.377TableOperations.prototype.buttonPress = function(editor, button_id) {378 this.editor = editor;379 var mozbr = HTMLArea.is_gecko ? "<br />" : "";380 var i18n = TableOperations.I18N;381382 // helper function that clears the content in a table row383 function clearRow(tr) {384 var tds = tr.getElementsByTagName("td");385 for (var i = tds.length; --i >= 0;) {386 var td = tds[i];387 td.rowSpan = 1;388 td.innerHTML = mozbr;389 }390 };391392 function splitRow(td) {393 var n = parseInt("" + td.rowSpan);394 var nc = parseInt("" + td.colSpan);395 td.rowSpan = 1;396 tr = td.parentNode;397 var itr = tr.rowIndex;398 var trs = tr.parentNode.rows;399 var index = td.cellIndex;400 while (--n > 0) {401 tr = trs[++itr];402 var otd = editor._doc.createElement("td");403 otd.colSpan = td.colSpan;404 otd.innerHTML = mozbr;405 tr.insertBefore(otd, tr.cells[index]);406 }407 editor.forceRedraw();408 editor.updateToolbar();409 };410411 function splitCol(td) {412 var nc = parseInt("" + td.colSpan);413 td.colSpan = 1;414 tr = td.parentNode;415 var ref = td.nextSibling;416 while (--nc > 0) {417 var otd = editor._doc.createElement("td");418 otd.rowSpan = td.rowSpan;419 otd.innerHTML = mozbr;420 tr.insertBefore(otd, ref);421 }422 editor.forceRedraw();423 editor.updateToolbar();424 };425426 function splitCell(td) {427 var nc = parseInt("" + td.colSpan);428 splitCol(td);429 var items = td.parentNode.cells;430 var index = td.cellIndex;431 while (nc-- > 0) {432 splitRow(items[index++]);433 }434 };435436 function selectNextNode(el) {437 var node = el.nextSibling;438 while (node && node.nodeType != 1) {439 node = node.nextSibling;440 }441 if (!node) {442 node = el.previousSibling;443 while (node && node.nodeType != 1) {444 node = node.previousSibling;445 }446 }447 if (!node) {448 node = el.parentNode;449 }450 editor.selectNodeContents(node);451 };452453 switch (button_id) {454 // ROWS455456 case "TO-row-insert-above":457 case "TO-row-insert-under":458 var tr = this.getClosest("tr");459 if (!tr) {460 break;461 }462 var otr = tr.cloneNode(true);463 clearRow(otr);464 tr.parentNode.insertBefore(otr, /under/.test(button_id) ? tr.nextSibling : tr);465 editor.forceRedraw();466 editor.focusEditor();467 break;468 case "TO-row-delete":469 var tr = this.getClosest("tr");470 if (!tr) {471 break;472 }473 var par = tr.parentNode;474 if (par.rows.length == 1) {475 alert(i18n["not-del-last-row"]);476 break;477 }478 // set the caret first to a position that doesn't479 // disappear.480 selectNextNode(tr);481 par.removeChild(tr);482 editor.forceRedraw();483 editor.focusEditor();484 editor.updateToolbar();485 break;486 case "TO-row-split":487 var td = this.getClosest("td");488 if (!td) {489 break;490 }491 splitRow(td);492 break;493494 // COLUMNS495496 case "TO-col-insert-before":497 case "TO-col-insert-after":498 var td = this.getClosest("td");499 if (!td) {500 break;501 }502 var rows = td.parentNode.parentNode.rows;503 var index = td.cellIndex;504 for (var i = rows.length; --i >= 0;) {505 var tr = rows[i];506 var ref = tr.cells[index + (/after/.test(button_id) ? 1 : 0)];507 var otd = editor._doc.createElement("td");508 otd.innerHTML = mozbr;509 tr.insertBefore(otd, ref);510 }511 editor.focusEditor();512 break;513 case "TO-col-split":514 var td = this.getClosest("td");515 if (!td) {516 break;517 }518 splitCol(td);519 break;520 case "TO-col-delete":521 var td = this.getClosest("td");522 if (!td) {523 break;524 }525 var index = td.cellIndex;526 if (td.parentNode.cells.length == 1) {527 alert(i18n["not-del-last-col"]);528 break;529 }530 // set the caret first to a position that doesn't disappear531 selectNextNode(td);532 var rows = td.parentNode.parentNode.rows;533 for (var i = rows.length; --i >= 0;) {534 var tr = rows[i];535 tr.removeChild(tr.cells[index]);536 }537 editor.forceRedraw();538 editor.focusEditor();539 editor.updateToolbar();540 break;541542 // CELLS543544 case "TO-cell-split":545 var td = this.getClosest("td");546 if (!td) {547 break;548 }549 splitCell(td);550 break;551 case "TO-cell-insert-before":552 case "TO-cell-insert-after":553 var td = this.getClosest("td");554 if (!td) {555 break;556 }557 var tr = td.parentNode;558 var otd = editor._doc.createElement("td");559 otd.innerHTML = mozbr;560 tr.insertBefore(otd, /after/.test(button_id) ? td.nextSibling : td);561 editor.forceRedraw();562 editor.focusEditor();563 break;564 case "TO-cell-delete":565 var td = this.getClosest("td");566 if (!td) {567 break;568 }569 if (td.parentNode.cells.length == 1) {570 alert(i18n["not-del-last-cell"]);571 break;572 }573 // set the caret first to a position that doesn't disappear574 selectNextNode(td);575 td.parentNode.removeChild(td);576 editor.forceRedraw();577 editor.updateToolbar();578 break;579 case "TO-cell-merge":580 // !! FIXME: Mozilla specific !!581 var sel = editor._getSelection();582 var range, i = 0;583 var rows = [];584 var row = null;585 var cells = null;586 if (!HTMLArea.is_ie) {587 try {588 while (range = sel.getRangeAt(i++)) {589 var td = range.startContainer.childNodes[range.startOffset];590 if (td.parentNode != row) {591 row = td.parentNode;592 (cells) && rows.push(cells);593 cells = [];594 }595 cells.push(td);596 }597 } catch(e) {/* finished walking through selection */}598 rows.push(cells);599 } else {600 // Internet Explorer "browser"601 var td = this.getClosest("td");602 if (!td) {603 alert(i18n["Please click into some cell"]);604 break;605 }606 var tr = td.parentElement;607 var no_cols = prompt(i18n["How many columns would you like to merge?"], 2);608 if (!no_cols) {609 // cancelled610 break;611 }612 var no_rows = prompt(i18n["How many rows would you like to merge?"], 2);613 if (!no_rows) {614 // cancelled615 break;616 }617 var cell_index = td.cellIndex;618 while (no_rows-- > 0) {619 td = tr.cells[cell_index];620 cells = [td];621 for (var i = 1; i < no_cols; ++i) {622 td = td.nextSibling;623 if (!td) {624 break;625 }626 cells.push(td);627 }628 rows.push(cells);629 tr = tr.nextSibling;630 if (!tr) {631 break;632 }633 }634 }635 var HTML = "";636 for (i = 0; i < rows.length; ++i) {637 // i && (HTML += "<br />");638 var cells = rows[i];639 for (var j = 0; j < cells.length; ++j) {640 // j && (HTML += "&nbsp;");641 var cell = cells[j];642 HTML += cell.innerHTML;643 (i || j) && (cell.parentNode.removeChild(cell));644 }645 }646 var td = rows[0][0];647 td.innerHTML = HTML;648 td.rowSpan = rows.length;649 td.colSpan = rows[0].length;650 editor.selectNodeContents(td);651 editor.forceRedraw();652 editor.focusEditor();653 break;654655 // PROPERTIES656657 case "TO-table-prop":658 this.dialogTableProperties();659 break;660661 case "TO-row-prop":662 this.dialogRowCellProperties(false);663 break;664665 case "TO-cell-prop":666 this.dialogRowCellProperties(true);667 break;668669 default:670 alert("Button [" + button_id + "] not yet implemented");671 }672};673674// the list of buttons added by this plugin675TableOperations.btnList = [676 // table properties button677 ["table-prop", "table"],678 null, // separator679680 // ROWS681 ["row-prop", "tr"],682 ["row-insert-above", "tr"],683 ["row-insert-under", "tr"],684 ["row-delete", "tr"],685 ["row-split", "td[rowSpan!=1]"],686 null,687688 // COLS689 ["col-insert-before", "td"],690 ["col-insert-after", "td"],691 ["col-delete", "td"],692 ["col-split", "td[colSpan!=1]"],693 null,694695 // CELLS696 ["cell-prop", "td"],697 ["cell-insert-before", "td"],698 ["cell-insert-after", "td"],699 ["cell-delete", "td"],700 ["cell-merge", "tr"],701 ["cell-split", "td[colSpan!=1,rowSpan!=1]"]702 ];703704705706//// GENERIC CODE [style of any element; this should be moved into a separate707//// file as it'll be very useful]708//// BEGIN GENERIC CODE -----------------------------------------------------709710TableOperations.getLength = function(value) {711 var len = parseInt(value);712 if (isNaN(len)) {713 len = "";714 }715 return len;716};717718// Applies the style found in "params" to the given element.719TableOperations.processStyle = function(params, element) {720 var style = element.style;721 for (var i in params) {722 var val = params[i];723 switch (i) {724 case "f_st_backgroundColor":725 style.backgroundColor = val;726 break;727 case "f_st_color":728 style.color = val;729 break;730 case "f_st_backgroundImage":731 if (/\S/.test(val)) {732 style.backgroundImage = "url(" + val + ")";733 } else {734 style.backgroundImage = "none";735 }736 break;737 case "f_st_borderWidth":738 style.borderWidth = val;739 break;740 case "f_st_borderStyle":741 style.borderStyle = val;742 break;743 case "f_st_borderColor":744 style.borderColor = val;745 break;746 case "f_st_borderCollapse":747 style.borderCollapse = val ? "collapse" : "";748 break;749 case "f_st_width":750 if (/\S/.test(val)) {751 style.width = val + params["f_st_widthUnit"];752 } else {753 style.width = "";754 }755 break;756 case "f_st_height":757 if (/\S/.test(val)) {758 style.height = val + params["f_st_heightUnit"];759 } else {760 style.height = "";761 }762 break;763 case "f_st_textAlign":764 if (val == "char") {765 var ch = params["f_st_textAlignChar"];766 if (ch == '"') {767 ch = '\\"';768 }769 style.textAlign = '"' + ch + '"';770 } else {771 style.textAlign = val;772 }773 break;774 case "f_st_verticalAlign":775 style.verticalAlign = val;776 break;777 case "f_st_float":778 style.cssFloat = val;779 break;780// case "f_st_margin":781// style.margin = val + "px";782// break;783// case "f_st_padding":784// style.padding = val + "px";785// break;786 }787 }788};789790// Returns an HTML element for a widget that allows color selection. That is,791// a button that contains the given color, if any, and when pressed will popup792// the sooner-or-later-to-be-rewritten select_color.html dialog allowing user793// to select some color. If a color is selected, an input field with the name794// "f_st_"+name will be updated with the color value in #123456 format.795TableOperations.createColorButton = function(doc, editor, color, name) {796 if (!color) {797 color = "";798 } else if (!/#/.test(color)) {799 color = HTMLArea._colorToRgb(color);800 }801802 var df = doc.createElement("span");803 var field = doc.createElement("input");804 field.type = "hidden";805 df.appendChild(field);806 field.name = "f_st_" + name;807 field.value = color;808 var button = doc.createElement("span");809 button.className = "buttonColor";810 df.appendChild(button);811 var span = doc.createElement("span");812 span.className = "chooser";813 // span.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";814 span.style.backgroundColor = color;815 button.appendChild(span);816 button.onmouseover = function() { if (!this.disabled) { this.className += " buttonColor-hilite"; }};817 button.onmouseout = function() { if (!this.disabled) { this.className = "buttonColor"; }};818 span.onclick = function() {819 if (this.parentNode.disabled) {820 return false;821 }822 editor._popupDialog("select_color.html", function(color) {823 if (color) {824 span.style.backgroundColor = "#" + color;825 field.value = "#" + color;826 }827 }, color);828 };829 var span2 = doc.createElement("span");830 span2.innerHTML = "&#x00d7;";831 span2.className = "nocolor";832 span2.title = TableOperations.I18N["Unset color"];833 button.appendChild(span2);834 span2.onmouseover = function() { if (!this.parentNode.disabled) { this.className += " nocolor-hilite"; }};835 span2.onmouseout = function() { if (!this.parentNode.disabled) { this.className = "nocolor"; }};836 span2.onclick = function() {837 span.style.backgroundColor = "";838 field.value = "";839 };840 return df;841};842843TableOperations.createStyleLayoutFieldset = function(doc, editor, el) {844 var i18n = TableOperations.I18N;845 var fieldset = doc.createElement("fieldset");846 var legend = doc.createElement("legend");847 fieldset.appendChild(legend);848 legend.innerHTML = i18n["Layout"];849 var table = doc.createElement("table");850 fieldset.appendChild(table);851 table.style.width = "100%";852 var tbody = doc.createElement("tbody");853 table.appendChild(tbody);854855 var tagname = el.tagName.toLowerCase();856 var tr, td, input, select, option, options, i;857858 if (tagname != "td" && tagname != "tr" && tagname != "th") {859 tr = doc.createElement("tr");860 tbody.appendChild(tr);861 td = doc.createElement("td");862 td.className = "label";863 tr.appendChild(td);864 td.innerHTML = i18n["Float"] + ":";865 td = doc.createElement("td");866 tr.appendChild(td);867 select = doc.createElement("select");868 td.appendChild(select);869 select.name = "f_st_float";870 options = ["None", "Left", "Right"];871 for (i in options) {872 var Val = options[i];873 var val = options[i].toLowerCase();874 option = doc.createElement("option");875 option.innerHTML = i18n[Val];876 option.value = val;877 option.selected = (("" + el.style.cssFloat).toLowerCase() == val);878 select.appendChild(option);879 }880 }881882 tr = doc.createElement("tr");883 tbody.appendChild(tr);884 td = doc.createElement("td");885 td.className = "label";886 tr.appendChild(td);887 td.innerHTML = i18n["Width"] + ":";888 td = doc.createElement("td");889 tr.appendChild(td);890 input = doc.createElement("input");891 input.type = "text";892 input.value = TableOperations.getLength(el.style.width);893 input.size = "5";894 input.name = "f_st_width";895 input.style.marginRight = "0.5em";896 td.appendChild(input);897 select = doc.createElement("select");898 select.name = "f_st_widthUnit";899 option = doc.createElement("option");900 option.innerHTML = i18n["percent"];901 option.value = "%";902 option.selected = /%/.test(el.style.width);903 select.appendChild(option);904 option = doc.createElement("option");905 option.innerHTML = i18n["pixels"];906 option.value = "px";907 option.selected = /px/.test(el.style.width);908 select.appendChild(option);909 td.appendChild(select);910911 select.style.marginRight = "0.5em";912 td.appendChild(doc.createTextNode(i18n["Text align"] + ":"));913 select = doc.createElement("select");914 select.style.marginLeft = select.style.marginRight = "0.5em";915 td.appendChild(select);916 select.name = "f_st_textAlign";917 options = ["Left", "Center", "Right", "Justify"];918 if (tagname == "td") {919 options.push("Char");920 }921 input = doc.createElement("input");922 input.name = "f_st_textAlignChar";923 input.size = "1";924 input.style.fontFamily = "monospace";925 td.appendChild(input);926 for (i in options) {927 var Val = options[i];928 var val = Val.toLowerCase();929 option = doc.createElement("option");930 option.value = val;931 option.innerHTML = i18n[Val];932 option.selected = (el.style.textAlign.toLowerCase() == val);933 select.appendChild(option);934 }935 function setCharVisibility(value) {936 input.style.visibility = value ? "visible" : "hidden";937 if (value) {938 input.focus();939 input.select();940 }941 };942 select.onchange = function() { setCharVisibility(this.value == "char"); };943 setCharVisibility(select.value == "char");944945 tr = doc.createElement("tr");946 tbody.appendChild(tr);947 td = doc.createElement("td");948 td.className = "label";949 tr.appendChild(td);950 td.innerHTML = i18n["Height"] + ":";951 td = doc.createElement("td");952 tr.appendChild(td);953 input = doc.createElement("input");954 input.type = "text";955 input.value = TableOperations.getLength(el.style.height);956 input.size = "5";957 input.name = "f_st_height";958 input.style.marginRight = "0.5em";959 td.appendChild(input);960 select = doc.createElement("select");961 select.name = "f_st_heightUnit";962 option = doc.createElement("option");963 option.innerHTML = i18n["percent"];964 option.value = "%";965 option.selected = /%/.test(el.style.height);966 select.appendChild(option);967 option = doc.createElement("option");968 option.innerHTML = i18n["pixels"];969 option.value = "px";970 option.selected = /px/.test(el.style.height);971 select.appendChild(option);972 td.appendChild(select);973974 select.style.marginRight = "0.5em";975 td.appendChild(doc.createTextNode(i18n["Vertical align"] + ":"));976 select = doc.createElement("select");977 select.name = "f_st_verticalAlign";978 select.style.marginLeft = "0.5em";979 td.appendChild(select);980 options = ["Top", "Middle", "Bottom", "Baseline"];981 for (i in options) {982 var Val = options[i];983 var val = Val.toLowerCase();984 option = doc.createElement("option");985 option.value = val;986 option.innerHTML = i18n[Val];987 option.selected = (el.style.verticalAlign.toLowerCase() == val);988 select.appendChild(option);989 }990991 return fieldset;992};993994// Returns an HTML element containing the style attributes for the given995// element. This can be easily embedded into any dialog; the functionality is996// also provided.997TableOperations.createStyleFieldset = function(doc, editor, el) {998 var i18n = TableOperations.I18N;999 var fieldset = doc.createElement("fieldset");1000 var legend = doc.createElement("legend");1001 fieldset.appendChild(legend);1002 legend.innerHTML = i18n["CSS Style"];1003 var table = doc.createElement("table");1004 fieldset.appendChild(table);1005 table.style.width = "100%";1006 var tbody = doc.createElement("tbody");1007 table.appendChild(tbody);10081009 var tr, td, input, select, option, options, i;10101011 tr = doc.createElement("tr");1012 tbody.appendChild(tr);1013 td = doc.createElement("td");1014 tr.appendChild(td);1015 td.className = "label";1016 td.innerHTML = i18n["Background"] + ":";1017 td = doc.createElement("td");1018 tr.appendChild(td);1019 var df = TableOperations.createColorButton(doc, editor, el.style.backgroundColor, "backgroundColor");1020 df.firstChild.nextSibling.style.marginRight = "0.5em";1021 td.appendChild(df);1022 td.appendChild(doc.createTextNode(i18n["Image URL"] + ": "));1023 input = doc.createElement("input");1024 input.type = "text";1025 input.name = "f_st_backgroundImage";1026 if (el.style.backgroundImage.match(/url\(\s*(.*?)\s*\)/)) {1027 input.value = RegExp.$1;1028 }1029 // input.style.width = "100%";1030 td.appendChild(input);10311032 tr = doc.createElement("tr");1033 tbody.appendChild(tr);1034 td = doc.createElement("td");1035 tr.appendChild(td);1036 td.className = "label";1037 td.innerHTML = i18n["FG Color"] + ":";1038 td = doc.createElement("td");1039 tr.appendChild(td);1040 td.appendChild(TableOperations.createColorButton(doc, editor, el.style.color, "color"));10411042 // for better alignment we include an invisible field.1043 input = doc.createElement("input");1044 input.style.visibility = "hidden";1045 input.type = "text";1046 td.appendChild(input);10471048 tr = doc.createElement("tr");1049 tbody.appendChild(tr);1050 td = doc.createElement("td");1051 tr.appendChild(td);1052 td.className = "label";1053 td.innerHTML = i18n["Border"] + ":";1054 td = doc.createElement("td");1055 tr.appendChild(td);10561057 var colorButton = TableOperations.createColorButton(doc, editor, el.style.borderColor, "borderColor");1058 var btn = colorButton.firstChild.nextSibling;1059 td.appendChild(colorButton);1060 // borderFields.push(btn);1061 btn.style.marginRight = "0.5em";10621063 select = doc.createElement("select");1064 var borderFields = [];1065 td.appendChild(select);1066 select.name = "f_st_borderStyle";1067 options = ["none", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"];1068 var currentBorderStyle = el.style.borderStyle;1069 // Gecko reports "solid solid solid solid" for "border-style: solid".1070 // That is, "top right bottom left" -- we only consider the first1071 // value.1072 (currentBorderStyle.match(/([^\s]*)\s/)) && (currentBorderStyle = RegExp.$1);1073 for (i in options) {1074 var val = options[i];1075 option = doc.createElement("option");1076 option.value = val;1077 option.innerHTML = val;1078 (val == currentBorderStyle) && (option.selected = true);1079 select.appendChild(option);1080 }1081 select.style.marginRight = "0.5em";1082 function setBorderFieldsStatus(value) {1083 for (i in borderFields) {1084 var el = borderFields[i];1085 el.style.visibility = value ? "hidden" : "visible";1086 if (!value && (el.tagName.toLowerCase() == "input")) {1087 el.focus();1088 el.select();1089 }1090 }1091 };1092 select.onchange = function() { setBorderFieldsStatus(this.value == "none"); };10931094 input = doc.createElement("input");1095 borderFields.push(input);1096 input.type = "text";1097 input.name = "f_st_borderWidth";1098 input.value = TableOperations.getLength(el.style.borderWidth);1099 input.size = "5";1100 td.appendChild(input);1101 input.style.marginRight = "0.5em";1102 var span = doc.createElement("span");1103 span.innerHTML = i18n["pixels"];1104 td.appendChild(span);1105 borderFields.push(span);11061107 setBorderFieldsStatus(select.value == "none");11081109 if (el.tagName.toLowerCase() == "table") {1110 // the border-collapse style is only for tables1111 tr = doc.createElement("tr");1112 tbody.appendChild(tr);1113 td = doc.createElement("td");1114 td.className = "label";1115 tr.appendChild(td);1116 input = doc.createElement("input");1117 input.type = "checkbox";1118 input.name = "f_st_borderCollapse";1119 input.id = "f_st_borderCollapse";1120 var val = (/collapse/i.test(el.style.borderCollapse));1121 input.checked = val ? 1 : 0;1122 td.appendChild(input);11231124 td = doc.createElement("td");1125 tr.appendChild(td);1126 var label = doc.createElement("label");1127 label.htmlFor = "f_st_borderCollapse";1128 label.innerHTML = i18n["Collapsed borders"];1129 td.appendChild(label);1130 }11311132// tr = doc.createElement("tr");1133// tbody.appendChild(tr);1134// td = doc.createElement("td");1135// td.className = "label";1136// tr.appendChild(td);1137// td.innerHTML = i18n["Margin"] + ":";1138// td = doc.createElement("td");1139// tr.appendChild(td);1140// input = doc.createElement("input");1141// input.type = "text";1142// input.size = "5";1143// input.name = "f_st_margin";1144// td.appendChild(input);1145// input.style.marginRight = "0.5em";1146// td.appendChild(doc.createTextNode(i18n["Padding"] + ":"));11471148// input = doc.createElement("input");1149// input.type = "text";1150// input.size = "5";1151// input.name = "f_st_padding";1152// td.appendChild(input);1153// input.style.marginLeft = "0.5em";1154// input.style.marginRight = "0.5em";1155// td.appendChild(doc.createTextNode(i18n["pixels"]));11561157 return fieldset;1158};1159 ...

Full Screen

Full Screen

InlineStyler.js

Source:InlineStyler.js Github

copy

Full Screen

...126 var self = this;127 var editor = this.editor;128 var doc = this.doc;129 var el = this.element;130 var fieldset = doc.createElement("fieldset");131 var legend = doc.createElement("legend");132 fieldset.appendChild(legend);133 legend.innerHTML = Xinha._lc("Layout", "TableOperations");134 var table = doc.createElement("table");135 fieldset.appendChild(table);136 table.style.width = "100%";137 var tbody = doc.createElement("tbody");138 table.appendChild(tbody);139 140 var tagname = el.tagName.toLowerCase();141 var tr, td, input, select, option, options, i;142 143 if (tagname != "td" && tagname != "tr" && tagname != "th") 144 {145 tr = doc.createElement("tr");146 tbody.appendChild(tr);147 td = doc.createElement("td");148 td.className = "label";149 tr.appendChild(td);150 td.innerHTML = Xinha._lc("Float", "TableOperations") + ":";151 td = doc.createElement("td");152 tr.appendChild(td);153 select = doc.createElement("select");154 select.name = this.dialog.createId("float");155 td.appendChild(select);156 this.inputs.styles['float'] = select;157 158 options = ["None", "Left", "Right"];159 for (var i = 0; i < options.length; ++i) 160 {161 var Val = options[i];162 var val = options[i].toLowerCase();163 option = doc.createElement("option");164 option.innerHTML = Xinha._lc(Val, "TableOperations");165 option.value = val;166 if (Xinha.is_ie) {167 option.selected = (("" + el.style.styleFloat).toLowerCase() == val);168 }169 else {170 option.selected = (("" + el.style.cssFloat).toLowerCase() == val);171 }172 select.appendChild(option);173 }174 }175 176 tr = doc.createElement("tr");177 tbody.appendChild(tr);178 td = doc.createElement("td");179 td.className = "label";180 tr.appendChild(td);181 td.innerHTML = Xinha._lc("Width", "TableOperations") + ":";182 td = doc.createElement("td");183 tr.appendChild(td);184 input = doc.createElement("input");185 input.name = this.dialog.createId("width");186 input.type = "text";187 input.value = Xinha.InlineStyler.getLength(el.style.width);188 input.size = "5";189 this.inputs.styles['width'] = input;190 input.style.marginRight = "0.5em";191 td.appendChild(input);192 select = doc.createElement("select");193 select.name = this.dialog.createId("widthUnit");194 this.inputs.aux['widthUnit'] = select;195 option = doc.createElement("option");196 option.innerHTML = Xinha._lc("percent", "TableOperations");197 option.value = "%";198 option.selected = /%/.test(el.style.width);199 select.appendChild(option);200 option = doc.createElement("option");201 option.innerHTML = Xinha._lc("pixels", "TableOperations");202 option.value = "px";203 option.selected = /px/.test(el.style.width);204 select.appendChild(option);205 td.appendChild(select);206 207 select.style.marginRight = "0.5em";208 td.appendChild(doc.createTextNode(Xinha._lc("Text align", "TableOperations") + ":"));209 select = doc.createElement("select");210 select.name = this.dialog.createId("textAlign");211 select.style.marginLeft = select.style.marginRight = "0.5em";212 td.appendChild(select);213 this.inputs.styles['textAlign'] = select;214 options = ["Left", "Center", "Right", "Justify", "-"];215 if (tagname == "td") 216 {217 options.push("Char");218 }219 input = doc.createElement("input");220 this.inputs.aux['textAlignChar'] = input;221 input.name= this.dialog.createId("textAlignChar");222 input.size = "1";223 input.style.fontFamily = "monospace";224 td.appendChild(input);225 226 for (var i = 0; i < options.length; ++i) 227 {228 var Val = options[i];229 var val = Val.toLowerCase();230 option = doc.createElement("option");231 option.value = val;232 option.innerHTML = Xinha._lc(Val, "TableOperations");233 option.selected = ((el.style.textAlign.toLowerCase() == val) || (el.style.textAlign == "" && Val == "-"));234 select.appendChild(option);235 }236 var textAlignCharInput = input;237 function setCharVisibility(value)238 {239 textAlignCharInput.style.visibility = value ? "visible" : "hidden";240 if (value) 241 {242 textAlignCharInput.focus();243 textAlignCharInput.select();244 }245 }246 select.onchange = function()247 {248 setCharVisibility(this.value == "char");249 };250 setCharVisibility(select.value == "char");251 252 tr = doc.createElement("tr");253 tbody.appendChild(tr);254 td = doc.createElement("td");255 td.className = "label";256 tr.appendChild(td);257 td.innerHTML = Xinha._lc("Height", "TableOperations") + ":";258 td = doc.createElement("td");259 tr.appendChild(td);260 input = doc.createElement("input");261 input.name = this.dialog.createId("height");262 input.type = "text";263 input.value = Xinha.InlineStyler.getLength(el.style.height);264 input.size = "5";265 this.inputs.styles['height'] = input;266 input.style.marginRight = "0.5em";267 td.appendChild(input);268 select = doc.createElement("select");269 select.name = this.dialog.createId("heightUnit");270 this.inputs.aux['heightUnit'] = select;271 option = doc.createElement("option");272 option.innerHTML = Xinha._lc("percent", "TableOperations");273 option.value = "%";274 option.selected = /%/.test(el.style.height);275 select.appendChild(option);276 option = doc.createElement("option");277 option.innerHTML = Xinha._lc("pixels", "TableOperations");278 option.value = "px";279 option.selected = /px/.test(el.style.height);280 select.appendChild(option);281 td.appendChild(select);282 283 select.style.marginRight = "0.5em";284 td.appendChild(doc.createTextNode(Xinha._lc("Vertical align", "TableOperations") + ":"));285 select = doc.createElement("select");286 select.name = this.dialog.createId("verticalAlign");287 this.inputs.styles['verticalAlign'] = select;288 select.style.marginLeft = "0.5em";289 td.appendChild(select);290 options = ["Top", "Middle", "Bottom", "Baseline", "-"];291 for (var i = 0; i < options.length; ++i) 292 {293 var Val = options[i];294 var val = Val.toLowerCase();295 option = doc.createElement("option");296 option.value = val;297 option.innerHTML = Xinha._lc(Val, "TableOperations");298 option.selected = ((el.style.verticalAlign.toLowerCase() == val) || (el.style.verticalAlign == "" && Val == "-"));299 select.appendChild(option);300 }301 302 return fieldset;303};304// Returns an HTML element containing the style attributes for the given305// element. This can be easily embedded into any dialog; the functionality is306// also provided.307Xinha.InlineStyler.prototype.createStyleFieldset = function()308{309 var editor = this.editor;310 var doc = this.doc;311 var el = this.element;312 313 var fieldset = doc.createElement("fieldset");314 var legend = doc.createElement("legend");315 fieldset.appendChild(legend);316 legend.innerHTML = Xinha._lc("CSS Style", "TableOperations");317 var table = doc.createElement("table");318 fieldset.appendChild(table);319 table.style.width = "100%";320 var tbody = doc.createElement("tbody");321 table.appendChild(tbody);322 323 var tr, td, input, select, option, options, i;324 325 tr = doc.createElement("tr");326 tbody.appendChild(tr);327 td = doc.createElement("td");328 tr.appendChild(td);329 td.className = "label";330 td.innerHTML = Xinha._lc("Background", "TableOperations") + ":";331 td = doc.createElement("td");332 tr.appendChild(td);333 input = doc.createElement("input");334 input.name = this.dialog.createId("backgroundColor");335 input.value = Xinha._colorToRgb( el.style.backgroundColor );336 input.type = "hidden";337 this.inputs.styles['backgroundColor'] = input;338 input.style.marginRight = "0.5em";339 td.appendChild(input);340 new Xinha.colorPicker.InputBinding(input)341 342 td.appendChild(doc.createTextNode(" " + Xinha._lc("Image URL", "TableOperations") + ": "));343 input = doc.createElement("input");344 input.name = this.dialog.createId("backgroundImage");345 input.type = "text";346 this.inputs.styles['backgroundImage'] = input;347 if (el.style.backgroundImage.match(/url\(\s*(.*?)\s*\)/))348 input.value = RegExp.$1;349 // input.style.width = "100%";350 td.appendChild(input);351 352 tr = doc.createElement("tr");353 tbody.appendChild(tr);354 td = doc.createElement("td");355 tr.appendChild(td);356 td.className = "label";357 td.innerHTML = Xinha._lc("FG Color", "TableOperations") + ":";358 td = doc.createElement("td");359 tr.appendChild(td);360 input = doc.createElement("input");361 input.name = this.dialog.createId("color");362 input.value = Xinha._colorToRgb( el.style.color );363 input.type = "hidden";364 this.inputs.styles['color'] = input;365 input.style.marginRight = "0.5em";366 td.appendChild(input);367 new Xinha.colorPicker.InputBinding(input)368 369 // for better alignment we include an invisible field.370 input = doc.createElement("input");371 input.style.visibility = "hidden";372 input.type = "text";373 td.appendChild(input);374 375 tr = doc.createElement("tr");376 tbody.appendChild(tr);377 td = doc.createElement("td");378 tr.appendChild(td);379 td.className = "label";380 td.innerHTML = Xinha._lc("Border", "TableOperations") + ":";381 td = doc.createElement("td");382 tr.appendChild(td);383 input = doc.createElement("input");384 input.name = this.dialog.createId("borderColor");385 input.value = Xinha._colorToRgb( el.style.borderColor );386 input.type = "hidden";387 this.inputs.styles['borderColor'] = input;388 input.style.marginRight = "0.5em";389 td.appendChild(input);390 new Xinha.colorPicker.InputBinding(input)391 392 select = doc.createElement("select");393 select.name = this.dialog.createId("borderStyle");394 var borderFields = [];395 td.appendChild(select);396 this.inputs.styles['borderStyle'] = select;397 options = ["none", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"];398 var currentBorderStyle = el.style.borderStyle;399 // Gecko reports "solid solid solid solid" for "border-style: solid".400 // That is, "top right bottom left" -- we only consider the first401 // value.402 if (currentBorderStyle.match(/([^\s]*)\s/)) currentBorderStyle = RegExp.$1;403 for (var i=0;i<options.length;i++) {404 var val = options[i];405 option = doc.createElement("option");406 option.value = val;407 option.innerHTML = val;408 if (val == currentBorderStyle) option.selected = true;409 select.appendChild(option);410 }411 select.style.marginRight = "0.5em";412 function setBorderFieldsStatus(value)413 {414 for (var i = 0; i < borderFields.length; ++i) 415 {416 var el = borderFields[i];417 el.style.visibility = value ? "hidden" : "visible";418 if (!value && (el.tagName.toLowerCase() == "input")) 419 {420 el.focus();421 el.select();422 }423 }424 }425 select.onchange = function()426 {427 setBorderFieldsStatus(this.value == "none");428 };429 430 input = doc.createElement("input");431 input.name = this.dialog.createId("borderWidth");432 borderFields.push(input);433 input.type = "text";434 this.inputs.styles['borderWidth'] = input;435 input.value = Xinha.InlineStyler.getLength(el.style.borderWidth);436 input.size = "5";437 td.appendChild(input);438 input.style.marginRight = "0.5em";439 var span = doc.createElement("span");440 span.innerHTML = Xinha._lc("pixels", "TableOperations");441 td.appendChild(span);442 borderFields.push(span);443 444 setBorderFieldsStatus(select.value == "none");445 446 if (el.tagName.toLowerCase() == "table") 447 {448 // the border-collapse style is only for tables449 tr = doc.createElement("tr");450 tbody.appendChild(tr);451 td = doc.createElement("td");452 td.className = "label";453 tr.appendChild(td);454 input = doc.createElement("input");455 input.name = this.dialog.createId("borderCollapse");456 input.type = "checkbox";457 input.value = "on";458 this.inputs.styles['borderCollapse'] = input;459 input.id = "f_st_borderCollapse";460 var val = (/collapse/i.test(el.style.borderCollapse));461 input.checked = val ? 1 : 0;462 td.appendChild(input);463 464 td = doc.createElement("td");465 tr.appendChild(td);466 var label = doc.createElement("label");467 label.htmlFor = "f_st_borderCollapse";468 label.innerHTML = Xinha._lc("Collapsed borders", "TableOperations");469 td.appendChild(label);470 }471 472 // tr = doc.createElement("tr");473 // tbody.appendChild(tr);474 // td = doc.createElement("td");475 // td.className = "label";476 // tr.appendChild(td);477 // td.innerHTML = Xinha._lc("Margin", "TableOperations") + ":";478 // td = doc.createElement("td");479 // tr.appendChild(td);480 // input = doc.createElement("input");481 // input.type = "text";482 // input.size = "5";483 // input.name = "f_st_margin";484 // td.appendChild(input);485 // input.style.marginRight = "0.5em";486 // td.appendChild(doc.createTextNode(Xinha._lc("Padding", "TableOperations") + ":"));487 488 // input = doc.createElement("input");489 // input.type = "text";490 // input.size = "5";491 // input.name = "f_st_padding";492 // td.appendChild(input);493 // input.style.marginLeft = "0.5em";494 // input.style.marginRight = "0.5em";495 // td.appendChild(doc.createTextNode(Xinha._lc("pixels", "TableOperations")));496 497 return fieldset;...

Full Screen

Full Screen

wordpress.js

Source:wordpress.js Github

copy

Full Screen

1/*2 * ***** BEGIN LICENSE BLOCK *****3 * Zimbra Collaboration Suite Zimlets4 * Copyright (C) 2007, 2009, 2010 Zimbra, Inc.5 * 6 * The contents of this file are subject to the Zimbra Public License7 * Version 1.3 ("License"); you may not use this file except in8 * compliance with the License. You may obtain a copy of the License at9 * http://www.zimbra.com/license.10 * 11 * Software distributed under the License is distributed on an "AS IS"12 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.13 * ***** END LICENSE BLOCK *****14 */15/**16 * Constructor.17 * 18 */19function WordPress(parent) {20 this.controller = parent;21}22WordPress.prototype.constructor = WordPress;23WordPress.REQUEST_HEADER={"Content-Type":"text/xml"};24WordPress.prototype.getDisplayName = function(){25 return "WordPress";26};27WordPress.prototype.getUsersBlogsXmlDoc = function(user,passwd) {28 var methodCall = AjxXmlDoc.createRoot("methodCall");29 var methodName = AjxXmlDoc.createElement("methodName","blogger.getUsersBlogs");30 var params = AjxXmlDoc.createElement("params");31 methodCall.appendChild(methodName); 32 var param1=this._createParamNode("string","0123456789ABCDEF",false);33 var param2=this._createParamNode("string",user,false);34 var param3=this._createParamNode("string",passwd,false);35 methodCall.appendChild(param1);36 methodCall.appendChild(param2);37 methodCall.appendChild(param3);38 39 return methodCall;40}41WordPress.prototype.getCategoriesXmlDoc = function(blogid,username,password) {42 var methodCall = AjxXmlDoc.createRoot("methodCall");43 var methodName = AjxXmlDoc.createElement("methodName","metaWeblog.getCategories");44 var params = AjxXmlDoc.createElement("params");45 methodCall.appendChild(methodName); 46 var param1=this._createParamNode("string",blogid,false);47 var param2=this._createParamNode("string",username,false);48 var param3=this._createParamNode("string",password,false);49 50 params.appendChild(param1);51 params.appendChild(param2);52 params.appendChild(param3);53 54 methodCall.appendChild(params);55 56 return methodCall;57}58WordPress.prototype.newPostXmlDoc = function(blogid,username,password,title,description,categories) {59 var methodCall = AjxXmlDoc.createRoot("methodCall");60 var methodName = AjxXmlDoc.createElement("methodName","metaWeblog.newPost");61 var params = AjxXmlDoc.createElement("params");62 methodCall.appendChild(methodName); 63 var param1=this._createParamNode("string",blogid,false);64 var param2=this._createParamNode("string",username,false);65 var param3=this._createParamNode("string",password,false);66 var param4 = AjxXmlDoc.createElement("param");67 var value41 = AjxXmlDoc.createElement("value"); 68 var struct = AjxXmlDoc.createElement("struct"); 69 var member1=this._createMemberNode("title","string",title,false);70 var member2=this._createMemberNode("description","string",description,true);71 72 73 struct.appendChild(member1);74 struct.appendChild(member2);75 if(categories && categories.length > 0 ){76 var member3 = this._createCategoryMemberNode(categories);77 struct.appendChild(member3);78 }79 value41.appendChild(struct);80 param4.appendChild(value41);81 var param5=this._createParamNode("boolean","1",false);82 params.appendChild(param1);83 params.appendChild(param2);84 params.appendChild(param3);85 params.appendChild(param4);86 params.appendChild(param5);87 methodCall.appendChild(params);88 89 return methodCall;90};91WordPress.prototype._createParamNode = function(type,value,isCdata) {92 var param=AjxXmlDoc.createElement("param");93 var valueNode=AjxXmlDoc.createElement("value");94 var data=null;95 96 if(!isCdata){97 data = valueNode.getDoc().createTextNode("");98 data.nodeValue=value;99 }else{100 data = valueNode.getDoc().createCDATASection("");101 data.nodeValue=value; 102 }103 var valueNode1=AjxXmlDoc.createElement(type); 104 valueNode1.root.appendChild(data);105 valueNode.appendChild(valueNode1);106 param.appendChild(valueNode);107 return param;108};109WordPress.prototype._createCategoryMemberNode = function(categories)110{111 var member=AjxXmlDoc.createElement("member");112 var name=AjxXmlDoc.createElement("name","categories");113 var value=AjxXmlDoc.createElement("value");114 var array=AjxXmlDoc.createElement("array");115 var data=AjxXmlDoc.createElement("data");116 117 for(var i=0;i<categories.length;i++){118 var value1=AjxXmlDoc.createElement("value");119 var stringnode=AjxXmlDoc.createElement("string",categories[i]);120 value1.appendChild(stringnode);121 data.appendChild(value1);122 }123 124 array.appendChild(data);125 value.appendChild(array);126 member.appendChild(name);127 member.appendChild(value);128 129 return member; 130};131WordPress.prototype._createMemberNode = function(nameValue,type,value,isCdata) {132 var member=AjxXmlDoc.createElement("member");133 134 var name=AjxXmlDoc.createElement("name",nameValue);135 var valueNode=AjxXmlDoc.createElement("value");136 var data=null;137 138 if(!isCdata){139 data = valueNode.getDoc().createTextNode("");140 data.nodeValue=value;141 }else{142 data = valueNode.getDoc().createCDATASection("");143 data.nodeValue=value; 144 }145 var valueNode1=AjxXmlDoc.createElement(type); 146 valueNode1.root.appendChild(data);147 valueNode.appendChild(valueNode1);148 member.appendChild(name);149 member.appendChild(valueNode);150 return member;151};152WordPress.prototype.filterNodes = function(xmlDoc) {153var names = xmlDoc.getElementsByTagName("name");154var result=new Array();155 for(var i=0;i<names.length;i++){156 var node = names[i];157 if(node.nodeName=="name"){158 var name = node.firstChild.nodeValue;159 var typeN=node.nextSibling; 160 if(typeN){161 if(typeN.hasChildNodes()){162 var valueN=typeN.firstChild;163 if(valueN) {164 var value = valueN.firstChild.nodeValue;165 result[name]=value;166 DBG.println(AjxDebug.DBG1,name+"="+value);167 } 168 } 169 }170 } 171 }172return result;173};174WordPress.prototype.handleBlogListResponse = function(result) {175 176 var r = result.text;177 try{ 178 179 var xmlDoc = AjxXmlDoc.createFromXml(r);180 var url,blogid,blogName=null;181 var struct = xmlDoc.getDoc().getElementsByTagName("struct");182 183 var binfo = [];184 185 DBG.println(AjxDebug.DBG1,"struct:"+struct.length);186 187 for(var i=0;i<struct.length;i++)188 {189 var node = struct[i];190 191 var result = this.filterNodes(node); 192 193 var burl = result['url'];194 195 burl = this.getAPIURL(burl); 196 197 binfo.push({blogid:result['blogid'],blogname:result['blogName'],url:burl});198 }199 /*200 var bloginfo = this.filterNodes(xmlDoc,"name");201 DBG.println(AjxDebug.DBG1,"ID:"+bloginfo["blogid"]);202 */203 this.blogInfoHandler.run(binfo);204 205 }catch(ex){206 DBG.println(AjxDebug.DBG1,'unable to post blog :'+ex);207 this.controller.showWarningMsg(Com_Zimbra_Blog.UNABLE_TO_FETCH);208 } 209 210};211WordPress.prototype._handleCategoryResponse = function(result) {212 213 var r = result.text;214 var categories = new Array();215 try{216 var xmlDoc = AjxXmlDoc.createFromXml(r);217 218 var struct = xmlDoc.getDoc().getElementsByTagName("struct");219 220 for(var i=0;i<struct.length;i++)221 {222 var node = struct[i];223 224 var result = this.filterNodes(node); 225 226 categories.push(result['categoryName']);227 }228 229 this.categoryHandler.run(categories); 230 //this.showCategories(categories);231 }catch(ex){232 DBG.println(AjxDebug.DBG1,"unable to post to blog : "+ex);233 this.controller.showWarningMsg(Com_Zimbra_Blog.UNABLE_TO_FETCH_CATEGORY);234 } 235 236 return categories;237};238WordPress.prototype._getBlogList = function(params) {239 params.url = this.getAPIURL(params.url);240 var methodCall = this.getUsersBlogsXmlDoc(params.username,params.password);241 var reqHeader = WordPress.REQUEST_HEADER;242 243 DBG.println(AjxDebug.DBG1,'sending request 2');244 this.blogInfoHandler = params.callback;245 246 this.controller.sendRequest('<?xml version="1.0"?>'+methodCall.getDocXml(), params.url, reqHeader, new AjxCallback(this,this.handleBlogListResponse), false);247};248WordPress.prototype._getCategories = function(params) {249 params.url = this.getAPIURL(params.url);250 var methodCall = this.getCategoriesXmlDoc(params.blogid,params.username,params.password);251 var reqHeader = WordPress.REQUEST_HEADER;252 253 DBG.println(AjxDebug.DBG1,'sending request 2');254 255 this.categoryHandler = params.callback;256 this.controller.sendRequest('<?xml version="1.0"?>'+methodCall.getDocXml(), params.url, reqHeader, new AjxCallback(this,this._handleCategoryResponse), false);257};258WordPress.prototype._newPost = function(params) {259 params.url = this.getAPIURL(params.url);260 var methodCall = this.newPostXmlDoc(params.blogid,params.username,params.password,params.subject,params.body,params.categories);261 DBG.println(AjxDebug.DBG1,'sending request 2');262 263 DBG.dumpObj(methodCall);264 var reqHeader = WordPress.REQUEST_HEADER;265 this.controller.sendRequest('<?xml version="1.0"?>'+methodCall.getDocXml(), params.url , reqHeader, params.callback , false);266};267WordPress.prototype.getAPIURL = function(burl){268 if(burl.indexOf('xmlrpc.php')<0){269 burl = burl + ((burl.charAt(burl.length-1)=='/')?'':'/')+ "xmlrpc.php";270 }271 272 return burl;...

Full Screen

Full Screen

marker-dom-utils.js

Source:marker-dom-utils.js Github

copy

Full Screen

...33 * @return nsIDOMNode34 */35 buildTitle: function (doc, marker) {36 let blueprint = MarkerBlueprintUtils.getBlueprintFor(marker);37 let hbox = doc.createElement("hbox");38 hbox.setAttribute("align", "center");39 let bullet = doc.createElement("hbox");40 bullet.className = `marker-details-bullet marker-color-${blueprint.colorName}`;41 let title = MarkerBlueprintUtils.getMarkerLabel(marker);42 let label = doc.createElement("label");43 label.className = "marker-details-type";44 label.setAttribute("value", title);45 hbox.appendChild(bullet);46 hbox.appendChild(label);47 return hbox;48 },49 /**50 * Builds the label representing the marker's duration.51 *52 * @param document doc53 * @param object marker54 * @return nsIDOMNode55 */56 buildDuration: function (doc, marker) {57 let label = L10N.getStr("marker.field.duration");58 let start = L10N.getFormatStrWithNumbers("timeline.tick", marker.start);59 let end = L10N.getFormatStrWithNumbers("timeline.tick", marker.end);60 let duration = L10N.getFormatStrWithNumbers("timeline.tick",61 marker.end - marker.start);62 let el = this.buildNameValueLabel(doc, label, duration);63 el.classList.add("marker-details-duration");64 el.setAttribute("tooltiptext", `${start} → ${end}`);65 return el;66 },67 /**68 * Builds labels for name:value pairs.69 * E.g. "Start: 100ms", "Duration: 200ms", ...70 *71 * @param document doc72 * @param string field73 * @param string value74 * @return nsIDOMNode75 */76 buildNameValueLabel: function (doc, field, value) {77 let hbox = doc.createElement("hbox");78 hbox.className = "marker-details-labelcontainer";79 let nameLabel = doc.createElement("label");80 nameLabel.className = "plain marker-details-name-label";81 nameLabel.setAttribute("value", field);82 hbox.appendChild(nameLabel);83 let valueLabel = doc.createElement("label");84 valueLabel.className = "plain marker-details-value-label";85 valueLabel.setAttribute("value", value);86 hbox.appendChild(valueLabel);87 return hbox;88 },89 /**90 * Builds a stack trace in an element.91 *92 * @param document doc93 * @param object params94 * An options object with the following members:95 * - string type: string identifier for type of stack ("stack", "startStack"96 or "endStack"97 * - number frameIndex: the index of the topmost stack frame98 * - array frames: array of stack frames99 */100 buildStackTrace: function (doc, { type, frameIndex, frames }) {101 let container = doc.createElement("vbox");102 container.className = "marker-details-stack";103 container.setAttribute("type", type);104 let nameLabel = doc.createElement("label");105 nameLabel.className = "plain marker-details-name-label";106 nameLabel.setAttribute("value", L10N.getStr(`marker.field.${type}`));107 container.appendChild(nameLabel);108 // Workaround for profiles that have looping stack traces. See109 // bug 1246555.110 let wasAsyncParent = false;111 let seen = new Set();112 while (frameIndex > 0) {113 if (seen.has(frameIndex)) {114 break;115 }116 seen.add(frameIndex);117 let frame = frames[frameIndex];118 let url = frame.source;119 let displayName = frame.functionDisplayName;120 let line = frame.line;121 // If the previous frame had an async parent, then the async122 // cause is in this frame and should be displayed.123 if (wasAsyncParent) {124 let asyncStr = L10N.getFormatStr("marker.field.asyncStack", frame.asyncCause);125 let asyncBox = doc.createElement("hbox");126 let asyncLabel = doc.createElement("label");127 asyncLabel.className = "devtools-monospace";128 asyncLabel.setAttribute("value", asyncStr);129 asyncBox.appendChild(asyncLabel);130 container.appendChild(asyncBox);131 wasAsyncParent = false;132 }133 let hbox = doc.createElement("hbox");134 if (displayName) {135 let functionLabel = doc.createElement("label");136 functionLabel.className = "devtools-monospace";137 functionLabel.setAttribute("value", displayName);138 hbox.appendChild(functionLabel);139 }140 if (url) {141 let linkNode = doc.createElement("a");142 linkNode.className = "waterfall-marker-location devtools-source-link";143 linkNode.href = url;144 linkNode.draggable = false;145 linkNode.setAttribute("title", url);146 let urlLabel = doc.createElement("label");147 urlLabel.className = "filename";148 urlLabel.setAttribute("value", getSourceNames(url).short);149 linkNode.appendChild(urlLabel);150 let lineLabel = doc.createElement("label");151 lineLabel.className = "line-number";152 lineLabel.setAttribute("value", `:${line}`);153 linkNode.appendChild(lineLabel);154 hbox.appendChild(linkNode);155 // Clicking here will bubble up to the parent,156 // which handles the view source.157 linkNode.setAttribute("data-action", JSON.stringify({158 url: url,159 line: line,160 action: "view-source"161 }));162 }163 if (!displayName && !url) {164 let unknownLabel = doc.createElement("label");165 unknownLabel.setAttribute("value", L10N.getStr("marker.value.unknownFrame"));166 hbox.appendChild(unknownLabel);167 }168 container.appendChild(hbox);169 if (frame.asyncParent) {170 frameIndex = frame.asyncParent;171 wasAsyncParent = true;172 } else {173 frameIndex = frame.parent;174 }175 }176 return container;177 },178 /**179 * Builds any custom fields specific to the marker.180 *181 * @param document doc182 * @param object marker183 * @param object options184 * @return array<nsIDOMNode>185 */186 buildCustom: function (doc, marker, options) {187 let elements = [];188 if (options.allocations && shouldShowAllocationsTrigger(marker)) {189 let hbox = doc.createElement("hbox");190 hbox.className = "marker-details-customcontainer";191 let label = doc.createElement("label");192 label.className = "custom-button devtools-button";193 label.setAttribute("value", "Show allocation triggers");194 label.setAttribute("type", "show-allocations");195 label.setAttribute("data-action", JSON.stringify({196 endTime: marker.start,197 action: "show-allocations"198 }));199 hbox.appendChild(label);200 elements.push(hbox);201 }202 return elements;203 },204};205/**...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1exports.tests = {2 notfound_getelementsbyclassname : function() {3 var doc = new browser.Document();4 var html = doc.createElement("html");5 doc.appendChild(html);6 var body = doc.createElement("body");7 html.appendChild(body);8 var p = doc.createElement("p");9 p.className = "unknown";10 body.appendChild(p);11 var elements = doc.getElementsByClassName("first-p");12 assertEquals("no results", 0, elements.length);13 },14 basic_getelementsbyclassname : function() {15 var doc = new browser.Document();16 var html = doc.createElement("html");17 doc.appendChild(html);18 var body = doc.createElement("body");19 html.appendChild(body);20 var p = doc.createElement("p");21 p.className = "first-p";22 body.appendChild(p);23 var elements = doc.getElementsByClassName("first-p");24 assertSame("p and first-p", p, elements.item(0));25 },26 multiple_getelementsbyclassname : function() {27 var doc = new browser.Document();28 var html = doc.createElement("html");29 doc.appendChild(html);30 var body = doc.createElement("body");31 html.appendChild(body);32 var p = doc.createElement("p");33 p.className = "first-p second third";34 body.appendChild(p);35 var first = doc.getElementsByClassName("first-p");36 assertSame("p and first-p", p, first.item(0));37 var second = doc.getElementsByClassName("second");38 assertSame("p and second", p, second.item(0));39 var third = doc.getElementsByClassName("third");40 assertSame("p and third", p, third.item(0));41 },42 testclassnameworksasexpected : function() {43 var doc = new browser.Document();44 var p = doc.createElement("p");45 p.setAttribute("class", "first-p");46 assertSame("class attribute is same as className", p.className,"first-p");47 p.className += " second";48 assertSame("className getter/setter", p.className,"first-p second");49 },50 basic_getelementbyid : function() {51 var doc = new browser.Document();52 var html = doc.createElement("html");53 doc.appendChild(html);54 var body = doc.createElement("body");55 html.appendChild(body);56 var p = doc.createElement("p");57 p.id = "theid";58 body.appendChild(p);59 var element = doc.getElementById("theid");60 assertSame("p and #theid", p, element);61 },62 nonexistant_getelementbyid : function() {63 var doc = new browser.Document();64 var html = doc.createElement("html");65 doc.appendChild(html);66 var body = doc.createElement("body");67 html.appendChild(body);68 var p = doc.createElement("p");69 p.id = "theid";70 body.appendChild(p);71 var element = doc.getElementById("non-existant-id");72 assertSame("p and #theid", null, element);73 },74 remove_nonexistantattribute : function() {75 var doc = new browser.Document();76 var html = doc.createElement("html");77 doc.appendChild(html);78 var body = doc.createElement("body");79 html.appendChild(body);80 exception = false;81 try {82 removedNode = body.removeAttribute("non-existant");83 }84 catch(ex) {85 exception = true;86 }87 assertFalse("setValue_throws_NO_MODIFICATION_ERR", exception);88 },89 render_singletag : function() {90 var doc = new browser.Document();91 var p = doc.createElement("p");92 var img = doc.createElement("img");93 p.appendChild(img);94 var out = p.outerHTML;95//debug(out);96 assertNull("end tag not included in output", out.match(/<\/img>/));97 },98 parse_scripttags : function() {99 var doc = new browser.Document();100 var head = doc.createElement("head");101 var scriptHtml = '<script>alert("hello world")</script>';102 head.innerHTML = scriptHtml;103 assertEquals("original and processed", head.innerHTML, scriptHtml);104 },105 parse_styletags : function() {106 var doc = new browser.Document();107 var head = doc.createElement("head");108 var styleHtml = '<style>body: {color: #fff;}</style>';109 head.innerHTML = styleHtml;110 assertEquals("original and processed", head.innerHTML, styleHtml);111 },112 parse_doublespacetags : function() {113 var doc = new browser.Document();114 var html = '<html><body class="testing" /></html>';115 exception = false;116 try {117 doc.innerHTML = html;118 }119 catch(ex) {120 exception = true;121 }122 assertFalse("setValue_throws_INVALID_CHARACTER_ERR", exception);123 },124 serialize_styleattribute : function() {125 var doc = new browser.Document();126 doc.appendChild(doc.createElement('html'));127 doc.documentElement.style.color = 'black';128 doc.documentElement.style.backgroundColor = 'white';129 assertEquals('',130 '<html style="color: black; background-color: white"></html>\r\n',131 require('../../lib/jsdom/browser/domtohtml').domToHtml(doc));132 }...

Full Screen

Full Screen

WfModel.js

Source:WfModel.js Github

copy

Full Screen

...3 var doc = mxUtils.createXmlDocument();4 var obj = value;5 //开始活动6 if(value=='start'){7 obj=doc.createElement('Start');8 obj.setAttribute('Name', 'Start');9 obj.setAttribute('DisplayName', '开始活动'); 10 obj.setAttribute('Form', '');11 obj.setAttribute('IsDeffered', 'false');12 obj.setAttribute('HandleType', '0');13 obj.setAttribute('Description', '');14 obj.setAttribute('IsBizNode', 'true');15 extras=doc.createElement('Extras');16 obj.appendChild(extras);17 }18 //结束活动19 if(value=='end'){20 obj=doc.createElement('End');21 obj.setAttribute('Name', 'End');22 obj.setAttribute('DisplayName', '结束活动'); 23 obj.setAttribute('Form', '');24 obj.setAttribute('IsDeffered', 'false');25 obj.setAttribute('HandleType', '0');26 obj.setAttribute('Description', ''); 27 obj.setAttribute('IsBizNode', 'true');28 extras=doc.createElement('Extras');29 obj.appendChild(extras);30 }31 //人工活动32 if(value=='manual'){33 obj=doc.createElement('Manual');34 obj.setAttribute('Name', 'Manual');35 obj.setAttribute('DisplayName', '人工活动');36 obj.setAttribute('Form', '');37 obj.setAttribute('IsDeffered', 'false');38 obj.setAttribute('HandleType', '0');39 obj.setAttribute('Description', ''); 40 obj.setAttribute('IsBizNode', 'true');41 extras=doc.createElement('Extras');42 obj.appendChild(extras);43 }44 //并发活动45 if(value=='fork'){46 obj=doc.createElement('Fork');47 obj.setAttribute('Name', 'Fork');48 obj.setAttribute('DisplayName', '并发活动');49 obj.setAttribute('Form', '');50 obj.setAttribute('IsDeffered', 'false');51 obj.setAttribute('HandleType', '0');52 obj.setAttribute('Description', '');53 obj.setAttribute('IsBizNode', 'true');54 extras=doc.createElement('Extras');55 obj.appendChild(extras);56 }57 //聚合活动58 if(value=='join'){59 obj=doc.createElement('Join');60 obj.setAttribute('Name', 'Join');61 obj.setAttribute('DisplayName', '聚合活动');62 obj.setAttribute('Form', '');63 obj.setAttribute('IsDeffered', 'false');64 obj.setAttribute('HandleType', '0');65 obj.setAttribute('Description', '');66 obj.setAttribute('IsBizNode', 'true');67 extras=doc.createElement('Extras');68 obj.appendChild(extras);69 }70 //子流程活动71 if(value=='subprocess'){72 obj=doc.createElement('SubProcess');73 obj.setAttribute('Name', 'SubProcess');74 obj.setAttribute('DisplayName', '子流程活动');75 obj.setAttribute('Form', '');76 obj.setAttribute('IsDeffered', 'false');77 obj.setAttribute('HandleType', '0');78 obj.setAttribute('Description', '');79 obj.setAttribute('IsBizNode', 'true');80 extras=doc.createElement('Extras');81 obj.appendChild(extras);82 }83 //可编程活动84 if(value=='code'){85 obj=doc.createElement('Code');86 obj.setAttribute('Name', 'Code');87 obj.setAttribute('DisplayName', '可编程活动');88 obj.setAttribute('Form', '');89 obj.setAttribute('IsDeffered', 'false');90 obj.setAttribute('HandleType', '0');91 obj.setAttribute('Description', '');92 obj.setAttribute('IsBizNode', 'true');93 extras=doc.createElement('Extras');94 obj.appendChild(extras);95 }96 //会签活动97 if(value=='countersignature'){98 obj=doc.createElement('CounterSignature');99 obj.setAttribute('Name', 'CounterSignature');100 obj.setAttribute('DisplayName', '会签活动');101 obj.setAttribute('Form', '');102 obj.setAttribute('IsDeffered', 'false');103 obj.setAttribute('HandleType', '0');104 obj.setAttribute('Description', '');105 obj.setAttribute('IsBizNode', 'true');106 extras=doc.createElement('Extras');107 obj.appendChild(extras);108 }109 //泳道110 if(value=='swimlane'){111 obj=doc.createElement('Swimlane');112 obj.setAttribute('Name', 'Swimlane');113 obj.setAttribute('DisplayName', '泳道');114 obj.setAttribute('Description', '');115 extras=doc.createElement('Extras');116 obj.appendChild(extras);117 }118 return obj;119};120WfModel.prototype.getWorkflowTransitionObject = function()121{122 var doc = mxUtils.createXmlDocument();123 var obj = doc.createElement('Transition');124 obj.setAttribute('Name', 'Transition');125 obj.setAttribute('DisplayName', '转移');126 obj.setAttribute('DecisionType', 'ByName');127 obj.setAttribute('ConditionName', 'normal');128 obj.setAttribute('Condition', '');129 obj.setAttribute('IsBizNode', 'true');130 return obj; ...

Full Screen

Full Screen

xml.js

Source:xml.js Github

copy

Full Screen

...3 let doc = documentImplementation.createDocument(null, null);4 var pi = doc.createProcessingInstruction("xml",5 "version= \"1.0\"encoding=\"UTF-8\"");6 doc.appendChild(pi);7 let books = doc.createElement("books");8 doc.appendChild(books);9 let book = doc.createElement("book");10 books.appendChild(book);11 addHeader(doc, book);12 addDetails(doc, book);13 return doc;14}15function addHeader(doc, book) {16 let book_header = doc.createElement("book_header");17 book.appendChild(book_header);18 let book_name = doc.createElement("book_name");19 book_name.appendChild(doc.createTextNode('Book name'));20 let price = doc.createElement("price");21 price.appendChild(doc.createTextNode('Price'));22 let cover = doc.createElement("cover");23 cover.setAttribute('path', '../path');24 book_header.appendChild(book_name);25 book_header.appendChild(price);26 book_header.appendChild(cover);27}28function addDetails(doc, book) {29 let book_details = doc.createElement("book_details");30 book.appendChild(book_details);31 let summary = doc.createElement("summary");32 summary.appendChild(doc.createTextNode('Summary text'));33 let publish_date = doc.createElement("publish_date");34 addDate(doc, publish_date, 2, 10, 1989);35 let pages = doc.createElement("pages");36 pages.appendChild(doc.createTextNode(234));37 let cover_type = doc.createElement("cover_type");38 cover_type.setAttribute('type', 'soft');39 let rating = doc.createElement("rating");40 rating.appendChild(doc.createTextNode(4.44));41 let publisher = doc.createElement("publisher");42 publisher.appendChild(doc.createTextNode('publisher'));43 let language = doc.createElement("language");44 language.setAttribute('name', 'bg');45 book_details.appendChild(summary);46 book_details.appendChild(publish_date);47 book_details.appendChild(pages);48 book_details.appendChild(cover_type);49 book_details.appendChild(rating);50 book_details.appendChild(publisher);51 book_details.appendChild(language);52 addGenres(doc, book_details);53 addAuthors(doc, book_details);54}55function addDate(doc, date, day, month, year) {56 let date_info = doc.createElement("date");57 date_info.setAttribute('day', day);58 date_info.setAttribute('month', month);59 date_info.setAttribute('year', year);60 date.appendChild(date_info);61}62function addGenres(doc, book_details) {63 let genres = doc.createElement("genres");64 let genre = doc.createElement("genre");65 genre.setAttribute('name', 'action');66 genres.appendChild(genre);67 book_details.appendChild(genres);68}69function addAuthors(doc, book_details) {70 let authors = doc.createElement("authors");71 let author = doc.createElement("author");72 authors.appendChild(author);73 book_details.appendChild(authors);74 let author_name = doc.createElement("author_name");75 author_name.appendChild(doc.createTextNode('Author name'));76 let biography = doc.createElement("biography");77 biography.appendChild(doc.createTextNode('biography'));78 let publishes_book = doc.createElement("publishes_book");79 publishes_book.appendChild(doc.createTextNode('publishes_book'));80 let nationality = doc.createElement("nationality");81 nationality.appendChild(doc.createTextNode('nationality'));82 let birth_day = doc.createElement("birth_day");83 addDate(doc, birth_day, 23, 5, 1987);84 author.appendChild(author_name);85 author.appendChild(biography);86 author.appendChild(publishes_book);87 author.appendChild(nationality);88 author.appendChild(birth_day);...

Full Screen

Full Screen

dom.js

Source:dom.js Github

copy

Full Screen

...12 content = doc.getElementById('content'),13 // references14 element,15 elements = {16 a: doc.createElement('a'),17 i: doc.createElement('i'),18 b: doc.createElement('b'),19 p: doc.createElement('p'),20 h1: doc.createElement('h1'),21 h2: doc.createElement('h2'),22 h3: doc.createElement('h3'),23 h4: doc.createElement('h4'),24 h5: doc.createElement('h5'),25 h6: doc.createElement('h6'),26 ol: doc.createElement('ol'),27 ul: doc.createElement('ul'),28 li: doc.createElement('li'),29 div: doc.createElement('div'),30 img: doc.createElement('img'),31 span: doc.createElement('span'),32 time: doc.createElement('time'),33 form: doc.createElement('form'),34 label: doc.createElement('label'),35 style: doc.createElement('style'),36 aside: doc.createElement('aside'),37 input: doc.createElement('input'),38 button: doc.createElement('button'),39 select: doc.createElement('select'),40 option: doc.createElement('option'),41 header: doc.createElement('header'),42 section: doc.createElement('section'),43 article: doc.createElement('article'),44 fragment: doc.createDocumentFragment()45 };46/* public */47 // Creates a DOM element with48 // attributes49 function element(e, attrs, str) {50 element = elements[e].cloneNode(false);51 for (var attr in attrs) {52 element.setAttribute(attr, attrs[attr])53 }54 if (str) {55 element.appendChild(text(str));56 }57 return element;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1const createNode = (tag, props, ...children) => {2 const element = document.createElement(tag);3 Object.keys(props).forEach(key => element[key] = props[key]);4 if (children.length > 0) {5 children.forEach(child => {6 if (typeof child === 'string') {7 child = document.createTextNode(child);8 }9 element.appendChild(child);10 });11 }12 return element;13};14const ul = createNode('ul', { className: 'list' }, [15 createNode('li', { className: 'item' }, 'Item 1'),16 createNode('li', { className: 'item' }, 'Item 2'),17 createNode('li', { className: 'item' }, 'Item 3'),18]);19document.body.appendChild(ul);20describe('test', () => {21 it('test', () => {22 cy.get('.list .item').should('have.length', 3);23 });24});25describe('test', () => {26 it('test', () => {27 cy.window().then((win) => {28 const ul = win.createNode('ul', { className: 'list' }, [29 win.createNode('li', { className: 'item' }, 'Item 1'),30 win.createNode('li', { className: 'item' }, 'Item 2'),31 win.createNode('li', { className: 'item' }, 'Item 3'),32 ]);33 win.document.body.appendChild(ul);34 });35 cy.get('.list .item').should('have.length', 3);36 });37});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.get('#main-form').then((form) => {4 const input = form[0].ownerDocument.createElement('input')5 form[0].appendChild(input)6 })7 cy.get('input[name="newInput"]').should('have.value', 'foo')8 })9 })

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Cypress', () => {2 it('is working', () => {3 cy.pause()4 cy.get('h1').then(($h1) => {5 const button = document.createElement('button')6 h1.appendChild(button)7 })8 })9})10Cypress.Commands.add('createButton', () => {11 cy.document().then((doc) => {12 const button = doc.createElement('button')13 doc.body.appendChild(button)14 })15})16describe('Cypress', () => {17 it('is working', () => {18 cy.pause()19 cy.get('h1').then(($h1) => {20 cy.createButton()21 })22 })23})24Cypress.Commands.add('createButton', () => {25 cy.document().then((doc) => {26 const button = doc.createElement('button')27 doc.body.appendChild(button)28 })29})30describe('Cypress', () => {31 it('is working', () => {32 cy.pause()33 cy.get('h1').then(($h1) => {34 cy.createButton()35 })36 })37})38Cypress.Commands.add('createButton', () => {39 cy.document().then((doc) => {40 const button = doc.createElement('button')41 doc.body.appendChild(button)42 })43})44describe('Cypress', () => {45 it('is working', () => {46 cy.pause()47 cy.get('h1').then(($h1) => {48 cy.createButton()49 })50 })51})52Cypress.Commands.add('createButton', () => {53 cy.document().then((doc) => {54 const button = doc.createElement('button')

Full Screen

Using AI Code Generation

copy

Full Screen

1doc.createElement('div')2doc.getElementById('mydiv')3doc.querySelector('#mydiv')4doc.querySelectorAll('.mydiv')5doc.getElementsByClassName('mydiv')6doc.getElementsByTagName('mydiv')7doc.getElementsByName('mydiv')

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("Test", () => {2 it("test", () => {3 cy.get("body").then((body) => {4 const div = body[0].ownerDocument.createElement("div");5 div.id = "div1";6 body[0].appendChild(div);7 });8 });9});10describe("Test", () => {11 it("test", () => {12 cy.document().then((doc) => {13 const div = doc.createElement("div");14 div.id = "div1";15 doc.body.appendChild(div);16 });17 });18});19describe("Test", () => {20 it("test", () => {21 cy.document().then((doc) => {22 const div = doc.createElement("div");23 div.id = "div1";24 doc.body.appendChild(div);25 });26 });27});28describe("Test", () => {29 it("test", () => {30 cy.document().then((doc) => {31 const div = doc.createElement("div");32 div.id = "div1";33 doc.body.appendChild(div);34 });35 });36});

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful