无法将Javascript结合到页面代码中。

时间:2014-01-15 13:17:44

标签: javascript jquery html

感谢他人的帮助,我将以下代码运行得很好。 http://goodandevilbook.com/test2.html

我现在需要将此代码添加到主页:http://goodandevilbook.com/mainpage.html

但是当我尝试从test.html添加代码时,javascript会中断。有人会关心检查我的代码并向我指出一些东西吗?

<html>
<head>
<title>jmit</title>
<link rel="stylesheet" href="style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript"
src='https://www.google.com/jsapi?autoload={"modules":[{"name":"visualization","version":"1","packages":["corechart","geochart"]}]}'>
</script>
<script>
$(document).ready(function(){
    var now = new Date();
    $("#date").append(now.toLocaleDateString());
});
</script>

<script type="text/javascript">
google.setOnLoadCallback(drawCharts);
function drawCharts(){
var map = new google.visualization.ChartWrapper({
    "containerId":"Chart1_div",
    "dataSourceUrl":"https://good-and-evil-stats.appspot.com/query?id=ahVzfmdvb2QtYW5kLWV2aWwtc3RhdHNyFQsSCEFwaVF1ZXJ5GICAgICAuYQKDA&format=data-table-response",
    "refreshInterval":3600,
    "chartType":"GeoChart",
    });
map.draw();}
</script>
<script type="text/javascript">
google.setOnLoadCallback(drawCharts);
function drawCharts(){
 var graph = new google.visualization.ChartWrapper({
     "containerId":"Chart2_div",
     "dataSourceUrl":"https://good-and-evil-stats.appspot.com/query?id=ahVzfmdvb2QtYW5kLWV2aWwtc3RhdHNyFQsSCEFwaVF1ZXJ5GICAgICA14wKDA&format=data-table-response",
    "refreshInterval":3600,
     "chartType":"AreaChart",
        "options":{
            "width":600,
            "height":400,
            "chartArea":{left:47, width:"89%", height:"80%"},
            "areaOpacity":0.1,
            "pointSize":4,
            "backgroundColor":"#F5F5F5",
            "colors":['#76BB72'],
            "legend":{position: 'none'},
            "tooltip":{textStyle: {fontSize:18}},
            "hAxis":{textPosition:"none", gridlines: {color: 'red', count: 7}},
            "dateFormat":{formatType: "long"}
        }
        });
graph.draw();}
</script>
<script type="text/javascript">
google.setOnLoadCallback(drawCharts);
function drawCharts(){
  var poppage = new google.visualization.ChartWrapper({
     "containerId":"Chart3_div",
     "dataSourceUrl":"https://good-and-evil-stats.appspot.com/query?id=ahVzfmdvb2QtYW5kLWV2aWwtc3RhdHNyFQsSCEFwaVF1ZXJ5GICAgIDA4YoKDA&format=data-table-response",
    "refreshInterval":3600,
     "chartType":"Table",
        "options":{
            "width":175,
            "sort":"disable",
            "allowHtml": "true",
            "cssClassNames": {hoverTableRow:'hoverrow', headerRow: 'tableheader',tableRow: 'tablerow', tableCell: 'tablecell'}
        }
        });
google.visualization.events.addListener(poppage, 'ready', hide);
poppage.draw();}
function hide() {
var thediv = $('#Chart3_div').find('.tablecell').eq(0);
var text = thediv.text();
text = text.replace(/\//g, '');
thediv.text(text);
}
</script>

<script type="text/javascript">
google.setOnLoadCallback(drawCharts);
function drawCharts(){
 var popdownload = new google.visualization.ChartWrapper({
     "containerId":"Chart4_div",
     "dataSourceUrl":"https://good-and-evil-stats.appspot.com/query?id=ahVzfmdvb2QtYW5kLWV2aWwtc3RhdHNyFQsSCEFwaVF1ZXJ5GICAgICAuYQJDA&format=data-table-response",
    "refreshInterval":3600,
     "chartType":"Table",
        "options":{
            "width":250,
            "sort":"disable",
            "allowHtml": "true",
            "showRowNumber":"true",
            "cssClassNames": {hoverTableRow:'hoverrow',headerRow: 'tableheader',tableRow: 'bdtablerow', oddTableRow:'bdoddrow', tableCell: 'bdtablecell'}}});
google.visualization.events.addListener(popdownload, 'ready', hidestuff);
popdownload.draw();}
function hidestuff() {
var ind = [1, 4, 7, 10, 13];
$('#Chart4_div').find('.bdtablecell').filter(function(i) {
  return $.inArray(i, ind) > -1;
}).text(function(_, currentText) {
return currentText.replace(/-/g, ' ').replace(/\//g, '');   }); }
</script>


</head>
<body>
  <h1>Test</h1>
  <div style="margin: 0 auto; width: 650px;">
  <div id="Chart1_div"></div>
  <p>Last 30 days</p>
  <div id="Chart2_div"></div><br><br>
  <div id="Chart3_div"></div>
  <div id="date"></div>
  <div id="Chart4_div"></div>
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

删除你上一个财产的逗号,可能是原因:

function drawCharts(){
   var map = new google.visualization.ChartWrapper({
      "containerId":"Chart1_div",
      "dataSourceUrl":"https://good-and-evil-stats.appspot.com/query?id=ahVzfmdvb2QtYW5kLWV2aWwtc3RhdHNyFQsSCEFwaVF1ZXJ5GICAgICAuYQKDA&format=data-table-response",
      "refreshInterval":3600,
      "chartType":"GeoChart"
    });
   map.draw();
}