function getData(){
var url = $('.gridly').attr('req');
$.get(url, function(data){
var json = JSON.parse(data)
$.each(json, function(i, obj) {
$('.gridly').append('<div class="brick small">'+obj.fields.title +'<a href="."><img src="/media/'+obj.fields.head_pic+'"'+'></a><a class="delete" slug="'+obj.fields.slug+'"href="#">×</a></div>');
$('.gridly').gridly({
base: 60, // px
gutter: 20, // px
columns: 10
});
});
});
}
$(document).ready( getData );
<input id="cancel_changes" class="btn btn-success col-sm-6 col-xs-12 margin-bottom col-sm-offset-1 col-xs-offset-0" value="Отменить" type="button" onclick="getData()">
using System.Management;
private class StaticIP : IConfigurationIP
{
// mac-адрес адаптера, которому присваиваются настройки:
public String macAddress;
public string[] IPAddress;
public string[] IPSubnet;
public string[] DefaultIPGateway;
public string[] DNSServerSearchOrder;
public UInt16[] GatewayCostMetric;
public int proxyStatus;
/// <summary>
/// Установить конфигурацию сетевого адаптера, используя имеющиеся в классе настройки.
/// В принципе было бы корректно освобождать IP-адрес перед установкой статического адреса. см. msdn.microsoft.com/en-us/library/aa393047(v=vs.85).aspx
/// (ReleaseDHCPLease)
/// </summary>
void IConfigurationIP.set()
{
ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection objMOC = objMC.GetInstances();
foreach (ManagementObject objMO in objMOC)
{
if ((bool)objMO["IPEnabled"])
{
try
{
// Параметры objMO: http://msdn.microsoft.com/en-us/library/aa394217%28v=vs.85%29.aspx
// Найти сетевую карту с mac-адресом, для которой предназначена эта настройка:
string _macAddress = (string)objMO["MACAddress"];
if (_macAddress.Equals(this.macAddress))
{
// http://www.java2s.com/Tutorial/CSharp/0580__Network/GetIPaddressfromWin32NetworkAdapterConfiguration.htm
// http://msdn.microsoft.com/en-us/library/aa394217%28v=vs.85%29.aspx
ManagementBaseObject EnableStatic = objMO.GetMethodParameters("EnableStatic");
ManagementBaseObject EnableStatic_ret;
EnableStatic["IPAddress"] = this.IPAddress;
EnableStatic["SubnetMask"] = this.IPSubnet;
EnableStatic_ret = objMO.InvokeMethod("EnableStatic", EnableStatic, null);
ManagementBaseObject DNSServerSearchOrder = objMO.GetMethodParameters("SetDNSServerSearchOrder");
ManagementBaseObject DNSServerSearchOrder_ret;
DNSServerSearchOrder["DNSServerSearchOrder"] = this.DNSServerSearchOrder;
DNSServerSearchOrder_ret = objMO.InvokeMethod("SetDNSServerSearchOrder", DNSServerSearchOrder, null);
ManagementBaseObject SetGateways = objMO.GetMethodParameters("SetGateways");
ManagementBaseObject SetGateways_ret;
SetGateways["DefaultIPGateway"] = this.DefaultIPGateway;
SetGateways["GatewayCostMetric"] = this.GatewayCostMetric;
SetGateways_ret = objMO.InvokeMethod("SetGateways", SetGateways, null);
RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", this.proxyStatus);
//proxyStatus = (int)registry.GetValue("ProxyEnable");
Console.WriteLine(" set {0} to {1} finished", this.macAddress, this.IPAddress[0]);
return;
}
}
catch (Exception)
{
throw;
}
}
}
}
}
function sortDate(a,b){
var aDate = new Date(a.createdAt);
var bDate = new Date(b.createdAt);
if(aDate == bDate)
return 0;
if(aDate < bDate)
return -1;
if(aDate > bDate)
return 1;
};
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "https://api.parse.com/1/classes/Blog", true);
xmlhttp.setRequestHeader('Content-Type', 'application/json');
xmlhttp.setRequestHeader('X-Parse-Application-Id', 'GKid48BAvytRnKn8Y8CFKiKQ8jIJSYwpUsr1vID1');
xmlhttp.setRequestHeader('X-Parse-REST-API-Key', '6bnW8hVQNvuLQYiDiXvMHwIvV0inEne93gLzOC0A');
xmlhttp.onload = function () {
if (xmlhttp.status === 200) {
var userInfo = JSON.parse(this.responseText);
console.log(this.responseText);
debugger;
userInfo.results = userInfo.results.sort( sortDate );
var arr = userInfo.results.reverse();
var text = "";
for (var i = 0; i < arr.length; i++) {
text += '<div class="blog-post"><div class="blog-header">'+arr[i].title + '</div><br><img width="560px;" src="' + arr[i].img + '"><br><div class="blog-text">' + arr[i].text + '</div><div class="blog-share"><a href="http://gamer-by-life.com/share/?title='+arr[i].title + '&text='+arr[i].text + '&img='+arr[i].img + '&time='+arr[i].createdAt + '"><img src="share.png"></a></div><br></div><br>\n';
}
console.log(text);
}
};
xmlhttp.send();