问:
Issue about my error stated in my ts file
I want user to click on this label here and they will be directed to Google Maps where it will state the address. I did have a onclick function on this label called 'startExternalMap()', but I got some errors I don't understand and I don't know how to solve it. Here is the error! All of the underline have the same error. How do I solve it?

This is my code for my html file here!

This is my code in my ts file for my onclick function.

```<code>@Component({
    selector: 'page-order',
    templateUrl: 'info.html'
})
export class OrderInfoPage {

    order: Order;
    moment;
    from: boolean = true;

    constructor(private alertCtrl: AlertController, private request: ApiRequest, private userData: UserData, public navCtrl: NavController, private params: NavParams, private drivers: DriverData, public plt: Platform, private user: User, private modalCtrl: ModalController, private viewCtrl: ViewController) {

        this.request.showLoading();

        this.order = this.params.get('order');
        this.moment = moment;

        this.plt.ready().then(()=>{
            let status = this.order.status_id;

        //if from is false updateStatus not working
            let id = ['102','301','311','321'];
            for(let i in id){
                if(status == id[i]){
                    this.from = false;
                }
            }
        });
        this.drivers.drivers_data.length>0 ? 0 : this.drivers.getDrivers();
    }

startExternalMap() {
    if (this.location.latitude){

    this.platform.ready().then(() => {

      Geolocation.getCurrentPosition().then((position) => {
        // android
        if (this.platform.is('android')) {
          window.open('geo://' + position.coords.latitude + ',' + position.coords.longitude + '?q=' + this.location.latitude + ',' + this.location.longitude + '(' + this.location.name + ')', '_system');
        };
      });
    });
    };
}
</code>```

答: You have defined Platform in constructor as  public plt: Platform. So you should call to this.plt not this.platform. Also there is no this.location so you should define it first. Solve these errors first and check it.

Body:
I want user to click on this label here and they will be directed to Google Maps where it will state the address. I did have a onclick function on this label called 'startExternalMap()', but I got some errors I don't understand and I don't know how to solve it. Here is the error! All of the underline have the same error. How do I solve it?

This is my code for my html file here!

This is my code in my ts file for my onclick function.

@Component({
    selector: 'page-order',
    templateUrl: 'info.html'
})
export class OrderInfoPage {

    order: Order;
    moment;
    from: boolean = true;

    constructor(private alertCtrl: AlertController, private request: ApiRequest, private userData: UserData, public navCtrl: NavController, private params: NavParams, private drivers: DriverData, public plt: Platform, private user: User, private modalCtrl: ModalController, private viewCtrl: ViewController) {

        this.request.showLoading();

        this.order = this.params.get('order');
        this.moment = moment;

        this.plt.ready().then(()=>{
            let status = this.order.status_id;

        //if from is false updateStatus not working
            let id = ['102','301','311','321'];
            for(let i in id){
                if(status == id[i]){
                    this.from = false;
                }
            }
        });
        this.drivers.drivers_data.length>0 ? 0 : this.drivers.getDrivers();
    }

startExternalMap() {
    if (this.location.latitude){

    this.platform.ready().then(() => {

      Geolocation.getCurrentPosition().then((position) => {
        // android
        if (this.platform.is('android')) {
          window.open('geo://' + position.coords.latitude + ',' + position.coords.longitude + '?q=' + this.location.latitude + ',' + this.location.longitude + '(' + this.location.name + ')', '_system');
        };
      });
    });
    };
}


来源: stackexchange

问:
Javascript (JS) application working on Chrome but not on mozilla firefox/safari
Here is my problem, i created a web application where you need to load a file (image) then it appears in a canvas after a resizing in order not to excess 1500 px. Then i use a canvas zoom programmed like this (another canvas where i zoom on the mouse position):

```<code>var x1, wdth1, psx1, wdth2, y1, heg1, psy1, heg2;
function drawZoom(x, y) {
    $('#zoom').css({
        'left': x - (parseInt($('#zoom').css('width')) / 2),
        'top': y - (parseInt($('#zoom').css('height')) / 2)
    });
    // console.log([x,y]);
    $('#zoom').show(function () {
        if (x < 25) {
            x1 = 0;
            wdth1 = (x + zoom_level / 2) * ratio;
            psx1 = (25 - x) * 2;
            wdth2 = 100 - psx1;
        } else if (x > width_canvas - zoom_level/ 2) {
            x1 = (x - zoom_level/ 2) * ratio;
            wdth1 = (width_canvas - x + zoom_level/ 2) * ratio;
            psx1 = 0;
            wdth2 = 100 - 2 * (x + zoom_level/ 2 - width_canvas);
        } else {
            x1 = (x - zoom_level/ 2) * ratio;
            wdth1 = zoom_level* ratio;
            psx1 = 0;
            wdth2 = 100;
        }
        if (y < 25) {
            y1 = 0;
            heg1 = (y + zoom_level/ 2) * ratio;
            psy1 = (25 - y) * 2;
            heg2 = 100 - psy1;
        } else if (y >= height_canvas - zoom_level/ 2) {
            y1 = (y - zoom_level/ 2) * ratio;
            heg1 = (height_canvas - y + zoom_level/ 2) * ratio - 1;
            psy1 = 0;
            heg2 = 100 - 2 * (y + zoom_level/ 2 - height_canvas);
        } else {
            y1 = (y - zoom_level/ 2) * ratio;
            heg1 = zoom_level* ratio;
            psy1 = 0;
            heg2 = 100;
        }
        // console.log(heg1);
        zoomctx.fillStyle = "black";
        zoomctx.fillRect(0, 0, 100, 100);
        zoomctx.drawImage(canvas, x1, y1, wdth1, heg1, psx1, psy1, wdth2, heg2);
    });
    zoomctx.beginPath();
    zoomctx.moveTo(0, 50);
    zoomctx.lineTo(100, 50);
    zoomctx.moveTo(50, 0);
    zoomctx.lineTo(50, 100);
    zoomctx.closePath();
    zoomctx.stroke();
}
</code>```

then i save the positions of the click and use them in order to calculate a distance etc.... (another story)
so i have a reset button, when you start clicking and fail one of the 4 click needed you can restart, it deletes all the points and restarts the fonction.

ISSUES :

-Chrome: works like a charm, no problem, nice zoom, smooth navigation, restart works perfectly etc....

-Firefox: i have a black circle on the left top corner (it's the zoom but it's all black, not working), it doesn't move, i can click and restart but i can't see where i click and the process after clicking doesn't work.

-Safari: the image appears well, the zoom is ok when i first load the image, i can click 4 times and the rest of the program works fine but if i restart then the zoom is like shifted when i put my mouse somewhere and the zoom doesn't show me the right place.

so i have no issue on chrome, and 2 different issues on safari and mozilla firefox, no error in the console.

i'm a beginner so i dont know if the is some constraints as the "webkit" in CSS for JS.

Tell me if you need more info ! Thanks !

答: I found what was going on with firefox, it was just an update problem. my friends tested it out with their version of firefox and all was ok si i updated my firefox (thought it was doing this alone but apparently not) and it worked fine. I'm gonna try with safari if this is the same problem or not</p>

ContentLicense: CC BY-SA 3.0

Body:
Here is my problem, i created a web application where you need to load a file (image) then it appears in a canvas after a resizing in order not to excess 1500 px. Then i use a canvas zoom programmed like this (another canvas where i zoom on the mouse position):

var x1, wdth1, psx1, wdth2, y1, heg1, psy1, heg2;
function drawZoom(x, y) {
    $('#zoom').css({
        'left': x - (parseInt($('#zoom').css('width')) / 2),
        'top': y - (parseInt($('#zoom').css('height')) / 2)
    });
    // console.log([x,y]);
    $('#zoom').show(function () {
        if (x < 25) {
            x1 = 0;
            wdth1 = (x + zoom_level / 2) * ratio;
            psx1 = (25 - x) * 2;
            wdth2 = 100 - psx1;
        } else if (x > width_canvas - zoom_level/ 2) {
            x1 = (x - zoom_level/ 2) * ratio;
            wdth1 = (width_canvas - x + zoom_level/ 2) * ratio;
            psx1 = 0;
            wdth2 = 100 - 2 * (x + zoom_level/ 2 - width_canvas);
        } else {
            x1 = (x - zoom_level/ 2) * ratio;
            wdth1 = zoom_level* ratio;
            psx1 = 0;
            wdth2 = 100;
        }
        if (y < 25) {
            y1 = 0;
            heg1 = (y + zoom_level/ 2) * ratio;
            psy1 = (25 - y) * 2;
            heg2 = 100 - psy1;
        } else if (y >= height_canvas - zoom_level/ 2) {
            y1 = (y - zoom_level/ 2) * ratio;
            heg1 = (height_canvas - y + zoom_level/ 2) * ratio - 1;
            psy1 = 0;
            heg2 = 100 - 2 * (y + zoom_level/ 2 - height_canvas);
        } else {
            y1 = (y - zoom_level/ 2) * ratio;
            heg1 = zoom_level* ratio;
            psy1 = 0;
            heg2 = 100;
        }
        // console.log(heg1);
        zoomctx.fillStyle = "black";
        zoomctx.fillRect(0, 0, 100, 100);
        zoomctx.drawImage(canvas, x1, y1, wdth1, heg1, psx1, psy1, wdth2, heg2);
    });
    zoomctx.beginPath();
    zoomctx.moveTo(0, 50);
    zoomctx.lineTo(100, 50);
    zoomctx.moveTo(50, 0);
    zoomctx.lineTo(50, 100);
    zoomctx.closePath();
    zoomctx.stroke();
}

then i save the positions of the click and use them in order to calculate a distance etc.... (another story)
so i have a reset button, when you start clicking and fail one of the 4 click needed you can restart, it deletes all the points and restarts the fonction.

ISSUES :

-Chrome: works like a charm, no problem, nice zoom, smooth navigation, restart works perfectly etc....

-Firefox: i have a black circle on the left top corner (it's the zoom but it's all black, not working), it doesn't move, i can click and restart but i can't see where i click and the process after clicking doesn't work.

-Safari: the image appears well, the zoom is ok when i first load the image, i can click 4 times and the rest of the program works fine but if i restart then the zoom is like shifted when i put my mouse somewhere and the zoom doesn't show me the right place.

so i have no issue on chrome, and 2 different issues on safari and mozilla firefox, no error in the console.

i'm a beginner so i dont know if the is some constraints as the "webkit" in CSS for JS.

Tell me if you need more info ! Thanks !


问:
JSON Array and splitting
I'm attempting to come up with a JSON format where I can split the array by TableName. i.e with the sample I'm providing 3 different outputs, grouping it by TableName. I have control of how the input JSON is supposed to look, I just don't have enough JSON experience to know how do it. So far all my attempts have failed. So how do I need the JSON to look like and what would be the JSON path to split it?

```<code>[
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEAS_DL"
},
{
    "TableName": "HH_CELL_CHMEAS_DL"
},
{
    "TableName": "HH_CELL_CHMEAS_DL"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
}
]
</code>```

I'm looking for something like the following as output.
File 1

```<code>[
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
}
]
</code>```

File 2

```<code>[   {
        "TableName": "HH_CELL_CHMEAS_DL"
    },
    {
        "TableName": "HH_CELL_CHMEAS_DL"
    },
    {
        "TableName": "HH_CELL_CHMEAS_DL"
    }
]
</code>```

File 3

```<code>[   {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    }
]
</code>```

答:
Try something like this :

var jsonObj = [
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEAS_DL"
},
{
    "TableName": "HH_CELL_CHMEAS_DL"
},
{
    "TableName": "HH_CELL_CHMEAS_DL"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
}
];

var largeStrObj = [];
var mediumStrObj = [];
var smallStrObj = [];

for (var i in jsonObj) {
  if (jsonObj[i].TableName == "HH_CELL_CHMEASDL_RANK_MCS") {
    largeStrObj.push(jsonObj[i]);
  }
  if (jsonObj[i].TableName == "HH_CELL_CHMEAS_DL") {
    mediumStrObj.push(jsonObj[i]);
  }
  if (jsonObj[i].TableName == "HH_S1") {
    smallStrObj.push(jsonObj[i]);
  }
}

console.log(largeStrObj);
console.log(mediumStrObj);
console.log(smallStrObj);```

ContentLicense: CC BY-SA 4.0

Title: JSON Array and splitting

Body:
I'm attempting to come up with a JSON format where I can split the array by TableName. i.e with the sample I'm providing 3 different outputs, grouping it by TableName. I have control of how the input JSON is supposed to look, I just don't have enough JSON experience to know how do it. So far all my attempts have failed. So how do I need the JSON to look like and what would be the JSON path to split it?

[
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEAS_DL"
},
{
    "TableName": "HH_CELL_CHMEAS_DL"
},
{
    "TableName": "HH_CELL_CHMEAS_DL"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
},
{
    "TableName": "HH_S1"
}
]

I'm looking for something like the following as output.
File 1

[
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
},
{
    "TableName": "HH_CELL_CHMEASDL_RANK_MCS"
}
]

File 2

[   {
        "TableName": "HH_CELL_CHMEAS_DL"
    },
    {
        "TableName": "HH_CELL_CHMEAS_DL"
    },
    {
        "TableName": "HH_CELL_CHMEAS_DL"
    }
]

File 3

[   {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    },
    {
        "TableName": "HH_S1"
    }
]


问:
What indicates an Office Open XML Cell contains a Date/Time value?
I'm reading an .xlsx file using the Office Open XML SDK and am confused about reading Date/Time values.  One of my spreadsheets has this markup (generated by Excel 2010)

```<code><x:row r="2" spans="1:22" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <x:c r="A2" t="s">
    <x:v>56</x:v>
  </x:c>
  <x:c r="B2" t="s">
    <x:v>64</x:v>
  </x:c>
  .
  .
  .
  <x:c r="J2" s="9">
    <x:v>17145</x:v>
  </x:c>
</code>```

Cell J2 has a date serial value in it and a style attribute s="9".  However, the Office Open XML Specification says that 9 corresponds to a followed hyperlink.  This is a screen shot from page 4,999 of ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference.pdf.

The presetCellStyles.xml file included with the spec also refers to builtinId 9 as a followed hyperlink.

```<code><followedHyperlink builtinId="9">
</code>```

All of the styles in the spec are simply visual formatting styles, not number styles.  Where are the number styles defined and how does one differentiate a style reference s="9" from indicating a cell formatting (visual) style vs a number style?

Obviously I'm looking in the wrong place to match styles on cells with their number formats.  Where's the right place to find this information?

答:
The s attribute references a style xf entry in styles.xml. The style xf in turn references a number format mask. To identify a cell that contains a date, you need to perform the style xf -> numberformat lookup, then identify whether that numberformat mask is a date/time numberformat mask (rather than, for example, a percentage or an accounting numberformat mask).

The style.xml file has elements like:

```<code><xf numFmtId="14" ... applyNumberFormat="1" />
<xf numFmtId="1" ... applyNumberFormat="1" />
</code>```

These are the xf entries, which in turn give you a numFmtId that references the number format mask.

You should find the numFmts section somewhere near the top of style.xml, as part of the styleSheet element

```<code><?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
        <numFmts count="3">
            <numFmt numFmtId="164" formatCode="[$-414]mmmm\ yyyy;@" />
            <numFmt numFmtId="165" formatCode="0.000" />
            <numFmt numFmtId="166" formatCode="#,##0.000" />
        </numFmts>
</code>```

The number format id may be here, or it may be one of the built-in formats. Number format codes (numFmtId) less than 164 are "built-in".

The list that I have is incomplete:

```<code>0 = 'General';
1 = '0';
2 = '0.00';
3 = '#,##0';
4 = '#,##0.00';

9 = '0%';
10 = '0.00%';
11 = '0.00E+00';
12 = '# ?/?';
13 = '# ??/??';
14 = 'mm-dd-yy';
15 = 'd-mmm-yy';
16 = 'd-mmm';
17 = 'mmm-yy';
18 = 'h:mm AM/PM';
19 = 'h:mm:ss AM/PM';
20 = 'h:mm';
21 = 'h:mm:ss';
22 = 'm/d/yy h:mm';

37 = '#,##0 ;(#,##0)';
38 = '#,##0 ;[Red](#,##0)';
39 = '#,##0.00;(#,##0.00)';
40 = '#,##0.00;[Red](#,##0.00)';

44 = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)';
45 = 'mm:ss';
46 = '[h]:mm:ss';
47 = 'mmss.0';
48 = '##0.0E+0';
49 = '@';

27 = '[$-404]e/m/d';
30 = 'm/d/yy';
36 = '[$-404]e/m/d';
50 = '[$-404]e/m/d';
57 = '[$-404]e/m/d';

59 = 't0';
60 = 't0.00';
61 = 't#,##0';
62 = 't#,##0.00';
67 = 't0%';
68 = 't0.00%';
69 = 't# ?/?';
70 = 't# ??/??';
</code>```

The missing values are mainly related to east asian variant formats.

ContentLicense: CC BY-SA 2.5

Body:
I'm reading an .xlsx file using the Office Open XML SDK and am confused about reading Date/Time values.  One of my spreadsheets has this markup (generated by Excel 2010)

<x:row r="2" spans="1:22" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <x:c r="A2" t="s">
    <x:v>56</x:v>
  </x:c>
  <x:c r="B2" t="s">
    <x:v>64</x:v>
  </x:c>
  .
  .
  .
  <x:c r="J2" s="9">
    <x:v>17145</x:v>
  </x:c>

Cell J2 has a date serial value in it and a style attribute s="9".  However, the Office Open XML Specification says that 9 corresponds to a followed hyperlink.  This is a screen shot from page 4,999 of ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference.pdf.

The presetCellStyles.xml file included with the spec also refers to builtinId 9 as a followed hyperlink.

<followedHyperlink builtinId="9">

All of the styles in the spec are simply visual formatting styles, not number styles.  Where are the number styles defined and how does one differentiate a style reference s="9" from indicating a cell formatting (visual) style vs a number style?

Obviously I'm looking in the wrong place to match styles on cells with their number formats.  Where's the right place to find this information?

Body:
The s attribute references a style xf entry in styles.xml. The style xf in turn references a number format mask. To identify a cell that contains a date, you need to perform the style xf -> numberformat lookup, then identify whether that numberformat mask is a date/time numberformat mask (rather than, for example, a percentage or an accounting numberformat mask).

The style.xml file has elements like:

<xf numFmtId="14" ... applyNumberFormat="1" />
<xf numFmtId="1" ... applyNumberFormat="1" />

These are the xf entries, which in turn give you a numFmtId that references the number format mask.

You should find the numFmts section somewhere near the top of style.xml, as part of the styleSheet element

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
        <numFmts count="3">
            <numFmt numFmtId="164" formatCode="[$-414]mmmm\ yyyy;@" />
            <numFmt numFmtId="165" formatCode="0.000" />
            <numFmt numFmtId="166" formatCode="#,##0.000" />
        </numFmts>

The number format id may be here, or it may be one of the built-in formats. Number format codes (numFmtId) less than 164 are "built-in".

The list that I have is incomplete:

0 = 'General';
1 = '0';
2 = '0.00';
3 = '#,##0';
4 = '#,##0.00';

9 = '0%';
10 = '0.00%';
11 = '0.00E+00';
12 = '# ?/?';
13 = '# ??/??';
14 = 'mm-dd-yy';
15 = 'd-mmm-yy';
16 = 'd-mmm';
17 = 'mmm-yy';
18 = 'h:mm AM/PM';
19 = 'h:mm:ss AM/PM';
20 = 'h:mm';
21 = 'h:mm:ss';
22 = 'm/d/yy h:mm';

37 = '#,##0 ;(#,##0)';
38 = '#,##0 ;[Red](#,##0)';
39 = '#,##0.00;(#,##0.00)';
40 = '#,##0.00;[Red](#,##0.00)';

44 = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)';
45 = 'mm:ss';
46 = '[h]:mm:ss';
47 = 'mmss.0';
48 = '##0.0E+0';
49 = '@';

27 = '[$-404]e/m/d';
30 = 'm/d/yy';
36 = '[$-404]e/m/d';
50 = '[$-404]e/m/d';
57 = '[$-404]e/m/d';

59 = 't0';
60 = 't0.00';
61 = 't#,##0';
62 = 't#,##0.00';
67 = 't0%';
68 = 't0.00%';
69 = 't# ?/?';
70 = 't# ??/??';

The missing values are mainly related to east asian variant formats.


问:
Do not request Window.FEATURE_ACTION_BAR issue
I'm trying to build my app but without success.. I tried several way but nothing was worked. The exception is:

```<code>Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
</code>```

My style.xml is:

```<code><resources>

    <style name="AppTheme" parent="Theme.AppCompat.Light">

        <!-- theme customizations -->

        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>

        <item name="android:textColorPrimary">@color/ldrawer_color</item>
        <item name="actionMenuTextColor">@color/ldrawer_color</item>
        <item name="android:textColorSecondary">@color/ldrawer_color</item>
    </style>

</resources>
</code>```

and as you can see i have declared

```<code><item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
</code>```

This is my manifest.xml

```<code> <application
        android:allowBackup="true"
        tools:replace="android:icon"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</code>```

and my BaseActivity that i use to extend other activities

```<code>import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

public abstract class BaseActivity extends AppCompatActivity {

    public Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutResource());
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        if (toolbar != null) {
            setSupportActionBar(toolbar);
            getSupportActionBar().setTitle(BaseActivity.this.getResources().getString(R.string.app_name));
            //getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    protected abstract int getLayoutResource();

    protected void setActionBarIcon(int iconRes) {
        toolbar.setNavigationIcon(iconRes);
    }

}
</code>```

I don't know why it crashes..The only way to start the application without crash is set the parent on the style.xml in Theme.AppCompat.Light.NoActionBar but in this way the status bar is transparent and not colored...

答:
I have solved the problem after changing the value for the "android:theme" for the Activity in the manifest from "@style/AppTheme" to "@style/AppTheme.NoActionBar":</p>

```<code><activity android:name=".MyXXXActivity"
            ...                android:theme="@style/AppTheme.NoActionBar" />
</code>```

Body:
I'm trying to build my app but without success.. I tried several way but nothing was worked. The exception is:

Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

My style.xml is:

<resources>

</resources>

and as you can see i have declared

<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>

This is my manifest.xml

 <application
        android:allowBackup="true"
        tools:replace="android:icon"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

and my BaseActivity that i use to extend other activities

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

public abstract class BaseActivity extends AppCompatActivity {

    public Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutResource());
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        if (toolbar != null) {
            setSupportActionBar(toolbar);
            getSupportActionBar().setTitle(BaseActivity.this.getResources().getString(R.string.app_name));
            //getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    protected abstract int getLayoutResource();

    protected void setActionBarIcon(int iconRes) {
        toolbar.setNavigationIcon(iconRes);
    }

}

I don't know why it crashes..The only way to start the application without crash is set the parent on the style.xml in Theme.AppCompat.Light.NoActionBar but in this way the status bar is transparent and not colored...

Body:
I have solved the problem after changing the value for the "android:theme" for the Activity in the manifest from "@style/AppTheme" to "@style/AppTheme.NoActionBar":

<activity android:name=".MyXXXActivity"
            ...                android:theme="@style/AppTheme.NoActionBar" />


问:
jQuery deferred: Nesting promises in methods, last callback too early
I have a problem with deferreds/promises. I have a main function that calls two functions that have to be executed serially. The first one contains a bunch of asynchronous web service calls that have to be executed serially first. But actually my second function is called before every asynchronous feedback in the first function is there.

I built a small example that shows my problem: https://fiddle.jshell.net/qLf1c0uq/

Here is the code for reference:

function first() {
  $('ul').append("
first started
");
  let deferred = $.Deferred();
  setTimeout(function() { // Any async function.
    $('ul').append("
first ended
");
    deferred.resolve();
  }, 2000);
  return deferred.promise();
}

function second(da) {
  $('ul').append("
second started
");
  let deferred = $.Deferred();
  $('ul').append("
second ended
");
  deferred.resolve();
  return deferred.promise();
}

function third(da) {
  $('ul').append('
third started
')
  let deferred = $.Deferred();
  setTimeout(function() {
    $('ul').append("
third ended
");
    deferred.resolve();
  }, 2000);

  return deferred.promise();
}

function GroupFunction1() {
  let deferred = $.Deferred();
  $('ul').append("
Group 1 started
");
  var data = "test2";
  $.when(first()).then(function() {
    second(data);
  }).then(function() {
    third("test2");
  }).then(function() {
    $('ul').append("
Group 1 ended
");
    deferred.resolve();
  });

  return deferred.promise();
}

function GroupFunction2() {
  $('ul').append("
Group 2 started
");

  $('ul').append("
Group 2 ended
");
}

$(function() {
  $.when(GroupFunction1()).then(GroupFunction2);
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul></ul></code>```

The GroupFunction2 is started before the third function ends. I was expecting it vice versa.

Anyone can help?

Thanks!

答:
Not really an answer to your question; JLRishe already explained why your code didn't wait for your promises.

This is rather a cleanup, and I've included a little utility that wraps setTimeout into a Promise so you don't have to do it maunally and don't repeat yourself all over the place.

function first(data) {
  $('ul').append("
first started
");
  return wait(2000)
    .then(function(){
      $('ul').append("
first ended
");
    });
}

function second(data) {
  $('ul').append("
second started
");
  $('ul').append("
second ended
");
  //let's stay consistent with our API
  //even if we have to return an empty/pointless Promise for that
  return Promise.resolve();
}

function third(data) {
  $('ul').append("
third started
");
  return wait(2000)
    .then(function(){
      $('ul').append("
third ended
");
    });
}

function GroupFunction1() {
  $('ul').append("
Group 1 started
");
  var data = "test2";
  return first(data)
    //.then(wait(1000))  //maybe a little pause in between?
    .then(function(){
      return second(data);
    })
    //.then(wait(1000))  //maybe a little pause in between?
    .then(function(){
      return third(data);
    })
    .then(function() {
      $('ul').append("
Group 1 ended
");
    });
}

function GroupFunction2() {
  $('ul').append("
Group 2 started
");

  $('ul').append("
Group 2 ended
");
  return Promise.resolve(); //again, just staying consistent
}

//DRY. Get rid of all the manual setTiemouts and the Deferreds and wrap them into a function:

//Examples on how to use:
//promise = somePromise.then(wait(1000)).then(someFn);
//promise = wait(1000).then(someFn);
//promise = wait(1000).resolve(42);
//promise = wait(30000).reject("timeout");
const wait = (function(){
 const reject = Promise.reject.bind(Promise);
 const methods = {
  then(a,b){ return this().then(a,b) },
  resolve(value){ return this(value) },
  reject(err){ return this(err).then(reject) }
 };
 return delay => Object.assign(value => new Promise(resolve => void setTimeout(resolve, delay, value)), methods);
})();

$(function() {
  GroupFunction1().then(GroupFunction2);
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul></ul></code>```

Body:
I have a problem with deferreds/promises. I have a main function that calls two functions that have to be executed serially. The first one contains a bunch of asynchronous web service calls that have to be executed serially first. But actually my second function is called before every asynchronous feedback in the first function is there.

I built a small example that shows my problem: https://fiddle.jshell.net/qLf1c0uq/

Here is the code for reference:

function first() {
  $('ul').append("
first started
");
  let deferred = $.Deferred();
  setTimeout(function() { // Any async function.
    $('ul').append("
first ended
");
    deferred.resolve();
  }, 2000);
  return deferred.promise();
}

function second(da) {
  $('ul').append("
second started
");
  let deferred = $.Deferred();
  $('ul').append("
second ended
");
  deferred.resolve();
  return deferred.promise();
}

function third(da) {
  $('ul').append('
third started
')
  let deferred = $.Deferred();
  setTimeout(function() {
    $('ul').append("
third ended
");
    deferred.resolve();
  }, 2000);

  return deferred.promise();
}

function GroupFunction1() {
  let deferred = $.Deferred();
  $('ul').append("
Group 1 started
");
  var data = "test2";
  $.when(first()).then(function() {
    second(data);
  }).then(function() {
    third("test2");
  }).then(function() {
    $('ul').append("
Group 1 ended
");
    deferred.resolve();
  });

  return deferred.promise();
}

function GroupFunction2() {
  $('ul').append("
Group 2 started
");

  $('ul').append("
Group 2 ended
");
}

$(function() {
  $.when(GroupFunction1()).then(GroupFunction2);
})

The GroupFunction2 is started before the third function ends. I was expecting it vice versa.

Anyone can help?

Thanks!

Body:
Not really an answer to your question; JLRishe already explained why your code didn't wait for your promises.

This is rather a cleanup, and I've included a little utility that wraps setTimeout into a Promise so you don't have to do it maunally and don't repeat yourself all over the place.

function first(data) {
  $('ul').append("<li>first started</li>");
  return wait(2000)
    .then(function(){
      $('ul').append("<li>first ended</li>");
    });
}

function second(data) {
  $('ul').append("<li>second started</li>");
  $('ul').append("<li>second ended</li>");
  //let's stay consistent with our API
  //even if we have to return an empty/pointless Promise for that
  return Promise.resolve();
}

function third(data) {
  $('ul').append("<li>third started</li>");
  return wait(2000)
    .then(function(){
      $('ul').append("<li>third ended</li>");
    });
}

function GroupFunction1() {
  $('ul').append("<li>Group 1 started</li>");
  var data = "test2";
  return first(data)
    //.then(wait(1000))  //maybe a little pause in between?
    .then(function(){
      return second(data);
    })
    //.then(wait(1000))  //maybe a little pause in between?
    .then(function(){
      return third(data);
    })
    .then(function() {
      $('ul').append("<li>Group 1 ended</li>");
    });
}

function GroupFunction2() {
  $('ul').append("<li>Group 2 started</li>");

  $('ul').append("<li>Group 2 ended</li>");
  return Promise.resolve(); //again, just staying consistent
}

//DRY. Get rid of all the manual setTiemouts and the Deferreds and wrap them into a function:

//Examples on how to use:
//promise = somePromise.then(wait(1000)).then(someFn);
//promise = wait(1000).then(someFn);
//promise = wait(1000).resolve(42);
//promise = wait(30000).reject("timeout");
const wait = (function(){
 const reject = Promise.reject.bind(Promise);
 const methods = {
  then(a,b){ return this().then(a,b) },
  resolve(value){ return this(value) },
  reject(err){ return this(err).then(reject) }
 };
 return delay => Object.assign(value => new Promise(resolve => void setTimeout(resolve, delay, value)), methods);
})();

$(function() {
  GroupFunction1().then(GroupFunction2);
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul></ul>


问:
Php check if my date from db is today echo with today and if tomorrow then echo tomorrow
How to make a check if datetime from my db is today and then echo with "today" and if my datetime is tomorrow echo with tomorrow. I want to make this for a date reminder for fullcalendar.

My Php code is not working or is messed:

```<code>$reminder = date('d-M-Y',strtotime(date("d-m-Y", strtotime($row['start'])) . " +0 days"));
$tomorrow = strtotime("+1 day");
$tomorrow = getdate($tomorrow);

if($reminder = "0 Days") {
    echo "Today";
} else if($reminder = "1 Days" ) {
    echo "Tomorrow";
} else {
    echo (strtotime($reminder) - strtotime(date('d-M-Y'))) / (60 * 60 * 24).' Days';
}
</code>```

答:
Check your if-statements, you are setting rather than checking.

Replace your = with == in your ifs:

```<code>if($reminder == "0 Days") {
    echo "Today";
} else if($reminder == "1 Days" ) {
    echo "Tomorrow";
} else {
    echo (strtotime($reminder) - strtotime(date('d-M-Y'))) / (60 * 60 * 24).' Days';
}
</code>```

Body:
How to make a check if datetime from my db is today and then echo with "today" and if my datetime is tomorrow echo with tomorrow. I want to make this for a date reminder for fullcalendar.

My Php code is not working or is messed:

$reminder = date('d-M-Y',strtotime(date("d-m-Y", strtotime($row['start'])) . " +0 days"));
$tomorrow = strtotime("+1 day");
$tomorrow = getdate($tomorrow);

if($reminder = "0 Days") {
    echo "Today";
} else if($reminder = "1 Days" ) {
    echo "Tomorrow";
} else {
    echo (strtotime($reminder) - strtotime(date('d-M-Y'))) / (60 * 60 * 24).' Days';
}

Body:
Check your if-statements, you are setting rather than checking.

Replace your = with == in your ifs:

if($reminder == "0 Days") {
    echo "Today";
} else if($reminder == "1 Days" ) {
    echo "Tomorrow";
} else {
    echo (strtotime($reminder) - strtotime(date('d-M-Y'))) / (60 * 60 * 24).' Days';
}


问:
Why does my Tkinter window background not change?
I've a small program with a feature to change the background color of a different window than the frame I use to ask for the background color. (I hope you understand this.) The program is written in Python with the Tkinter library.

Every time I click Enable in the window it changes the color of the background in the second window but not to the color I choose.

Where is the problem?

```<code>def Options():
def OptionButton():
    c= wert.get()
    if c == 1:
        fenster.config(background="red")
    elif c == 2:
        fenster.config(background="blue")
    else:
        fenster.config(background="yellow")

    global usermod
    usermod= tkinter.Entry.get(opEntry)

    fenster.update()
    option.destroy()

def close():
    option.destroy()

option=tkinter.Tk()
option.title("Options")
option.config(background="white")

#Backgroundframe
bgFrame= tkinter.Frame(option)
bgFrame.grid(row=0, column=0, padx=10, pady=20)

info3=tkinter.Label(bgFrame,text="Hintergrund im Menü")
info3.grid(row=1,column=0,padx=10, pady=20)

#2 Radiobutton

global wert
wert = tkinter.StringVar()

knopfA=tkinter.Radiobutton(bgFrame,text="Red", variable=wert,value="1")
knopfB=tkinter.Radiobutton(bgFrame,text="Blue", variable=wert, value="2")
knopfC=tkinter.Radiobutton(bgFrame,text="green", variable=wert,value="3")

knopfA.grid(column=0,row=2)
knopfB.grid(column=0,row=3)
knopfC.grid(column=0,row=4)

knopfA.select()

#OptionFrame
opFrame = tkinter.Frame(option)
opFrame.grid(row=0, column=1,padx=10,pady=20)

#Optionbutton
oplabel=tkinter.Label(opFrame,text="Value User Mode")
oplabel.grid(row=1,column=0,padx=10,pady=2)

opEntry=tkinter.Entry(opFrame,width=12)
opEntry.grid(row=2,column=0,padx=10,pady=2)

#OptionButtonFrame
btFrame=tkinter.Frame(option)
btFrame.grid(row=3,column=0,padx=10,pady=20)

opbutton=tkinter.Button(btFrame,text="Enable", command = lambda:OptionButton())
opbutton.grid(row=1, column=0,padx=10,pady=2)

clbutton=tkinter.Button(btFrame,text="close",command=lambda:close())
clbutton.grid(row=2, column=0,padx=10,pady=2)

option.mainloop()
</code>```

答:
The problem is this code:

```<code>c = wert.get()

if c == 1:
        fenster.config(background="red")
elif c == 2:
        fenster.config(background="blue")
else:
        fenster.config(background="yellow")
</code>```

The .get() method is returning a str, because you declared wert to be a StringVar() but you're comparing to an int.  Either convert via int(c) or compare strings:

```<code>if c == '1':
</code>```

or perhaps declare wert to be an IntVar().  Also, reread how the Python global statement works -- use it where you want to modify a global within a function, not where the global is defined.

Body:
I've a small program with a feature to change the background color of a different window than the frame I use to ask for the background color. (I hope you understand this.) The program is written in Python with the Tkinter library.

Every time I click Enable in the window it changes the color of the background in the second window but not to the color I choose.

Where is the problem?

def Options():
def OptionButton():
    c= wert.get()
    if c == 1:
        fenster.config(background="red")
    elif c == 2:
        fenster.config(background="blue")
    else:
        fenster.config(background="yellow")

    global usermod
    usermod= tkinter.Entry.get(opEntry)

    fenster.update()
    option.destroy()

def close():
    option.destroy()

option=tkinter.Tk()
option.title("Options")
option.config(background="white")

#Backgroundframe
bgFrame= tkinter.Frame(option)
bgFrame.grid(row=0, column=0, padx=10, pady=20)

info3=tkinter.Label(bgFrame,text="Hintergrund im Menü")
info3.grid(row=1,column=0,padx=10, pady=20)

#2 Radiobutton

global wert
wert = tkinter.StringVar()

knopfA=tkinter.Radiobutton(bgFrame,text="Red", variable=wert,value="1")
knopfB=tkinter.Radiobutton(bgFrame,text="Blue", variable=wert, value="2")
knopfC=tkinter.Radiobutton(bgFrame,text="green", variable=wert,value="3")

knopfA.grid(column=0,row=2)
knopfB.grid(column=0,row=3)
knopfC.grid(column=0,row=4)

knopfA.select()

#OptionFrame
opFrame = tkinter.Frame(option)
opFrame.grid(row=0, column=1,padx=10,pady=20)

#Optionbutton
oplabel=tkinter.Label(opFrame,text="Value User Mode")
oplabel.grid(row=1,column=0,padx=10,pady=2)

opEntry=tkinter.Entry(opFrame,width=12)
opEntry.grid(row=2,column=0,padx=10,pady=2)

#OptionButtonFrame
btFrame=tkinter.Frame(option)
btFrame.grid(row=3,column=0,padx=10,pady=20)

opbutton=tkinter.Button(btFrame,text="Enable", command = lambda:OptionButton())
opbutton.grid(row=1, column=0,padx=10,pady=2)

clbutton=tkinter.Button(btFrame,text="close",command=lambda:close())
clbutton.grid(row=2, column=0,padx=10,pady=2)

option.mainloop()

Body:
The problem is this code:

c = wert.get()

if c == 1:
        fenster.config(background="red")
elif c == 2:
        fenster.config(background="blue")
else:
        fenster.config(background="yellow")

The .get() method is returning a str, because you declared wert to be a StringVar() but you're comparing to an int.  Either convert via int(c) or compare strings:

if c == '1':

or perhaps declare wert to be an IntVar().  Also, reread how the Python global statement works -- use it where you want to modify a global within a function, not where the global is defined.


问:
Generating maps Dynamically
I am looking to generate transport maps in a style similar to the iconic London underground [tube] map.

These maps will change from time to time and many will be required so instead of drawing them up manually in inkscape [or similar] I am hoping to have them generated dynamically from a db or dataset.

Does anyone know if there is any library apis etc. out there that would help with this task, or any suggestions in general of how [or how not] to go about this ?

I am thinking svg's would be the best way to go with this, plus there may be need for basic interactivity down the line.

I am working in php so otherwise it's GDlib, ImageMagick ?

Thanks in advance.

.k

答:
One strategy I use when I need to generate graphs from data in a db is to extract the data in some kind of XML way (e.g. Oracle SQLX or Cocoon XSP/ESQL or eXist-db XQuery) and process it through an XSLT to generate SVG.  Good old Cocoon is fine for this kind of job if you don't want to write any code (except the XSL of course ;-).

The SVG itself can be loaded in some graphic tools to reprocess.

Title: Generating maps Dynamically


问:
Can't use Bootstrap in PHP file
I'm fetching some data from a MySQL database onto a WebPage. I came up with a simple PHP page that queries the database and shows the query in the form of a table and it works just fine.

However, when I try to add bootstrap to the page and style it, the entire page stops working.

Here's my index.php

```<code><!DOCTYPE html>
<html>
<head>
<title>MakersBox</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<center>
<h1>Sensor Testing Dashboard</h1>
<div class="container">
<?php
echo "<table class='table table-hover' align=center>";
 echo "<thead><tr><th>Sensor Id</th><th>Temperature</th><th>Light</th><th>Last Updated</th></tr></thead>";

class TableRows extends RecursiveIteratorIterator {
    function __construct($it) {
        parent::__construct($it, self::LEAVES_ONLY);
    }

    function current() {
        return "<td>" . parent::current(). "</td>";
    }

    function beginChildren() {
        echo "<tr>";
    }

    function endChildren() {
        echo "</tr>" . "\n";
    }
}

$servername = "localhost";
$username = "root";
$password = "paanikiboond";
$dbname = "testbox1";

try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $conn->prepare("SELECT * FROM sensor ORDER BY LastUpdate DESC LIMIT 1");
    $stmt->execute();

    // set the resulting array to associative
    $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);

    foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
        echo $v;
    }
}
catch(PDOException $e) {
    echo "Error: " . $e->getMessage();
}
$conn = null;
echo "</table>";
</div>

$url1=$_SERVER['REQUEST_URI'];
header("Refresh: 3600 ; URL=$url1");
?>

</body>
</html>
</code>```

Any idea what I may be doing wrong here?

答:
for one thing you arent closing your , so your code should be

```<code><!DOCTYPE html>
<html>
<head>
<title>MakersBox</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
...
</code>```

EDIT: close to the bottom your code should look like

```<code>...
echo "</table>";
echo "</div>";

$url1=$_SERVER['REQUEST_URI'];
header("Refresh: 3600 ; URL=$url1");
?>

</body>
</html>
</code>```

Title: Can't use Bootstrap in PHP file

Body:
I'm fetching some data from a MySQL database onto a WebPage. I came up with a simple PHP page that queries the database and shows the query in the form of a table and it works just fine.

However, when I try to add bootstrap to the page and style it, the entire page stops working.

Here's my index.php

<!DOCTYPE html>

<title>MakersBox</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

Sensor Testing Dashboard

<?php
echo "
";
 echo "

Sensor Id	Temperature	Light	Last Updated

";

class TableRows extends RecursiveIteratorIterator {
    function __construct($it) {
        parent::__construct($it, self::LEAVES_ONLY);
    }

    function current() {
        return "" . parent::current(). "	";
    }

    function beginChildren() {
        echo "
";
    }

    function endChildren() {
        echo "
" . "\n";
    }
}

$servername = "localhost";
$username = "root";
$password = "paanikiboond";
$dbname = "testbox1";

try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $conn->prepare("SELECT * FROM sensor ORDER BY LastUpdate DESC LIMIT 1");
    $stmt->execute();

    // set the resulting array to associative
    $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);

    foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
        echo $v;
    }
}
catch(PDOException $e) {
    echo "Error: " . $e->getMessage();
}
$conn = null;
echo "
";

$url1=$_SERVER['REQUEST_URI'];
header("Refresh: 3600 ; URL=$url1");
?>

Any idea what I may be doing wrong here?

Body:
for one thing you arent closing your <head>, so your code should be

<!DOCTYPE html>
<html>
<head>
<title>MakersBox</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
...

EDIT: close to the bottom your code should look like

...
echo "</table>";
echo "</div>";

$url1=$_SERVER['REQUEST_URI'];
header("Refresh: 3600 ; URL=$url1");
?>

</body>
</html>


问:
type_traits(1545): error C2280:
vs2013,it's wrongs:

D:\vs2013\VC\include\type_traits(1545): error C2280: “std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream(const std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>> &)”: 尝试引用已删除的函数
        1>          D:\vs2013\VC\include\sstream(631) : 参见“std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream”的声明
        1>          D:\vs2013\VC\include\thread(47): 参见对正在编译的函数 模板 实例化“std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>> std::_Decay_copy<std::stringstream&>(_Ty)”的引用
        1>          with
        1>          [
        1>              _Ty=std::stringstream &
        1>          ]
        1>          GA_SpikeDlg.cpp(253): 参见对正在编译的函数 模板 实例化“std::thread::thread<float(__cdecl &)(M_args,double,double,double,double,int [],M_args_Bound [],int,float,float,int,float,float,std::stringstream &),M_args&,double&,double&,double&,double&,int(&)[5],M_args_Bound(&)[5],int&,float&,float&,const int&,float&,float&,std::stringstream&>(_Fn,M_args &,double &,double &,double &,double &,int (&)[5],M_args_Bound (&)[5],int &,float &,float &,const int &,float &,float &,std::stringstream &)”的引用
        1>          with
        1>          [
        1>              _Fn=float (__cdecl &)(M_args,double,double,double,double,int [],M_args_Bound [],int,float,float,int,float,float,std::stringstream &)
        1>          ]
        1>  GA_Spike.cpp
        1>  cuda_transfer.cpp
        1>  正在生成代码...
        ========== 全部重新生成:  成功 0 个，失败 1 个，跳过 0 个 ==========
```

<p>my main code is:</p>

```thread t1(task1, Parameter_, Mtime, tempVB, TimeStep, m_I, FlagParameter, Parameter_Bound, MaxGeneration, gL, C, POPULATION_SIZE, crossver, mutations, strResult);

void task1(M_args Parameter_, double Mtime, double tempVB, double TimeStep, double m_I, int FlagParameter[], M_args_Bound Parameter_Bound[], int MaxGeneration, float gL, float C, const int POPULATION_SIZE, float crossver, float mutations, stringstream &strResult)
{
solveGPU_cpp(Parameter_, Mtime, tempVB, TimeStep, m_I, FlagParameter, Parameter_Bound, MaxGeneration, gL, C, POPULATION_SIZE, crossver, mutations, strResult);
    cout << "task1 says: " << endl;
}
```

AND solveGPU_cpp is a Interface functions of .cu
so what's wrong?

答:
The last parameter is by reference you need std::ref(strResult).

Like:

```<code>thread t1(task1, Parameter_, Mtime, tempVB, TimeStep, m_I, FlagParameter, Parameter_Bound, MaxGeneration, gL, C, POPULATION_SIZE, crossver, mutations,
  std::ref(strResult));    // Pass reference
</code>```

Here a quick & dirty playground - https://godbolt.org/g/iQzJPH

Title: type_traits(1545): error C2280:

Body:
vs2013,it's wrongs:

D:\vs2013\VC\include\type_traits(1545): error C2280: “std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream(const std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>> &)”: 尝试引用已删除的函数
        1>          D:\vs2013\VC\include\sstream(631) : 参见“std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream”的声明
        1>          D:\vs2013\VC\include\thread(47): 参见对正在编译的函数 模板 实例化“std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>> std::_Decay_copy<std::stringstream&>(_Ty)”的引用
        1>          with
        1>          [
        1>              _Ty=std::stringstream &
        1>          ]
        1>          GA_SpikeDlg.cpp(253): 参见对正在编译的函数 模板 实例化“std::thread::thread<float(__cdecl &)(M_args,double,double,double,double,int [],M_args_Bound [],int,float,float,int,float,float,std::stringstream &),M_args&,double&,double&,double&,double&,int(&)[5],M_args_Bound(&)[5],int&,float&,float&,const int&,float&,float&,std::stringstream&>(_Fn,M_args &,double &,double &,double &,double &,int (&)[5],M_args_Bound (&)[5],int &,float &,float &,const int &,float &,float &,std::stringstream &)”的引用
        1>          with
        1>          [
        1>              _Fn=float (__cdecl &)(M_args,double,double,double,double,int [],M_args_Bound [],int,float,float,int,float,float,std::stringstream &)
        1>          ]
        1>  GA_Spike.cpp
        1>  cuda_transfer.cpp
        1>  正在生成代码...
        ========== 全部重新生成:  成功 0 个，失败 1 个，跳过 0 个 ==========

my main code is:

thread t1(task1, Parameter_, Mtime, tempVB, TimeStep, m_I, FlagParameter, Parameter_Bound, MaxGeneration, gL, C, POPULATION_SIZE, crossver, mutations, strResult);

void task1(M_args Parameter_, double Mtime, double tempVB, double TimeStep, double m_I, int FlagParameter[], M_args_Bound Parameter_Bound[], int MaxGeneration, float gL, float C, const int POPULATION_SIZE, float crossver, float mutations, stringstream &strResult)
{
solveGPU_cpp(Parameter_, Mtime, tempVB, TimeStep, m_I, FlagParameter, Parameter_Bound, MaxGeneration, gL, C, POPULATION_SIZE, crossver, mutations, strResult);
    cout << "task1 says: " << endl;
}

AND solveGPU_cpp is a Interface functions of .cu
so what's wrong?

Body:
The last parameter is by reference you need std::ref(strResult).

Like:

thread t1(task1, Parameter_, Mtime, tempVB, TimeStep, m_I, FlagParameter, Parameter_Bound, MaxGeneration, gL, C, POPULATION_SIZE, crossver, mutations,
  std::ref(strResult));    // Pass reference

Here a quick & dirty playground - https://godbolt.org/g/iQzJPH


问:
How to compare Double Array Set
Hi, I would really appreciate the help for this lab. I don't understand what I did wrong; for example, I don't understand the program errors displayed.

5.13 Lab 5b

Objectives

In this lab you will practice using for loops with arrays and comparing double values, using a threshold, to see if two sets of numbers are the same.

Background Reading

ZyBooks Chapter 5

Task

The first comment of your main method should be your identification comment:

```<code>//Lab5b, [Name], [mascID]
</code>```

You will need to then:

Create and populate the two sets of double values, in which the number of elements and the elements themselves are specified by the user. (i.e. the user will state how many numbers are in the first set, give the values for that set and then move on to the second set of numbers).

Iterate through the sets and compare the values. For the purposes of this lab, we will say that the order matters in determining if the sets are the same. (HINT: This also means that the lengths of the arrays must be the same).

If the arrays are the same in both length and values, print set one and set two are equal. Otherwise, print set one and set two are not equal

Comparing double values using a threshold

Recall that floating-point numbers may differ in a very small value. For example, 1.0 might actually be stored as 0.9999999... or 1.0000000002.

When comparing these values, we often use a "tolerance" level that says, "if the difference is smaller than some amount, then it is negligible and the numbers can be thought of as the same." We can achieve this by comparing the absolute value of the difference of the elements to the tolerance. For example,

```<code>if ( Math.abs( array1[0] - array2[0] ) > 0.001 ) )
    System.out.println("The values of array1[0] and array2[0] are not equal");
</code>```

Code:

import java.lang.Math;
import java.util.Scanner;

public class SetComparison {
   public static void main (String [] args) {

      Scanner scnr = new Scanner(System.in);

      int array1Elems = 0;
      int array2Elems = 0;
      int i = 0;
      int j = 0;

      array1Elems = scnr.nextInt();
      array2Elems = scnr.nextInt();

      double array1[] = new double[array1Elems];
      double array2[] = new double[array2Elems];

      for (i = 0; i < array1Elems; ++i) {
         array1[i] = scnr.nextInt;
         for (j = 0; j < array2Elems; ++j) {
            array2[j] = scnr.nextInt;
         }
         if (Math.abs(array1[i] - array2[j]) > 0.001) {
            System.out.println("set one and set two are not equal");
         }
         else if (Math.abs(array1[i] - array2[j]) < 0.001) {
            System.out.println("set one and set two are equal");
         }
      }
   }
}```

Enter program input

6
  45.24 54.67 42.55 44.61 65.29 49.75 6
  45.24 54.67 42.55 44.61 65.29 49.75

Program errors displayed here SetComparison.java:23: error: cannot
  find symbol
           array1[i] = scnr.nextInt;
                           ^   symbol:   variable nextInt   location: variable scnr of type Scanner SetComparison.java:25: error: cannot
  find symbol
              array2[j] = scnr.nextInt;
                              ^   symbol:   variable nextInt   location: variable scnr of type Scanner 2 errors

答:
Besides what @Andy Turner stated in the comments (you are missing the ()), your problem is in the nested loops*. You need to break out of the inner loop after you check the values.

Note: This will also print whether they are equal or not equal on each iteration, and not overall.

```<code>for (i = 0; i < array1Elems; i++) {
        array1[i] = scnr.nextDouble();
        for (j = 0; j < array2Elems; j++) {
            array2[j] = scnr.nextDouble();
            if (Math.abs(array1[i] - array2[j]) > 0.001) {
                System.out.println("set one and set two are not equal");
            } else if (Math.abs(array1[i] - array2[j]) < 0.001) {
                System.out.println("set one and set two are equal");
            }
            break;
        }
    }
</code>```

*Whilst there are far better ways to do this, this is just to match the OPs code as close as possible

Title: How to compare Double Array Set

Body:
Hi, I would really appreciate the help for this lab. I don't understand what I did wrong; for example, I don't understand the program errors displayed.

5.13 Lab 5b

Objectives

In this lab you will practice using for loops with arrays and comparing double values, using a threshold, to see if two sets of numbers are the same.

Background Reading

ZyBooks Chapter 5

Task

The first comment of your main method should be your identification comment:

//Lab5b, [Name], [mascID]

You will need to then:

Create and populate the two sets of double values, in which the number of elements and the elements themselves are specified by the user. (i.e. the user will state how many numbers are in the first set, give the values for that set and then move on to the second set of numbers).

Iterate through the sets and compare the values. For the purposes of this lab, we will say that the order matters in determining if the sets are the same. (HINT: This also means that the lengths of the arrays must be the same).

If the arrays are the same in both length and values, print set one and set two are equal. Otherwise, print set one and set two are not equal

Comparing double values using a threshold

Recall that floating-point numbers may differ in a very small value. For example, 1.0 might actually be stored as 0.9999999... or 1.0000000002.

When comparing these values, we often use a "tolerance" level that says, "if the difference is smaller than some amount, then it is negligible and the numbers can be thought of as the same." We can achieve this by comparing the absolute value of the difference of the elements to the tolerance. For example,

if ( Math.abs( array1[0] - array2[0] ) > 0.001 ) )
    System.out.println("The values of array1[0] and array2[0] are not equal");

Code:

import java.lang.Math;
import java.util.Scanner;

public class SetComparison {
   public static void main (String [] args) {

      Scanner scnr = new Scanner(System.in);

      int array1Elems = 0;
      int array2Elems = 0;
      int i = 0;
      int j = 0;

      array1Elems = scnr.nextInt();
      array2Elems = scnr.nextInt();

      double array1[] = new double[array1Elems];
      double array2[] = new double[array2Elems];

      for (i = 0; i < array1Elems; ++i) {
         array1[i] = scnr.nextInt;
         for (j = 0; j < array2Elems; ++j) {
            array2[j] = scnr.nextInt;
         }
         if (Math.abs(array1[i] - array2[j]) > 0.001) {
            System.out.println("set one and set two are not equal");
         }
         else if (Math.abs(array1[i] - array2[j]) < 0.001) {
            System.out.println("set one and set two are equal");
         }
      }
   }
}

Enter program input

6
  45.24 54.67 42.55 44.61 65.29 49.75 6
  45.24 54.67 42.55 44.61 65.29 49.75

Program errors displayed here SetComparison.java:23: error: cannot
  find symbol
           array1[i] = scnr.nextInt;
                           ^   symbol:   variable nextInt   location: variable scnr of type Scanner SetComparison.java:25: error: cannot
  find symbol
              array2[j] = scnr.nextInt;
                              ^   symbol:   variable nextInt   location: variable scnr of type Scanner 2 errors

Body:
Besides what @Andy Turner stated in the comments (you are missing the ()), your problem is in the nested loops*. You need to break out of the inner loop after you check the values.

Note: This will also print whether they are equal or not equal on each iteration, and not overall.

for (i = 0; i < array1Elems; i++) {
        array1[i] = scnr.nextDouble();
        for (j = 0; j < array2Elems; j++) {
            array2[j] = scnr.nextDouble();
            if (Math.abs(array1[i] - array2[j]) > 0.001) {
                System.out.println("set one and set two are not equal");
            } else if (Math.abs(array1[i] - array2[j]) < 0.001) {
                System.out.println("set one and set two are equal");
            }
            break;
        }
    }

*Whilst there are far better ways to do this, this is just to match the OPs code as close as possible


问:
Application's Toolbar is not collapsing when Scrolling RecyclerView inside fragments
Application's Toolbar is not collapsing. Here is my activity_main xml file, how

to collapse the application toolbar. I tried implementing with the bellow code but my code doesn't even collapse and showing something else. If i remove the
android.support.design.widget.CollapsingToolbarLayout tag then I can see my original layout like

This is the view without implementation of CollapsingToolBar.

More about the design is, I have 9 tabs with 9 fragments implemented for each tab with RecyclerView in it. While scrolling the recyclerview upwards the toolbar is not collapsing after implementation of CollapsingToolBar in the activity_main.xml file.

```<code><android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:theme="@style/ThemeOverlay.AppCompat.Dark">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorPrimary"/>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabGravity="fill"
            app:tabIndicatorHeight="2dp"
            app:tabMode="scrollable"
            app:tabMaxWidth="0dp"
            android:theme="@style/MyMaterialTheme"/>
 </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>
    <View
        android:id="@+id/view_line"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#f90404"
        android:layout_below="@+id/appbar"/>

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawerLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/view_line">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/main_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:clickable="true"
            android:padding="5dp">

        </FrameLayout>
        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

            <FrameLayout
                android:id="@+id/mensaje_vp_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:clickable="true" />

        </RelativeLayout>
        <android.support.design.widget.NavigationView
            android:id="@+id/navigation"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:fitsSystemWindows="true"
            app:itemBackground="@android:color/transparent"
            app:itemTextColor="#780d0d"
            app:menu="@menu/navigation_drawer_items"
            />

    </android.support.v4.widget.DrawerLayout>

</android.support.design.widget.CoordinatorLayout>
</code>```

答:
Try this. You need to set app:layout_behavior="@string/appbar_scrolling_view_behavior" to the layout below AppBarLayout.

```<code><android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/view_line">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:theme="@style/ThemeOverlay.AppCompat.Dark">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/colorPrimary"
                    app:layout_collapseMode="pin"/>

                <android.support.design.widget.TabLayout
                    android:id="@+id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabGravity="fill"
                    app:tabIndicatorHeight="2dp"
                    app:tabMaxWidth="0dp"
                    app:tabMode="scrollable"/>
            </android.support.design.widget.CollapsingToolbarLayout>

        </android.support.design.widget.AppBarLayout>

        <View
            android:id="@+id/view_line"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/appbar"
            android:background="#f90404"/>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <FrameLayout
                android:id="@+id/main_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentBottom="true"
                android:clickable="true"
                android:padding="5dp">

            </FrameLayout>

            <android.support.v4.view.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

            <FrameLayout
                android:id="@+id/mensaje_vp_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:clickable="true"/>

        </RelativeLayout>
    </android.support.design.widget.CoordinatorLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:fitsSystemWindows="true"
        app:itemBackground="@android:color/transparent"
        app:itemTextColor="#780d0d"
        app:menu="@menu/sample_actions"/>

</android.support.v4.widget.DrawerLayout>
</code>```

Body:
Application's Toolbar is not collapsing. Here is my activity_main xml file, how

to collapse the application toolbar. I tried implementing with the bellow code but my code doesn't even collapse and showing something else. If i remove the
android.support.design.widget.CollapsingToolbarLayout tag then I can see my original layout like

This is the view without implementation of CollapsingToolBar.

More about the design is, I have 9 tabs with 9 fragments implemented for each tab with RecyclerView in it. While scrolling the recyclerview upwards the toolbar is not collapsing after implementation of CollapsingToolBar in the activity_main.xml file.

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:theme="@style/ThemeOverlay.AppCompat.Dark">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorPrimary"/>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabGravity="fill"
            app:tabIndicatorHeight="2dp"
            app:tabMode="scrollable"
            app:tabMaxWidth="0dp"
            android:theme="@style/MyMaterialTheme"/>
 </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>
    <View
        android:id="@+id/view_line"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#f90404"
        android:layout_below="@+id/appbar"/>

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawerLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/view_line">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/main_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:clickable="true"
            android:padding="5dp">

        </FrameLayout>
        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

            <FrameLayout
                android:id="@+id/mensaje_vp_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:clickable="true" />

        </RelativeLayout>
        <android.support.design.widget.NavigationView
            android:id="@+id/navigation"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:fitsSystemWindows="true"
            app:itemBackground="@android:color/transparent"
            app:itemTextColor="#780d0d"
            app:menu="@menu/navigation_drawer_items"
            />

    </android.support.v4.widget.DrawerLayout>

</android.support.design.widget.CoordinatorLayout>

Body:
Try this. You need to set app:layout_behavior="@string/appbar_scrolling_view_behavior" to the layout below AppBarLayout.

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/view_line">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:theme="@style/ThemeOverlay.AppCompat.Dark">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/colorPrimary"
                    app:layout_collapseMode="pin"/>

                <android.support.design.widget.TabLayout
                    android:id="@+id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabGravity="fill"
                    app:tabIndicatorHeight="2dp"
                    app:tabMaxWidth="0dp"
                    app:tabMode="scrollable"/>
            </android.support.design.widget.CollapsingToolbarLayout>

        </android.support.design.widget.AppBarLayout>

        <View
            android:id="@+id/view_line"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/appbar"
            android:background="#f90404"/>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <FrameLayout
                android:id="@+id/main_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentBottom="true"
                android:clickable="true"
                android:padding="5dp">

            </FrameLayout>

            <android.support.v4.view.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

            <FrameLayout
                android:id="@+id/mensaje_vp_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:clickable="true"/>

        </RelativeLayout>
    </android.support.design.widget.CoordinatorLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:fitsSystemWindows="true"
        app:itemBackground="@android:color/transparent"
        app:itemTextColor="#780d0d"
        app:menu="@menu/sample_actions"/>

</android.support.v4.widget.DrawerLayout>


问:
How to add jQuery library to Wordpress?
I would like to add a jQuery library to my Wordpress site. I watched a lot of tutorials but all of them explain how to add a single js file only. But my library has multiple js files, css, etc. How can I add the whole library? Thank you very much!</p>

答:
Wordpress alredy includes a copy of Jquery library. In your theme functions.php file you just simply have to load it like this</p>

```<code>add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' );

function theme_enqueue_scripts() {
  wp_enqueue_script("jquery");
  wp_enqueue_script( 'map-script', get_template_directory_uri() . '/js/map-script.js', array('jquery'), '20151215', true );
}
</code>```

Title: How to add jQuery library to Wordpress?

Body:
Wordpress alredy includes a copy of Jquery library. In your theme functions.php file you just simply have to load it like this

add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' );

function theme_enqueue_scripts() {
  wp_enqueue_script("jquery");
  wp_enqueue_script( 'map-script', get_template_directory_uri() . '/js/map-script.js', array('jquery'), '20151215', true );
}


问:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
I am facing the Problem when I have updated my Xcode to 7.0 or iOS 9.0.
Somehow it started giving me the Titled error

"The resource could not be loaded because the App Transport Security
policy requires the use of a secure connection"

Webservice Method:

- (void)ServiceCall:(NSString*)ServiceName :(NSString *)DataString
{
    NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
    [sessionConfiguration setAllowsCellularAccess:YES];
    [sessionConfiguration setHTTPAdditionalHeaders:@{ @"Accept" : @"application/json" }];
    NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",ServiceURL]];
    NSLog(@"URl %@%@",url,DataString);
    // Configure the Request
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setValue:[NSString stringWithFormat:@"%@=%@", strSessName, strSessVal] forHTTPHeaderField:@"Cookie"];
    request.HTTPBody = [DataString dataUsingEncoding:NSUTF8StringEncoding];
    request.HTTPMethod = @"Post";

    // post the request and handle response
    NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
        {
        // Handle the Response
        if(error)
        {
            NSLog(@"%@",[NSString stringWithFormat:@"Connection failed: %@", [error description]]);

            // Update the View
            dispatch_async(dispatch_get_main_queue(), ^{

                // Hide the Loader
                [MBProgressHUD hideHUDForView:[[UIApplication sharedApplication] delegate].window animated:YES];

            });
            return;
        }
        NSArray * cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:request.URL];
        for (NSHTTPCookie * cookie in cookies)
        {
            NSLog(@"%@=%@", cookie.name, cookie.value);
            strSessName=cookie.name;
            strSessVal=cookie.value;

        }

        NSString *retVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    }];

    [postDataTask resume];
}
```

The service is Running fine for Xcode earlier versions and iOS previous versions But when I have updated to Xcode 7.0 that is on iOS 9.0, it started to give me the Problem like following when I am calling the above web service method. The Logged Error which I am getting is:

Connection failed: Error Domain=NSURLErrorDomain Code=-1022 "The
resource could not be loaded because the App Transport Security policy
requires the use of a secure connection."
UserInfo={NSUnderlyingError=0x7fada0f31880 {Error
Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"},
NSErrorFailingURLStringKey=MyServiceURL,
NSErrorFailingURLKey=MyServiceURL,
NSLocalizedDescription=The resource could not be loaded because the
App Transport Security policy requires the use of a secure
connection.}

I have tried Following Questions and answers but did not get any result there, is there any advance idea how I can remove that service call error?

The resource could not be loaded is ios9

App Transport Security Xcode 7 beta 6

https://stackoverflow.com/a/32609970

答:
Open your pList.info as Source Code and at bottom just before </dict> add following code,

```<code> <!--By Passing-->
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>your.domain.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>1.0</string>
                <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
        </dict>
    </dict>
    <!--End Passing-->
</code>```

And finally change your.domain.com with your base Url. Thanks.

Body:
I am facing the Problem when I have updated my Xcode to 7.0 or iOS 9.0.
Somehow it started giving me the Titled error

"The resource could not be loaded because the App Transport Security
policy requires the use of a secure connection"

Webservice Method:

- (void)ServiceCall:(NSString*)ServiceName :(NSString *)DataString
{
    NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
    [sessionConfiguration setAllowsCellularAccess:YES];
    [sessionConfiguration setHTTPAdditionalHeaders:@{ @"Accept" : @"application/json" }];
    NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",ServiceURL]];
    NSLog(@"URl %@%@",url,DataString);
    // Configure the Request
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setValue:[NSString stringWithFormat:@"%@=%@", strSessName, strSessVal] forHTTPHeaderField:@"Cookie"];
    request.HTTPBody = [DataString dataUsingEncoding:NSUTF8StringEncoding];
    request.HTTPMethod = @"Post";

    // post the request and handle response
    NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
        {
        // Handle the Response
        if(error)
        {
            NSLog(@"%@",[NSString stringWithFormat:@"Connection failed: %@", [error description]]);

            // Update the View
            dispatch_async(dispatch_get_main_queue(), ^{

                // Hide the Loader
                [MBProgressHUD hideHUDForView:[[UIApplication sharedApplication] delegate].window animated:YES];

            });
            return;
        }
        NSArray * cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:request.URL];
        for (NSHTTPCookie * cookie in cookies)
        {
            NSLog(@"%@=%@", cookie.name, cookie.value);
            strSessName=cookie.name;
            strSessVal=cookie.value;

        }

        NSString *retVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    }];

    [postDataTask resume];
}

The service is Running fine for Xcode earlier versions and iOS previous versions But when I have updated to Xcode 7.0 that is on iOS 9.0, it started to give me the Problem like following when I am calling the above web service method. The Logged Error which I am getting is:

Connection failed: Error Domain=NSURLErrorDomain Code=-1022 "The
resource could not be loaded because the App Transport Security policy
requires the use of a secure connection."
UserInfo={NSUnderlyingError=0x7fada0f31880 {Error
Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"},
NSErrorFailingURLStringKey=MyServiceURL,
NSErrorFailingURLKey=MyServiceURL,
NSLocalizedDescription=The resource could not be loaded because the
App Transport Security policy requires the use of a secure
connection.}

I have tried Following Questions and answers but did not get any result there, is there any advance idea how I can remove that service call error?

The resource could not be loaded is ios9

App Transport Security Xcode 7 beta 6

https://stackoverflow.com/a/32609970

Body:
Open your pList.info as Source Code and at bottom just before </dict> add following code,

 <!--By Passing-->
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>your.domain.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>1.0</string>
                <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
        </dict>
    </dict>
    <!--End Passing-->

And finally change your.domain.com with your base Url. Thanks.


问:
woocommerce products shortcode with limit property not working
I am using woocommerce product shortcode for feching product list

```<code>echo do_shortcode( '[products limit="4" columns="4" orderby="popularity" ]' );
</code>```

and referring it from here.

Columns and orderby property works fine but limit is not working.
I always return list of all the product.

How can i fix this?

答:
Perhaps because none of your product was purchased. Try making a test purchase of several products. Or change popularity to title or to another. Read more information on that site

```<code>echo do_shortcode( '[products limit="4" columns="4" orderby="title" ]' );
</code>```

or

```<code>echo do_shortcode( '[products limit="4" columns="4" orderby="id" ]' );
</code>```

Body:
I am using woocommerce product shortcode for feching product list

echo do_shortcode( '[products limit="4" columns="4" orderby="popularity" ]' );

and referring it from here.

Columns and orderby property works fine but limit is not working.
I always return list of all the product.

How can i fix this?

Body:
Perhaps because none of your product was purchased. Try making a test purchase of several products. Or change popularity to title or to another. Read more information on that site

echo do_shortcode( '[products limit="4" columns="4" orderby="title" ]' );

or

echo do_shortcode( '[products limit="4" columns="4" orderby="id" ]' );


问:
Disable delete row in transaction's grids
I need to disable o remove the "x" (delete) icon in transaction's grid.

Genexus X Ev.3 U1

Thanks!

答:
You can change the visibility value to false in the CSS class of the item. In this case I think that the CSS class is called "DeleteAttribute".
The CSS configuration is in KB Explorer -> Customization -> Themes -> your_theme_name.</p>


问:
How to have checkbox items create a list
I am new to PHP and the project I am working on is a codeigniter php form writing back to a FileMaker database.

The checkboxes should be populating as a list field.

Here is my form

```<code><input name="fieldname[]" value="value1"<?php echo (set_checkbox('fieldname', $join->fieldname))?> type="checkbox" class="form-check-input"> value1
<input name="fieldname[]" value="value2"<?php echo (set_checkbox('fieldname', $join->fieldname))?> type="checkbox" class="form-check-input"> value2
</code>```

There are about 7 checkboxes.

I assume that I have to setup a foreach loop to get it to go thought to FileMaker's field, but unsure how to do that.

If I take away the array, the last one selected goes through to the layout.

Any help would be great.

答:
```<code>    $ids=implode(",", $_REQUEST["fieldname"]);
    $result3=mysqli_query($dbh,'SELECT* FROM excel_tenant WHERE ID IN ("' .
    $ids .    '") AND
    ManagerID =  "'.$_SESSION["ManagerID"].'" ORDER BY ID DESC ') or
    die(mysqli_error($dbh));
</code>```

Body:
I am new to PHP and the project I am working on is a codeigniter php form writing back to a FileMaker database.

The checkboxes should be populating as a list field.

Here is my form

<input name="fieldname[]" value="value1"<?php echo (set_checkbox('fieldname', $join->fieldname))?> type="checkbox" class="form-check-input"> value1
<input name="fieldname[]" value="value2"<?php echo (set_checkbox('fieldname', $join->fieldname))?> type="checkbox" class="form-check-input"> value2

There are about 7 checkboxes.

I assume that I have to setup a foreach loop to get it to go thought to FileMaker's field, but unsure how to do that.

If I take away the array, the last one selected goes through to the layout.

Any help would be great.


问:
Is there any way to access response / request details for the last executed Postman call
Is there any way to access the response and request properties of the last run postman call using pm api's. In other words, does postman keep any historical log which is accessible till at least the last request.

Something like:
pm.lastResponse.body or pm.lastRequest.Url

答:
You can save the response from the last call to an environment variable and get it on the next one

http://blog.getpostman.com/2014/01/27/extracting-data-from-responses-and-chaining-requests/


问:
Play youtube video on hover
I just need to play the youtube video only when hovered

I have here a fiddle and can't get it to work.

```<code>$(document).ready(function(){
  $(function() {

      var playersrc = jQuery(iframe).attr('src');

          $('div').hover(function(){
          $('iframe').attr('src',playersrc+'&autoplay=1');
      }, function(){
          $('iframe').attr('src',playersrc);
      });
  });
});
</code>```

https://jsfiddle.net/rhr5p0pg/2/

updated fiddle: https://jsfiddle.net/rhr5p0pg/4/

now it plays all and when your mouse leaves the it does not go back to its originial video

答:
You store just the first video uri (src).

What about something like this

```<code>$(document).ready(function(){
  var nowPlaying = "none";
      $('div').hover(function(){
          nowPlaying = $(this).find('iframe').attr('src');
          $(this).find('iframe').attr('src',nowPlaying+'&autoplay=1');
      }, function(){
          $(this).find('iframe').attr('src',nowPlaying);
      });
});
</code>```

https://jsfiddle.net/rhr5p0pg/5/

Title: Play youtube video on hover

Body:
I just need to play the youtube video only when hovered

I have here a fiddle and can't get it to work.

$(document).ready(function(){
  $(function() {

      var playersrc = jQuery(iframe).attr('src');

          $('div').hover(function(){
          $('iframe').attr('src',playersrc+'&autoplay=1');
      }, function(){
          $('iframe').attr('src',playersrc);
      });
  });
});

https://jsfiddle.net/rhr5p0pg/2/

updated fiddle: https://jsfiddle.net/rhr5p0pg/4/

now it plays all and when your mouse leaves the it does not go back to its originial video

Body:
You store just the first video uri (src).

What about something like this

$(document).ready(function(){
  var nowPlaying = "none";
      $('div').hover(function(){
          nowPlaying = $(this).find('iframe').attr('src');
          $(this).find('iframe').attr('src',nowPlaying+'&autoplay=1');
      }, function(){
          $(this).find('iframe').attr('src',nowPlaying);
      });
});

https://jsfiddle.net/rhr5p0pg/5/