小编Mas*_*rAM的帖子

使用Javascript从Joomla加载数据

我目前正在使用PHP编写时间表应用程序.

我想要做的是为一周中的每一天都设置一个按钮,当用户点击每个按钮时,使用JavaScript将当天列出的任务加载到浏览器窗口中.

我目前的代码是:

<?php
class loadTimetable
{
    public static function getTimetable( $params )
    {
        //Obtain a database connection
        $db = JFactory::getDbo();
        //Retrieve the shout
        $query = $db->getQuery(true)
                    ->select($db->quoteName('title'))
                    ->from($db->quoteName('#__timetable'))
                    ->where('day = '. $db->Quote($params));
        //Prepare the query
        $db->setQuery($query);
        // Load the row.
        $result = $db->loadResult();
        //Return the Hello
        return $result;
    }
}
$day = date("N");
$timetable = getTimetable($day);
?>
<h1><?php echo $timetable; ?></h1>
Run Code Online (Sandbox Code Playgroud)

该功能在Joomla内部,经过测试可以正常工作.我需要的帮助是如何使用Javascript/AJAX调用该函数.

据我所知,所有Javascript必须做的是调用所选日期的函数(例如,getTimetable(1)其中1是HTML中星期一按钮的值).

javascript ajax jquery joomla

5
推荐指数
1
解决办法
565
查看次数

VSCode断点不能在带有gulp-sourcemaps生成的源映射的typescript中工作

users.ts在子目录中有一个打字稿文件routes.

gulp代码gulpfile.js:

var tsProject = ts.createProject(tsConfigFile);
return tsProject.src()
    .pipe(sourcemaps.init())
    .pipe(ts(tsProject))
    .js
    .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})) 
    .pipe(gulp.dest('.'));
Run Code Online (Sandbox Code Playgroud)

生成的源映射gulp-sourcemaps不适用于VSCode:

{"version":3,"sources":["routes/users.ts"],"names":[], "mappings":"...","file":"routes/users.js","sourceRoot":""}
Run Code Online (Sandbox Code Playgroud)

在VSCode中正常生成的tsc源映射:

{"version":3,"file":"users.js","sourceRoot":"","sources":["users.ts"],"names":[], "mappings":"..."}
Run Code Online (Sandbox Code Playgroud)

并且VSCode断点与生成的源映射一起正常工作tsc.

那么如何配置gulp-typescript/gulp-sourcemaps生成相同的源图tsc

typescript gulp gulp-sourcemaps visual-studio-code

4
推荐指数
1
解决办法
2735
查看次数

C++"访问冲突读取位置"错误

VertexGraph类中有以下结构:

struct Vertex
{
    string country;
    string city;
    double lon;
    double lat;
    vector<edge> *adj;

    Vertex(string country, string city, double lon, double lat)
    {
        this->country = country;
        this->city = city;
        this->lon = lon;
        this->lat = lat;
        this->adj = new vector<edge>();
    }
};
Run Code Online (Sandbox Code Playgroud)

当调用我写的方法时getCost(),我会一直得到同样的Unhandled Exception

访问冲突读取位置0x00000048

我无法弄清楚为什么.

getCost()方法:

void Graph::getCost(string from, string to)
{

    Vertex *f = (findvertex(from));
    vector<edge> *v = f->adj;     // Here is where it gives the error
    vector<edge>::iterator itr = v->begin(); …
Run Code Online (Sandbox Code Playgroud)

c++

3
推荐指数
1
解决办法
9万
查看次数

如何在$(window).resize()中的$(this)上使用e.preventDefault()?

我怎么用$(this).e.preventDefault()

我想要/需要的是在窗口调整大小时<a>应该表现不同.因此,如果小提示示例中窗口宽度小于710,则href不应触发.只会有一些JavaScript函数切换subnav.但如果窗口宽于710px,我希望href"正常"工作.

现在设置示例我已经看到事件多次触发.如果只发射一次怎么办呢?

另外,有没有更好的方法来实现我想要的?

请在点击前调整jsfiddle中的窗口大小!在这里小提琴

$( window ).resize(function() {
    var wW = $(window).width();
    $('.windowWidth span').html(wW);
    if(wW < 710) {
        $('nav ul.nav > li > a').on('click',function(e){
            e.preventDefault();
            alert("here");
        });
    } else {
        $('nav ul.nav > li > a').on('click',function(e){
            alert("there");
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

3
推荐指数
1
解决办法
1579
查看次数

如何从右到左渲染进度元素?

我有一个从左到右显示的进度条。我需要制作另一个相同风格的进度,但将从右到左显示。

这是我的风格定义:

progress, progress[role] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    background-size: auto;
    height: 50px;
    width: 100%;
    padding-top: 10px;
}
 progress[value]::-webkit-progress-bar {
     background-color: grey;
     border-radius: 2px;
     box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
 }
 progress[value]::-webkit-progress-value {
    background-image:
        -webkit-linear-gradient(-45deg, 
                               transparent 33%, rgba(0, 0, 0, .1) 33%, 
                               rgba(0,0, 0, .1) 66%, transparent 66%),
        -webkit-linear-gradient(top, 
                               rgba(255, 255, 255, .25), 
                               rgba(0, 0, 0, .25)),
        -webkit-linear-gradient(left, #09c, #f44);
    border-radius: 2px; 
    background-size: 35px 20px, 100% 100%, 100% 100%; 
}

.valuebar {
    position: relative;
} …
Run Code Online (Sandbox Code Playgroud)

html css progress-bar

2
推荐指数
1
解决办法
2326
查看次数

在Meteor.js中将数组对象添加到Users集合

我对Meteor.js很新,我发现文档有点难以理解.

我从一个非常简单的应用程序开始,用户可以通过单击按钮简单地允许用户将现有游戏添加到他们的个人资料中.该游戏存储在另一个流星集合.

在rails中,我只想创建一个has_and_belongs_to_many关系,但这不是Meteor的工作方式.我认为最好的方法是在创建用户帐户时添加一个空数组 - 然后,当他们点击"添加游戏"按钮时,它会将游戏的标题传递给用户数组.

我在/server/users.js文件中有这个:

Accounts.onCreateUser(function(options, user){
    user.games = [];
    return user;
});

Meteor.methods({
    addGame: function(title) {
        Meteor.users.update(Meteor.userId(), { $addToSet: { games: title}});
    }
});
Run Code Online (Sandbox Code Playgroud)

我正在调用addGame我的/client/views/games/games_list.js文件中的方法:

Template.gamesList.events({
    'click .add-to-chest-btn': function(e){
        var title = $(e.target).attr('name');
        e.preventDefault();
        Meteor.call('addGame', title, function(title){ console.log(title)});
    }
});
Run Code Online (Sandbox Code Playgroud)

我是在正确的轨道上还是有更好的方法来做到这一点?

meteor

1
推荐指数
1
解决办法
4355
查看次数

C ++ lambda表达式可以抛出吗?

在构造闭包对象期间,我找不到有关引发异常的任何信息。

显而易见,此表达式在向量的副本构造期间可能会抛出:

auto v = std::vector<int>(1000000);
[v]{};
Run Code Online (Sandbox Code Playgroud)

但是像这样的空列表或“按引用”捕获列表呢?

[&]{};
Run Code Online (Sandbox Code Playgroud)

我现在只讲封闭对象的构造。打电话没意思。

我阅读了5.1.2 Lambda expressions [expr.prim.lambda],但是没有发现关于无担保的特殊要求。

c++ lambda exception c++11

1
推荐指数
1
解决办法
2385
查看次数

无法让Phaser工作

在过去的几天里,我一直无法让移相器工作:只是试着测试一个hello world程序.我完全遵循了phaser网站上的指示,但它仍然不适合我.

我正在使用node.js.

这是index.html:

<!DOCTYPE html>
<html>

<head>
     <meta charset="utf-8" />
     <title>Hello World</title>

     <style>
        #game_div {
        width: 500px;
        margin: auto;
        margin-top: 50px;
      }
    </style>

    <script type="text/javascript" src="phaser.min.js"></script>
    <script type="text/javascript" src="main.js"></script>
</head>

<body>

    <div id="game_div"> </div>

</body>

</html>
Run Code Online (Sandbox Code Playgroud)

这是main.js:

/*jslint node: true */
"use strict";
var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game_div');

var main_state = {

    preload: function () {
        game.load.image('hello', 'assets/hello.png');
    },

    create: function () {
        this.hello_sprite = game.add.sprite(200, 245, 'hello');
    },

    update: function () {
        this.hello_sprite.angle += 1; …
Run Code Online (Sandbox Code Playgroud)

javascript html5 phaser-framework

1
推荐指数
1
解决办法
2541
查看次数

是否可以从fragmentActivity扩展并同时扩展ActionBarActivity?

我有一个扩展的活动FragmentActivity(使用Android Maps API v2),但我需要对其进行更改ActionBar,并且我总是扩展ActionBarActivity以更改此类更改.
我知道不能太延长,但我可以扩展和编辑FragmentActivityActionBar

public class AMapsSi extends android.support.v4.app.FragmentActivity {
    private GoogleMap mapa = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.getWindow().setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_amapssi);
        //actionbar
        ActionBar actionBar = **getSupportActionBar();**-->eclipse error mark
        actionBar.setTitle(vg.getCiudad());

        actionBar.setIcon(R.drawable.manu_perfil); 
        Drawable d=getResources().getDrawable(R.drawable.headeractionbar);
        actionBar.setBackgroundDrawable(d);
Run Code Online (Sandbox Code Playgroud)

android extends android-fragments android-actionbar

0
推荐指数
1
解决办法
179
查看次数