How to use contentFrame method in Puppeteer

Best JavaScript code snippet using puppeteer

editor.js

Source:editor.js Github

copy

Full Screen

1/*************************************2±à¼­Æ÷×é¼þ3ÌÀÆôÀñ2004-4-144**************************************/5var EditorTemp=null;6var perfix = "eform_data_";7Editor.currentEditor=null;8Editor.uploadFile="";//ÉÏ´«Îļþ³ÌÐòÎļþ9Editor.context="";//·þÎñÆ÷ÉÏÏÂÎÄ10function Editor(id,width,height){11 this.id=id;12 if(width==null || width<=0){13 this.width=400;14 }else{15 this.width=width;16 }17 if(height==null || height<=0){18 this.height=500;19 }else{20 this.height=height;21 }22 this.mode=true;23 this.value="";24 this.htmlCode="";25 this.toolbarContainer=null;26 this.container=null;27 this.viewSource=false;28 this.toolbars=new Array();29 window[this.id]=this;30 this.init(); 3132}3334Editor.prototype.getId=function(){35 return this.id;36}37Editor.prototype.getWidth=function(){38 return this.width;39}40Editor.prototype.getHeight=function(){41 return this.width;42}43Editor.prototype.getHeight=function(){44 return this.height;45}46Editor.prototype.getValue=function(){47 this.editorHidden.value=this.contentFrame.document.body.outerHTML;48 return this.editorHidden.value;49}50Editor.prototype.setValue=function(html){51 this.contentFrame.document.open()52 this.contentFrame.document.write(html);53 this.contentFrame.document.close();54 //this.contentFrame.document.body.innerHTML=html; 55}56Editor.prototype.getHtmlCode=function(){57 return this.htmlCode;58}59function addZero(eform_count){60 if(eform_count<10)61 return "000"+eform_count;62 else if(eform_count<100)63 return "00"+eform_count;64 else if(eform_count<1000)65 return "0"+eform_count;66 else67 return eform_count;68}69//byt add70Editor.prototype.putElementsToHidden=function(actionType){71 var eform_count = 0;//¼Ç¼Æ÷, 72 if(this.viewSource) {73 alert("Ô´´úÂë²é¿´Ä£Ê½Ï²»ÄÜÌá½»");74 return false;75 } 76 for(var i=0;i<this.contentFrame.document.all.length;i++){77 var tagTmp = this.contentFrame.document.all[i].tagName; 78 if(tagTmp=="INPUT"||tagTmp=="TEXTAREA"||tagTmp=="SELECT"){79 this.contentFrame.document.all[i].name=perfix+(addZero(eform_count++)); 80 } 81}//for82 window.document.bytfrm.htmls.value = this.getValue();83 if(window.document.bytfrm.templateName.value==""){84 alert("Ä£°åÃû²»ÄÜΪ¿Õ");85 return false;86 }87 if(window.document.bytfrm.htmls.value==""){88 alert("Ä£°åÄÚÈݲ»ÄÜ¿Õ");89 return false;90 } 91 window.document.bytfrm.saveTemplate.value = "±£´æ";92 93 window.document.bytfrm.action = window.document.bytfrm.action +"?action="+actionType;94 95 window.document.bytfrm.submit(); 96}97Editor.prototype.getElements=function(){98 for(var i=0;i<this.contentFrame.document.all.length;i++){99 if(this.contentFrame.document.all[i].tagName=="INPUT"){100 alert('if'); 101 alert(this.contentFrame.document.all[i].title);102 alert(this.contentFrame.document.all[i].value);103 alert('-----if----'); 104 }else105 alert("else");106}107}108Editor.prototype.init=function(){109 document.write("<div id=\"editorcontainer"+this.id+"\" class=\"editor\" ></div>");110 this.container=eval("document.all.editorcontainer"+this.id);111 this.container.cid=this.id;112 this.container.style.display="none";113 this.container.style.pixelWidth=this.width;114 this.container.style.pixelHeight=this.height;115 var editorTable=document.createElement("TABLE");116 this.container.appendChild(editorTable);117 editorTable.cellPadding=0;118 editorTable.cellSpacing=0;119 editorTable.border=0;120 editorTable.width="100%";121 editorTable.height="100%";122123124 var tbRow=editorTable.insertRow();125 var tbCell=tbRow.insertCell();126 tbCell.className="toolbarcontainer";127 tbCell.valign="top";128 this.toolbarContainer=tbRow;//¼Ç¼¹¤¾ßÀ¸ÈÝÆ÷129 var cRow=editorTable.insertRow();130 var cCell=cRow.insertCell();131 this.initToolbar();132 this.initContent();133 this.container.onmouseover=function(){134 var editorTmp=eval(this.cid);135 Editor.currentEditor=editorTmp;136 }137 this.container.style.display="block";138}139/*140*³õʼ»¯¹¤¾ßÀ¸141*/142Editor.prototype.initToolbar=function(){143 var tbCell=this.container.children[0].rows[0].cells[0];144 var cCell=this.container.children[0].rows[1].cells[0];145146 var tb=new ToolBar(this.id+"_editorToolbar1",tbCell);147 tb.addHandler();148 tb.addImgButton("delete",context+"/common/htmleditor/images/editor/delete.gif","ɾ³ý");149 tb.addImgButton("paste",context+"/common/htmleditor/images/editor/paste.gif","Õ³Ìù");150 tb.addImgButton("cut",context+"/common/htmleditor/images/editor/cut.gif","¼ôÇÐ");151 tb.addImgButton("copy",context+"/common/htmleditor/images/editor/copy.gif","¸´ÖÆ");152 tb.addImgButton("undo",context+"/common/htmleditor/images/editor/undo.gif","³·Ïû");153 tb.addImgButton("redo",context+"/common/htmleditor/images/editor/redo.gif","»Ö¸´");154 tb.addSpliter();155 tb.addImgButton("intable",context+"/common/htmleditor/images/editor/intable.gif","²åÈë±í¸ñ");156 tb.addImgButton("inlink",context+"/common/htmleditor/images/editor/inlink.gif","²åÈ볬¼¶Á¬½Ó");157 tb.addImgButton("inimg",context+"/common/htmleditor/images/editor/inimg.gif","²åÈëͼƬ");158 tb.addImgButton("inhr",context+"/common/htmleditor/images/editor/inhr.gif","²åÈëˮƽÏß");159 tb.addImgButton("inicon",context+"/common/htmleditor/images/editor/smile.gif","²åÈëͼÊÍ");160 tb.addImgButton("inchar",context+"/common/htmleditor/images/editor/inchar.gif","²åÈë×Ö·û");161 tb.addSpliter();162 tb.addImgButton("forecolor",context+"/common/htmleditor/images/editor/fontcolor.gif","ÎÄ×Ö¾°É«");163 tb.addImgButton("backbolor",context+"/common/htmleditor/images/editor/fontbgcolor.gif","ÎÄ×Ö±³¾°É«");164 tb.addImgButton("backgroundbolor",context+"/common/htmleditor/images/editor/pagecolor.gif","ÍøÒ³±³¾°É«");165166 //tb.addSpliter();167 tb.setAction("editorToolbar1_onclick");168 this.toolbars[0]=tb;169 tb=new ToolBar(this.id+"_editorToolbar2",tbCell);170 tb.addHandler();171 tb.addImgButton("bold",context+"/common/htmleditor/images/editor/bold.gif","¼Ó´Ö",true);172 tb.addImgButton("italic",context+"/common/htmleditor/images/editor/italic.gif","бÌå",true);173 tb.addImgButton("underline",context+"/common/htmleditor/images/editor/underline.gif","Ï»®Ïß",true);174 tb.addImgButton("strikethrough",context+"/common/htmleditor/images/editor/strikethrough.gif","ɾ³ýÏß",true);175 tb.addSpliter();176 tb.addImgButton("leftalign",context+"/common/htmleditor/images/editor/leftalign.gif","×ó¶ÔÆë");177 tb.addImgButton("center",context+"/common/htmleditor/images/editor/center.gif","¾ÓÖÐ");178 tb.addImgButton("rightalign",context+"/common/htmleditor/images/editor/rightalign.gif","ÓÒ¶ÔÆë");179 tb.addSpliter();180181 tb.addImgButton("numlist",context+"/common/htmleditor/images/editor/numlist.gif","±àºÅ");182 tb.addImgButton("bullist",context+"/common/htmleditor/images/editor/bullist.gif","ÏîÄ¿·ûºÅ");183 tb.addImgButton("indent",context+"/common/htmleditor/images/editor/indent.gif","¼õÉÙËõ½øÁ¿");184 tb.addImgButton("outdent",context+"/common/htmleditor/images/editor/outdent.gif","Ôö¼ÓËõ½øÁ¿");185 tb.addSpliter();186 tb.addImgButton("delformat",context+"/common/htmleditor/images/editor/removeformat.gif","ÒƳý¸ñʽ");187 //tb.addImgButton("test",context+"/common/htmleditor/images/editor/outdent.gif","test");188 tb.setAction("editorToolbar2_onclick");189 this.toolbars[1]=tb;190191 tb=new ToolBar(this.id+"_editorToolbar3",tbCell);192 tb.addHandler();193 var selStr='<select ID="formatSelect" class="TBGen" title="¶ÎÂä¸ñʽ" onchange="_setFormat()" style="font: icon; width: 80px;">'194 selStr+= '<option>¶ÎÂä¸ñʽ</option>'195 selStr+= '<option VALUE="&lt;P&gt;">ÆÕͨ '196 selStr+= '<option VALUE="&lt;PRE&gt;">ÒѱàÅŸñʽ '197 selStr+= '<option VALUE="&lt;H1&gt;">±êÌâÒ» '198 selStr+= '<option VALUE="&lt;H2&gt;">±êÌâ¶þ '199 selStr+= '<option VALUE="&lt;H3&gt;">±êÌâÈý '200 selStr+= '<option VALUE="&lt;H4&gt;">±êÌâËÄ '201 selStr+= '<option VALUE="&lt;H5&gt;">±êÌâÎå '202 selStr+= '<option VALUE="&lt;H6&gt;">±êÌâÁù '203 selStr+= '<option VALUE="&lt;H7&gt;">±êÌâÆß '204 selStr+= '</select>'205 tb.addButton("pformat",selStr);206207 208209 var lable=document.createElement("SPAN");210 lable.innerText="×ÖÌå"211 tb.addButton("fonelable",lable);212 selStr='<select language="javascript" class="TBGen" id="FontName" title="×ÖÌåÃû" onchange="_setFontName()">'213 selStr+= ' <option class="heading" selected>×ÖÌå '214 selStr+=' <option value="ËÎÌå">ËÎÌå '215 selStr+= ' <option value="ºÚÌå">ºÚÌå '216 selStr+=' <option value="¿¬Ìå_GB2312">¿¬Ìå '217 selStr+=' <option value="·ÂËÎ_GB2312">·ÂËÎ '218 selStr+=' <option value="Á¥Êé">Á¥Êé '219 selStr+=' <option value="Ó×Ô²">Ó×Ô² '220 selStr+=' <option value="ÐÂËÎÌå">ÐÂËÎÌå '221 selStr+=' <option value="ϸÃ÷Ìå">ϸÃ÷Ìå '222 selStr+=' <option value="Arial">Arial '223 selStr+=' <option value="Arial Black">Arial Black '224 selStr+=' <option value="Arial Narrow">Arial Narrow '225 selStr+=' <option value="Bradley Hand ITC">Bradley Hand ITC '226 selStr+=' <option value="Brush Script MT">Brush Script MT '227 selStr+=' <option value="Century Gothic">Century Gothic '228 selStr+=' <option value="Comic Sans MS">Comic Sans MS '229 selStr+=' <option value="Courier">Courier '230 selStr+=' <option value="Courier New">Courier New '231 selStr+=' <option value="MS Sans Serif">MS Sans Serif '232 selStr+=' <option value="Script">Script '233 selStr+=' <option value="System">System '234 selStr+=' <option value="Times New Roman">Times New Roman '235 selStr+=' <option value="Viner Hand ITC">Viner Hand ITC '236 selStr+=' <option value="Verdana">Verdana '237 selStr+=' <option value="Wide Latin">Wide Latin '238 selStr+=' <option value="Wingdings">Wingdings</option>'239 selStr+='</select>'240 tb.addButton("fontfalimy",selStr);241 selStr='<select language="javascript" class="TBGen" id="FontSize" title="×ֺŴóС" onchange="_setFontSize()">'242 selStr+=' <option class="heading" selected>×ֺŠ'243 selStr+=' <option value="7">Ò»ºÅ '244 selStr+=' <option value="6">¶þºÅ '245 selStr+=' <option value="5">ÈýºÅ '246 selStr+=' <option value="4">ËĺŠ'247 selStr+=' <option value="3">ÎåºÅ '248 selStr+=' <option value="2">ÁùºÅ '249 selStr+=' <option value="1">ÆߺÅ</option>'250 selStr+='</select>'251 tb.addButton("fontsize",selStr);252 253 tb.setAction("editorToolbar3_onclick");254255 /*256 tb.addSpliter();257 var strCheckbox='<input type="checkbox" name="" onclick="Editor.changeState()">'258 tb.addButton("html",strCheckbox); 259 */260 this.toolbars[2]=tb;261262263 264 tbCell.style.pixelHeight=ToolBar.HEIGHT*3+14;265 cCell.style.pixelHeight=this.height-tbCell.style.pixelHeight;266}267/*268*³õʼ»¯±à¼­¿ò269*/270Editor.prototype.initContent=function(){271 var cCell=this.container.children[0].rows[1].cells[0]; 272 var src="";//Editor.context+"/common/htmleditor/empty.htm";273 var ifrmHTML="<iframe id='editor_frame_"+this.id+"' cid='"+this.id+"' width=100% height=100% classname='editorframe' name='editor_frame_"+this.id+"' src='"+src+"'></iframe>";274 cCell.innerHTML=ifrmHTML;275 this.contentFrame=eval("editor_frame_"+this.id);276 var contentFrameObj=eval("document.all.editor_frame_"+this.id); 277 this.contentFrame.cid=this.id;278279 this.contentFrame.document.designMode="On";280 //this.contentFrame.document.open()281 //this.contentFrame.document.write("<body>gggggggggggggggggggggggg</body>");282 //this.contentFrame.document.close();283 this.contentFrame.document.onmouseup=function(){284 var editor=Editor.currentEditor; 285 };286287 var strHidden="<textarea style='display:none' id='editorContent_"+this.id+"'></textarea>";288 document.write(strHidden);289 //var editorHidden=document.createElement("TEXTAREA");290 this.editorHidden=eval("document.all.editorContent_"+this.id);291 //editorHidden.style.display="none";292 //this.container.appendChild(editorHidden);293294 contentFrameObj.onblur=function(){295 var editorTmp=eval(this.cid);296 if(editorTmp.mode){297 editorTmp.editorHidden.value=editorTmp.contentFrame.document.body.outerHTML;298 }else{299 editorTmp.editorHidden.value=editorTmp.contentFrame.document.body.innerText;300 }301 }302 contentFrameObj.onfocus=function(){303 var editorTmp=eval(this.cid);304 Editor.currentEditor=editorTmp;305 var doc=Editor.currentEditor.contentFrame.document;306 if(doc.body==null){307 doc.open();308 alert()309 doc.write("<body style='font-size:100'></body>");310 doc.close();311 }312 doc.body.style.fontSize=12;313 }314 //this.contentFrame.document.open();315 //this.contentFrame.document.write("<body><font size='1'>fghh</font></body>");316 //this.contentFrame.document.body.style.fontSize=1;317318}319Editor.prototype.setMode=function(mode){320 this.mode=mode;321 var contentData="";322 if(!this.mode){323 contentData=this.contentFrame.document.body.innerText;324 this.contentFrame.document.body.innerHTML=contentData;325 }else{326 contentData=this.contentFrame.document.body.outerHTML;327 this.contentFrame.document.body.innerText=contentData;328 }329 this.contentFrame.focus();330}331/*332*ÉèÖñ༭Æ÷״̬333*@param state booleanÀàÐÍ trueÉèÖÃΪֻ¶Á,falseÉèÖÃΪ¿Éд334*@param flag booleanÀàÐÍ 335*/336Editor.prototype.setState=function(state,flag){337 if(state==null) state=true;338 if(flag==null) flag=true;339 if(flag==true){340 //Òþ²Ø¹¤¾ßÀ¹341 this.toolbarContainer.style.display="none";342 }else{343 //ÏÔʾ¹¤¾ßÀ¹344 this.toolbarContainer.style.display="block";345 }346 347 348 if(!state){349 //É趨Ϊֻ¶Á350 this.contentFrame.document.designMode="Off";351 }else{352 this.contentFrame.document.designMode="On";353 }354}355/*356*ÉèÖñ༭Æ÷״̬357*@param state booleanÀàÐÍ trueÉèÖÃΪֻ¶Á,falseÉèÖÃΪ¿Éд358*@param flag booleanÀàÐÍ 359*/360Editor.prototype.setReadOnly=function(flag){361 this.setState(false,flag);362}363364Editor.prototype.executeCommand=function(command,value){365 var ret=true;366 if(value==null){367 ret=this.contentFrame.document.execCommand(command);368 }else{369 ret=this.contentFrame.document.execCommand(command,false,value);370 }371 return ret;372}373Editor.prototype.focus=function(){374 this.contentFrame.focus();375}376Editor.prototype.insert=function(type){377 var strInsert="";378 var range = this.contentFrame.document.selection.createRange();379 if (this.contentFrame.document.selection.type == 'Control') {380 if(range.length==1){381 Editor.showDialog(type,range(0));382 }383 }else{384 strInsert=Editor.showDialog(type);385 range.pasteHTML(strInsert);386 }387}388Editor.prototype.setToolbarState=function(){389 //alert("ÉèÖù¤¾ßÀ¸×´Ì¬")390}391392//¹«¹²·½·¨393Editor.changeState=function(){394 var editor=Editor.currentEditor;395 if(editor.viewSource){396 var strText=editor.contentFrame.document.body.innerText;397 editor.contentFrame.document.body.innerHTML=strText;398 }else{399 var strHtml=editor.contentFrame.document.body.innerHTML;400 editor.contentFrame.document.body.innerText=strHtml;401 }402 editor.viewSource=!editor.viewSource;403}404Editor.showDialog=function(type,obj){405 var ret="";406 var strUrl,strAttr;407 var openType="dialog";408 switch(type)409 {410 case "table":411 strUrl = context+"/common/htmleditor/js/intable.htm";412 strAttr = "status:no;dialogWidth:400px;dialogHeight:360px;help:no";413 break;414 case "icon":415 strUrl = context+"/common/htmleditor/js/inicon.htm";416 strAttr = "status:no;dialogWidth:300px;dialogHeight:350px;help:no";417 break;418 case "char":419 strUrl = context+"/common/htmleditor/js/inchar.htm";420 strAttr = "status:no;dialogWidth:450px;dialogHeight:290px;help:no";421 break;422 case "img":423 strUrl = context+"/common/htmleditor/js/inimg.htm";424 strAttr = "status:no;dialogWidth:400px;dialogHeight:200px;help:no";425 break;426 case "link":427 strUrl = context+"/common/htmleditor/js/inlink.htm";428 strAttr = "status:no;dialogWidth:400px;dialogHeight:200px;help:no";429 break;430 case "attachment": 431 strUrl = Editor.uploadFile;432 openType="window";433 strAttr = "width=400px;height=200px";434 break;435 }436 if(openType=="window"){437 window.open(strUrl,null,strAttr);438 }else{439 ret = window.showModalDialog(strUrl, obj, strAttr);440 }441 if(ret==null) ret="";442 return ret;443}444function _setFormat(){445 var formatSel=event.srcElement;446 var editor=Editor.currentEditor;447 editor.executeCommand("FormatBlock",formatSel[formatSel.selectedIndex].value);448449}450451function _setFontName(){452 var fontNameSel=event.srcElement;453 var editor=Editor.currentEditor;454 editor.executeCommand("fontname",fontNameSel[fontNameSel.selectedIndex].value);455456}457function _setFontSize(){458 var fontSizeSel=event.srcElement;459 var editor=Editor.currentEditor;460 editor.executeCommand("fontsize",fontSizeSel[fontSizeSel.selectedIndex].value);461462}463464function _setForeColor(color){465 var editor=Editor.currentEditor;466 editor.executeCommand("ForeColor",color);467 editor.focus();468}469function _setBackColor(color){470 var editor=Editor.currentEditor;471 editor.executeCommand("BackColor",color);472 editor.focus();473}474function _setBackGroundColor(color){475 var editor=Editor.currentEditor;476 //editor.executeCommand("BackgroundColor",color);477 editor.contentFrame.document.body.bgColor=color;478 editor.focus();479}480481function editorToolbar1_onclick(button){482 var editor=Editor.currentEditor;483 //editor.focus();484 switch(button.getIndex()){485 case 0:486 editor.executeCommand("Delete");487 /*if(button.isCheck()){488 editor.setMode(button.getValue());489 }*/490 break;491 case 1:492 editor.executeCommand("Paste");493 break;494 case 2:495 editor.executeCommand("Cut");496 break;497 case 3:498 editor.executeCommand("Copy");499 break;500 case 4:501 editor.executeCommand("Undo");502 break;503 case 5:504 editor.executeCommand("Redo");505 break;506 case 6:507 editor.focus();508 editor.insert("table");509 break;510 case 7:511 editor.focus();512 editor.insert("link");513 break;514 case 8:515 editor.focus();516 editor.insert("img");517 break;518 case 9:519 editor.focus();520 editor.executeCommand("InsertHorizontalRule");521 break;522 case 10:523 editor.focus();524 editor.insert("icon");525 break;526 case 11:527 editor.focus();528 editor.insert("char");529 break;530 /*case 12:531 editor.focus();532 editor.insert("attachment");533 break;534*/535 case 12:536 var picker=ColorPicker.createColorPicker(context+"/common/htmleditor/js/");537 picker.show(button.getHtmlObj(),"_setForeColor"); 538 break;539 case 13:540 var picker=ColorPicker.createColorPicker(context+"/common/htmleditor/js/");541 picker.show(button.getHtmlObj(),"_setBackColor"); 542 break;543 case 14:544 var picker=ColorPicker.createColorPicker(context+"/common/htmleditor/js/");545 picker.show(button.getHtmlObj(),"_setBackGroundColor"); 546 break;547548 }549}550function editorToolbar2_onclick(button){551 var editor=Editor.currentEditor;552 editor.focus();553 switch(button.getIndex()){554 case 0:555 editor.executeCommand("Bold");556 break;557 case 1:558 editor.executeCommand("Italic");559 break;560 case 2:561 editor.executeCommand("Underline");562 break;563 case 3:564 editor.executeCommand("Strikethrough");565 break;566 case 4:567 editor.executeCommand("JustifyLeft");568 break;569 case 5:570 editor.executeCommand("JustifyCenter");571 break;572 case 6:573 editor.executeCommand("JustifyRight");574 break;575 case 7:576 editor.executeCommand("InsertOrderedList");577 break;578 case 8:579 editor.executeCommand("InsertUnorderedList");580 break;581 case 9:582 editor.executeCommand("Indent");583 break;584 case 10:585 editor.executeCommand("Outdent");586 break;587 case 11:588 editor.executeCommand("RemoveFormat");589 break;590 }591 592}593function editorToolbar3_onclick(button){594 ...

Full Screen

Full Screen

backmanageservice.js

Source:backmanageservice.js Github

copy

Full Screen

1$(function() {2 var pageloade = false;3 var flowloade = false;4 var pagesetloade = false;5 var orgloade =false;6 var serverloade = false;7 var perloade = false;8 var powloade = false;9 var flowsetting=false;10 $(document).bind("contextmenu", function(e) {11 return true;12 });13 $("#myheader").find("a").bind("click", function() {14 var btnID = $(this).prop("id")15 $(document.getElementsByName("guanlxuanz")).css("background-color", "#008CBA");16 if (btnID != "backbtn") {17 $(this).css("background-color", "#FFFFFF");18 }19 if (btnID == "pagesetting") {20 if(!pagesetloade){21 $("#pagesetting_contentframe").attr("src", "../admin/pagesetting/editHTMLPage.htm");22 //pagesetloade = true;23 }24 $("#frontsetting_contentframe").css("display","none");25 $("#pagesetting_contentframe").css("display","block");26 $("#newpagesetting_contentframe").css("display","none");27 $("#personsetting_contentframe").css("display","none");28 $("#orgsetting_contentframe").css("display","none")29 $("#powersetting_contentframe").css("display","none");30 $("#serversetting_contentframe").css("display","none");31 $("#statichtml_contentframe").css("display","none")32 $("#flowsetting_contentframe").css("display","none");33 34 35 36 }37 else if (btnID == "newpagesetting") {38 $("#newpagesetting_contentframe").attr("src", "../admin/pagedesign/form_desing.html");39 $("#frontsetting_contentframe").css("display","none");40 $("#pagesetting_contentframe").css("display","none");41 $("#newpagesetting_contentframe").css("display","block");42 $("#personsetting_contentframe").css("display","none");43 $("#orgsetting_contentframe").css("display","none")44 $("#powersetting_contentframe").css("display","none");45 $("#serversetting_contentframe").css("display","none");46 $("#statichtml_contentframe").css("display","none")47 $("#flowsetting_contentframe").css("display","none");48 }49 else if (btnID == "orgsetting") {50 51 52 if(!orgloade){53 $("#orgsetting_contentframe").attr("src", "../admin/organizesetting/bumenTree.html");54 orgloade = true;55 }56 $("#frontsetting_contentframe").css("display","none");57 $("#pagesetting_contentframe").css("display","none");58 $("#newpagesetting_contentframe").css("display","none");59 $("#personsetting_contentframe").css("display","none");60 $("#orgsetting_contentframe").css("display","block")61 $("#powersetting_contentframe").css("display","none");62 $("#serversetting_contentframe").css("display","none");63 $("#statichtml_contentframe").css("display","none")64 $("#flowsetting_contentframe").css("display","none");65 } 66 else if (btnID == "serversetting") {67 68 if(!serverloade){69 $("#serversetting_contentframe").attr("src", "../admin/cdmain/main.aspx");70 serverloade = true;71 }72 $("#frontsetting_contentframe").css("display","none");73 $("#pagesetting_contentframe").css("display","none");74 $("#newpagesetting_contentframe").css("display","none");75 $("#personsetting_contentframe").css("display","none");76 $("#orgsetting_contentframe").css("display","none")77 $("#powersetting_contentframe").css("display","none");78 $("#serversetting_contentframe").css("display","block");79 $("#statichtml_contentframe").css("display","none")80 $("#flowsetting_contentframe").css("display","none");81 }82 else if (btnID == "personsetting") {83 $("#frontsetting_contentframe").css("display","none");84 $("#pagesetting_contentframe").css("display","none");85 $("#newpagesetting_contentframe").css("display","none");86 $("#personsetting_contentframe").css("display","block");87 $("#orgsetting_contentframe").css("display","none")88 $("#powersetting_contentframe").css("display","none");89 $("#serversetting_contentframe").css("display","none");90 $("#statichtml_contentframe").css("display","none")91 $("#flowsetting_contentframe").css("display","none");92 }93 else if (btnID == "powersetting") {94 if(!powloade){95 $("#powersetting_contentframe").attr("src", "../admin/powerdesign/quanxian.htm");96 powloade = true;97 }98 $("#frontsetting_contentframe").css("display","none");99 $("#pagesetting_contentframe").css("display","none");100 $("#newpagesetting_contentframe").css("display","none");101 $("#personsetting_contentframe").css("display","none");102 $("#orgsetting_contentframe").css("display","none")103 $("#powersetting_contentframe").css("display","block");104 $("#serversetting_contentframe").css("display","none");105 $("#statichtml_contentframe").css("display","none")106 $("#flowsetting_contentframe").css("display","none");107 }108 else if (btnID == "flowsetting") {109 if(!flowsetting){110 $("#flowsetting_contentframe").attr("src", "../admin/flowsetting/index.htm");111 flowsetting =true;112 }113 $("#frontsetting_contentframe").css("display","none");114 $("#pagesetting_contentframe").css("display","none");115 $("#newpagesetting_contentframe").css("display","none");116 $("#personsetting_contentframe").css("display","none");117 $("#orgsetting_contentframe").css("display","none")118 $("#powersetting_contentframe").css("display","none");119 $("#serversetting_contentframe").css("display","none");120 $("#statichtml_contentframe").css("display","none")121 $("#flowsetting_contentframe").css("display","block");122 123 }else if (btnID == "frontsetting") {124 // $("#contentframe").attr("src", "/admin/flowsetting/index.htm");125 if(!flowloade){126 $("#frontsetting_contentframe").attr("src", "../admin/frontsetting/index.htm");127 flowloade =true;128 }129 $("#pagesetting_contentframe").css("display","none");130 $("#newpagesetting_contentframe").css("display","none");131 $("#personsetting_contentframe").css("display","none");132 $("#orgsetting_contentframe").css("display","none")133 $("#powersetting_contentframe").css("display","none");134 $("#serversetting_contentframe").css("display","none");135 $("#statichtml_contentframe").css("display","none")136 $("#flowsetting_contentframe").css("display","none");137 $("#frontsetting_contentframe").css("display","block");138 }else if (btnID == "statichtml") {139 if(!pageloade){ 140 $("#statichtml_contentframe").attr("src", "../front/statichtml/index.htm");141 pageloade = true;142 }143 144 $("#frontsetting_contentframe").css("display","none");145 $("#statichtml_contentframe").css("display","block")146 $("#pagesetting_contentframe").css("display","none");147 $("#newpagesetting_contentframe").css("display","none");148 $("#personsetting_contentframe").css("display","none");149 $("#orgsetting_contentframe").css("display","none");150 $("#powersetting_contentframe").css("display","none");151 $("#serversetting_contentframe").css("display","none");152 153 $("#flowsetting_contentframe").css("display","none");154 }155 else if (btnID == "flowsetting2") {156 $("#pagesetting_contentframe").attr("src", "/admin/flowsetting2/index.htm");157 }158 else if (btnID == "backbtn") {159 location.href = "/front/main/mainpage.php";160 }161 });162 $("#saveBt").bind("click", function() {163 $.ajax({ url: "/handler/runtimeWeb.ashx", type: "POST", data: { operatetype: "getTableByDataview", tableName: escape(flotGetPageDiv.Json.name) },164 success: function(data) {165 var list = eval(data);166 if (list.length > 0) {167 var grl = confirm("该页面有数据视图,保存该页面将删除其相关联的数据视图!!是否保存??");168 if (grl) {169 $.ajax({ url: "/handler/runtimeWeb.ashx", type: "POST", data: { operatetype: "deleteDataview", list: escape(list) },170 success: function(data) {171 if (data == 1) {172 var divControls = [];173 for (var i = 0; i < flotGetPageDiv.Json.modelControls.length; i++) {174 var modelChildControls = flotGetPageDiv.Json.modelControls[i].ModelChildControls;175 for (var j = 1; j < modelChildControls.length; j += 2) {176 divControls.push(modelChildControls[j]);177 }178 }179 var allName = getAllControls(flotGetPageDiv);180 var temp = [];181 var temparray = [];182 for (var i = 0; i < divControls.length; i++) {183 temp[divControls[i]] = true;184 }185 for (var i = 0; i < allName.length; i++) {186 if (!temp[allName[i]]) {187 temparray.push(allName[i]);188 }189 }190 if (temparray.length > 0) {191 var strs = "";192 for (var i = 0; i < temparray.length; i++) {193 strs = strs + " " + temparray[i] + "控件 "194 }195 var gnl = confirm("还有" + strs + "没有放入模版排版控件!是否强制删除" + strs + "?");196 if (gnl) {197 for (var i = 0; i < temparray.length; i++) {198 $("#" + temparray[i]).remove();199 }200 deleteChildControls(temparray, flotGetPageDiv);201 } else {202 return;203 }204 }205 var pageStr = JSON.stringify(flotGetPageDiv.Json);206 $.ajax({ url: "/handler/runtimeWeb.ashx", type: "POST", dataType: "json", data: { operatetype: "saveDesignPage", pageStr: escape(pageStr) },207 success: function(data) {208 if (data.IsSuccess) {209 alert(data.Data);210 }211 else {212 alert(data.Message);213 }214 },215 error: function(e) {216 alert(e.status);217 }218 });219 } else if (data == 0) {220 alert("数据视图删除失败,保存失败!!!退出保存!!!");221 }222 }, error: function(e) {223 alert(e.status);224 }225 });226 }227 }228 else {229 var divControls = [];230 for (var i = 0; i < flotGetPageDiv.Json.modelControls.length; i++) {231 var modelChildControls = flotGetPageDiv.Json.modelControls[i].ModelChildControls;232 for (var j = 1; j < modelChildControls.length; j += 2) {233 divControls.push(modelChildControls[j]);234 }235 }236 var allName = getAllControls(flotGetPageDiv);237 var temp = [];238 var temparray = [];239 for (var i = 0; i < divControls.length; i++) {240 temp[divControls[i]] = true;241 }242 for (var i = 0; i < allName.length; i++) {243 if (!temp[allName[i]]) {244 temparray.push(allName[i]);245 }246 }247 if (temparray.length > 0) {248 var strs = "";249 for (var i = 0; i < temparray.length; i++) {250 strs = strs + " " + temparray[i] + "控件 "251 }252 var gnl = confirm("还有" + strs + "没有放入模版排版控件!是否强制删除" + strs + "?");253 if (gnl) {254 for (var i = 0; i < temparray.length; i++) {255 $("#" + temparray[i]).remove();256 }257 deleteChildControls(temparray, flotGetPageDiv);258 } else {259 return;260 }261 }262 var pageStr = JSON.stringify(flotGetPageDiv.Json);263 $.ajax({ url: "/handler/runtimeWeb.ashx", type: "POST", dataType: "json", data: { operatetype: "saveDesignPage", pageStr: escape(pageStr) },264 success: function(data) {265 if (data.IsSuccess) {266 alert(data.Data);267 }268 else {269 alert(data.Message);270 }271 },272 error: function(e) {273 alert(e.status);274 }275 });276 }277 },278 error: function(e) {279 alert(e.status);280 }281 });282 });...

Full Screen

Full Screen

wb_frame.js

Source:wb_frame.js Github

copy

Full Screen

1/*2Copyright(c) 2013-2018 Rhizome and Ilya Kreymer. Released under the GNU General Public License.3This file is part of pywb, https://github.com/webrecorder/pywb4 pywb is free software: you can redistribute it and/or modify5 it under the terms of the GNU General Public License as published by6 the Free Software Foundation, either version 3 of the License, or7 (at your option) any later version.8 pywb is distributed in the hope that it will be useful,9 but WITHOUT ANY WARRANTY; without even the implied warranty of10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11 GNU General Public License for more details.12 You should have received a copy of the GNU General Public License13 along with pywb. If not, see <http://www.gnu.org/licenses/>.14*/15/**16 * @param {Object} content_info - Information about the contents to be replayed17 */18function ContentFrame(content_info) {19 if (!(this instanceof ContentFrame)) return new ContentFrame(content_info);20 this.last_inner_hash = window.location.hash;21 this.last_url = content_info.url;22 this.last_ts = content_info.request_ts;23 this.content_info = content_info;24 // bind event callbacks25 this.outer_hash_changed = this.outer_hash_changed.bind(this);26 this.handle_event = this.handle_event.bind(this);27 this.wbBanner = null;28 this.checkBannerToId = null;29 window.addEventListener('hashchange', this.outer_hash_changed, false);30 window.addEventListener('message', this.handle_event);31 if (document.readyState === 'complete') {32 this.init_iframe();33 } else {34 document.addEventListener('DOMContentLoaded', this.init_iframe.bind(this), {35 once: true36 });37 }38 window.__WB_pmw = function(win) {39 this.pm_source = win;40 return this;41 };42}43/**44 * @desc Initializes the replay iframe. If a banner exists (exposed on window as WBBanner)45 * then the init function of the banner is called.46 */47ContentFrame.prototype.init_iframe = function() {48 if (typeof this.content_info.iframe === 'string') {49 this.iframe = document.querySelector(this.content_info.iframe);50 } else {51 this.iframe = this.content_info.iframe;52 }53 if (!this.iframe) {54 console.warn('no iframe found ' + this.content_info.iframe + ' found');55 return;56 }57 this.extract_prefix();58 if (window.WBBanner) {59 this.wbBanner = window.WBBanner;60 this.wbBanner.init();61 }62 this.load_url(this.content_info.url, this.content_info.request_ts);63};64/**65 * @desc Initializes the prefixes used to load the pages to be replayed66 */67ContentFrame.prototype.extract_prefix = function() {68 this.app_prefix = this.content_info.app_prefix || this.content_info.prefix;69 this.content_prefix =70 this.content_info.content_prefix || this.content_info.prefix;71 if (this.app_prefix && this.content_prefix) {72 return;73 }74 var inx = window.location.href.indexOf(this.content_info.url);75 if (inx < 0) {76 inx = window.location.href.indexOf('/http') + 1;77 if (inx <= 0) {78 inx = window.location.href.indexOf('///') + 1;79 if (inx <= 0) {80 console.warn('No Prefix Found!');81 }82 }83 }84 this.prefix = window.location.href.substr(0, inx);85 this.app_prefix = this.app_prefix || this.prefix;86 this.content_prefix = this.content_prefix || this.prefix;87};88/**89 * @desc Returns an absolute URL (with correct prefix and replay modifier) given90 * the replayed pages URL and optional timestamp and content_url91 * @param {string} url - The URL of the replayed page92 * @param {?string} ts - The timestamp of the replayed page93 * @param {?boolean} content_url - Is the abs URL to be constructed using the content_prefix or app_prefix94 * @returns {string}95 */96ContentFrame.prototype.make_url = function(url, ts, content_url) {97 var mod, prefix;98 if (content_url) {99 mod = 'mp_';100 prefix = this.content_prefix;101 } else {102 mod = '';103 prefix = this.app_prefix;104 }105 if (ts || mod) {106 mod += '/';107 }108 if (ts) {109 return prefix + ts + mod + url;110 } else {111 return prefix + mod + url;112 }113};114/**115 * @desc Handles and routes all messages received from the replay iframe.116 * @param {MessageEvent} event - A message event potentially containing a message from the replay iframe117 */118ContentFrame.prototype.handle_event = function(event) {119 var frame_win = this.iframe.contentWindow;120 if (event.source === window.parent) {121 // Pass to replay frame122 frame_win.postMessage(event.data, '*');123 } else if (event.source === frame_win) {124 // Check if iframe url change message125 if (typeof event.data === 'object' && event.data['wb_type']) {126 this.handle_message(event);127 } else {128 // Pass to parent129 window.parent.postMessage(event.data, '*');130 }131 }132};133/**134 * @desc Handles messages intended for the content frame (indicated by data.wb_type). If a banner135 * is exposed, calls the onMessage function of the exposed banner.136 * @param {MessageEvent} event - The message event containing a message from the replay iframe137 */138ContentFrame.prototype.handle_message = function(event) {139 if (this.wbBanner) {140 this.wbBanner.onMessage(event);141 }142 var state = event.data;143 var type = state.wb_type;144 if (type === 'load' || type === 'replace-url') {145 this.set_url(state);146 } else if (type === 'hashchange') {147 this.inner_hash_changed(state);148 }149};150/**151 * @desc Updates the URL of the top frame152 * @param {Object} state - The contents of a message rreceived from the replay iframe153 */154ContentFrame.prototype.set_url = function(state) {155 if (156 state.url &&157 (state.url !== this.last_url || state.request_ts !== this.last_ts)158 ) {159 var new_url = this.make_url(state.url, state.request_ts, false);160 window.history.replaceState(state, '', new_url);161 this.last_url = state.url;162 this.last_ts = state.request_ts;163 }164};165/**166 * @desc Checks to see if the banner is still indicating the replay iframe is still loading167 * 2 seconds after the load event is fired by the replay iframe. If the banner is still168 * indicating the replayed page is loading. Updates the displayed information using169 * newURL and newTS170 * @param {string} newUrl - The new URL of the replay iframe171 * @param {?string} newTs - The new timestamp of the replay iframe. Is falsy if172 * operating in live mode173 */174ContentFrame.prototype.initBannerUpdateCheck = function(newUrl, newTs) {175 if (!this.wbBanner) return;176 var contentFrame = this;177 var replayIframeLoaded = function() {178 contentFrame.iframe.removeEventListener('load', replayIframeLoaded);179 contentFrame.checkBannerToId = setTimeout(function() {180 contentFrame.checkBannerToId = null;181 if (contentFrame.wbBanner.stillIndicatesLoading()) {182 contentFrame.wbBanner.updateCaptureInfo(183 newUrl,184 newTs,185 contentFrame.content_prefix.indexOf('/live') !== -1186 );187 }188 }, 2000);189 };190 if (this.checkBannerToId) {191 clearTimeout(this.checkBannerToId);192 }193 this.iframe.addEventListener('load', replayIframeLoaded);194};195/**196 * @desc Navigates the replay iframe to a newURL and if a banner is exposed197 * the initBannerUpdateCheck function is called.198 * @param {string} newUrl - The new URL of the replay iframe199 * @param {?string} newTs - The new timestamp of the replay iframe. Is falsy if200 * operating in live mode201 */202ContentFrame.prototype.load_url = function(newUrl, newTs) {203 this.iframe.src = this.make_url(newUrl, newTs, true);204 if (this.wbBanner) {205 this.initBannerUpdateCheck(newUrl, newTs);206 }207};208/**209 * @desc Updates this frames hash to the one inside the replay iframe210 * @param {Object} state - The contents of message received from the replay iframe211 */212ContentFrame.prototype.inner_hash_changed = function(state) {213 if (window.location.hash !== state.hash) {214 window.location.hash = state.hash;215 }216 this.last_inner_hash = state.hash;217};218/**219 * @desc Updates the hash of the replay iframe on a hash change in this frame220 * @param event221 */222ContentFrame.prototype.outer_hash_changed = function(event) {223 if (window.location.hash === this.last_inner_hash) {224 return;225 }226 if (this.iframe) {227 var message = { wb_type: 'outer_hashchange', hash: window.location.hash };228 this.iframe.contentWindow.postMessage(message, '*', undefined, true);229 }230};231/**232 * @desc Cleans up any event listeners added by the content frame233 */234ContentFrame.prototype.close = function() {235 window.removeEventListener('hashchange', this.outer_hash_changed);236 window.removeEventListener('message', this.handle_event);...

Full Screen

Full Screen

child.js

Source:child.js Github

copy

Full Screen

1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4"use strict";5const { isChildLoader } = require('./core');6if (!isChildLoader)7 throw new Error("Cannot load sdk/remote/child in a main process loader.");8const { Ci, Cc, Cu } = require('chrome');9const runtime = require('../system/runtime');10const { Class } = require('../core/heritage');11const { Namespace } = require('../core/namespace');12const { omit } = require('../util/object');13const { when } = require('../system/unload');14const { EventTarget } = require('../event/target');15const { emit } = require('../event/core');16const { Disposable } = require('../core/disposable');17const { EventParent } = require('./utils');18const { addListItem, removeListItem } = require('../util/list');19const loaderID = require('@loader/options').loaderID;20const MAIN_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;21const mm = Cc['@mozilla.org/childprocessmessagemanager;1'].22 getService(Ci.nsISyncMessageSender);23const ns = Namespace();24const process = {25 port: new EventTarget(),26 get id() {27 return runtime.processID;28 },29 get isRemote() {30 return runtime.processType != MAIN_PROCESS;31 }32};33exports.process = process;34function definePort(obj, name) {35 obj.port.emit = (event, ...args) => {36 let manager = ns(obj).messageManager;37 if (!manager)38 return;39 manager.sendAsyncMessage(name, { loaderID, event, args });40 };41}42function messageReceived({ data, objects }) {43 // Ignore messages from other loaders44 if (data.loaderID != loaderID)45 return;46 let keys = Object.keys(objects);47 if (keys.length) {48 // If any objects are CPOWs then ignore this message. We don't want child49 // processes interracting with CPOWs50 if (!keys.every(name => !Cu.isCrossProcessWrapper(objects[name])))51 return;52 data.args.push(objects);53 }54 emit(this.port, data.event, this, ...data.args);55}56ns(process).messageManager = mm;57definePort(process, 'sdk/remote/process/message');58let processMessageReceived = messageReceived.bind(process);59mm.addMessageListener('sdk/remote/process/message', processMessageReceived);60when(() => {61 mm.removeMessageListener('sdk/remote/process/message', processMessageReceived);62 frames = null;63});64process.port.on('sdk/remote/require', (process, uri) => {65 require(uri);66});67function listenerEquals(a, b) {68 for (let prop of ["type", "callback", "isCapturing"]) {69 if (a[prop] != b[prop])70 return false;71 }72 return true;73}74function listenerFor(type, callback, isCapturing = false) {75 return {76 type,77 callback,78 isCapturing,79 registeredCallback: undefined,80 get args() {81 return [82 this.type,83 this.registeredCallback ? this.registeredCallback : this.callback,84 this.isCapturing85 ];86 }87 };88}89function removeListenerFromArray(array, listener) {90 let index = array.findIndex(l => listenerEquals(l, listener));91 if (index < 0)92 return;93 array.splice(index, 1);94}95function getListenerFromArray(array, listener) {96 return array.find(l => listenerEquals(l, listener));97}98function arrayContainsListener(array, listener) {99 return !!getListenerFromArray(array, listener);100}101function makeFrameEventListener(frame, callback) {102 return callback.bind(frame);103}104var FRAME_ID = 0;105var tabMap = new Map();106const Frame = Class({107 implements: [ Disposable ],108 extends: EventTarget,109 setup: function(contentFrame) {110 // This ID should be unique for this loader across all processes111 let priv = ns(this);112 priv.id = runtime.processID + ":" + FRAME_ID++;113 priv.contentFrame = contentFrame;114 priv.messageManager = contentFrame;115 priv.domListeners = [];116 tabMap.set(contentFrame.docShell, this);117 priv.messageReceived = messageReceived.bind(this);118 priv.messageManager.addMessageListener('sdk/remote/frame/message', priv.messageReceived);119 this.port = new EventTarget();120 definePort(this, 'sdk/remote/frame/message');121 priv.messageManager.sendAsyncMessage('sdk/remote/frame/attach', {122 loaderID,123 frameID: priv.id,124 processID: runtime.processID125 });126 frames.attachItem(this);127 },128 dispose: function() {129 let priv = ns(this);130 emit(this, 'detach', this);131 for (let listener of priv.domListeners)132 priv.contentFrame.removeEventListener(...listener.args);133 priv.messageManager.removeMessageListener('sdk/remote/frame/message', priv.messageReceived);134 tabMap.delete(priv.contentFrame.docShell);135 priv.contentFrame = null;136 },137 get content() {138 return ns(this).contentFrame.content;139 },140 get isTab() {141 let docShell = ns(this).contentFrame.docShell;142 if (process.isRemote) {143 // We don't want to roundtrip to the main process to get this property.144 // This hack relies on the host app having defined webBrowserChrome only145 // in frames that are part of the tabs. Since only Firefox has remote146 // processes right now and does this this works.147 let tabchild = docShell.QueryInterface(Ci.nsIInterfaceRequestor)148 .getInterface(Ci.nsITabChild);149 return !!tabchild.webBrowserChrome;150 }151 else {152 // This is running in the main process so we can break out to the browser153 // And check we can find a tab for the browser element directly.154 let browser = docShell.chromeEventHandler;155 let tab = require('../tabs/utils').getTabForBrowser(browser);156 return !!tab;157 }158 },159 addEventListener: function(...args) {160 let priv = ns(this);161 let listener = listenerFor(...args);162 if (arrayContainsListener(priv.domListeners, listener))163 return;164 listener.registeredCallback = makeFrameEventListener(this, listener.callback);165 priv.domListeners.push(listener);166 priv.contentFrame.addEventListener(...listener.args);167 },168 removeEventListener: function(...args) {169 let priv = ns(this);170 let listener = getListenerFromArray(priv.domListeners, listenerFor(...args));171 if (!listener)172 return;173 removeListenerFromArray(priv.domListeners, listener);174 priv.contentFrame.removeEventListener(...listener.args);175 }176});177const FrameList = Class({178 implements: [ EventParent, Disposable ],179 extends: EventTarget,180 setup: function() {181 EventParent.prototype.initialize.call(this);182 this.port = new EventTarget();183 ns(this).domListeners = [];184 this.on('attach', frame => {185 for (let listener of ns(this).domListeners)186 frame.addEventListener(...listener.args);187 });188 },189 dispose: function() {190 // The only case where we get destroyed is when the loader is unloaded in191 // which case each frame will clean up its own event listeners.192 ns(this).domListeners = null;193 },194 getFrameForWindow: function(window) {195 let docShell = window.QueryInterface(Ci.nsIInterfaceRequestor)196 .getInterface(Ci.nsIDocShell);197 return tabMap.get(docShell) || null;198 },199 addEventListener: function(...args) {200 let listener = listenerFor(...args);201 if (arrayContainsListener(ns(this).domListeners, listener))202 return;203 ns(this).domListeners.push(listener);204 for (let frame of this)205 frame.addEventListener(...listener.args);206 },207 removeEventListener: function(...args) {208 let listener = listenerFor(...args);209 if (!arrayContainsListener(ns(this).domListeners, listener))210 return;211 removeListenerFromArray(ns(this).domListeners, listener);212 for (let frame of this)213 frame.removeEventListener(...listener.args);214 }215});216var frames = exports.frames = new FrameList();217function registerContentFrame(contentFrame) {218 let frame = new Frame(contentFrame);219}220exports.registerContentFrame = registerContentFrame;221function unregisterContentFrame(contentFrame) {222 let frame = tabMap.get(contentFrame.docShell);223 if (!frame)224 return;225 frame.destroy();226}...

Full Screen

Full Screen

workspace.js

Source:workspace.js Github

copy

Full Screen

1var menuOpen = false;2var menuTarget = false;3var menuIds = ["driveFileMenu"];4var pdfType = "google"; //Let this equal iframe, object, google or library5var drag = {6 file: "",7 startPos: [0,0],8 elemStartPos: [0,0],9 threshold: 15, //The number of pixels dragged before the element moves10}11function createTile(name,type,contentLink,service){12 //Name generation:13 var searchedType = mimeTypes.getExtension(type); //Turn mime types into their appropriate extensions14 if(searchedType != false){15 type = searchedType;16 }17 var tile = document.createElement("DIV");18 if(service === "googledrive"){19 tile.title = name;20 }21 else{22 tile.title = name+"."+type;23 }24 //Create tile25 $(tile).dialog({26 27 });28 tile.parentNode.className += " fileTile";29 //Content rendering:30 var contentHolder = document.createElement("DIV");31 contentHolder.className = "contentHolder";32 switch(type){ //Document-type specific rendering code33 case "pdf":34 var contentFrame;35 if(pdfType === "library"){36 contentFrame = document.createElement("CANVAS");37 contentFrame.className = "contentFrame";38 }39 else if(pdfType === "iframe"){40 contentFrame = document.createElement("IFRAME");41 contentFrame.className = "contentFrame";42 httpGetFile(contentLink,function(resp){43 if(resp != false){44 contentFrame.src = createUrl(resp,"application/pdf");45 }46 });47 }48 else if(pdfType === "object"){49 contentFrame = document.createElement("OBJECT");50 contentFrame.className = "contentFrame";51 var contentSource = document.createElement("EMBED");52 contentFrame.setAttribute("type","application/pdf");53 contentSource.setAttribute("type","application/pdf");54 httpGetFile(contentLink,function(resp){55 if(resp != false){56 var link = createUrl(resp,"application/pdf");57 contentFrame.setAttribute("data",link);58 contentSource.src = link;59 }60 });61 contentFrame.appendChild(contentSource);62 63 }64 else if(pdfType === "google"){65 if(service === "dropbox"){66 contentFrame = document.createElement("IFRAME");67 contentFrame.className = "contentFrame";68 contentFrame.src = "https://docs.google.com/viewer?url="+contentLink+"&embedded=true";69 }70 else{71 contentFrame = document.createElement("IFRAME");72 contentFrame.className = "contentFrame";73 contentFrame.src = contentLink;74 }75 }76 else{77 console.error("Invalid PDF type: " + String(pdfType));78 }79 break;80 81 case "doc":82 case "docx":83 case "xlsx":84 var contentFrame;85 if(service === "dropbox"){86 contentFrame = document.createElement("IFRAME");87 contentFrame.className = "contentFrame";88 contentFrame.src = "https://docs.google.com/viewer?url="+contentLink+"&embedded=true";89 }90 else{91 contentFrame = document.createElement("IFRAME");92 contentFrame.className = "contentFrame";93 contentFrame.src = contentLink;94 }95 96 break;97 98 default:99 var contentFrame = document.createElement("DIV");100 101 }102 console.info(type);103// var contentFrame = document.createElement("IFRAME");104// contentFrame.className = "contentFrame";105// contentFrame.src = contentLink;106 tile.appendChild(contentHolder);107 contentHolder.appendChild(contentFrame);108 if(pdfType === "library" && type === "pdf"){109 createPdf(contentLink,contentFrame); //Used for PDFJS110 }111 //Icon selection:112 var icon = document.createElement("IMG");113 icon.className = "fileIcon";114 switch(service){115 case "googledrive":116 icon.src = "../images/product16.png";117 break;118 119 case "dropbox":120 icon.src = "../images/drop16.png";121 break;122 123 case "onedrive":124 break;125 }126 contentHolder.parentNode.parentNode.children[0].insertBefore(icon,contentHolder.parentNode.parentNode.children[0].children[0]);127 var bgImg = "";128 switch(type){129 case "doc":130 case "docx":131 // bgImg = "../images/docBg.png";132 break;133 }134 //contentHolder.parentElement.parentElement.style.backgroundImage = "url('"+bgImg+"')";135 contentHolder.parentElement.parentElement.children[0].children[1].setAttribute("ondblclick","if(checkTarget(event)){toggleDialog(event);}");136 contentHolder.parentElement.parentElement.children[0].setAttribute("ondblclick","if(checkTarget(event)){toggleDialog(event);}");137}138function menu(event){139 targ = event.target;140 if(targ != document.body){141 menuOpen = true;142 menuTarget = targ;143 if($(targ).hasClass("fileOptionThumb") || $(targ).hasClass("fileOption")){ //Google File Options144 if($(targ).hasClass("fileOptionThumb")){145 menuTarget = targ.parentNode;146 }147 event.preventDefault();148 $("#driveFileMenu").css({149 left: String(event.clientX)+"px",150 top: String(event.clientY)+"px"151 });152 for(var menuNum in menuIds){153 $("#"+menuIds[menuNum]).hide();154 }155 $("#driveFileMenu").show();156 }157 else if(true){158 159 }160 else{161 162 }163 //164 return false;165 }166}167function checkClick(event){168 var clickedMenu = false;169 for(var menuNum in menuIds){170 if(document.getElementById(menuIds[menuNum]).contains(event.target)){171 clickedMenu = true;172 console.log("clicked menu!");173 }174 }175 if(!clickedMenu){176 for(var menuNum in menuIds){177 $("#"+menuIds[menuNum]).hide();178 }179 }180}181function createPdf(src,elem){182 httpGetFile(src,function(data){183 if(data != false){184 newUrl = createUrl(data,"application/pdf");185 PDFJS.getDocument(newUrl).then(function(newPdf){186 newPdf.getPage(1).then(function(newPage){187 var scale = 1;188 var viewport = newPage.getViewport(scale);189 var context = elem.getContext("2d");190 newPage.render({ 191 canvasContext: context, 192 viewport: viewport193 });194 });195 });196 }197 });198}199function createUrl(data,type){200 var blob = new Blob([data],{"type":"application/pdf"});201 var newUrl = URL.createObjectURL(blob);202 return newUrl;...

Full Screen

Full Screen

paper_common-1.2.js

Source:paper_common-1.2.js Github

copy

Full Screen

12var IE = false ;3if (window.navigator.appName.indexOf("Explorer") !=-1)4{5 IE = true;6}78function reSize()9{10 var ParentFrame = null;11 if(IE){12 ParentFrame = papermain.document.body;13 }else{14 ParentFrame = papermain.contentDocument.body;15 }16 var ContentFrame = document.all["papermain"];17 ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight) + 100;18 //ContentFrame.style.width = ParentFrame.scrollWidth + (ParentFrame.offsetWidth - ParentFrame.clientWidth);19 20}21function reSizeG()22{23 try24 {25 var ParentFrame = gameiframe.document.body;26 var ContentFrame = document.all["gameiframe"];27 ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight);28 //ContentFrame.style.width = ParentFrame.scrollWidth + (ParentFrame.offsetWidth - ParentFrame.clientWidth); 29 }catch(e){}30}31function reSizeF()32{33 var ParentFrame = papermain.document.body;34 var ContentFrame = document.all["papermain"];35 ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight);36 37}3839function reSize0()40{41 var ParentFrame = papermain.document.body;42 var ContentFrame = document.all["papermain"];43 ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight);44 //ContentFrame.style.width = ParentFrame.scrollWidth + (ParentFrame.offsetWidth - ParentFrame.clientWidth);4546 //parent.document.location.href = parent.document.location.href + '#';47}4849function reSize2(fno)50{51 try{52 var ParentFrame = null;53 if(IE){54 ParentFrame = eval("CommentFrm" + fno + ".document.body");55 }else{56 ParentFrame = document.getElementById("CommentFrm" + fno).contentDocument.body;57 }58 var ContentFrame = eval("document.all.CommentFrm" +fno);5960 ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight);61 parent.reSize0();62 }catch(e){}63}6465function reSize3(fno)66{67 68 var ParentFrame = eval("EventCommentFrm" + fno + ".document.body");69 var ContentFrame = eval("document.all.EventCommentFrm" +fno);7071 ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight);72 parent.reSize();73}74function reSize4(obj)75{76 var ParentFrame = eval(obj+".document.body");77 var ContentFrame = eval("document.all."+obj);78 ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight);79}8081function paperInit()82{83 parent.reSize();84 //parent.document.location.href = '#';85}86function paperInit2()87{88 parent.reSizeF();89 //parent.document.location.href = '#';90}91function paperInit_sub(fno)92{93 parent.reSize2(fno);94 //parent.document.location.href = parent.document.location.href + '#';95}96function paperInit_eventcomment(fno)97{98 parent.reSize3(fno);99 //parent.document.location.href = parent.document.location.href + '#';100}101102function strLenCk(str)103{104 var len = 0;105 for (var i=0;i<str.length; i++) {106 var n = str.charCodeAt(i);107 if ((n>= 0)&&(n<256)) {108 len ++;109 } else {110 len += 2;111 }112 }113 return len;114}115 ...

Full Screen

Full Screen

content.jsm

Source:content.jsm Github

copy

Full Screen

1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4"use strict";5const { utils: Cu, classes: Cc, interfaces: Ci } = Components;6const { Services } = Cu.import('resource://gre/modules/Services.jsm');7const cpmm = Cc['@mozilla.org/childprocessmessagemanager;1'].8 getService(Ci.nsISyncMessageSender);9this.EXPORTED_SYMBOLS = ["registerContentFrame"];10// This may be an overriden version of the SDK so use the PATH as a key for the11// initial messages before we have a loaderID.12const PATH = __URI__.replace('framescript/content.jsm', '');13const { Loader } = Cu.import(PATH + 'toolkit/loader.js', {});14// one Loader instance per addon (per @loader/options to be precise)15var addons = new Map();16// Tell the parent that a new process is ready17cpmm.sendAsyncMessage('sdk/remote/process/start', {18 modulePath: PATH19});20// Load a child process module loader with the given loader options21cpmm.addMessageListener('sdk/remote/process/load', ({ data: { modulePath, loaderID, options, reason } }) => {22 if (modulePath != PATH)23 return;24 // During startup races can mean we get a second load message25 if (addons.has(loaderID))26 return;27 options.waiveInterposition = true;28 let loader = Loader.Loader(options);29 let addon = {30 loader,31 require: Loader.Require(loader, { id: 'LoaderHelper' }),32 }33 addons.set(loaderID, addon);34 cpmm.sendAsyncMessage('sdk/remote/process/attach', {35 loaderID,36 processID: Services.appinfo.processID,37 isRemote: Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT38 });39 addon.child = addon.require('sdk/remote/child');40 for (let contentFrame of frames.values())41 addon.child.registerContentFrame(contentFrame);42});43// Unload a child process loader44cpmm.addMessageListener('sdk/remote/process/unload', ({ data: { loaderID, reason } }) => {45 if (!addons.has(loaderID))46 return;47 let addon = addons.get(loaderID);48 Loader.unload(addon.loader, reason);49 // We want to drop the reference to the loader but never allow creating a new50 // loader with the same ID51 addons.set(loaderID, {});52})53var frames = new Set();54this.registerContentFrame = contentFrame => {55 contentFrame.addEventListener("unload", () => {56 unregisterContentFrame(contentFrame);57 }, false);58 frames.add(contentFrame);59 for (let addon of addons.values()) {60 if ("child" in addon)61 addon.child.registerContentFrame(contentFrame);62 }63};64function unregisterContentFrame(contentFrame) {65 frames.delete(contentFrame);66 for (let addon of addons.values()) {67 if ("child" in addon)68 addon.child.unregisterContentFrame(contentFrame);69 }...

Full Screen

Full Screen

WebMenuFramed.js

Source:WebMenuFramed.js Github

copy

Full Screen

1var hideDelay = 100;2var menucount = 0;3var ua = navigator.userAgent;4var opera = /opera [56789]|opera\/[56789]/i.test(ua);5var moz = !opera && /gecko/i.test(ua);6function WebMenu() {7 this.topFrame = 0;8 this.contentFrame = 1;9 if (arguments.length > 0) {10 this.topFrame = arguments[0];11 if (arguments.length > 1) {12 this.contentFrame = arguments[1];13 }14 }15 this.name = "WebMenu_" + menucount++;16 this.obj = this.name;17 eval(this.obj + "=this");18}19WebMenu.prototype.show = function(caller, id) {20 if (!parent) return;21 if (!parent.frames[this.contentFrame].resetHiding) return;22 parent.frames[this.contentFrame].resetHiding();23 parent.frames[this.contentFrame].ShowMenu(caller, id);24}25WebMenu.prototype.hide = function(e, id) {26 if (!parent) return;27 if (!moz) {28 target = e.toElement;29 } else {30 target = e.target;31 }32 if (!parent.frames[this.contentFrame].HideMenu) return;33 parent.frames[this.contentFrame].HideMenu(target, id);34}35WebMenu.prototype.contains = function(el) {36 if (el != null) {37 if (!moz) {38 return document.body.contains(el);39 } else {40 found = false;41 for (i = 0; i < document.documentElement.childNodes; i++) {42 if (document.documentElement.childNodes[i] = target) {43 found = true;44 break;45 }46 }47 return found;48 }49 }50 return false;51}52WebMenu.prototype.blur = function(e) {53 if (!parent.frames[this.contentFrame].HideAll) return;54 if (!moz) {55 src = e.srcElement;56 target = e.toElement;57 } else {58 src = e.target;59 target = e.target;60 }61 if ((src.tagName.toLowerCase() == "table") && (src.className.toLowerCase() == "menubar")) {62 if (this.contains(target)) {63 if (parent != null) {64 parent.frames[this.contentFrame].HideAll();65 }66 }67 } else {68 if (parent != null) {69 parent.frames[this.contentFrame].HideAll();70 }71 }72}73WebMenu.prototype.selectMenu = function(submenu) {74 var links = document.getElementsByTagName("a");75 for (var i = 0; i < links.length; i++) {76 if (links[i].getAttribute("submenu") != null) {77 if (links[i].getAttribute("submenu") == submenu) {78 links[i].className = "menubar-selected";79 links[i].setAttribute("selected", "true");80 } else {81 links[i].className = null;82 links[i].setAttribute("selected", null);83 }84 }85 }86}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 const frame = await page.contentFrame();6 const elementHandle = await frame.$('#hplogo');7 await elementHandle.screenshot({path: 'hplogo.png'});8 await browser.close();9})();10const puppeteer = require('puppeteer');11(async () => {12 const browser = await puppeteer.launch({headless: false});13 const page = await browser.newPage();14 await page.waitForSelector('#hplogo');15 await page.screenshot({path: 'hplogo.png'});16 await browser.close();17})();18const puppeteer = require('puppeteer');19(async () => {20 const browser = await puppeteer.launch({headless: false});21 const page = await browser.newPage();22 await page.waitForXPath('/html/body/div/div[2]/form/div[2]/div[1]/div[1]/div/div[2]/input');23 await page.screenshot({path: 'hplogo.png'});24 await browser.close();25})();26const puppeteer = require('puppeteer');27(async () => {28 const browser = await puppeteer.launch({headless: false});29 const page = await browser.newPage();30 await page.waitFor(1000);31 await page.screenshot({path: 'hplogo.png'});32 await browser.close();33})();34const puppeteer = require('puppeteer');35(async () => {36 const browser = await puppeteer.launch({headless: false});37 const page = await browser.newPage();38 await page.waitForNavigation();39 await page.screenshot({path: 'hplogo.png'});40 await browser.close();41})();

Full Screen

Using AI Code Generation

copy

Full Screen

1(async () => {2 const browser = await puppeteer.launch();3 const page = await browser.newPage();4 await page.pdf({path: 'example.pdf', format: 'A4'});5 await browser.close();6})();7(async () => {8 const browser = await puppeteer.launch();9 const page = await browser.newPage();10 await page.pdf({path: 'example.pdf', format: 'A4'});11 await browser.close();12})();13(async () => {14 const browser = await puppeteer.launch();15 const page = await browser.newPage();16 await page.pdf({path: 'example.pdf', format: 'A4'});17 await browser.close();18})();19(async () => {20 const browser = await puppeteer.launch();21 const page = await browser.newPage();22 await page.pdf({path: 'example.pdf', format: 'A4'});23 await browser.close();24})();25(async () => {26 const browser = await puppeteer.launch();27 const page = await browser.newPage();28 await page.pdf({path: 'example.pdf', format: 'A4'});29 await browser.close();30})();31(async () => {32 const browser = await puppeteer.launch();33 const page = await browser.newPage();34 await page.pdf({path: 'example.pdf', format: 'A4'});35 await browser.close();36})();37(async () => {38 const browser = await puppeteer.launch();39 const page = await browser.newPage();40 await page.pdf({path: 'example.pdf', format: 'A4'});41 await browser.close();42})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async() => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 const frame = await page.mainFrame();6 const contentFrame = frame.childFrames()[0];7 console.log(await contentFrame.content());8 await browser.close();9})();10const puppeteer = require('puppeteer');11(async() => {12 const browser = await puppeteer.launch();13 const page = await browser.newPage();14 const frame = await page.mainFrame();15 const contentFrame = frame.childFrames()[0];16 console.log(await contentFrame.content());17 await browser.close();18})();19const puppeteer = require('puppeteer');20(async() => {21 const browser = await puppeteer.launch();22 const page = await browser.newPage();23 const frame = await page.mainFrame();24 const contentFrame = frame.childFrames()[0];25 console.log(await contentFrame.content());26 await browser.close();27})();28const puppeteer = require('puppeteer');29(async() => {30 const browser = await puppeteer.launch();31 const page = await browser.newPage();32 const frame = await page.mainFrame();33 const contentFrame = frame.childFrames()[0];34 console.log(await contentFrame.content());35 await browser.close();36})();37const puppeteer = require('puppeteer');38(async() => {39 const browser = await puppeteer.launch();40 const page = await browser.newPage();41 const frame = await page.mainFrame();42 const contentFrame = frame.childFrames()[0];43 console.log(await contentFrame.content());44 await browser.close();45})();46const puppeteer = require('puppeteer');47(async() => {48 const browser = await puppeteer.launch();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 const frame = await page.frames().find(f => f.name() === 'contentFrame');6 await frame.click('#gbqfb');7 await page.waitFor(5000);8 await browser.close();9})();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Puppeteer 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