问:
How to Set id as a Session value using JavaScript
Here is my JavaScript code,

```<code>     function register_popup(id,name,msg)
        {
          for(var iii = 0; iii < popups.length; iii++)
           {
             //already registered. Bring it to front.
             if(id == popups[iii])
               {
                 Array.remove(popups, iii);
                 popups.unshift(id);
                 calculate_popups();
                 return;
                }
           }
            var element = '<div class="msg_box" style="right:290px" id="'+ id +'">';
                element = element + '<div class="msg_head">'+ id +'';
                element = element + '<div class="close"><a href="javascript:close_popup(\''+ id +'\');">✕</a></div></div>';
                element = element +'<div class="msg_wrap"><div class="msg_body" class="msg-wgt-body"><ul id="chatlog"></ul>'+ msg+'<div class="msg_push" id="textmesage">dg</div></div><div class="msg_footer" ><textarea id="myTextArea" class="msg_input" rows="4" onkeypress="PushMessage(event , this);"+"\n">  </textarea></div></div>';
                element = element + '<div><a href="get_message('+id+'","'+msg+');"></a></div>';
            document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML + element;
            popups.unshift(id);
            calculate_popups();

        }
</code>```

I want to set id as a session value in this code. I am new in javascript kindly help me to solve this problem.

答:
```<code><script>
var someVal = <?php echo $_SESSION['some_var']; ?>;
</script>
</code>```

That should do it.

Body:
Here is my JavaScript code,

     function register_popup(id,name,msg)
        {
          for(var iii = 0; iii < popups.length; iii++)
           {
             //already registered. Bring it to front.
             if(id == popups[iii])
               {
                 Array.remove(popups, iii);
                 popups.unshift(id);
                 calculate_popups();
                 return;
                }
           }
            var element = '
';
                element = element + '
'+ id +'';
                element = element + '
✕

';
                element = element +'

'+ msg+'
dg

<textarea id="myTextArea" class="msg_input" rows="4" onkeypress="PushMessage(event , this);"+"\n">  </textarea>

';
                element = element + '

';
            document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML + element;
            popups.unshift(id);
            calculate_popups();

        }

I want to set id as a session value in this code. I am new in javascript kindly help me to solve this problem.

Body:
<script>
var someVal = <?php echo $_SESSION['some_var']; ?>;
</script>

That should do it.


来源: stackexchange

问:
how to make my video become a responsive web
How to make my video become a responsive on my web page ?

Here is the code:

```<code><div class="container container-fluid">
    <div class="row">
        <div class="col-sm-2"></div>
        <div class="col-sm-4 col-md-4 " style="background-color:dark;">
            <video width="800" height="450" controls>
                <source src="video/seatoskygondola.mp4" type="video/mp4">
                <source src="movie.ogg" type="video/ogg">
                Your browser does not support the video tag.
            </video>
        </div>
    </div>
</div>
</code>```

Thank you very much!

答:
I solve the problem myself by changing:

```
</div>
</div>
  </p>

<p>into</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="col-sm-6 col-md-6 " style="background-color:dark;"></code>```

You can check the web page:

http://tsangwangwang.com/vancouverthegondolasquamish.html

ContentLicense: CC BY-SA 3.0

Body:
How to make my video become a responsive on my web page ?

Here is the code:

            <video width="800" height="450" controls>
                <source src="video/seatoskygondola.mp4" type="video/mp4">
                <source src="movie.ogg" type="video/ogg">
                Your browser does not support the video tag.
            </video>

Thank you very much!

Body:
I solve the problem myself by changing:

<div class="col-sm-4 col-md-4 " style="background-color:dark;">

into

<div class="col-sm-6 col-md-6 " style="background-color:dark;">

You can check the web page:

http://tsangwangwang.com/vancouverthegondolasquamish.html


问:
Communication between an app-plugin to a service of a different app [Android]
I am new to this so can you please help me by pointing me to the right direction on how I can achieve this.

I have 2 apps

1) App that has the service - APP1

2) App that has the plugin - APP2

The scenario:

APP2 would like to access the server of APP1, so that it can send its data from its source app. APP2 would then have to access APP1's service in order to do so.

The process:

APP2 STARTS UP -> APP2 PLUGIN -> SENDS DATA -> APP1 Service -> APP1 Server

APP1 Server -> APP1 Service -> SENDS DATA -> APP2 PLUGIN -> Do action to APP2 based on result

Thanks in advance! I really am at a loss on this one.

答:
The following methods can be used.

ContentProvider:

A content provider manages access to a central repository of data. A
  provider is part of an Android application, which often provides its
  own UI for working with the data. However, content providers are
  primarily intended to be used by other applications, which access the
  provider using a provider client object. Together, providers and
  provider clients offer a consistent, standard interface to data that
  also handles inter-process communication and secure data access.

For more info: content-provider-basics

You can use permission,readPermission,writePermission for security.

```<code><provider
          android:permission="string"
          android:readPermission="string"
          android:writePermission="string" >
    . . .
</provider>
</code>```

For more info: provider-element

2.broadcast:

Android apps can send or receive broadcast messages from the Android
  system and other Android apps, similar to the publish-subscribe design
  pattern. These broadcasts are sent when an event of interest occurs.
  For example, the Android system sends broadcasts when various system
  events occur, such as when the system boots up or the device starts
  charging. Apps can also send custom broadcasts, for example, to notify
  other apps of something that they might be interested in (for example,
  some new data has been downloaded).

For more info Broadcasts

Body:
The following methods can be used.

ContentProvider:

A content provider manages access to a central repository of data. A
  provider is part of an Android application, which often provides its
  own UI for working with the data. However, content providers are
  primarily intended to be used by other applications, which access the
  provider using a provider client object. Together, providers and
  provider clients offer a consistent, standard interface to data that
  also handles inter-process communication and secure data access.

For more info: content-provider-basics

You can use permission,readPermission,writePermission for security.

<provider
          android:permission="string"
          android:readPermission="string"
          android:writePermission="string" >
    . . .
</provider>

For more info: provider-element

2.broadcast:

Android apps can send or receive broadcast messages from the Android
  system and other Android apps, similar to the publish-subscribe design
  pattern. These broadcasts are sent when an event of interest occurs.
  For example, the Android system sends broadcasts when various system
  events occur, such as when the system boots up or the device starts
  charging. Apps can also send custom broadcasts, for example, to notify
  other apps of something that they might be interested in (for example,
  some new data has been downloaded).

For more info Broadcasts


问:
excel - nested if condition formatting
I was just wondering if this is the proper way to nest this many conditions. It does work, just looks like it could be written simpler.</p>

```<code>=IF(H13>0,IF(H14>0,IF(H15>0,IF(H16>0,IF(H17>0,IF(H18>0,IF(H19>0,"Yes","No"),"No"),"No"),"No"),"No"),"No"),"No")
</code>```

答:
Above formula can be written as</p>

```<code>=IF(COUNTIF(H13:H19,">0")=7,"Yes","No")
</code>```

Title: excel - nested if condition formatting

Body:
I was just wondering if this is the proper way to nest this many conditions. It does work, just looks like it could be written simpler.

=IF(H13>0,IF(H14>0,IF(H15>0,IF(H16>0,IF(H17>0,IF(H18>0,IF(H19>0,"Yes","No"),"No"),"No"),"No"),"No"),"No"),"No")

Body:
Above formula can be written as

=IF(COUNTIF(H13:H19,">0")=7,"Yes","No")


问:
Problems loading rJava Package on Win7
I have installed the latest versions of R (2.15.2) and Java (7.11), and through RStudio (0.97.310) I am trying to load the rJava package. It seemed to install properly, but when I call library(rJava) I get the following error:

```<code> Error : .onLoad failed in loadNamespace() for 'rJava', details:
 call: stop("No CurrentVersion entry in '", key, "'!
 Try re-installing Java and make sure R and Java have matching architectures.")
 error: object 'key' not found
 Error: package/namespace load failed for ‘rJava’
</code>```

The documentation for rJava makes reference to Java 1.5+, so I am wondering if I need to install an ancient version of Java to resolve this problem. Any help would be much appreciated!

答: I had this problem and solved it by downloading and installing Java 64-bit (which you should probably choose if you have a modern computer) from the Java download site.</p>

Title: Problems loading rJava Package on Win7

Body:
I have installed the latest versions of R (2.15.2) and Java (7.11), and through RStudio (0.97.310) I am trying to load the rJava package. It seemed to install properly, but when I call library(rJava) I get the following error:

 Error : .onLoad failed in loadNamespace() for 'rJava', details:
 call: stop("No CurrentVersion entry in '", key, "'!
 Try re-installing Java and make sure R and Java have matching architectures.")
 error: object 'key' not found
 Error: package/namespace load failed for ‘rJava’

The documentation for rJava makes reference to Java 1.5+, so I am wondering if I need to install an ancient version of Java to resolve this problem. Any help would be much appreciated!


Title: excel - nested if condition formatting

Body:
You can use AND

=IF(AND(H13>0,H14>0,H15>0,H16>0,H17>0,H18>0,H19>0),"Yes","No")

Also use OR

=IF(OR(H13<=0,H14<=0,H15<=0,H16<=0,H17<=0,H18<=0,H19<=0),"No","Yes")


问:
Swift: How to refresh tableview without lag (UIRefreshControl)
Filling my table view with objects from a MYSQL database using PHP and JSON to Swift 3. I have a pull down to refresh function but when I'm pulling down to refresh it lags mid way for a second and then continues (like the wheel won't spin for a second).

How can I update my tableview smoother because I'm guessing as I add more content to the database in the future the bigger the lag. I currently have 12 objects in my database so imagine with 100+ objects.

In viewDidLoad

```<code>// Pull to Refresh
    let refreshControl = UIRefreshControl()
    refreshControl.addTarget(self, action: #selector(handleRefresh), for: .valueChanged)
    if #available(iOS 10.0, *) {
        myTableView.refreshControl = refreshControl
        print("iOS 10")
    } else {
        myTableView.addSubview(refreshControl)
        print("iOS 9 or iOS 8")
    }
</code>```

Then pull to refresh function

```<code>// Pull to Refresh
func handleRefresh(refreshControl: UIRefreshControl) {

    // Fetching Data for TableView
    retrieveDataFromServer()

    // Stop Refreshing
    refreshControl.endRefreshing()
}

// Retrieving Data from Server
func retrieveDataFromServer() {

    // Loading Data from File Manager
    loadData()

    let getDataURL = "http://example.com/receiving.php"
    let url: NSURL = NSURL(string: getDataURL)!

    do {
        let data: Data = try Data(contentsOf: url as URL)
        let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! NSMutableArray

        // Clear the arrays
        self.followedArray = [Blog]()
        self.mainArray = [Blog]()

        // Looping through jsonArray
        for jsonObject in jsonArray {

            if let blog = Blog(jsonObject:jsonObject as! [String : Any]) {

                // Check if Identifiers Match
                if followedIdentifiers.contains(blog.blogID) {
                    self.followedArray.append(blog)
                } else {
                    self.mainArray.append(blog)
                }
            }
        }
    } catch {
        print("Error: (Retrieving Data)")
    }
    myTableView.reloadData()
}
</code>```

答:
My guess is that your retrieveDataFromServer() is blocking the main thread, and therefore causing the lag. Try wrapping it in an async block</p>

```<code>// Pull to Refresh
func handleRefresh(refreshControl: UIRefreshControl) {

    // Fetching Data for TableView
    retrieveDataFromServer { [weak refreshControl] in
        // This block will run once retrieveDataFromServer() is completed

        // Reload data
        myTableView.reloadData()

        // Stop Refreshing
        refreshControl?.endRefreshing()
    }
}

// Retrieving Data from Server
func retrieveDataFromServer(completion: (() -> Void)?) {

    // Loading Data from File Manager
    loadData()

    let getDataURL = "http://example.com/receiving.php"
    let url: NSURL = NSURL(string: getDataURL)!

    do {
        let data: Data = try Data(contentsOf: url as URL)
        let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! NSMutableArray

        // Clear the arrays
        self.followedArray = [Blog]()
        self.mainArray = [Blog]()

        // Looping through jsonArray
        for jsonObject in jsonArray {

            if let blog = Blog(jsonObject:jsonObject as! [String : Any]) {

                // Check if Identifiers Match
                if followedIdentifiers.contains(blog.blogID) {
                    self.followedArray.append(blog)
                } else {
                    self.mainArray.append(blog)
                }
            }
        }
    } catch {
        print("Error: (Retrieving Data)")
    }

    // Calls completion block when finished
    completion?()
}
</code>```

Body:
Filling my table view with objects from a MYSQL database using PHP and JSON to Swift 3. I have a pull down to refresh function but when I'm pulling down to refresh it lags mid way for a second and then continues (like the wheel won't spin for a second).

How can I update my tableview smoother because I'm guessing as I add more content to the database in the future the bigger the lag. I currently have 12 objects in my database so imagine with 100+ objects.

In viewDidLoad

// Pull to Refresh
    let refreshControl = UIRefreshControl()
    refreshControl.addTarget(self, action: #selector(handleRefresh), for: .valueChanged)
    if #available(iOS 10.0, *) {
        myTableView.refreshControl = refreshControl
        print("iOS 10")
    } else {
        myTableView.addSubview(refreshControl)
        print("iOS 9 or iOS 8")
    }

Then pull to refresh function

// Pull to Refresh
func handleRefresh(refreshControl: UIRefreshControl) {

    // Fetching Data for TableView
    retrieveDataFromServer()

    // Stop Refreshing
    refreshControl.endRefreshing()
}

// Retrieving Data from Server
func retrieveDataFromServer() {

    // Loading Data from File Manager
    loadData()

    let getDataURL = "http://example.com/receiving.php"
    let url: NSURL = NSURL(string: getDataURL)!

    do {
        let data: Data = try Data(contentsOf: url as URL)
        let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! NSMutableArray

        // Clear the arrays
        self.followedArray = [Blog]()
        self.mainArray = [Blog]()

        // Looping through jsonArray
        for jsonObject in jsonArray {

            if let blog = Blog(jsonObject:jsonObject as! [String : Any]) {

                // Check if Identifiers Match
                if followedIdentifiers.contains(blog.blogID) {
                    self.followedArray.append(blog)
                } else {
                    self.mainArray.append(blog)
                }
            }
        }
    } catch {
        print("Error: (Retrieving Data)")
    }
    myTableView.reloadData()
}

Body:
My guess is that your retrieveDataFromServer() is blocking the main thread, and therefore causing the lag. Try wrapping it in an async block

// Pull to Refresh
func handleRefresh(refreshControl: UIRefreshControl) {

    // Fetching Data for TableView
    retrieveDataFromServer { [weak refreshControl] in
        // This block will run once retrieveDataFromServer() is completed

        // Reload data
        myTableView.reloadData()

        // Stop Refreshing
        refreshControl?.endRefreshing()
    }
}

// Retrieving Data from Server
func retrieveDataFromServer(completion: (() -> Void)?) {

    // Loading Data from File Manager
    loadData()

    let getDataURL = "http://example.com/receiving.php"
    let url: NSURL = NSURL(string: getDataURL)!

    do {
        let data: Data = try Data(contentsOf: url as URL)
        let jsonArray = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! NSMutableArray

        // Clear the arrays
        self.followedArray = [Blog]()
        self.mainArray = [Blog]()

        // Looping through jsonArray
        for jsonObject in jsonArray {

            if let blog = Blog(jsonObject:jsonObject as! [String : Any]) {

                // Check if Identifiers Match
                if followedIdentifiers.contains(blog.blogID) {
                    self.followedArray.append(blog)
                } else {
                    self.mainArray.append(blog)
                }
            }
        }
    } catch {
        print("Error: (Retrieving Data)")
    }

    // Calls completion block when finished
    completion?()
}


问:
How do I change NavBar Color in CSS
Hello I have view some of responsive multi level menu.
I Copy exactly the css and javascript. Here is my NavBar. The problem is, Im having trouble to change the default color(green) to other color. Here is the CSS file.

```<code> @import url(http://fonts.googleapis.com/css?
 family=Open+Sans:400italic,400,300,600);

@font-face {
font-family: 'icomoon';
src:url('../fonts/icomoon.eot');
src:url('../fonts/icomoon.eot?#iefix') format('embedded-opentype'),
    url('../fonts/icomoon.woff') format('woff'),
    url('../fonts/icomoon.ttf') format('truetype'),
    url('../fonts/icomoon.svg#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}

/* minimal styles for that navi */
.rmm {margin: 0 auto;}
.rmm ul {margin: 0; padding:0; list-style: none; position: relative;
background: #000;}
.rmm ul:after {content: ""; clear: both; display: block;}
.rmm ul li {float: left;}
.rmm ul li:hover {background: #202020;}
.rmm ul li:hover > ul {display: block;}
.rmm ul li:hover a{color: #fff;}
.rmm ul li a {color: #fff; display: block; text-decoration: none;}
.rmm ul ul {display: none; margin:0; padding: 0; position: absolute; top:
100%;}
.rmm ul ul li {float: none; position: relative;}
.rmm ul ul li a{color: #fff;}
.rmm ul ul li a:hover {background: #202020;}
.rmm ul ul ul {position: absolute; left: 100%; top:0; width: 100%;}

/* mobile menu header button */
.rmm-toggled {width: 100%; background-color: #555555; min-height: 50px;
margin: 0 auto; display: none;}
.rmm-closed ~ .rmm-mobile {display: none!important;}
.rmm-toggled-controls{width: 100%;}
.rmm-toggled-title{width: 60%; float: left; font-size: 27px; color: #fff;
font-weight:600; display: block; padding: 8px 0; text-decoration: none;
text-transform: uppercase; text-align: left; padding-left: 35px;}
.rmm-toggled-button{width: 20%; float: left; margin-top: 3px;
display:block;
width: 32px;
padding:0 !important;
margin:10px 10px 0 0;
border:1px solid #fff;
border-radius:3px;
float: right;
}
.rmm-toggled-button span{float: left; display:block; margin: 3px 6px;
height: 3px; background:white; width:20px;}

/* normalny back button visible only on mobiles  */
.rmm .rmm-back{display: none; font-size: 12px;}
.rmm .rmm-back:after {display: none;}
.rmm .rmm-back a:after {
font-family: 'icomoon';
speak: none;
-webkit-font-smoothing: antialiased;
content: "\e000";
position: relative;
display: inline-block;
-webkit-transform: rotate(-60deg);
transform: rotate(-60deg);
top: 1px;
right: -2px ;
float: left;
font-size: 10px;
 }
.rmm-mobile .rmm-back{display: block;}

   /* mobile menu list */
  .rmm-mobile{width: 100%;}
  .rmm-mobile .rmm-dropdown:hover ~ ul, .rmm-mobile .rmm-dropdown:hover > ul
  ,.rmm-mobile .rmm-dropdown:hover + ul {display: none!important;}
   .rmm-mobile ul{width: 100%; position: inherit!important;}
   .rmm-mobile li{width: 100%; }

   /* mobile menu js action */
  .rmm-dropdown{display: block!important;}
  .rmm-mobile .rmm-subview{display: block!important; width: 100%;}
  .rmm-mobile .rmm-subover-hidden{display: none!important;}
  .rmm-mobile .rmm-subover-visible{display: block;}
  .rmm-mobile .rmm-subover-header{display: none!important; padding: 0;
   margin:0;}

  /* mobile menu content */
  .rmm-mobile .rmm-submenu{position: relative; left: 0px;}

  .rmm .rmm-mobile li:hover > ul {display: none;}

  /* arrow down for wide screen */
  .rmm.style {text-align: left; font-family: Tahoma;}
  .rmm.style ul {box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
   background:#990;
   text-transform: uppercase; display: inline-table; text-align:left;}
  .rmm.style ul li {text-align:left;}
  .rmm.style ul li:hover {background: #4b545f;}
  .rmm.style ul ul {display: none; margin:0; background: #5f6975; border-
   radius: 0px; padding: 0; position: absolute;}
  .rmm.style ul li a {color: #fff; font-weight:600; display: block; padding:
   15px 35px; text-decoration: none; font-weight:600; }
  .rmm.style ul ul li {border-bottom: 1px solid #575F6A; border-top: 1px
  solid #6B727C;}
  .rmm.style ul ul li a {padding: 12px 35px; color: #fff; }
  .rmm.style ul ul li a:hover {background: #4b545f;}

    /* arrow down for wide screen */
   .rmm.style ul li > a:not(:only-child):after {
   font-family: 'icomoon';
    speak: none;
   -webkit-font-smoothing: antialiased;
   content: "\e000";
   position: relative;
   display: inline-block;
   -webkit-transform: rotate(210deg);
    transform: rotate(210deg);
    top: -4px;
    left: 1px;
     font-size: 10px;
    }

   /* arrow left for wide screen submenus  */
   .rmm.style ul ul li > a:not(:only-child):after {-webkit-transform:
   rotate(120deg)!important; transform: rotate(120deg)!important; top: 2px;
   font-size: 14px; float: right; margin-right: -20px;}

   /* mobile style */
   .rmm.style .rmm-mobile li > a:not(:only-child):after {-webkit-transform:
     rotate(120deg)!important; transform: rotate(120deg)!important; top:
    4px!important; font-size: 14px!important; float: right; margin-right:
   -20px;}
   .rmm.style .rmm-mobile li{background: #3ab4a6; border-bottom: 1px solid
    #575f6a!important; border-top: 0!important; }
</code>```

I have tried to change the color or add something for background-color. But the default color still Green. The javascript is to executed to function of the mobile version. Nothing to do with the color. Please Help. Im still newbie :)
Here is My HTML

```<code><!DOCTYPE html>
<html>
<head>
<title></title>

<!-- Include scripts -->
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js">
</script>
<script type="text/javascript" src="js/responsivemultimenu.js"></script>

<!-- Include styles -->
<link rel="stylesheet" href="css/responsivemultimenu.css" type="text/css"/>

<!-- Include media queries -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-
scale=1, user-scalable=no"/>
</head>
<body >

<div >

    <div class="rmm style">
        <ul>
        <li>

                <a href="KPIhome.php" title="KPI">eKPI</a>

        </li>

        <?php if(isset($_SESSION['admin']) || $_SESSION['user_level'] == 5
|| $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1 ){ ?>

            <li>

                <a href="#">Value Graph</a>
                <ul>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="sales_form.php">Sales Achievement against
Target</a>
                    </li>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="promo_form.php">Promotion Sales Achievement
against Target </a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="manhour_form.php">Sales per Manhour</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="trans_form.php">Transaction per Manhour</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="salmonform.php">Salmon Usage Per 1K</a>
                    </li>

                </ul>
            </li>

            <?php } ?>

             <?php if(isset($_SESSION['admin']) || $_SESSION['user_level']
  == 5 || $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1){ ?>

            <li>

                <a href="#">Percentage Graph</a>
                <ul>
                    <li <?php if($page == 'home.php'){echo '
 class="active"';};?>>
                        <a href="sales_form2.php">Sales Achievement against
Target (%)</a>
                    </li>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="promo_form2.php">Promotion Sales
Achievement against Target (%)</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="wastage_form.php">Wastage against Target
(%)</a>
                    </li>

                </ul>
            </li>

            <?php } ?>

             <?php if(isset($_SESSION['admin']) || $_SESSION['user_level']
== 5 || $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1){ ?>

            <li>

                <a href="#">Over Budget</a>
                <ul>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="obtargetform.php">Sales Achievement</a>
                    </li>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="obmtdform.php">Sales Month to Date
 Achievement</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="obtargetform2.php">Promotion Sales
Achievement</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="obmtdform2.php">Promotion Month to Date
Sales Achivement</a>
                    </li>

                </ul>
            </li>

            <?php } ?>

             <?php if(isset($_SESSION['admin'])&& $_SESSION['user_level'] == 0 || $_SESSION['user_level']==7 ){ ?>
            <li>

                <a href="#">Report</a>
                <ul>
                    <li <?php if($page == 'home.php'){echo ' class="active"';};?>>
                        <a href="typereport.php">Add Report</a>
                    </li>

                </ul>
            </li>

            <?php } ?>

        <li>

                <a href="KPIhome.php" title="KPI">Website</a>

        </li>

        <li>

                <a href="KPIhome.php" title="KPI">Admin</a>

        </li>

        </ul>
    </div>
</div>
</code>```

答:
here is your working solution. please find the "RED" background, you can replace it with anything you want.

@import url(http://fonts.googleapis.com/css? family=Open+Sans:400italic,400,300,600); @font-face { font-family: 'icomoon'; src:url('../fonts/icomoon.eot'); src:url('../fonts/icomoon.eot?#iefix') format('embedded-opentype'), url('../fonts/icomoon.woff') format('woff'), url('../fonts/icomoon.ttf') format('truetype'), url('../fonts/icomoon.svg#icomoon') format('svg'); font-weight: normal; font-style: normal; } /* minimal styles for that navi */ .rmm {margin: 0 auto;} .rmm ul {margin: 0; padding:0; list-style: none; position: relative; background: #000;} .rmm ul:after {content: ""; clear: both; display: block;} .rmm ul li {float: left;} .rmm ul li:hover {background: #202020;} .rmm ul li:hover > ul {display: block;} .rmm ul li:hover a{color: #fff;} .rmm ul li a {color: #fff; display: block; text-decoration: none;} .rmm ul ul {display: none; margin:0; padding: 0; position: absolute; top: 100%;} .rmm ul ul li {float: none; position: relative;} .rmm ul ul li a{color: #fff;} .rmm ul ul li a:hover {background: #202020;} .rmm ul ul ul {position: absolute; left: 100%; top:0; width: 100%;} /* mobile menu header button */ .rmm-toggled {width: 100%; background-color: #555555; min-height: 50px; margin: 0 auto; display: none;} .rmm-closed ~ .rmm-mobile {display: none!important;} .rmm-toggled-controls{width: 100%;} .rmm-toggled-title{width: 60%; float: left; font-size: 27px; color: #fff; font-weight:600; display: block; padding: 8px 0; text-decoration: none; text-transform: uppercase; text-align: left; padding-left: 35px;} .rmm-toggled-button{width: 20%; float: left; margin-top: 3px; display:block; width: 32px; padding:0 !important; margin:10px 10px 0 0; border:1px solid #fff; border-radius:3px; float: right; } .rmm-toggled-button span{float: left; display:block; margin: 3px 6px; height: 3px; background:white; width:20px;} /* normalny back button visible only on mobiles */ .rmm .rmm-back{display: none; font-size: 12px;} .rmm .rmm-back:after {display: none;} .rmm .rmm-back a:after { font-family: 'icomoon'; speak: none; -webkit-font-smoothing: antialiased; content: "\e000"; position: relative; display: inline-block; -webkit-transform: rotate(-60deg); transform: rotate(-60deg); top: 1px; right: -2px ; float: left; font-size: 10px; } .rmm-mobile .rmm-back{display: block;} /* mobile menu list */ .rmm-mobile{width: 100%;} .rmm-mobile .rmm-dropdown:hover ~ ul, .rmm-mobile .rmm-dropdown:hover > ul ,.rmm-mobile .rmm-dropdown:hover + ul {display: none!important;} .rmm-mobile ul{width: 100%; position: inherit!important;} .rmm-mobile li{width: 100%; } /* mobile menu js action */ .rmm-dropdown{display: block!important;} .rmm-mobile .rmm-subview{display: block!important; width: 100%;} .rmm-mobile .rmm-subover-hidden{display: none!important;} .rmm-mobile .rmm-subover-visible{display: block;} .rmm-mobile .rmm-subover-header{display: none!important; padding: 0; margin:0;} /* mobile menu content */ .rmm-mobile .rmm-submenu{position: relative; left: 0px;} .rmm .rmm-mobile li:hover > ul {display: none;} /* arrow down for wide screen */ .rmm.style {text-align: left; font-family: Tahoma;} .rmm.style ul {box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15); background:RED; text-transform: uppercase; display: inline-table; text-align:left;} .rmm.style ul li {text-align:left;} .rmm.style ul li:hover {background: #4b545f;} .rmm.style ul ul {display: none; margin:0; background: #5f6975; border- radius: 0px; padding: 0; position: absolute;} .rmm.style ul li a {color: #fff; font-weight:600; display: block; padding: 15px 35px; text-decoration: none; font-weight:600; } .rmm.style ul ul li {border-bottom: 1px solid #575F6A; border-top: 1px solid #6B727C;} .rmm.style ul ul li a {padding: 12px 35px; color: #fff; } .rmm.style ul ul li a:hover {background: #4b545f;} /* arrow down for wide screen */ .rmm.style ul li > a:not(:only-child):after { font-family: 'icomoon'; speak: none; -webkit-font-smoothing: antialiased; content: "\e000"; position: relative; display: inline-block; -webkit-transform: rotate(210deg); transform: rotate(210deg); top: -4px; left: 1px; font-size: 10px; } /* arrow left for wide screen submenus */ .rmm.style ul ul li > a:not(:only-child):after {-webkit-transform: rotate(120deg)!important; transform: rotate(120deg)!important; top: 2px; font-size: 14px; float: right; margin-right: -20px;} /* mobile style */ .rmm.style .rmm-mobile li > a:not(:only-child):after {-webkit-transform: rotate(120deg)!important; transform: rotate(120deg)!important; top: 4px!important; font-size: 14px!important; float: right; margin-right: -20px;} .rmm.style .rmm-mobile li{background: #3ab4a6; border-bottom: 1px solid #575f6a!important; border-top: 0!important; }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<title></title>

<!-- Include scripts -->
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js">
</script>
<script type="text/javascript" src="js/responsivemultimenu.js"></script>

<!-- Include styles -->
<link rel="stylesheet" href="css/responsivemultimenu.css" type="text/css"/>

<!-- Include media queries -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-
scale=1, user-scalable=no"/>
</head>
<body >

<div >

    <div class="rmm style">
        <ul>
        <li>

                eKPI

        </li>

        <?php if(isset($_SESSION['admin']) || $_SESSION['user_level'] == 5
|| $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1 ){ ?>

            <li>

                Value Graph
                <ul>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Sales Achievement against
Target
                    </li>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Promotion Sales Achievement
against Target
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Sales per Manhour
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Transaction per Manhour
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Salmon Usage Per 1K
                    </li>

                </ul>
            </li>

            <?php } ?>

             <?php if(isset($_SESSION['admin']) || $_SESSION['user_level']
  == 5 || $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1){ ?>

            <li>

                Percentage Graph
                <ul>
                    <li <?php if($page == 'home.php'){echo '
 class="active"';};?>>
                        Sales Achievement against
Target (%)
                    </li>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Promotion Sales
Achievement against Target (%)
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Wastage against Target
(%)
                    </li>

                </ul>
            </li>

            <?php } ?>

             <?php if(isset($_SESSION['admin']) || $_SESSION['user_level']
== 5 || $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1){ ?>

            <li>

                Over Budget
                <ul>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Sales Achievement
                    </li>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Sales Month to Date
 Achievement
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Promotion Sales
Achievement
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Promotion Month to Date
Sales Achivement
                    </li>

                </ul>
            </li>

            <?php } ?>

             <?php if(isset($_SESSION['admin'])&& $_SESSION['user_level'] == 0 || $_SESSION['user_level']==7 ){ ?>
            <li>

                Report
                <ul>
                    <li <?php if($page == 'home.php'){echo ' class="active"';};?>>
                        Add Report
                    </li>

                </ul>
            </li>

            <?php } ?>

        <li>

                Website

        </li>

        <li>

                Admin

        </li>

        </ul>
    </div>
</div></code>```

Title: How do I change NavBar Color in CSS

Body:
Hello I have view some of responsive multi level menu.
I Copy exactly the css and javascript. Here is my NavBar. The problem is, Im having trouble to change the default color(green) to other color. Here is the CSS file.

 @import url(http://fonts.googleapis.com/css?
 family=Open+Sans:400italic,400,300,600);

@font-face {
font-family: 'icomoon';
src:url('../fonts/icomoon.eot');
src:url('../fonts/icomoon.eot?#iefix') format('embedded-opentype'),
    url('../fonts/icomoon.woff') format('woff'),
    url('../fonts/icomoon.ttf') format('truetype'),
    url('../fonts/icomoon.svg#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}

/* minimal styles for that navi */
.rmm {margin: 0 auto;}
.rmm ul {margin: 0; padding:0; list-style: none; position: relative;
background: #000;}
.rmm ul:after {content: ""; clear: both; display: block;}
.rmm ul li {float: left;}
.rmm ul li:hover {background: #202020;}
.rmm ul li:hover > ul {display: block;}
.rmm ul li:hover a{color: #fff;}
.rmm ul li a {color: #fff; display: block; text-decoration: none;}
.rmm ul ul {display: none; margin:0; padding: 0; position: absolute; top:
100%;}
.rmm ul ul li {float: none; position: relative;}
.rmm ul ul li a{color: #fff;}
.rmm ul ul li a:hover {background: #202020;}
.rmm ul ul ul {position: absolute; left: 100%; top:0; width: 100%;}

/* mobile menu header button */
.rmm-toggled {width: 100%; background-color: #555555; min-height: 50px;
margin: 0 auto; display: none;}
.rmm-closed ~ .rmm-mobile {display: none!important;}
.rmm-toggled-controls{width: 100%;}
.rmm-toggled-title{width: 60%; float: left; font-size: 27px; color: #fff;
font-weight:600; display: block; padding: 8px 0; text-decoration: none;
text-transform: uppercase; text-align: left; padding-left: 35px;}
.rmm-toggled-button{width: 20%; float: left; margin-top: 3px;
display:block;
width: 32px;
padding:0 !important;
margin:10px 10px 0 0;
border:1px solid #fff;
border-radius:3px;
float: right;
}
.rmm-toggled-button span{float: left; display:block; margin: 3px 6px;
height: 3px; background:white; width:20px;}

/* normalny back button visible only on mobiles  */
.rmm .rmm-back{display: none; font-size: 12px;}
.rmm .rmm-back:after {display: none;}
.rmm .rmm-back a:after {
font-family: 'icomoon';
speak: none;
-webkit-font-smoothing: antialiased;
content: "\e000";
position: relative;
display: inline-block;
-webkit-transform: rotate(-60deg);
transform: rotate(-60deg);
top: 1px;
right: -2px ;
float: left;
font-size: 10px;
 }
.rmm-mobile .rmm-back{display: block;}

   /* mobile menu list */
  .rmm-mobile{width: 100%;}
  .rmm-mobile .rmm-dropdown:hover ~ ul, .rmm-mobile .rmm-dropdown:hover > ul
  ,.rmm-mobile .rmm-dropdown:hover + ul {display: none!important;}
   .rmm-mobile ul{width: 100%; position: inherit!important;}
   .rmm-mobile li{width: 100%; }

   /* mobile menu js action */
  .rmm-dropdown{display: block!important;}
  .rmm-mobile .rmm-subview{display: block!important; width: 100%;}
  .rmm-mobile .rmm-subover-hidden{display: none!important;}
  .rmm-mobile .rmm-subover-visible{display: block;}
  .rmm-mobile .rmm-subover-header{display: none!important; padding: 0;
   margin:0;}

  /* mobile menu content */
  .rmm-mobile .rmm-submenu{position: relative; left: 0px;}

  .rmm .rmm-mobile li:hover > ul {display: none;}

  /* arrow down for wide screen */
  .rmm.style {text-align: left; font-family: Tahoma;}
  .rmm.style ul {box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
   background:#990;
   text-transform: uppercase; display: inline-table; text-align:left;}
  .rmm.style ul li {text-align:left;}
  .rmm.style ul li:hover {background: #4b545f;}
  .rmm.style ul ul {display: none; margin:0; background: #5f6975; border-
   radius: 0px; padding: 0; position: absolute;}
  .rmm.style ul li a {color: #fff; font-weight:600; display: block; padding:
   15px 35px; text-decoration: none; font-weight:600; }
  .rmm.style ul ul li {border-bottom: 1px solid #575F6A; border-top: 1px
  solid #6B727C;}
  .rmm.style ul ul li a {padding: 12px 35px; color: #fff; }
  .rmm.style ul ul li a:hover {background: #4b545f;}

    /* arrow down for wide screen */
   .rmm.style ul li > a:not(:only-child):after {
   font-family: 'icomoon';
    speak: none;
   -webkit-font-smoothing: antialiased;
   content: "\e000";
   position: relative;
   display: inline-block;
   -webkit-transform: rotate(210deg);
    transform: rotate(210deg);
    top: -4px;
    left: 1px;
     font-size: 10px;
    }

   /* arrow left for wide screen submenus  */
   .rmm.style ul ul li > a:not(:only-child):after {-webkit-transform:
   rotate(120deg)!important; transform: rotate(120deg)!important; top: 2px;
   font-size: 14px; float: right; margin-right: -20px;}

   /* mobile style */
   .rmm.style .rmm-mobile li > a:not(:only-child):after {-webkit-transform:
     rotate(120deg)!important; transform: rotate(120deg)!important; top:
    4px!important; font-size: 14px!important; float: right; margin-right:
   -20px;}
   .rmm.style .rmm-mobile li{background: #3ab4a6; border-bottom: 1px solid
    #575f6a!important; border-top: 0!important; }

I have tried to change the color or add something for background-color. But the default color still Green. The javascript is to executed to function of the mobile version. Nothing to do with the color. Please Help. Im still newbie :)
Here is My HTML

<!DOCTYPE html>

<title></title>

<link rel="stylesheet" href="css/responsivemultimenu.css" type="text/css"/>

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-
scale=1, user-scalable=no"/>

                eKPI

        <?php if(isset($_SESSION['admin']) || $_SESSION['user_level'] == 5
|| $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1 ){ ?>

                Value Graph

                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Sales Achievement against
Target

                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Promotion Sales Achievement
against Target

                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Sales per Manhour

                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Transaction per Manhour

                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Salmon Usage Per 1K

            <?php } ?>

             <?php if(isset($_SESSION['admin']) || $_SESSION['user_level']
  == 5 || $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1){ ?>

                Percentage Graph

                    <li <?php if($page == 'home.php'){echo '
 class="active"';};?>>
                        Sales Achievement against
Target (%)

                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Promotion Sales
Achievement against Target (%)

                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Wastage against Target
(%)

            <?php } ?>

             <?php if(isset($_SESSION['admin']) || $_SESSION['user_level']
== 5 || $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1){ ?>

                Over Budget

                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Sales Achievement

                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Sales Month to Date
 Achievement

                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Promotion Sales
Achievement

                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        Promotion Month to Date
Sales Achivement

            <?php } ?>

             <?php if(isset($_SESSION['admin'])&& $_SESSION['user_level'] == 0 || $_SESSION['user_level']==7 ){ ?>

                Report

                    <li <?php if($page == 'home.php'){echo ' class="active"';};?>>
                        Add Report

            <?php } ?>

                Website

                Admin

Body:
here is your working solution. please find the "RED" background, you can replace it with anything you want.

@import url(http://fonts.googleapis.com/css? family=Open+Sans:400italic,400,300,600); @font-face { font-family: 'icomoon'; src:url('../fonts/icomoon.eot'); src:url('../fonts/icomoon.eot?#iefix') format('embedded-opentype'), url('../fonts/icomoon.woff') format('woff'), url('../fonts/icomoon.ttf') format('truetype'), url('../fonts/icomoon.svg#icomoon') format('svg'); font-weight: normal; font-style: normal; } /* minimal styles for that navi */ .rmm {margin: 0 auto;} .rmm ul {margin: 0; padding:0; list-style: none; position: relative; background: #000;} .rmm ul:after {content: ""; clear: both; display: block;} .rmm ul li {float: left;} .rmm ul li:hover {background: #202020;} .rmm ul li:hover > ul {display: block;} .rmm ul li:hover a{color: #fff;} .rmm ul li a {color: #fff; display: block; text-decoration: none;} .rmm ul ul {display: none; margin:0; padding: 0; position: absolute; top: 100%;} .rmm ul ul li {float: none; position: relative;} .rmm ul ul li a{color: #fff;} .rmm ul ul li a:hover {background: #202020;} .rmm ul ul ul {position: absolute; left: 100%; top:0; width: 100%;} /* mobile menu header button */ .rmm-toggled {width: 100%; background-color: #555555; min-height: 50px; margin: 0 auto; display: none;} .rmm-closed ~ .rmm-mobile {display: none!important;} .rmm-toggled-controls{width: 100%;} .rmm-toggled-title{width: 60%; float: left; font-size: 27px; color: #fff; font-weight:600; display: block; padding: 8px 0; text-decoration: none; text-transform: uppercase; text-align: left; padding-left: 35px;} .rmm-toggled-button{width: 20%; float: left; margin-top: 3px; display:block; width: 32px; padding:0 !important; margin:10px 10px 0 0; border:1px solid #fff; border-radius:3px; float: right; } .rmm-toggled-button span{float: left; display:block; margin: 3px 6px; height: 3px; background:white; width:20px;} /* normalny back button visible only on mobiles */ .rmm .rmm-back{display: none; font-size: 12px;} .rmm .rmm-back:after {display: none;} .rmm .rmm-back a:after { font-family: 'icomoon'; speak: none; -webkit-font-smoothing: antialiased; content: "\e000"; position: relative; display: inline-block; -webkit-transform: rotate(-60deg); transform: rotate(-60deg); top: 1px; right: -2px ; float: left; font-size: 10px; } .rmm-mobile .rmm-back{display: block;} /* mobile menu list */ .rmm-mobile{width: 100%;} .rmm-mobile .rmm-dropdown:hover ~ ul, .rmm-mobile .rmm-dropdown:hover > ul ,.rmm-mobile .rmm-dropdown:hover + ul {display: none!important;} .rmm-mobile ul{width: 100%; position: inherit!important;} .rmm-mobile li{width: 100%; } /* mobile menu js action */ .rmm-dropdown{display: block!important;} .rmm-mobile .rmm-subview{display: block!important; width: 100%;} .rmm-mobile .rmm-subover-hidden{display: none!important;} .rmm-mobile .rmm-subover-visible{display: block;} .rmm-mobile .rmm-subover-header{display: none!important; padding: 0; margin:0;} /* mobile menu content */ .rmm-mobile .rmm-submenu{position: relative; left: 0px;} .rmm .rmm-mobile li:hover > ul {display: none;} /* arrow down for wide screen */ .rmm.style {text-align: left; font-family: Tahoma;} .rmm.style ul {box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15); background:RED; text-transform: uppercase; display: inline-table; text-align:left;} .rmm.style ul li {text-align:left;} .rmm.style ul li:hover {background: #4b545f;} .rmm.style ul ul {display: none; margin:0; background: #5f6975; border- radius: 0px; padding: 0; position: absolute;} .rmm.style ul li a {color: #fff; font-weight:600; display: block; padding: 15px 35px; text-decoration: none; font-weight:600; } .rmm.style ul ul li {border-bottom: 1px solid #575F6A; border-top: 1px solid #6B727C;} .rmm.style ul ul li a {padding: 12px 35px; color: #fff; } .rmm.style ul ul li a:hover {background: #4b545f;} /* arrow down for wide screen */ .rmm.style ul li > a:not(:only-child):after { font-family: 'icomoon'; speak: none; -webkit-font-smoothing: antialiased; content: "\e000"; position: relative; display: inline-block; -webkit-transform: rotate(210deg); transform: rotate(210deg); top: -4px; left: 1px; font-size: 10px; } /* arrow left for wide screen submenus */ .rmm.style ul ul li > a:not(:only-child):after {-webkit-transform: rotate(120deg)!important; transform: rotate(120deg)!important; top: 2px; font-size: 14px; float: right; margin-right: -20px;} /* mobile style */ .rmm.style .rmm-mobile li > a:not(:only-child):after {-webkit-transform: rotate(120deg)!important; transform: rotate(120deg)!important; top: 4px!important; font-size: 14px!important; float: right; margin-right: -20px;} .rmm.style .rmm-mobile li{background: #3ab4a6; border-bottom: 1px solid #575f6a!important; border-top: 0!important; }

<!DOCTYPE html>
<html>
<head>
<title></title>

<!-- Include scripts -->
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js">
</script>
<script type="text/javascript" src="js/responsivemultimenu.js"></script>

<!-- Include styles -->
<link rel="stylesheet" href="css/responsivemultimenu.css" type="text/css"/>

<!-- Include media queries -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-
scale=1, user-scalable=no"/>
</head>
<body >

<div >

    <div class="rmm style">
        <ul>
        <li>

                <a href="KPIhome.php" title="KPI">eKPI</a>

        </li>

        <?php if(isset($_SESSION['admin']) || $_SESSION['user_level'] == 5
|| $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1 ){ ?>

            <li>

                <a href="#">Value Graph</a>
                <ul>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="sales_form.php">Sales Achievement against
Target</a>
                    </li>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="promo_form.php">Promotion Sales Achievement
against Target </a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="manhour_form.php">Sales per Manhour</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="trans_form.php">Transaction per Manhour</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="salmonform.php">Salmon Usage Per 1K</a>
                    </li>

                </ul>
            </li>

            <?php } ?>

             <?php if(isset($_SESSION['admin']) || $_SESSION['user_level']
  == 5 || $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1){ ?>

            <li>

                <a href="#">Percentage Graph</a>
                <ul>
                    <li <?php if($page == 'home.php'){echo '
 class="active"';};?>>
                        <a href="sales_form2.php">Sales Achievement against
Target (%)</a>
                    </li>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="promo_form2.php">Promotion Sales
Achievement against Target (%)</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="wastage_form.php">Wastage against Target
(%)</a>
                    </li>

                </ul>
            </li>

            <?php } ?>

             <?php if(isset($_SESSION['admin']) || $_SESSION['user_level']
== 5 || $_SESSION['user_level']==7 || $_SESSION['user_level'] ==1){ ?>

            <li>

                <a href="#">Over Budget</a>
                <ul>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="obtargetform.php">Sales Achievement</a>
                    </li>
                    <li <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="obmtdform.php">Sales Month to Date
 Achievement</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="obtargetform2.php">Promotion Sales
Achievement</a>
                    </li>
                    <li  <?php if($page == 'home.php'){echo '
class="active"';};?>>
                        <a href="obmtdform2.php">Promotion Month to Date
Sales Achivement</a>
                    </li>

                </ul>
            </li>

            <?php } ?>

             <?php if(isset($_SESSION['admin'])&& $_SESSION['user_level'] == 0 || $_SESSION['user_level']==7 ){ ?>
            <li>

                <a href="#">Report</a>
                <ul>
                    <li <?php if($page == 'home.php'){echo ' class="active"';};?>>
                        <a href="typereport.php">Add Report</a>
                    </li>

                </ul>
            </li>

            <?php } ?>

        <li>

                <a href="KPIhome.php" title="KPI">Website</a>

        </li>

        <li>

                <a href="KPIhome.php" title="KPI">Admin</a>

        </li>

        </ul>
    </div>
</div>


问:
Xcode storyboard elements showing as white rather than blue
Sorry if the title doesn't explain the issue properly.

In all tutorials I see, a UIImageView, for example, has a blue background on storyboards. (Refer to below)

Whereas mine looks like this:

答:
Okay, guys, I solved it, if anyone else is having this issue, here's how to fix it.

Editor > Canvas > Show Placeholder Backgrounds

 Canvas > Show Placeholder Backgrounds">


问:
Passing String to Prepared Statement in Golang
The idea is I want to update the status and returning the id only if the status is different.

So, I have a prepared statement like this:

```<code>var theQuery = `UPDATE process SET status=$1 WHERE status!=$1 AND id=$2 RETURNING id`
</code>```

Then, I called it with this:

```<code>err = statement.QueryRow("set", 12).Scan(&id)
</code>```

Then there is an error appear like this.

```<code>runtime error: invalid memory address or nil pointer dereference
</code>```

When I tried:

```<code>var theQuery = `UPDATE process SET status='$1' WHERE status!='$1' AND id=$2 RETURNING id`
</code>```

It runs. Then, when I run it again, I am expecting to get no rows, but it still returning the id. It looked like it still updating the rows and ignored the status!='$1' part.

Thank you

答:
So, I just find the solution. Instead of using $1 twice, the prepared statement will received 3 arguments:

```<code>var theQuery = `UPDATE process SET status=$1 WHERE status!=$2 AND id=$3 RETURNING id`
</code>```

Then, I call the prepared statement like this.

```<code>status := "set"
err = statement.QueryRow(status, status, 12).Scan(&id)
</code>```

I know maybe this is not the best approach to solve the problem. But it worked for me.

Body:
The idea is I want to update the status and returning the id only if the status is different.

So, I have a prepared statement like this:

var theQuery = `UPDATE process SET status=$1 WHERE status!=$1 AND id=$2 RETURNING id`

Then, I called it with this:

err = statement.QueryRow("set", 12).Scan(&id)

Then there is an error appear like this.

runtime error: invalid memory address or nil pointer dereference

When I tried:

var theQuery = `UPDATE process SET status='$1' WHERE status!='$1' AND id=$2 RETURNING id`

It runs. Then, when I run it again, I am expecting to get no rows, but it still returning the id. It looked like it still updating the rows and ignored the status!='$1' part.

Thank you

Body:
So, I just find the solution. Instead of using $1 twice, the prepared statement will received 3 arguments:

var theQuery = `UPDATE process SET status=$1 WHERE status!=$2 AND id=$3 RETURNING id`

Then, I call the prepared statement like this.

status := "set"
err = statement.QueryRow(status, status, 12).Scan(&id)

I know maybe this is not the best approach to solve the problem. But it worked for me.


问:
Remove blank attributes from an Object in Javascript
How do I remove all attributes which are undefined or null in a JavaScript object?

(Question is similar to this one for Arrays)

答:
If you use eslint and want to avoid tripping the the no-param-reassign rule, you can use Object.assign in conjunction with .reduce and a computed property name for a fairly elegant ES6 solution:</p>

```<code>const queryParams = { a: 'a', b: 'b', c: 'c', d: undefined, e: null, f: '', g: 0 };
const cleanParams = Object.keys(queryParams)
  .filter(key => queryParams[key] != null)
  .reduce((acc, key) => Object.assign(acc, { [key]: queryParams[key] }), {});
// { a: 'a', b: 'b', c: 'c', f: '', g: 0 }
</code>```

OwnerDisplayName: globetrotter

Body:
If you use eslint and want to avoid tripping the the no-param-reassign rule, you can use Object.assign in conjunction with .reduce and a computed property name for a fairly elegant ES6 solution:

const queryParams = { a: 'a', b: 'b', c: 'c', d: undefined, e: null, f: '', g: 0 };
const cleanParams = Object.keys(queryParams)
  .filter(key => queryParams[key] != null)
  .reduce((acc, key) => Object.assign(acc, { [key]: queryParams[key] }), {});
// { a: 'a', b: 'b', c: 'c', f: '', g: 0 }


问:
How to store the value in datagridview in to a collection class C#
First, I import a csv file to the datagridview and changed it to the format that I want.

I'm able to filter out the data that i do not want by clicking a button, i get the data i want in the console by using console.writeline. (just for testing so  i can see what's actually happen). There are quite numbers of column that do not content the data i want for calculation, so i use .contains() and .replace to filter it out.

Now, i want to store the cell.value.toString()  which hold the value to an array but i have no idea how to implant array to it.

Here is the code

```<code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace test2
{
    public partial class Form1 : Form
    {
        OpenFileDialog openFile = new OpenFileDialog();

        public int colC { get; private set; }

        public Form1()
        {
            InitializeComponent();
        }

        public void Button1_Click(object sender, EventArgs e)
        {
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                List<string[]> rows = File.ReadLines(openFile.FileName).Select(x => x.Split(',')).ToList();
                DataTable dt = new DataTable();
                List<string> headerNames = rows[0].ToList();

                foreach (var headers in rows[0])
                {
                    dt.Columns.Add(headers);
                }
                foreach (var x in rows.Skip(1).OrderBy(r => r.First()))
                {
                    if (x[0] == "Lot ID")   //linq to check if 2 lists are have the same elements (perfect for strings)
                        continue;     //skip the row with repeated headers
                    if (x.All(val => string.IsNullOrWhiteSpace(val))) //if all columns of the row are whitespace / empty, skip this row
                        continue;
                    dt.Rows.Add(x);
                }

                dataGridView1.DataSource = dt;
                dataGridView1.ReadOnly = true;
               // dataGridView1.Columns["Lot ID"].ReadOnly = true;
                //dataGridView1.Columns[" Magazine ID"].ReadOnly = true;
                //dataGridView1.Columns["Frame ID"].ReadOnly = true;

            }
        }

        public void Form1_Load_1(object sender, EventArgs e)
        {
            openFile.Filter = "CSV|*.csv";

        }

        public void Button2_Click(object sender, EventArgs e)
        {

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "txt files (*.txt)|*.txt|Csv files (*.csv)|*.csv";
            sfd.FilterIndex = 2;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    StreamWriter sw = new StreamWriter(sfd.FileName, false);
                    {
                        string columnHeaderText = "";

                        int countColumn = dataGridView1.ColumnCount - 1;

                        if (countColumn >= 0)
                        {
                            columnHeaderText = dataGridView1.Columns[0].HeaderText;
                        }

                        for (int i = 1; i <= countColumn; i++)
                        {
                            columnHeaderText = columnHeaderText + ',' + dataGridView1.Columns[i].HeaderText;
                        }

                        sw.WriteLine(columnHeaderText);

                        foreach (DataGridViewRow dataRowObject in dataGridView1.Rows)
                        {
                            if (!dataRowObject.IsNewRow)
                            {
                                string dataFromGrid = "";

                                dataFromGrid = dataRowObject.Cells[0].Value.ToString();

                                for (int i = 1; i <= countColumn; i++)
                                {
                                    dataFromGrid = dataFromGrid + ',' + dataRowObject.Cells[i].Value.ToString();

                                }
                                sw.WriteLine(dataFromGrid);
                            }
                        }

                        sw.Flush();
                        sw.Close();
                    }
                }
                catch (Exception exceptionObject)
                {
                    MessageBox.Show(exceptionObject.ToString());
                }
                }
            }

        public void Button3_Click(object sender, EventArgs e)
        {

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                    //prevent error occur coz , only execute the not null line
                    if(cell.Value != null)
                    {
                        string cellV = cell.Value.ToString();

                        //do operations with cell, filter out the unnecessary data
                        if (!cellV.Contains("="))
                        {
                            continue;
                        }
                       else if (cellV.Contains("P = "))
                        {
                            cellV = cellV.Replace("P = ", "");
                        }
                        else if (cellV.Contains("F = n/a"))
                        {
                            cellV =cellV.Replace("F = n/a", "0");

                        }
                        else if (cellV.Contains("F = "))
                        {
                            cellV = cellV.Replace("F = ", "");

                        }

                        Console.WriteLine(cellV + "\n");
                    }

                }
            }

        }

    }
    }
</code>```

Please have a look in the last method and the Picture.

Here is the output.

I skip all the data which is not related to calculation by using continue

How do i store the data that i filtered out in array???

Please do not hesitate to ask if you have any inquiry about the question.

答:
You could use a List<string> values and store the values in the string using
values.Add(cellV);

You can then use values.ToArray() to get an array to the stored values.

Your function will look like this

```<code>public void Button3_Click(object sender, EventArgs e)
    {

        List<string> values = new List<string>();
        // Create a new instance of the Form2 class
        // Form2 goForm2 = new Form2();

        // Show the settings form
        // goForm2.Show();

        //string checkP = "p = ";
       // string removePE = checkP.Replace("P = ", "").Replace("F = ", "");

        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            foreach (DataGridViewCell cell in row.Cells)
            {
                //prevent error occur coz , only execute the not null line
                if(cell.Value != null)
                {
                    string cellV = cell.Value.ToString();

                    //do operations with cell
                    if (!cellV.Contains("="))
                    {
                        continue;
                    }
                   else if (cellV.Contains("P = "))
                    {
                        cellV = cellV.Replace("P = ", "");
                    }
                    else if (cellV.Contains("F = n/a"))
                    {
                        cellV =cellV.Replace("F = n/a", "0");

                    }
                    else if (cellV.Contains("F = "))
                    {
                        cellV = cellV.Replace("F = ", "");

                    }
                    values.Add(cellV);
                    Console.WriteLine(cellV + "\n");
                }

            }
        }

    }
</code>```

Body:
First, I import a csv file to the datagridview and changed it to the format that I want.

I'm able to filter out the data that i do not want by clicking a button, i get the data i want in the console by using console.writeline. (just for testing so  i can see what's actually happen). There are quite numbers of column that do not content the data i want for calculation, so i use .contains() and .replace to filter it out.

Now, i want to store the cell.value.toString()  which hold the value to an array but i have no idea how to implant array to it.

Here is the code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace test2
{
    public partial class Form1 : Form
    {
        OpenFileDialog openFile = new OpenFileDialog();

        public int colC { get; private set; }

        public Form1()
        {
            InitializeComponent();
        }

        public void Button1_Click(object sender, EventArgs e)
        {
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                List<string[]> rows = File.ReadLines(openFile.FileName).Select(x => x.Split(',')).ToList();
                DataTable dt = new DataTable();
                List<string> headerNames = rows[0].ToList();

                foreach (var headers in rows[0])
                {
                    dt.Columns.Add(headers);
                }
                foreach (var x in rows.Skip(1).OrderBy(r => r.First()))
                {
                    if (x[0] == "Lot ID")   //linq to check if 2 lists are have the same elements (perfect for strings)
                        continue;     //skip the row with repeated headers
                    if (x.All(val => string.IsNullOrWhiteSpace(val))) //if all columns of the row are whitespace / empty, skip this row
                        continue;
                    dt.Rows.Add(x);
                }

                dataGridView1.DataSource = dt;
                dataGridView1.ReadOnly = true;
               // dataGridView1.Columns["Lot ID"].ReadOnly = true;
                //dataGridView1.Columns[" Magazine ID"].ReadOnly = true;
                //dataGridView1.Columns["Frame ID"].ReadOnly = true;

            }
        }

        public void Form1_Load_1(object sender, EventArgs e)
        {
            openFile.Filter = "CSV|*.csv";

        }

        public void Button2_Click(object sender, EventArgs e)
        {

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "txt files (*.txt)|*.txt|Csv files (*.csv)|*.csv";
            sfd.FilterIndex = 2;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    StreamWriter sw = new StreamWriter(sfd.FileName, false);
                    {
                        string columnHeaderText = "";

                        int countColumn = dataGridView1.ColumnCount - 1;

                        if (countColumn >= 0)
                        {
                            columnHeaderText = dataGridView1.Columns[0].HeaderText;
                        }

                        for (int i = 1; i <= countColumn; i++)
                        {
                            columnHeaderText = columnHeaderText + ',' + dataGridView1.Columns[i].HeaderText;
                        }

                        sw.WriteLine(columnHeaderText);

                        foreach (DataGridViewRow dataRowObject in dataGridView1.Rows)
                        {
                            if (!dataRowObject.IsNewRow)
                            {
                                string dataFromGrid = "";

                                dataFromGrid = dataRowObject.Cells[0].Value.ToString();

                                for (int i = 1; i <= countColumn; i++)
                                {
                                    dataFromGrid = dataFromGrid + ',' + dataRowObject.Cells[i].Value.ToString();

                                }
                                sw.WriteLine(dataFromGrid);
                            }
                        }

                        sw.Flush();
                        sw.Close();
                    }
                }
                catch (Exception exceptionObject)
                {
                    MessageBox.Show(exceptionObject.ToString());
                }
                }
            }

        public void Button3_Click(object sender, EventArgs e)
        {

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                    //prevent error occur coz , only execute the not null line
                    if(cell.Value != null)
                    {
                        string cellV = cell.Value.ToString();

                        //do operations with cell, filter out the unnecessary data
                        if (!cellV.Contains("="))
                        {
                            continue;
                        }
                       else if (cellV.Contains("P = "))
                        {
                            cellV = cellV.Replace("P = ", "");
                        }
                        else if (cellV.Contains("F = n/a"))
                        {
                            cellV =cellV.Replace("F = n/a", "0");

                        }
                        else if (cellV.Contains("F = "))
                        {
                            cellV = cellV.Replace("F = ", "");

                        }

                        Console.WriteLine(cellV + "\n");
                    }

                }
            }

        }

    }
    }

Please have a look in the last method and the Picture.

Here is the output.

I skip all the data which is not related to calculation by using continue

How do i store the data that i filtered out in array???

Please do not hesitate to ask if you have any inquiry about the question.

Body:
You could use a List<string> values and store the values in the string using
values.Add(cellV);

You can then use values.ToArray() to get an array to the stored values.

Your function will look like this

public void Button3_Click(object sender, EventArgs e)
    {

        List<string> values = new List<string>();
        // Create a new instance of the Form2 class
        // Form2 goForm2 = new Form2();

        // Show the settings form
        // goForm2.Show();

        //string checkP = "p = ";
       // string removePE = checkP.Replace("P = ", "").Replace("F = ", "");

        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            foreach (DataGridViewCell cell in row.Cells)
            {
                //prevent error occur coz , only execute the not null line
                if(cell.Value != null)
                {
                    string cellV = cell.Value.ToString();

                    //do operations with cell
                    if (!cellV.Contains("="))
                    {
                        continue;
                    }
                   else if (cellV.Contains("P = "))
                    {
                        cellV = cellV.Replace("P = ", "");
                    }
                    else if (cellV.Contains("F = n/a"))
                    {
                        cellV =cellV.Replace("F = n/a", "0");

                    }
                    else if (cellV.Contains("F = "))
                    {
                        cellV = cellV.Replace("F = ", "");

                    }
                    values.Add(cellV);
                    Console.WriteLine(cellV + "\n");
                }

            }
        }

    }


问:
what is the simplest way to check for occurrence of character/substring in dataframe values?
consider a pandas dataframe that has values such as 'a - b'. I would like to check for the occurrence of '-' anywhere across all values of the dataframe without looping through individual columns. Clearly a check such as the following won't work:

if '-' in df.values

Any suggestions on how to check for this? Thanks.

答:
One way may be to try using flatten to values and list comprehension.

```<code>df = pd.DataFrame([['val1','a-b', 'val3'],['val4','3', 'val5']],columns=['col1','col2', 'col3'])
print(df)
</code>```

Output:

```<code>   col1   col2    col3
0  val1    a-b    val3
1  val4    3      val5
</code>```

Now, to search for -:

```<code>find_value = [val for val in df.values.flatten() if '-' in val]
print(find_value)
</code>```

Output:

```<code>['a-b']
</code>```

Body:
One way may be to try using flatten to values and list comprehension.

df = pd.DataFrame([['val1','a-b', 'val3'],['val4','3', 'val5']],columns=['col1','col2', 'col3'])
print(df)

Output:

   col1   col2    col3
0  val1    a-b    val3
1  val4    3      val5

Now, to search for -:

find_value = [val for val in df.values.flatten() if '-' in val]
print(find_value)

Output:

['a-b']


问:
Nuget package of whole Habitat solution
We are following Habitat Struture which has three layers Feature,Foundation and Projects.So,all the Projects can generate separate .Nuget package using Octo pack but Can we create Nuget Package of whole solution like we publish all projects together using Gulp task from task runner explorer in visual studio?Is there any way to create Nuget package of whole Solution containing all the WebProject dlls in Feature,Foundation and project layers together?

答:
For TDS and Helix, I create another level called Platform and then bundle in all the other TDS projects into my Platform project. This makes one single update package and could make one nuget package for you.

Here is an image of my Platform TDS project with the other projects included as a bundle.

Title: Nuget package of whole Habitat solution


问:
Angular: ng is not recognized as a command
C:\Users\Vivek Ghanchi>ng
'ng' is not recognized as an internal or external command,
operable program or batch file.

I have  installed  angular CLI but it is showing me the ng is not recognized  is there any solution

答:
You should install angular cli by enter the following command:</p>
```<code>npm install -g @angular/cli
</code>```

ContentLicense: CC BY-SA 4.0

Body:
You should install angular cli by enter the following command:

npm install -g @angular/cli


问:
NodeJS & Express authentication middleware not functioning correctly
I am attempting to run the function isUserAuthenticated on every request to the server by requiring it in app.js and 'using' it as so: app.use(authenticate.isUserAuthenticated).

I have an /authenticate callback route that is being POSTED to by our SAML Identity Provider which contains the information required to validate the user and the session.  This is what is inside my authenticate.js file:

```<code>module.exports = router;
module.exports.isUserAuthenticated = function(req, res, next) {
    console.log(req.cookies.subject);
  if (req.cookies.subject) {
      console.log(req.cookies.subject)
    return next();
    } res.redirect("LINK TO IDP FOR VERIFICATION, callback func. is then ran to get value of user and session");
}
</code>```

As referenced, this authentication function is being required and used in app.js: authenticate = require('./routes/authenticate'), and app.use(authenticate.isUserAuthenticated).

The problem: No matter what variation of the if statement to verify if the subject cookie is present in the request, the authentication check is not being fired and the redirect to the IDP authentication route is not being redirected too.  The console.log checks in the code above are returning:

undefined, and
{}.

Authentication was working on a single route when I was using the isUserAuthenticated function manually like this: router.use('/', isUserAuthenticated, function(req, res, next) {..., but I am trying to use this function globally so I don't have to manually incorporate this middleware on each route.

Any advice/suggestions would be greatly appreciated.  Thank you.

答:
as suggested in comment,

you can move the isUserAuthenticated function to app.js. It'd look something like this

```<code>app.use(function(req, res, next) {
  if (req.cookies.subject) {
    next();
    }
else
    res.redirect("LINK TO IDP FOR VERIFICATION, callback func. is then ran to get value of user and session");

})
</code>```

This will process all the requests before they are forwarded to the routes later.

Body:
I am attempting to run the function isUserAuthenticated on every request to the server by requiring it in app.js and 'using' it as so: app.use(authenticate.isUserAuthenticated).

I have an /authenticate callback route that is being POSTED to by our SAML Identity Provider which contains the information required to validate the user and the session.  This is what is inside my authenticate.js file:

module.exports = router;
module.exports.isUserAuthenticated = function(req, res, next) {
    console.log(req.cookies.subject);
  if (req.cookies.subject) {
      console.log(req.cookies.subject)
    return next();
    } res.redirect("LINK TO IDP FOR VERIFICATION, callback func. is then ran to get value of user and session");
}

As referenced, this authentication function is being required and used in app.js: authenticate = require('./routes/authenticate'), and app.use(authenticate.isUserAuthenticated).

The problem: No matter what variation of the if statement to verify if the subject cookie is present in the request, the authentication check is not being fired and the redirect to the IDP authentication route is not being redirected too.  The console.log checks in the code above are returning:

undefined, and
{}.

Authentication was working on a single route when I was using the isUserAuthenticated function manually like this: router.use('/', isUserAuthenticated, function(req, res, next) {..., but I am trying to use this function globally so I don't have to manually incorporate this middleware on each route.

Any advice/suggestions would be greatly appreciated.  Thank you.

Body:
as suggested in comment,

you can move the isUserAuthenticated function to app.js. It'd look something like this

app.use(function(req, res, next) {
  if (req.cookies.subject) {
    next();
    }
else
    res.redirect("LINK TO IDP FOR VERIFICATION, callback func. is then ran to get value of user and session");

})

This will process all the requests before they are forwarded to the routes later.


问:
NameError: name 'hasattr' is not defined - Python3.6, Django1.11, Ubuntu16-17, Apache2.4, mod_wsgi
I've set up my Python/Django virtual environment, and mod_wsgi in daemon mode,  and am pretty sure (done this before) it's "mostly correct" except I get the following error...

```<code>[Thu Jul 06 00:35:26.986363 2017] [mpm_event:notice] [pid 11442:tid 140557758930432] AH00493: SIGUSR1 received.  Doing graceful restart
Exception ignored in: <object repr() failed>
Traceback (most recent call last):
  File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/PIL/Image.py", line 572, in __del__
NameError: name 'hasattr' is not defined
[Thu Jul 06 00:35:27.194483 2017] [mpm_event:notice] [pid 11442:tid 140557758930432] AH00489: Apache/2.4.25 (Ubuntu) mod_wsgi/4.5.15 Python/3.6 configured -- resuming normal operations
[Thu Jul 06 00:35:27.194561 2017] [core:notice] [pid 11442:tid 140557758930432] AH00094: Command line: '/usr/sbin/apache2'
</code>```

My django app itself is loading fine through wsgi.py but it seems something to do with core python (error with my setup likely) is going wrong as per: NameError: name 'hasattr' is not defined

In the browser - I get a plain "Server Error (500)" page and not the standard Apache "Internal Server Error" page.

Leaving out my VirtualHost and steps beyond here are the basic steps I put together for myself if you can spot anything... (I've tried all the different python packages as well not just -venv)

```<code>Install Python 3.6 and virtualenv
    sudo apt-get update
    sudo apt-get install python3.6-venv
    sudo apt-get install virtualenv
(or find the latest and greatest python package that includes pip https://packages.ubuntu.com/ )

Install Apache2
    sudo apt-get install apache2 apache2-dev

Make and enter a folder for your project - then build a Virtual Environment in it
    mkdir ~/example.com
    cd ~/example.com
    virtualenv --python=/usr/bin/python3.6 py361ve

Enter your new Virtual Environment to install packages to it
    source py361ve/bin/activate

Install Django, mod_wsgi, and any other needed packages
    pip install django
    pip install mod_wsgi
    pip install ...
(no need for pip3 in virtual environment - django should be the latest release)

Run following command and place output in apache config file ( in /etc/apache2/ )
    mod_wsgi-express module-config

Exit your virtual environment
    deactivate
(You can re-enter your virtual environment any time using the source method in step 8)
</code>```

Here's what happens when I stop/start/restart apache2...

```<code>apache2 stop...

[Thu Jul 06 06:01:34.190940 2017] [mpm_event:notice] [pid 2015:tid 140157449797120] AH00491: caught SIGTERM, shutting down
_______________________________________________________________
apache2 start...

[Thu Jul 06 06:02:39.076741 2017] [mpm_event:notice] [pid 2181:tid 140553545080320] AH00489: Apache/2.4.25 (Ubuntu) mod_wsgi/4.5.15 Python/3.6 configured -- resuming $
[Thu Jul 06 06:02:39.076890 2017] [core:notice] [pid 2181:tid 140553545080320] AH00094: Command line: '/usr/sbin/apache2'
_______________________________________________________________
apache2 restart...

Exception ignored in: <object repr() failed>
Traceback (most recent call last):
  File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/PIL/Image.py", line 572, in __del__
NameError: name 'hasattr' is not defined
[Thu Jul 06 06:05:43.307877 2017] [mpm_event:notice] [pid 2181:tid 140553545080320] AH00491: caught SIGTERM, shutting down
[Thu Jul 06 06:05:43.492499 2017] [mpm_event:notice] [pid 2301:tid 140353155558912] AH00489: Apache/2.4.25 (Ubuntu) mod_wsgi/4.5.15 Python/3.6 configured -- resuming $
[Thu Jul 06 06:05:43.492705 2017] [core:notice] [pid 2301:tid 140353155558912] AH00094: Command line: '/usr/sbin/apache2'
</code>```

答:
Try uninstalling PIL completely, and then reinstall Pillow package.

Actually there is conflict in PIL old package and Pillow package which is in conflict with newer versions of django.

You need to install the new Pillow package.

First Uninstall both

```<code>sudo pip3 uninstall pil
sudo pip3 uninstall pillow
</code>```

Reinstall Pillow

```<code>sudo pip3 install pillow
</code>```

Body:
I've set up my Python/Django virtual environment, and mod_wsgi in daemon mode,  and am pretty sure (done this before) it's "mostly correct" except I get the following error...

[Thu Jul 06 00:35:26.986363 2017] [mpm_event:notice] [pid 11442:tid 140557758930432] AH00493: SIGUSR1 received.  Doing graceful restart
Exception ignored in: <object repr() failed>
Traceback (most recent call last):
  File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/PIL/Image.py", line 572, in __del__
NameError: name 'hasattr' is not defined
[Thu Jul 06 00:35:27.194483 2017] [mpm_event:notice] [pid 11442:tid 140557758930432] AH00489: Apache/2.4.25 (Ubuntu) mod_wsgi/4.5.15 Python/3.6 configured -- resuming normal operations
[Thu Jul 06 00:35:27.194561 2017] [core:notice] [pid 11442:tid 140557758930432] AH00094: Command line: '/usr/sbin/apache2'

My django app itself is loading fine through wsgi.py but it seems something to do with core python (error with my setup likely) is going wrong as per: NameError: name 'hasattr' is not defined

In the browser - I get a plain "Server Error (500)" page and not the standard Apache "Internal Server Error" page.

Leaving out my VirtualHost and steps beyond here are the basic steps I put together for myself if you can spot anything... (I've tried all the different python packages as well not just -venv)

Install Python 3.6 and virtualenv
    sudo apt-get update
    sudo apt-get install python3.6-venv
    sudo apt-get install virtualenv
(or find the latest and greatest python package that includes pip https://packages.ubuntu.com/ )

Install Apache2
    sudo apt-get install apache2 apache2-dev

Make and enter a folder for your project - then build a Virtual Environment in it
    mkdir ~/example.com
    cd ~/example.com
    virtualenv --python=/usr/bin/python3.6 py361ve

Enter your new Virtual Environment to install packages to it
    source py361ve/bin/activate

Install Django, mod_wsgi, and any other needed packages
    pip install django
    pip install mod_wsgi
    pip install ...
(no need for pip3 in virtual environment - django should be the latest release)

Run following command and place output in apache config file ( in /etc/apache2/ )
    mod_wsgi-express module-config

Exit your virtual environment
    deactivate
(You can re-enter your virtual environment any time using the source method in step 8)

Here's what happens when I stop/start/restart apache2...

apache2 stop...

[Thu Jul 06 06:01:34.190940 2017] [mpm_event:notice] [pid 2015:tid 140157449797120] AH00491: caught SIGTERM, shutting down
_______________________________________________________________
apache2 start...

[Thu Jul 06 06:02:39.076741 2017] [mpm_event:notice] [pid 2181:tid 140553545080320] AH00489: Apache/2.4.25 (Ubuntu) mod_wsgi/4.5.15 Python/3.6 configured -- resuming $
[Thu Jul 06 06:02:39.076890 2017] [core:notice] [pid 2181:tid 140553545080320] AH00094: Command line: '/usr/sbin/apache2'
_______________________________________________________________
apache2 restart...

Exception ignored in: <object repr() failed>
Traceback (most recent call last):
  File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/PIL/Image.py", line 572, in __del__
NameError: name 'hasattr' is not defined
[Thu Jul 06 06:05:43.307877 2017] [mpm_event:notice] [pid 2181:tid 140553545080320] AH00491: caught SIGTERM, shutting down
[Thu Jul 06 06:05:43.492499 2017] [mpm_event:notice] [pid 2301:tid 140353155558912] AH00489: Apache/2.4.25 (Ubuntu) mod_wsgi/4.5.15 Python/3.6 configured -- resuming $
[Thu Jul 06 06:05:43.492705 2017] [core:notice] [pid 2301:tid 140353155558912] AH00094: Command line: '/usr/sbin/apache2'

Body:
Try uninstalling PIL completely, and then reinstall Pillow package.

Actually there is conflict in PIL old package and Pillow package which is in conflict with newer versions of django.

You need to install the new Pillow package.

First Uninstall both

sudo pip3 uninstall pil
sudo pip3 uninstall pillow

Reinstall Pillow

sudo pip3 install pillow


问:
Spring Restful Mutipart
I would like to ask information regarding Multipart/Form-data, if these are compatible with RequestMethod.GET?

In my case I have to return a file + JSON in one response. (Note: File should not be inside the JSON). Sample response:

```<code>FILE

{

    "id":"1234",
    "name":"question Man"

}
</code>```

答:
I think this might be helpful, please modify it as of your needs.</p>

```<code>@RequestMapping(value = URIConstansts.GET_FILE, produces = { "application/json" }, method = RequestMethod.GET)
public @ResponseBody ResponseEntity getFile(@RequestParam(value="fileName", required=false) String fileName,HttpServletRequest request) throws IOException{

    ResponseEntity respEntity = null;

    byte[] reportBytes = null;
    File result=new File("/filepath/"+fileName);

    if(result.exists()){
        InputStream inputStream = new FileInputStream("/filepath/"+fileName);
        String type=result.toURL().openConnection().guessContentTypeFromName(fileName);

        byte[]out=org.apache.commons.io.IOUtils.toByteArray(inputStream);

        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.add("content-disposition", "attachment; filename=" + fileName);
        responseHeaders.add("Content-Type",type);

        respEntity = new ResponseEntity(out, responseHeaders,HttpStatus.OK);
    }else{
        respEntity = new ResponseEntity ("File Not Found", HttpStatus.OK);
    }
    return respEntity;
}
</code>```

Title: Spring Restful Mutipart

Body:
I would like to ask information regarding Multipart/Form-data, if these are compatible with RequestMethod.GET?

In my case I have to return a file + JSON in one response. (Note: File should not be inside the JSON). Sample response:

FILE

{

    "id":"1234",
    "name":"question Man"

}

Body:
I think this might be helpful, please modify it as of your needs.

@RequestMapping(value = URIConstansts.GET_FILE, produces = { "application/json" }, method = RequestMethod.GET)
public @ResponseBody ResponseEntity getFile(@RequestParam(value="fileName", required=false) String fileName,HttpServletRequest request) throws IOException{

    ResponseEntity respEntity = null;

    byte[] reportBytes = null;
    File result=new File("/filepath/"+fileName);

    if(result.exists()){
        InputStream inputStream = new FileInputStream("/filepath/"+fileName);
        String type=result.toURL().openConnection().guessContentTypeFromName(fileName);

        byte[]out=org.apache.commons.io.IOUtils.toByteArray(inputStream);

        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.add("content-disposition", "attachment; filename=" + fileName);
        responseHeaders.add("Content-Type",type);

        respEntity = new ResponseEntity(out, responseHeaders,HttpStatus.OK);
    }else{
        respEntity = new ResponseEntity ("File Not Found", HttpStatus.OK);
    }
    return respEntity;
}


问:
About resolving Resource Leaks
I'm a newbee to spring framework and I encounted some errors when I was compiling the "HelloSpring" code on tutorialscom. Throughout the code there is only one warning in the main class:

```<code>package com.tutorialspoint;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
        HelloWorld  HW = (HelloWorld)context.getBean("Hello Spring");
        HW.getMsg();
    }
}
</code>```

Eclipse warns me "Resource Leak: 'context' is never close", but for ApplicationContext class I dont know how to close it. Can anyone help me with it?

The errors are:

```<code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:164)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:89)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:58)
    at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:61)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.tutorialspoint.MainApp.main(MainApp.java:10)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 7 more
</code>```

BTW my java version is the latest 1.80, idk if this matters.
Thank you!

答:
To fix your error : Add commons-logging.jar file to your project classpath. that will fix the issue.

To fix the resource leak : You have to register the shutdown hook. You can find more details here.

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-spring-application.html

Hope this helps :)

Title: About resolving Resource Leaks

Body:
I'm a newbee to spring framework and I encounted some errors when I was compiling the "HelloSpring" code on tutorialscom. Throughout the code there is only one warning in the main class:

package com.tutorialspoint;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
        HelloWorld  HW = (HelloWorld)context.getBean("Hello Spring");
        HW.getMsg();
    }
}

Eclipse warns me "Resource Leak: 'context' is never close", but for ApplicationContext class I dont know how to close it. Can anyone help me with it?

The errors are:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:164)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:89)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:58)
    at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:61)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.tutorialspoint.MainApp.main(MainApp.java:10)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 7 more

BTW my java version is the latest 1.80, idk if this matters.
Thank you!