JavaScript - Executing Simple .js File
Hi all,
I'm a beginner in javascript so, i was trying to execute a single simple .js file that should retrieve a value from a sql server db and display it in a popup window like the following: var Statement = "SELECT coalesce(TotalWork,0) AS TotalWork FROM dual as x left outer join (SELECT 1 as Y,CONVERT(INT, SUM(MSP_TimesheetActual.ActualWorkBillable)) AS TotalWork FROM MSP_EpmResource LEFT OUTER JOIN MSP_TimesheetResource INNER JOIN MSP_TimesheetActual ON MSP_TimesheetResource.ResourceNameUID = MSP_TimesheetActual.LastChangedResourceNameUID ON MSP_EpmResource.ResourceUID = MSP_TimesheetResource.ResourceUID LEFT OUTER JOIN MSP_TimesheetPeriod INNER JOIN MSP_Timesheet ON MSP_TimesheetPeriod.PeriodUID = MSP_Timesheet.PeriodUID ON MSP_TimesheetResource.ResourceNameUID = MSP_Timesheet.OwnerResourceNameUID WHERE (MSP_EpmResource.ResourceNTAccount = 'INTERCOM\%username%') AND (MSP_TimesheetActual.TimeByDay BETWEEN MSP_TimesheetPeriod.StartDate AND MSP_TimesheetPeriod.EndDate) GROUP BY MSP_TimesheetPeriod.StartDate, MSP_TimesheetPeriod.EndDate HAVING (MSP_TimesheetPeriod.StartDate <= DATEADD(d, - 7, GETDATE())) AND (MSP_TimesheetPeriod.EndDate >= DATEADD(d, - 7, GETDATE()))) as y on x.x=y.Y"; var Connection = new ActiveXObject('ADODB.Connection'); var Recordset = new ActiveXObject('ADODB.Recordset'); var Shell = new ActiveXObject('WScript.Shell'); Connection.Open('Data Source={servername};Initial Catalog={database name};User ID={username};Password={password};Provider=SQLOLEDB'); Recordset.Open(Statement, Connection); Recordset.MoveFirst(); while (!Recordset.EOF) { Shell.Popup(Recordset('TotalWork'), 0, 'Message', 48); Recordset.MoveNext(); } Recordset.Close(); Connection.Close(); but for some reasons it returns 0 and while i'm trying to run the query on sql server it returns the correct value does anybody have an idea about where the error may be ?? thanks in advance Similar Tutorialsi have this code: Code: if (($has_freechat1['confirmed'] == 1) && ($has_freechat2['confirmed'] == 1)) { $was_clicked = 0; ?> <a href="freechatcontacts.php?id=<?php echo $id_to.$was_clicked; ?>" class="charcoal_link" style="line-height: 20px;" name="message" id="message" onClick="return send('<?php echo $was_clicked;?> return false;')"> <?php echo $uniqueCode1?><span class="pink_text"><?php echo $uniqueCode2?></span><?php echo $uniqueCode3?> </a> <?php if ($was_clicked == 1) { ?> <tr> <td><input name="password" type="textarea" rows="10" cols="20" value="<?php echo $aCleanPost['message']['value']?>" /></td> </tr> <tr> <td><br /><input name="cmdSubmit" type="submit" value="Send" /><br/> </td> </tr> <?php } } then i have my JS:; and this is not executing because even though i clicked on my link, $was_clicked stays 0???? Code: <script type="text/JavaScript"> function send(val) { val = 1; //was clicked return val; } window.reload(); </script> what am i doing wrong please help? thank you i have this line: Code: echo $new_mail_cnt = '<script type="text/javascript">getMessages();</script>'; then have: Code: <script language="JavaScript" type="text/javascript"> var receiveReq = getXmlHttpRequestObject(); var mTimer; function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object.' + 'Consider upgrading your browser.'; } } function getMessages() { receiveReq = getXmlHttpRequestObject(); if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { receiveReq.open("POST", 'getMessage.php', true); receiveReq.onreadystatechange = handleReceiveMessage(); receiveReq.send(null); document.getElementById('new_messages').innerHTML = receiveReq.responseXML; //not sure here } mTimer = setTimeout('getMessage();',2000); } function handleReceiveMessage() { if (receiveReq.readyState == 4) { var chat_div = document.getElementById('div_chat'); var xmldoc = receiveReq.responseXML; var message_nodes = xmldoc.getElementsByTagName("message"); } } </script> all i need to do is update/refresh $new_mail_cnt so user can see when new messages come in, but getMessages() does not execute because no alerts pop up??? i dont understand please help? thank you var action = method+'sometexthere' submit eval('action') Hi, Here is something i was digging up but i stop after 3 hours of interpreting the code... (The code is inaccurate) What i was trying to get was load up a page and pass a javascript example: 1) load www.mysite.com 2) pass javascript using javascript: The problem that i'm facing is +action+ isn't define after the page was load up and i can't seem to validate by passing vars into the browser. example: javascript:document.write('<script>var desc = 10; var offx = 10; var offy = 10</script>') I'm a bit vague here, i will post more info later... See the code below, the alert is displayed when the page is loaded. It should only display when the image is moused over... Code: <script type="text/javascript"> addEvent(document.getElementById('snake'), "mouseover", fadeByid(this)); //This function attaches events to elements. function addEvent( elm, evt, fun ) { if ( elm.addEventListener ) { elm.addEventListener( evt, fun, false ); } else if ( elm.attachEvent ) { elm.attachEvent( 'on' + evt, fun ); } else { elm [ 'on' + evt ] = fun; } }; //Image fade, for the main front navigation function fadeByid(objId) { alert("wtf"); if (document.getElementById) { obj = document.getElementById(objId); opacity = obj.style.opacity; alert(opacity); if (opacity >= 100) { setOpacity(obj, opacity); opacity -= 10; window.setTimeout("fadeByid('"+objID+"','"+opacity+")", 100); } } } What's wrong with it? :/ i have this line in my code: PHP Code: echo '<a href="" onClick="yesnolist()">Free Chat</a>'; then at the top i have: Code: <? php //have some php here ?> <div class="innerContainer"> <head> <script type="text/JavaScript"> function yesnolist(val) { alert("lakjsd"); var e = confirm('Do you want to send a free chat request?'); if (e == true) { window.location.href = "http://www-rainbowcode-mobi/confirmfreechat.php"; window.location('http://www-rainbowcode-mobi/confirmfreechat.php'); return true; } else return false; } </script> </head> <span class="headings2">CONTACTS</span> //and more code after this echo '<a href="" onClick="yesnolist()">Free Chat</a>'; why is it not doing my onClick()?? please help? thanks Hi there! I set up a variable that should replace HTML code when run but it doesn't seem to be doing that... Here it is: Code: var finale = "document.getElementById(" + theid + ").innerHTML='test';"; eval("finale"); Any idea why? (My console isn't showing any issues) Thanks! Matt Hello, I have stack of images arrange one behind another, when ever i click on them current image should flip down, image is flipping down but its parent container is staying at same position. Due to that i am not able to perform action on other images. i have chosen the option of providing lesser z index value to parent element so that it will not cause problem to perform event on other images. But still it is not working. I am able to add z index value but when running the code both flipping and adding z index to parent is executing at one time. Due to that animation is not coming in a right way. i want to know, How i can execute code one after another, example when flipping image is completed then only i want to add z index value to parent element (f1_container) SO that it will not cause problem for other images. Please help <div id="f1_container" class="f1_container"> <div id="f1_card" class="shadow"> <div class="front face"> <img src="img/8.jpg"/> </div> <div class="back face center"> <img src="img/1.jpg"/> </div> </div> </div> var flipImage=document.querySelectorAll('.shadow'); for(j=0; j<flipImage.length; j++){ var currentFlipImage=flipImage[j]; currentFlipImage.addEventListener('click', function(event){ var currentElement=event.currentTarget; //this should be executed first currentElement.style.webkitTransform='rotateX(-120deg)'; and this one should execute after flipping is completely done this.parentNode.style.zIndex=-100; },false); } I have a secure server that I want users to be able to execute sinple .cmd files by clicking in a button on a web form. I am very new to this and kindly ask for some guidance. When I click on the button I get a error on page at the bottom of the window and the file the .cmd should create is not. Here is what I have so far: <HTML><HEAD><SCRIPT type="text/javascript" LANGUAGE="JavaScript"> function run(file) { var ws = new ActiveXObject("WScript.Shell"); ws.run(file); }</SCRIPT></HEAD> <BODY> <FORM name="Form1"><CENTER> <BR><img src="../icons/HelpDesk_logo.png" alt="OIT Support and Operations" height="100" Width="525"/> <BR> <H1>Reset Reader MGR in CS Gold </H1> <BR>This site is to be used only when all the readers contained in a single MGR have gone offline. Confirm this by using the Gold Reader Status screen.<BR><BR> <B> DO NOT USE THIS IF ALL READERS ARE OFFLINE. CALL PSIG STAFF ASAP!</B><BR><BR> Please select the appropriate MGR to bounce from the list below.<BR> Once you click the correct button please verify that the readers are now online using the Gold Reader Status screen.. If the readers do not come back online contact the AIS PSIG representative.<BR><BR> <B>ONLY CKICK THE BUTTON ONCE</B> <BR> <BR> <Input type="Button" name="Bounce Aero MGR" value="Bounce Aero MGR" onClick="run('D:\bounce_mgrs\BounceMGR2200-Aero.cmd')"/> <BR><BR> <Input type="Button" name="Bounce Copier MGR" value="Bounce Copier MGR" onClick="run('D:\bounce_mgrs\BounceMGR2400-Aero.cmd')"/> <BR><BR> <Input type="Button" name="Bounce Micros_Default MGR" value="Bounce Micros_Default MGR" onClick="run('D:\bounce_mgrs\BounceMGR2600-Aero.cmd')"/> <BR><BR> <Input type="Button" name="Bounce Micros_A MGR" value="Bounce Micros_A MGR" onClick="run('D:\bounce_mgrs\BounceMGR2800-Aero.cmd')"/> <BR><BR> <Input type="Button" name="Bounce Micros_B MGR" value="Bounce Micros_Bo MGR" onClick="run('D:\bounce_mgrs\BounceMGR3000-Aero.cmd')"/> <BR><BR> <Input type="Button" name="Bounce XML MGR" value="Bounce XML MGR" onClick="run('D:\bounce_mgrs\BounceMGR3400-Aero.cmd')"/> <BR><BR> <Input type="Button" name="Bounce Vending MGR" value="Bounce Vending MGR" onClick="run('D:\bounce_mgrs\BounceMGR3600-Aero.cmd')"/> </CENTER> </BODY> </FORM> </HTML> Thank you. Code: function displayResult() { var damn = document.getElementById("textyar").value; document.getElementById("oneforty").innerHTML = damn; var newDIV = document.createElement('div'); newDIV.className = "tweets"; var newspan =document.createElement('span'); newspan.className = "imagespanleft"; var img = document.createElement("IMG"); img.className="image"; img.src = "tweets/me.jpg"; newDIV.innerHTML = document.getElementById('textyar').value; document.getElementById('leftmaindiv').appendChild(newDIV).appendChild(newspan).appendChild(img); } this is the code , i m trying to create an interface like twitter where u put in text box and tweet appears below in problem is it is creating two divs instead of one , i tried insertbefore() as well but same behaviour plz ask any questions if u r still not clear I'm attempting to run a small piece of code that will execute one of two source js files on my server. I have no problem creating the proper DOM script object with the proper type and conditional src value. However, when i add it to the document it does not seem to execute. I've tried adding it in two places, both using .appendChild(); myLocation.parentNode.appendChild(newScript); and document.getElementsByTagName("head")[0].appendChild(newScript); (myLocation is a calculated element representing the current script tag) In both these cases, the script tag is added to the document where I intended, but it does not appear to execute. The src has some doc writes in it and the tags the new script should generate right after itself are not there, as they are when I hard code the new sourced script tag into the document. All in all, my confusion comes from the fact that when I write a <script ... src="mysrc.js"></script> into my document, it behaves differently than when I have a script write an identical tag into the document in the same location. Also, fyi, I'm currently using Chrome (though I will require a multi-platform solution). Thanks for your time. I have been using Perl code for about 15 years and I develop/support Perl code used by engineers who run this code in Linux terminals. The code uses Tk as the user interface, which in turn executes Perl scripts. We are looking into the possibility of putting the user interface in a web browser, which would (somehow) still run the same scripts on a Linux box. I can write a Perl script that, given a Linux machine name, user name and password, can open a connection to that machine and execute anything on that machine. My question: Can this sort of thing be done via a web page? This is posted in the JS forum because JS seems like it would provide the tools to create the type of interactive user interface I require. (I don't know a thing about JS, at the moment I'm trying to decide which language to use to implement my s/w, but first I need to determine if the language can do what I need.) I have three buttons on my form. The user has to be logged in for the buttons to do anything. Is it possible to get an alert to popup on the form page without the form action occuring? If so, how do I go about it?
hi. i'm using this script to replace text on a page loaded into another frame, called 'booker'. the script works when i use it on the same page, but i can't seem to get it to reference the other frame for some reason. it executed with 'body OnLoad' any ideas for what i'm doing wrong? thanks. Code: function myscript() { input = 'Membership'; output='Service Fee'; top.booker.document.body.innerHTML = top.booker.document.body.innerHTML.replace(input,output); Hey. I'm working on a simple slideshow made with jQuery, and i need some help now. What i'm trying to do now, is to make it change image every X second. I know how to change image, but i'm kind of stuck trying to find out how to make it "do something" every Xth second... i hope you understand what i mean. Here's an example: (obviously not working..) Code: function slideSwitch() { //change image... } setInterval(slideSwitch, 5000); //make the function slideSwitch execute every 5th second. If anyone could help me out here, i'd really appreciate it! Also, is there any "else if" function in jQuery? Like in for example PHP, you can use "if", "else if" and "else".. like this: Code: if(){ }else if(){ }else { } So is there any function like that? I googled it, and i found out i have to use some kind of plugin for it to work? How do i use it? Thanks in advance, -Nike Hi, I am new to programming and I am trying to write a code that will time how long it takes for you to write a word. First you input the word you would like to write, and than after you have pressed enter I want the program to "feel" when you start writing the word, at that point the timer should start. And then it shall know when you have completed the word and in that moment stop the timer. I have a built a timer that works fine, see startCounter() but i want it to be executed as i described above... This is the code: Code: <div> <div class="inputBox"> <input id="textBox" type="text" placeholder=" What word would you like to time?" onKeydown="Javascript: if (event.keyCode==13) hello();"> <input type="button" value="RushWrite" id="Btn" onclick="hello()"></input> <script> function hello() { if (textBox.value != "") { var wordInput = document.getElementById("textBox").value; document.getElementById("textBox").placeholder=" Let's RushWrite: "+wordInput; textBox.value = ""; document.getElementById("Btn").value="GoGo!"; document.getElementById("time").innerHTML="00.00"; }; } </script> <button id="time" type="text"></button> <script> function startCounter(){ var counter = 0; setInterval(function () { ++counter; document.getElementById("time").innerHTML=(counter); }, 1000); }; </script> <script> </script> </div> </div> Thankful for any advise! I am doing a project in which I have to automatically download a file from a secured website by providing a username and password for which I am using "Selenium" with "Python 3.4.1" in Windows 7 x86_64 environment. The website is written using "JavaScript". And I don't have any practical working knowledge of JavaScript. I know Java but not JavaScript. So far, I have done this in Python: Code: from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Firefox() driver.get("http://www.website_name.com") element_user_name = driver.find_element_by_id("userid") element_user_name.send_keys("user_name") element_passwd = driver.find_element_by_id("password") element_passwd.send_keys("some_passwd") elem = driver.find_element_by_id("submit") elem.send_keys(Keys.RETURN) After this code snippet, I am successfully directed to the home screen of the website. But now, I hit the snag. The source code of the website contains JavaScript functions which do not contain the code of the elements on the page which I want to manipulate. The main page contains code for user authentication, invalidate client and the likes of it. But when I right click on an element on the Home page, I get to see their source codes in a separate window (in Firefox 32). The source code of the element which I want to use "Favorites and Dashboards": Code: <!DOCTYPE html> <html id="ext-gen3" class=" ext-strict x-viewport" decorator="blank" webdriver="true"> <head></head> <body id="ext-gen4" class="ext-gecko3 cwc-view x-border-layout-ct" onload="cwc.getFrameworkWindow()"> <div id="cwc_header" class=" masthead x-border-panel" style="left: 0px; top: 0px; width: 1366px; height: 27px;"></div> <div id="cwcNavPanel" class=" x-panel cwc-navPanel x-border-panel" style="width: 220px; left: 0px; top: 56px;"> <div id="ext-gen17" class="x-panel-bwrap"> <div id="ext-gen18" class="x-panel-tbar x-panel-tbar-noheader" style="width: 220px;"></div> <div id="ext-gen19" class="x-panel-body x-panel-body-noheader" style="width: 220px; height: 323px;"> <div id="cwcAccordionNav" class=" x-panel x-panel-noborder" style="width: 218px;"> <div id="ext-gen48" class="x-panel-bwrap"> <div id="ext-gen49" class="x-panel-body x-panel-body-noheader x-panel-body-noborder" style="overflow: auto; width: 218px; height: 321px;" role="navigation"> <div id="ROOT/Favorites and Dashboards" class="x-panel x-panel-noborder x-tree" style="width: auto;"> <div id="ext-gen76" class="x-panel-header x-panel-header-noborder x-unselectable x-accordion-hd" style="cursor: pointer;" tabindex="0" role="tab" aria-expanded="true"></div> <div id="ext-gen77" class="x-panel-bwrap" style="display: block; visibility: visible; position: static; left: 0px; top: 0px; z-index: auto;"> <div id="ext-gen78" class="x-panel-body x-panel-body-noborder" style="width: auto; height: auto;"> <ul id="ext-gen79" class="x-tree-root-ct x-tree-arrows" role="group"> <div class="x-tree-root-node"> <li class="x-tree-node"></li> <li class="x-tree-node"></li> <li class="x-tree-node"></li> <li class="x-tree-node"></li> <li class="x-tree-node"></li> <li class="x-tree-node"></li> <li id="ext-gen447" class="x-tree-node"> <div id="ROOT/Favorites and Dashboards/6" class="x-tree-node-el x-unselectable x-tree-node-collapsed" unselectable="on" ext:tree-node-id="ROOT/Favorites and Dashboards/6"> <span class="x-tree-node-indent"></span> <img id="ext-gen94" class="x-tree-ec-icon x-tree-elbow-plus" src="/sm/default/s.gif" alt=""></img> <img class="x-tree-node-icon cwc-tree-noIcon-node" unselectable="on" src="/sm/default/s.gif" alt=""></img> <a id="ext-gen95" class="x-tree-node-anchor" tabindex="0" href="" role="treeitem" hidefocus="on" aria-expanded="false"> In this snippet, I want to click on "Favorites and Dashboards". How do I do it? Thanks for your help! Hi! I'm trying to run this script on Firefox. I'm copying and pasting the whole thing in here just to be safe, but I'm mostly concerned with getting the findLegendary function to call catchPok(). The script executes fine, goes into the battle, but then...does nothing. It runs the catchPok function if I manually click and deselect the "Find Legendary" window option, so alternately, if somebody knows how to make the program automatically click the element at that point to stop repeating the function (maybe?) and it works, I'd be just as happy with that. My best guess is that the autoContinue function might be interfering somehow, since it runs that portion of the code with the manual findLegendary shutoff, but to be honest I'm pretty clueless. What I want it to do is run the catch function through, catch the game pixel, and then go back to repeating. I don't care how this is accomplished as long as it can feasibly loop. The game rules allow botting, so this isn't against any site rules, either. Any and all help/advice is much appreciated! Code: // ==UserScript== // @name Pokemon Vortex Tool // @namespace vortexrising.tk // @include http://*pokemonvortex.org/* // @exclude http://*pokemonvortex.org/adv.php* // ==/UserScript== var legends = [ // Custom // Grass 'Shaymin (Sky)', 'Celebi', 'Latios', 'Latias', 'Rayquaza', 'Shaymin', 'Mew', 'Cresselia', 'Azelf', 'Uxie', 'Mesprit', 'Virizion', 'Genesect', // Grass (water) 'Manaphy', 'Phione', 'Suicune', 'Keldeo', // Ice 'Articuno', 'Suicune', 'Lugia', 'Regice', 'Kyurem', // Cave (land) 'Groudon', 'Arceus', 'Regigigas', 'Palkia', 'Dialga', 'Deoxys', 'Jirachi', 'Registeel', 'Regirock', 'Mewtwo', 'Cobalion', 'Terrakion', 'Virizion', 'Reshiram', 'Zekrom', 'Kyurem', 'Genesect', 'Tornadus', 'Landorus', // Cave (water) 'Kyogre', 'Lugia', 'Keldeo', // Ghost 'Mew', 'Giratina', 'Rotom', 'Mesprit', 'Azelf', 'Uxie', 'Celebi', 'Darkrown', 'Darkrai', // Electric 'Zapdos', 'Raikou', 'Jirachi', 'Darkrai', 'Darkrown', 'Thundurus', 'Zekrom', 'Genesect', // Fire 'Heatran', 'Ho-oh', 'Moltres', 'Entei', 'Reshiram', 'Victini' ]; var settings = { 'keys': ['autoBattle', 'findRare', 'findLegendary','catchPok','findNewpoke'], 'data': {}, 'save': function() { for (var i = 0; i < this.keys.length; i++) { GM_setValue(this.keys[i], this.data[this.keys[i]]); } }, 'load': function() { for (var i = 0; i < this.keys.length; i++) { this.data[this.keys[i]] = GM_getValue(this.keys[i], false); } } }; var movPos = 0; function moveAround() { movPos += 10; if (movPos > 360) { movPos = 0; } var xpos = parseInt(Math.sin(movPos * (Math.PI / 180))*10); var ypos = parseInt(Math.cos(movPos * (Math.PI / 180))*10); unsafeWindow.PlayRequest(xpos + 14, ypos + 14, parseInt(Math.random()*8)+1); /* var btnArrow = unsafeWindow.document.querySelector('#arrows img[onclick]') if (btnArrow) { btnArrow.click(); } else { unsafeWindow.console.info('No buttons?'); }*/ } function catchPok() { try { var btnPo = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue"]'); if (btnPo) { btnPo.click(); } var radMaster = unsafeWindow.document.querySelector('#itemForm input[type="radio"][value="Master Ball"]'); if (radMaster) { radMaster.click(); } var btnItem = unsafeWindow.document.querySelector('#itemForm input[type="submit"][value="Use Item"]'); if (btnItem) { btnItem.click(); } var btnCont2 = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue!"]'); if (btnCont2) { btnCont2.click(); } var linkReturnToMap = unsafeWindow.document.querySelector('.optionsList a'); if (linkReturnToMap && linkReturnToMap.textContent.trim() == 'Return to the Map') { settings.data.nextBattle = new Date().getTime() + 10000; unsafeWindow.location.href = linkReturnToMap.href; } }catch (e) { unsafeWindow.console.warn('Exception: ', e); } } function findNewpoke() { var aPoke = unsafeWindow.document.querySelector('#appear p'); var oldPoke = unsafeWindow.document.querySelector('#appear strong'); var searchPoke = unsafeWindow.document.querySelector('#alert p') if (!aPoke) { moveAround(); return; } else if (oldPoke) { moveAround(); return; } else if (searchPoke) { moveAround(); return; } else { var btnDo = unsafeWindow.document.querySelector('input[type="submit"][value="Battle!"]'); if (btnDo) { btnDo.click(); } catchPok(); return; } } function findLegendary() { var wildText = unsafeWindow.document.querySelector('#appear p'); if (!wildText) { moveAround(); return; } wildText = wildText.textContent.trim(); for (var i = 0; i < legends.length; i++) { if (wildText.match(legends[i])) { var btnDo = unsafeWindow.document.querySelector('input[type="submit"][value="Battle!"]'); if (btnDo) { btnDo.click(); } catchPok(); return; } } moveAround(); } function findRare() { var wildText = unsafeWindow.document.querySelector('#appear p'); if (!wildText) { moveAround(); return; } wildText = wildText.textContent.trim(); if (!wildText.match(/Wild (Shiny|Shaymin (Sky)|Celebi|Latios|Latias|Rayquaza|Shaymin|Mew|Cresselia|Azelf|Uxie|Mesprit|Virizion|Genesect|Manaphy|Phione|Suicune|Keldeo|Articuno|Lugia|Regice|Kyurem|Groudon|Arceus|Regigigas|Palkia|Dialga|Deoxys|Jirachi|Registeel|Regirock|Mewtwo|Cobalion|Terrakion|Reshiram|Zekrom|Tornadus|Landorus|Kyogre|Giratina|Rotom|Zapdos|Raikou|Darkrai|Darkrown|Thundurus|Heatran|Ho-oh|Moltres|Entei|Victini)/)) { moveAround(); return; } unsafeWindow.console.info('Rare found ', wildText); } function autoBattle() { try { var btnContinue = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue"]'); if (btnContinue) { btnContinue.click(); } var btnContinue2 = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue!"]'); if (btnContinue2) { btnContinue2.click(); } var btnAttack = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Attack!"]'); if (btnAttack) { btnAttack.click(); } var linkReturnToMap = unsafeWindow.document.querySelector('.optionsList a'); if (linkReturnToMap && linkReturnToMap.textContent.trim() == 'Return to the Map') { settings.data.nextBattle = new Date().getTime() + 10000; unsafeWindow.location.href = linkReturnToMap.href; } // check for battle button var btnBattle = unsafeWindow.document.querySelector('#appear form input[type="submit"][value="Battle!"]'); var linkRebattle = unsafeWindow.document.querySelector('.optionsList a'); if (btnBattle) { // wait until 10 seconds since last battle //var delay = GM_getValue('lastBattle'); window.setTimeout(function() { btnBattle.click(); }, 10000); } else if (linkRebattle && linkRebattle.textContent.trim() == 'Rebattle Opponent') { window.setTimeout(function() { unsafeWindow.location.href = linkRebattle.href; }, 10000); } else { // if not found, click a direction var btnArrow = unsafeWindow.document.querySelector('#arrows img[onclick]') console.info('arrow', btnArrow); if (btnArrow) { btnArrow.click(); } } } catch (e) { unsafeWindow.console.warn('Exception: ', e); } } function autoContinue() { if (settings.data.findRare) { findRare(); } if (settings.data.autoBattle) { autoBattle(); } if (settings.data.findLegendary) { findLegendary(); } if (settings.data.catchPok) { catchPok(); } if (settings.data.findNewpoke) { findNewpoke(); } } unsafeWindow.AjaxRequest = function () { if (!this.xmlhttp) { try { // Try to create object for Firefox, Safari, IE7, etc. this.xmlhttp = new XMLHttpRequest(); } catch (e) { try { // Try to create object for later versions of IE. this.xmlhttp = new ActiveXObject('MSXML2.XMLHTTP'); } catch (e) { try { // Try to create object for early versions of IE. this.xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) { // Could not create an XMLHttpRequest object. return false; } } } } this.method = 'post'; this.async = true; this.url; this.query = ''; this.data = ''; this.reponseText; this.reponseXML; this.responseHandler; this.abortHandler; this.showLoading = false; this.send = function () { if (this.method && this.url) { var self = this; this.xmlhttp.onreadystatechange = function () { if (self.xmlhttp.readyState == 4) { if (self.xmlhttp.status && (self.xmlhttp.status == 200 || self.xmlhttp.status == 304)) { //unsafeWindow.console.info('success', self); self.responseText = self.xmlhttp.responseText; if (self.xmlhttp.responseXML) { self.responseXML = self.xmlhttp.responseXML; } else { self.responseXML = null; } if (self.responseHandler) { self.responseHandler(); var evt = document.createEvent('Event'); evt.initEvent('gm:ajaxhook', false, true); document.dispatchEvent(evt); //autoContinue(); } } else { showAlert('<p>An error occured while requesting the data.</p><p>Status Msg: ' + self.xmlhttp.statusText + '</p><p><input type="button" name="ok" value="OK" onclick="removeAlert();" id="alertFocus"></p>'); } if (self.showLoading && self.loading) { self.loading.style.visibility = 'hidden'; } } } if (this.showLoading) { this.displayLoading(); } this.xmlhttp.open(this.method, this.url + '?' + encodeURI(this.query), this.async); if (this.method == 'post') { this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } this.xmlhttp.send(encodeURI(this.data)); } else { showAlert("<p>An error occured while requesting the data.</p><p>No method, URL, and/or query string provided.</p><p><input type=\"button\" name=\"ok\" value=\"OK\" onclick=\"removeAlert();\" id=\"alertFocus\"></p>"); } } this.abort = function () { this.xmlhttp.onreadystatechange = function () {}; this.xmlhttp.abort(); if (this.abortHandler) { this.abortHandler(); } } this.getFormValues = function (form) { for (i = 0; i < form.elements.length; i++) { switch (form.elements[i].type) { case 'text': case 'hidden': case 'password': case 'textarea': this.data += form.elements[i].name + "=" + form.elements[i].value + "&"; break; case 'checkbox': case 'radio': if (form.elements[i].checked) this.data += form.elements[i].name + "=" + form.elements[i].value + "&"; break; case 'select-one': this.data += form.elements[i].name + "=" + form.elements[i].options[form.elements[i].selectedIndex].value + "&"; break; } } this.data = this.data.substr(0, (this.data.length - 1)); } this.appendHTML = function (object, flag) { if (this.xmlhttp.responseText) { if (flag) { object.innerHTML = this.responseText; } else { object.innerHTML += this.responseText; } } else {} } this.displayLoading = function () { if (this.showLoading == 'sidebar') { this.loading = document.getElementById('sidebarLoading'); this.loading.style.height = document.getElementById('sidebar').offsetHeight - 2 + 'px'; this.loading.style.width = document.getElementById('sidebarContent').offsetWidth + 'px'; this.loading.innerHTML = '<p style="text-align: center; margin-top: 150px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'message') // message { this.loading = document.getElementById('messageContent'); this.loading.style.height = document.getElementById('message').offsetHeight + 'px'; this.loading.style.width = document.getElementById('message').offsetWidth + 'px'; this.loading.innerHTML = '<p style="text-align: center; margin-top: 75px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'messageList') // message list { this.loading = document.getElementById('messageList'); this.loading.style.height = document.getElementById('messageList').offsetHeight + 'px'; this.loading.style.width = document.getElementById('messageList').offsetWidth + 'px'; this.loading.innerHTML = '<p style="text-align: center; margin-top: 50px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'map') // map { this.loading = document.getElementById('mapLoading') this.loading.innerHTML = '<p style="text-align: center; margin-top: 150px;"><img src="http://static.pokemonvortex.org/images/loading_white.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'live') { this.loading = document.getElementById('loading'); this.loading.style.height = document.getElementById('scroll').offsetHeight + 'px'; if (document.getElementById('scrollContent')) { this.loading.style.width = document.getElementById('scrollContent').offsetWidth + 'px'; } else { this.loading.style.width = document.getElementById('scroll').offsetWidth + 'px'; } this.loading.innerHTML = '<p class="large" style="margin-top: 75px; text-align: center;"><strong>Waiting for the other user to respond...</strong></p><p style="text-align: center;">You have been waiting <span id="waitTime">0 seconds</span>.</p>'; waitTime(0); } else // main { this.loading = document.getElementById('loading'); this.loading.style.height = document.getElementById('scroll').offsetHeight + 'px'; if (document.getElementById('scrollContent')) { this.loading.style.width = document.getElementById('scrollContent').offsetWidth + 'px'; } else { this.loading.style.width = document.getElementById('scroll').offsetWidth + 'px'; } this.loading.innerHTML = '<p style="text-align: center; margin-top: 150px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } this.loading.style.visibility = 'visible'; } } function createToggler(container, title, varname) { var toggleEnable = unsafeWindow.document.createElement('p'); container.appendChild(toggleEnable); toggleEnable.innerHTML = title + ' <b>' + (settings.data[varname] ? 'Enabled' : 'Disabled') + '</b>'; toggleEnable.addEventListener('click', function() { settings.data[varname] = !settings.data[varname]; toggleEnable.innerHTML = title + ' <b>' + (settings.data[varname] ? 'Enabled' : 'Disabled') + '</b>'; settings.save(); autoContinue(); }, false); } function init() { var iframes = unsafeWindow.document.getElementsByTagName('iframe'); for (var i = 0; i < iframes.length; i++) { iframes[i].parentNode.removeChild(iframes[i]); } var sty = unsafeWindow.document.createElement('style'); unsafeWindow.document.querySelector('head').appendChild(sty); sty.textContent = '#fscctrl { background: green; border: 1px solid yellow; cursor:pointer; margin: auto; padding: 10px; width: 1010px; } #fscctrl p { margin: 0; } #alert{position:absolute; z-index: 1; background:#ffc; padding: 0 10px; right: 0; width: 100px;} #alert p { margin: 0; } #loading {z-index: 0; top: 0; height: 200px;} #loading p {margin-top:0 !important;} #header{ height: 70px; }'; unsafeWindow.disableSubmitButton = function(form) { for (i = 0; i < form.elements.length; i++) { if (form.elements[i].type == 'submit') { form.elements[i].value = 'Please Wait... or click again - by rockingdo'; } } return true; } settings.load(); document.addEventListener('gm:ajaxhook', function() { autoContinue(); }, false); var container = unsafeWindow.document.createElement('div'); unsafeWindow.document.body.insertBefore(container, unsafeWindow.document.body.firstChild); container.setAttribute('id', 'fscctrl'); createToggler(container, 'Auto-battle', 'autoBattle'); createToggler(container, 'Find Rare', 'findRare'); createToggler(container, 'Find Legendary', 'findLegendary'); createToggler(container, 'Catch Pokemon', 'catchPok'); createToggler(container, 'Find New Pokemon', 'findNewpoke'); autoContinue(); } init(); Hello. Can someone please be so kind to answer the above question. Here is the code: Code: if (document.getElementById("os0").value=="1010") { price_per_inch=1.90; 'document.write(price_per_inch);' } else if (document.getElementById("os0").value=="1020") { price_per_inch=2.00; 'document.write(price_per_inch);' } else if (document.getElementById("os0").value=="1030") { price_per_inch=2.10; 'document.write(price_per_inch);' } else if (document.getElementById("os0").value=="1040")'well then 1040 is chosen' { price_per_inch=2.20; 'document.write(price_per_inch);' } else { } It is setting the price per inch based on the selection the user makes from a drop down menu. I need the correct section to work and for the else to not execute. After all, it never should, because there are only 4 options to choose from, and one of the 4 will always be chosen. If I uncomment the document.write lines after each option, things work o.k. So, what's going on? On a side note, has any ever gotten any kind of programming help from the chatrooms at Gogloom he http://gogloom.com/DIR?cat=84126&catdesc=Programming I ask because about three times I have gone there hoping to receive immediate help, but no one ever responds, hardly anyone chats, and yet the rooms are filled like with 300 and something users. I just find it odd and if nothing is wrong, how can so many people be so unhelpful? This is my first time here and hopefully when I have future problems I can count on returning here. Hi All, I have written a chrome extension which will redirect to all hrefs for a given source urls in current tab.. But i don't know why all of a sudden it stops executing after reaching some page. I am attaching my code as attachment. Can any one help me out. Thanks in advance. Greetings! I'm not a huge javascript person, I barely know enough php to get by. I struggle and I learn. I have this page that take a while to load and I really don't want it to show the results in the browser before the php script finishes. So I was hoping that somebody could point me to a way to either give some sort of wait indicator (i.e. a bar, the trendy twrilling circle thingy) or just hide the everything till the page is completely loaded. Below this sentence is the original post I left in the PHP forum. Since the birth of CSS3 you can easily use fonts that are NOT on the local users PC. This is the best! Although some fonts do not render through the browser. I wrote this script (for personal use) which is pretty elementary which reads fonts in a directory (without installing them in windows) and then lets you display them in various web aspects. In the script I pick a random background color and calculate a contrast color and then determine if the text color should be black or white depending on the color of the background. What's happening is that if I pile a bunch of fonts in the fonts directory when the script executes it displays the contents until it 100% complete. Basically I'd like it NOT to do that. I was looking around a progress bars but .. they don't seem to do much. I couldn't find one that would either give you that twrilling circle while it loads or something to that nature. **Is you test this script you MUST create a folder named 'fonts' in the root of where you put the script! ***If you find ways that I can make this more effecient or any tips or tricks that'd be great and constructive criticism is always appreciated! Thanks so much for any help or advice given! You'll need the javascript file animatedcollapse.js from my site http://handlersspot.net/css3font/animatedcollapse.js There's are three images: http://handlersspot.net/css3font/slantdivider.gif http://handlersspot.net/css3font/minus.png http://handlersspot.net/css3font/plus.png I tried to post the source here but it seems that I used up my allotment of 20K characters I tried to use the attachments feature but it doesn't work for me for some reason so I posted all the source here on my website: http://handlersspot.net/css3font/source.html Whew! That's allot of stuff! Again .. thanks for the effort/advice/help way in advance! Oh! Sorry! Meant to put the actual working version of this here --> http://handlersspot.net/css3font |