Jump to content

A_tom

Members
  • Posts

    43
  • Joined

  • Last visited

Posts posted by A_tom

  1. I want to be able to force visitors to my website to visit and acknowledge a disclaimer on the first time they visit, after which they will never see it again. Searching, I have found a couple of examples, neither of which seem to do what I want.

    <script>
        $(document).ready(function(){
          if(!$.cookie('welcomeMsg')){
            $(".top").show();
            $.cookie('welcomeMsg', 'Y', { expires: 365*3 });
          }
        });
    </script>

    and 

    <script>
    if (localStorage.getItem("visited")) {
        window.location.href = "OneTimePage.html";
    }
    localStorage.setItem("visited", "true");    
    </script>

     

  2. I have used the same html code (self developer/amateur - siftradingsytems.com) for the past ten years. I've just noticed that I am getting a 404 error code message overlay when I mouse over my menu, which you can see from the image. Everything works as it always has. If I select an item from the menu it navigates to it as it always has. I'm trying to figure out the cause of the errant 404 error message. The only changes to my website have been that I asked the webhost company (Hostgator) to provide a security certificate, which they did. The menu uses some javascript that I got from DynamicDrive.com (ddlevelsmenu.js). Hostgator, says it's a script problem. I'm looking for a little guidance on how to fix this.

     

     

    SorryThisPageDoesn'tExist.PNG

  3. I have a website http://www.siftradingsystems.com/

    I would like to devote one page to some comments which would come to the page in the form of a small text file uploaded from my desktop. The page would be scrollable and each added comment would appear in its own window. I simply want the web page to grab the uploaded text files and display them sequentially without my having to do anything other than create the original text file and put it where it can be uploaded.

    Can someone please point me in the right direction.

    Thanks for any advice.

  4. 4 hours ago, justsomeguy said:

    This isn't really event-driven, this is just running a script on a schedule.  On Linux servers, you use cron to create a task to run on a schedule, on Windows servers you use the task scheduler.  If it's a cron job you typically just tell it to execute PHP and pass the filename to your script, e.g.:

     

    
    php -f /path/to/script.php

     

    You can have it run as often as once per minute, or however else you'd like.  If you rent a server from a host then you can probably set up cron jobs in your control panel somewhere.

    Right, I was planning on it being a cron job. I was mainly concerned about figuring out what the php script would look like.

  5. On my home network, I have a computer that is uploading data to my website. One file being uploaded is just the date and time, and this happens about once every five minutes. I wish to create a php script that will test this file and send me an email when the file is no longer updating. This will tell me when my home computer has lost internet connectivity or has stopped working. There seems to be plenty of examples of php script that would do the file test. How do I get the script to execute on a timer?

  6. It looks like you were missing a comma here

    $.cookie('Cookie1', 'Kooky'{ expires: date });

    And I'm not sure why you were checking for typeof, it should just be sufficient to pass the cookie name

    if ($.cookie('Cookie1')) {  //cookie exists} else {  //cookie doesn't exist};

    here are the docs

    https://github.com/carhartl/jquery-cookie/tree/v1.4.1

     

    Regarding references to $.cookie not doing anything, where you checking for errors in the console? What happens if you logged $.cookie? Are you sure the file was being loaded correctly?

    Thanks for your comments. I will try using jquery again and come back if I can't get it to work. Where was the comma supposed to be?

     

    Nevermind, I finally got it to work. Here is my test page:

    http://www.siftradingsystems.com/LightBoxTest.html

  7. I have been experimenting with a lightbox and it works well enough.

    http://www.siftradingsystems.com/P15C2.html

     

    However, I need to turn this off for some period of time some the user is not repeatedly confronted with the disclaimer. For this I would seem to need to use a cookie, but I cannot get the jquery.cookie plugin to do anything.

     

    Here is some test code I've been working with. Any reference at all to $.cookie causes nothing to happen.

    <!doctype html><html><head><meta charset="utf-8"><title>Lightbox 2</title><meta name="description" lang="en" content="testing" /><meta name="author" content="Lokesh Dhakar"><meta name="viewport" content="width=device-width"><link rel="shortcut icon" type="image/ico" href="images/favicon.gif" /> <link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" /><link rel="stylesheet" href="css/lightbox.css" type="text/css"     media="screen" /><script src="http://code.jquery.com/jquery-latest.js"></script>  <script src="/js/jquery.cookie.js"></script> <script src="/js/lightbox.js"></script><script>if(typeof $.cookie('Cookie1') === 'undefined'){//if (1 == 1){ //no cookie $('document').ready(function(){$('#ele_id').trigger('click');var date = new Date();date.setTime(date.getTime() + (5 * 1 * 1000));$.cookie('Cookie1', 'Kooky'{ expires: date }); });}  //} else {// have cookie, do nothing// alert($.cookie('Cookie1'));//}</script></head><body><a id ="ele_id" href="img/Disclaimer.png" rel="lightbox" data-title="Disclaimer"></a><p>This is a test page.</p></body></html>
  8. I found this code which would appear to do what I want, except (in my browser, at least) the disclaimer page is blocked by my adblocker. How does one avoid this? The other problem is that the popup blocker can completely defeat the purpose of the cookie code? How does one get around that?

     

    <script>function getCookie(NameOfCookie){    if (document.cookie.length > 0) {                  begin = document.cookie.indexOf(NameOfCookie+"=");           if (begin != -1) {                 begin += NameOfCookie.length+1;             end = document.cookie.indexOf(";", begin);      if (end == -1) end = document.cookie.length;        return unescape(document.cookie.substring(begin, end));    }   }  return null;}function setCookie(NameOfCookie, value, expiredays) {var ExpireDate = new Date ();ExpireDate.setTime(ExpireDate.getTime() + (360));  document.cookie = NameOfCookie + "=" + escape(value) +   ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());}function delCookie (NameOfCookie) {  if (getCookie(NameOfCookie)) {    document.cookie = NameOfCookie + "=" +    "; expires=Thu, 01-Jan-70 00:00:01 GMT";  }}function DoTheCookieStuff(){ visited=getCookie('visited'); if (visited==null)  {setCookie('visited','yes',365)MyWindow=window.open('Disclaimer.html'); }}</script>
  9. The question isn't how you want it to look, it's how you want it to act. Do you only want it to appear once for a particular user, or every time? If it appears every time then it's just a regular web page, maybe with a Javascript overlay to show the disclaimer over the actual page content. If you only want it to appear once then you can use cookies to keep track of the last time that computer was shown the disclaimer.

    I think the best would be to have the user only have to acknowledge the disclaimer once. I am sure there are examples of this here and other places, but in searching, I have been unable find what I'm looking for.

  10. You can either use Javascript or PHP. If you haven't learned any of them, check the W3Schools tutorials.

    I am somewhat familiar and when given some example code, I can usually adapt it to my needs. I'm just looking for an example of how to do it.The disclaimer I want people to have to see is about 250 words, so I need something that looks more like a web page than just a simple text box with a button.

  11. This code runs ok in Chrome and IE, but not Firefox. How to fix?

    <!DOCTYPE html><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0,user-scalable=no" />        <title>Document Title</title>        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>        <script  type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>        <script type="text/javascript">$(function(){    //option 1    insertme('LineChart');    });            function insertme(ref) {//this can be placed in external js file                var join = "";                join += '<object type="application/x-shockwave-flash" width="500" height="300">';                join += '<param name="movie" value="../FusionCharts/Line.swf" />';                join += '<param name="FlashVars" value="&dataURL=clientFTP/' + ref + 'MoTrnd.xml&chartWidth=500&chartHeight=300">';                join += '<param name="quality" value="high" />';                join += '<embed src="../FusionCharts/Line.swf" flashVars="&dataURL=clientFTP/' + ref + 'MoTrnd.xml&chartWidth=500&chartHeight=300" quality="high" width="500" height="300" id="Line" type="application/x-shockwave-flash"  pluginspage="http://www.macromedia.com/go/getflashplayer" />';                join += '</object>';                $('#dumphere').append(join);            }        </script>        <style type="text/css">        </style>    </head>    <body>    <h1>The chart goes here</h1>        <div id="dumphere">           <!--<script> ///option 2 - just remove comment tags                insertme('LineChart');            </script>-->        </div>    </body></html>

     

  12. I've run across one more small problem with these revisions. Everything seems to work ok with Chrome and IE, but Firefox will not display the chart. It does have the flash plug in and it will display the chart on the old website, but not the new one.

     

    Any suggestions?

     

    Here is the page which is supposed to display the chart:

    <!DOCTYPE html><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0,user-scalable=no" />        <title>Document Title</title>        <link href="styles.css" rel="stylesheet" type="text/css" />        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>        <script  type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>        <script type="text/javascript">$(function(){    //option 1    //insertme('ESCombo7');    insertme('<?php echo $_GET["sysname"].$_GET["period"]."Bar" ?>');});            function insertme(ref) {//this can be placed in external js file                var join = "";                join += '<object type="application/x-shockwave-flash" width="500" height="300">';                join += '<param name="movie" value="../FusionCharts/Column2D.swf" />';                join += '<param name="FlashVars" value="&dataURL=clientFTP/' + ref + '.xml&chartWidth=500&chartHeight=300">';                join += '<param name="quality" value="high" />';                join += '<embed src="../FusionCharts/Column2D.swf" flashVars="&dataURL=clientFTP/' + ref + '.xml&chartWidth=500&chartHeight=300" quality="high" width="500" height="300" id="Column2D" type="application/x-shockwave-flash"  pluginspage="http://www.macromedia.com/go/getflashplayer" />';                join += '</object>';                $('#dumphere').append(join);            }        </script>        <style type="text/css">        </style>    </head>    <body class="twoColFixLtHdr">        <div id="container">    <div id="header" class="fltlft"><img src="images/logo.jpg" alt="SIF Trading Systems Logo" class="fltlft" />    <img src="images/software_box.jpg" alt="Software Box" class="fltrt" />          </div>    <br class="clearfloat" />         <div id="dumphere" style="text-align: center">           <!-- <script> ///option 2 - just remove comment tags                insertme('ESCombo7');            </script>--></div><div style="margin-left: 200px"><br><p>This chart is automatically updated directly from a TradeStation chart.</p><p style="margin-right: 125px">PAST PERFORMANCE WHETHER REAL OR HYPOTHETICAL IS NO GUARANTEE OF FUTURE RESULTS.</p></div><div id="footer"><p><a href="<?php echo $_GET["sysname"] ?>.html"><?php echo $_GET["sysname"] ?></a></p></div>        </div>        </body></html>
  13. I am seeing that the above code works ok on Chrome, but not IE9. How to fix that?

     

    edit: Adding <body onload="PDataFunc()"> along with wrapping the the earlier code in the PdataFunc() fixes the IE problem.

     

    edit: On further review, I notice that once the values get loaded in IE, they never seem to update, while they do in Chrome. Ideas?

     

    edit: IE has a setting which makes this problem go away.

  14. HTML5 actually does offer some local file support, but only if the user manually selects or drags a file. Will you manually select this CSV file?

    No. The data is updated daily by FTP from my local computers. The file is on the server. I want to get the data and display it on the page whenever someone browses the page. It does not need to be asynchronous. I have used an ajax ticker in the past to do something like this, but I thought there might be a simpler way.

     

    After much flailing around, I put together something that does what I wanted.

     

    <script>var txt ="";var Ary ="";$.get('../clientFTP/AlligatorFin.txt', function (data) {    txt = data;    Ary = txt.split(",");    document.getElementById("Gain").innerHTML = "Gain: "+"$"+Ary[0];    document.getElementById("Maxrunup").innerHTML = "Max RunUp: "+"$"+Ary[1];    document.getElementById("Drawdown").innerHTML = "Drawdown: "+"$"+Ary[2];    document.getElementById("Acctsize").innerHTML = "Min Account Size: "+"$K"+Ary[3];});</script>
  15. I need to be able to read a text file (csv), parse it, and then display the parsed values (numerics) in a web page. This only needs to happen on page load. The values in the file will not change more than once per day. I have spent a couple of hours trying to figure this out on my own, so I'm giving up on finding it.

     

    I found this bit of code which will read the text file and display it on the page, but I can't figure out how to break the string apart and assign it to different elements.

     

    <script>$(document).ready(function(){$("#div1").load("../clientFTP/SomeData.txt");});</script>

    Thanks for any assistance.

  16. Is the chart page a single page? which you send information regarding what chart to show? not quite understanding, this is the only conclusion i have come up with with what you are trying to achieve, IF not! i don't understand, what you are not getting with my method, it is not sending variable value through get querystring on what chart to show, but gathering this information directly from custom data- attribute, set on individual pages.

    I'm sorry, but I've probably done a poor job of even asking the right question. This is the main website: SIFTradingSystems If you go there, you'll see a menu on the left which invites you to go to some linked pages (different systems). Each system has it's own main page like ESCombo7. Once you get to a system page, you have the opportunity to pull up one of a number of charts which will give some historical performance on the system, usually a flash chart, such as the one we'be been working on: ESCombo7 monthly bar chart. Each system may have 3 or 4 charts, and up until now, each chart has had its own page. It dawned on me that I might be able to avoid duplicating all these pages, by just have a generic page and telling it which data file to use when the page is loaded. The hand off of this system name needs to occur between the system page and the chart page. That's what I've been trying to figure out how to do. I hope that's clearer, but since I've already have the php method, perhaps we should just let it go at that.

     

    I appreciate all your help.

  17. Yes. How does the page which displays the chart (ESCombo7 24 Mo Bar Chart), acquire the name of the system for which the chart is to be displayed from the page which is requesting the chart page (ESCombo7 Main Page)? If you look at the main page, you'll see two links which are both requesting the 24 month bar chart. One is my original method, and the other uses php to request the chart page by passing the name of the system to a generic chart display page. So my question was, how does that happen using js instead of php. You may well have explained how that is to be done, but I have failed to grasp it. If that is the case, then don't go to any more trouble; just tell me to look harder.

  18. Only drawback insertme('<?php echo $_GET["sysname"] ?>'); has to be placed in php every time, but in my previous post all can be placed in external js file, you just add target chart file ref to data-chartref="ESCombo7"

    <div id="dumphere" data-chartref="ESCombo7">

    it will then find this and creates object, embed tags with this chart ref.

    I have rerun the code you are referencing here and it does load the page; not sure why it didn't before. In order to understand what you've done, I need a much better understanding of how js works, and that will take some time, and I'm not sure that investment in time is worth my trouble. When I used the php, I understood how the xml file reference was being passed to the page which is to display the data in the xml file. I do not understand how that is supposed to work in your example. What does that calling page need to do using js to get the xml file reference passed to the page being called and which is supposed to display the data in that file?

  19. I could not get your last code to load a chart, but I've been looking at using PHP, and this is what I've come up with.

    In the html calling page I've changed the link which calls the chart page to this:

    <p><a title="" href="FCBarChart.php?sysname=ESCombo7">Bar chart for last 24 mo.</a></p>

     

    This will pass the sysname as a variable in the url.

     

    Now, using your first example above I've change the chart page to this

     

    !DOCTYPE html><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0,user-scalable=no" />        <title>Document Title</title>        <link href="styles.css" rel="stylesheet" type="text/css" />        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>        <script  type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>        <script type="text/javascript">$(function(){    //option 1    //insertme('ESCombo7');    insertme('<?php echo $_GET["sysname"] ?>');});            function insertme(ref) {//this can be placed in external js file                var join = "";                join += '<object type="application/x-shockwave-flash" width="500" height="300">';                join += '<param name="movie" value="../FusionCharts/Column2D.swf" />';                join += '<param name="FlashVars" value="&dataURL=clientFTP/' + ref + 'MoBar.xml&chartWidth=500&chartHeight=300">';                join += '<param name="quality" value="high" />';                join += '<embed src="../FusionCharts/Column2D.swf" flashVars="&dataURL=clientFTP/' + ref + 'MoBar.xml&chartWidth=500&chartHeight=300" quality="high" width="500" height="300" id="Column2D" type="application/x-shockwave-flash"  pluginspage="http://www.macromedia.com/go/getflashplayer" />';                join += '</object>';                $('#dumphere').append(join);            }        </script>        <style type="text/css">        </style>    </head>    <body class="twoColFixLtHdr">        <div id="container">    <div id="header" class="fltlft"><img src="images/logo.jpg" alt="SIF Trading Systems Logo" class="fltlft" />    <img src="images/software_box.jpg" alt="Software Box" class="fltrt" />          </div>    <br class="clearfloat" />         <div id="dumphere" style="text-align: center">           <!-- <script> ///option 2 - just remove comment tags                insertme('ESCombo7');            </script>--></div><div style="margin-left: 200px"><br><p>This chart is automatically updated directly from a TradeStation chart.</p><p style="margin-right: 125px">PAST PERFORMANCE WHETHER REAL OR HYPOTHETICAL IS NO GUARANTEE OF FUTURE RESULTS.</p></div><div id="footer"><p><a href="ESCombo7.html">ESCombo7</a></p></div>        </div>        </body></html>

    This correctly loads the chart page, so I can now maintain only one chart page and just pass the sysname variable to tell it which xml file to use.

     

    Is this a proper/good way to do this?

  20. So far, so good. The page above renders ok, and I have modified it so it will look like all my existing chart pages. What I still need is to understand how to pass the 'ESCombo7' as a variable or value from the page where the link is which will cause the chart page to load. I gather there are several ways to do this, but I can't understand any of them well enough to implement it or to understand which is the best/correct method.

×
×
  • Create New...